fixed facade display and pipe initialization

This commit is contained in:
SpaceToad 2014-02-09 19:03:13 +01:00
parent 58ed5ee20c
commit c516cc5862
3 changed files with 32 additions and 36 deletions

View file

@ -61,7 +61,6 @@ import net.minecraft.client.Minecraft;
public class BlockGenericPipe extends BlockBuildCraft {
static enum Part {
Pipe,
Gate,
Facade,
@ -965,7 +964,7 @@ public class BlockGenericPipe extends BlockBuildCraft {
try {
Class<? extends Pipe> pipe = pipes.get(key);
if (pipe != null)
return pipe.getConstructor(int.class).newInstance(key);
return pipe.getConstructor(Item.class).newInstance(key);
else {
BCLog.logger.warning("Detected pipe with unknown key (" + key + "). Did you remove a buildcraft addon?");
}

View file

@ -15,6 +15,7 @@ import cpw.mods.fml.relauncher.SideOnly;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@ -100,42 +101,38 @@ public class ItemFacade extends ItemBuildCraft {
}
public static void initialize() {
for (Field f : Block.class.getDeclaredFields()) {
if (Modifier.isStatic(f.getModifiers()) && Block.class.isAssignableFrom(f.getType())) {
Block b;
try {
b = (Block) f.get(null);
} catch (Exception e) {
for (Object o : Block.blockRegistry) {
Block b = (Block) o;
if (!(b == Blocks.glass)) {
if (b == Blocks.bedrock
|| b == Blocks.grass
|| b == Blocks.leaves
|| b == Blocks.sponge
|| b == Blocks.chest
|| b == Blocks.redstone_lamp
|| b == Blocks.lit_redstone_lamp
|| b == Blocks.lit_pumpkin) {
continue;
}
if (!(b == Blocks.glass)) {
if (b == Blocks.bedrock
|| b == Blocks.grass
|| b == Blocks.leaves
|| b == Blocks.sponge
|| b == Blocks.chest
|| b == Blocks.redstone_lamp
|| b == Blocks.lit_redstone_lamp
|| b == Blocks.lit_pumpkin) {
continue;
}
if (!b.isOpaqueCube() || b.hasTileEntity(0) || !b.renderAsNormalBlock()) {
continue;
}
}
ItemStack base = new ItemStack(b, 1);
if (base.getHasSubtypes()) {
Set<String> names = Sets.newHashSet();
for (int meta = 0; meta <= 15; meta++) {
ItemStack is = new ItemStack(b, 1, meta);
if (!Strings.isNullOrEmpty(is.getUnlocalizedName()) && names.add(is.getUnlocalizedName())) {
ItemFacade.addFacade(is);
}
}
} else {
ItemFacade.addFacade(base);
if (!b.isOpaqueCube()
|| b.hasTileEntity(0)
|| !b.renderAsNormalBlock()
|| b.getRenderType() != 0) {
continue;
}
}
Item base = Item.getItemFromBlock(b);
if (base != null) {
List <ItemStack> stackList = new ArrayList<ItemStack> ();
base.getSubItems(base, null, stackList);
for (ItemStack s : stackList) {
ItemFacade.addFacade(s);
}
}
}
}

View file

@ -20,7 +20,7 @@ public class FacadeItemRenderer implements IItemRenderer {
private void renderFacadeItem(RenderBlocks render, ItemStack item, float translateX, float translateY, float translateZ) {
int decodedMeta = ItemFacade.getMetaData(item);
Block block = Block.getBlockFromItem(item.getItem());
Block block = ItemFacade.getBlock(item);
try {
int color = item.getItem().getColorFromItemStack(new ItemStack(block, 1, decodedMeta), 0);