Add support for rotated log textures. To change a facade, put it in your crafting grid- it'll turn around..

Works with any mod logs using render 31 as well..
This commit is contained in:
Christian 2013-06-10 20:01:51 -04:00
parent 3ea39c78bb
commit e6c0361f4f
3 changed files with 55 additions and 10 deletions

View file

@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import buildcraft.BuildCraftCore;
import buildcraft.BuildCraftTransport; import buildcraft.BuildCraftTransport;
import buildcraft.api.recipes.AssemblyRecipe; import buildcraft.api.recipes.AssemblyRecipe;
import buildcraft.core.CreativeTabBuildCraft; import buildcraft.core.CreativeTabBuildCraft;
@ -44,6 +45,9 @@ public class ItemFacade extends ItemBuildCraft {
String name = super.getItemDisplayName(itemstack); String name = super.getItemDisplayName(itemstack);
int decodedBlockId = ItemFacade.getBlockId(itemstack.getItemDamage()); int decodedBlockId = ItemFacade.getBlockId(itemstack.getItemDamage());
int decodedMeta = ItemFacade.getMetaData(itemstack.getItemDamage()); int decodedMeta = ItemFacade.getMetaData(itemstack.getItemDamage());
if (decodedBlockId < Block.blocksList.length && Block.blocksList[decodedBlockId] != null && Block.blocksList[decodedBlockId].getRenderType() == 31) {
decodedMeta &= 0x3;
}
ItemStack newStack = new ItemStack(decodedBlockId, 1, decodedMeta); ItemStack newStack = new ItemStack(decodedBlockId, 1, decodedMeta);
if (Item.itemsList[decodedBlockId] != null) { if (Item.itemsList[decodedBlockId] != null) {
name += ": " + CoreProxy.proxy.getItemDisplayName(newStack); name += ": " + CoreProxy.proxy.getItemDisplayName(newStack);
@ -157,6 +161,21 @@ public class ItemFacade extends ItemBuildCraft {
// 3 Structurepipes + this block makes 6 facades // 3 Structurepipes + this block makes 6 facades
AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(BuildCraftTransport.pipeStructureCobblestone, 3), itemStack }, AssemblyRecipe.assemblyRecipes.add(new AssemblyRecipe(new ItemStack[] { new ItemStack(BuildCraftTransport.pipeStructureCobblestone, 3), itemStack },
8000, new ItemStack(BuildCraftTransport.facadeItem, 6, ItemFacade.encode(itemStack.itemID, itemStack.getItemDamage())))); 8000, new ItemStack(BuildCraftTransport.facadeItem, 6, ItemFacade.encode(itemStack.itemID, itemStack.getItemDamage()))));
if (itemStack.itemID < Block.blocksList.length && Block.blocksList[itemStack.itemID] != null) {
Block bl = Block.blocksList[itemStack.itemID];
// Special handling for logs
if (bl.getRenderType() == 31) {
ItemStack mainLog = new ItemStack(BuildCraftTransport.facadeItem, 1, ItemFacade.encode(itemStack.itemID, itemStack.getItemDamage()));
ItemStack rotLog1 = new ItemStack(BuildCraftTransport.facadeItem, 1, ItemFacade.encode(itemStack.itemID, itemStack.getItemDamage() | 4));
ItemStack rotLog2 = new ItemStack(BuildCraftTransport.facadeItem, 1, ItemFacade.encode(itemStack.itemID, itemStack.getItemDamage() | 8));
allFacades.add(rotLog1);
allFacades.add(rotLog2);
CoreProxy.proxy.addShapelessRecipe(rotLog1, new Object[] { mainLog });
CoreProxy.proxy.addShapelessRecipe(rotLog2, new Object[] { rotLog1 });
CoreProxy.proxy.addShapelessRecipe(mainLog, new Object[] { rotLog2 });
}
}
} }
@Override @Override

View file

@ -183,7 +183,24 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (state.facadeMatrix.getFacadeBlockId(direction) != 0) { if (state.facadeMatrix.getFacadeBlockId(direction) != 0) {
state.currentTexture = Block.blocksList[state.facadeMatrix.getFacadeBlockId(direction)].getIcon(direction.ordinal(), state.facadeMatrix.getFacadeMetaId(direction)); Block renderBlock = Block.blocksList[state.facadeMatrix.getFacadeBlockId(direction)];
int renderMeta = state.facadeMatrix.getFacadeMetaId(direction);
state.currentTexture = renderBlock.getIcon(direction.ordinal(), renderMeta);
if (renderBlock.getRenderType() == 31) {
if ((renderMeta & 12) == 4)
{
renderblocks.uvRotateEast = 1;
renderblocks.uvRotateWest = 1;
renderblocks.uvRotateTop = 1;
renderblocks.uvRotateBottom = 1;
}
else if ((renderMeta & 12) == 8)
{
renderblocks.uvRotateSouth = 1;
renderblocks.uvRotateNorth = 1;
}
}
// Hollow facade // Hollow facade
if (state.pipeConnectionMatrix.isConnected(direction)) { if (state.pipeConnectionMatrix.isConnected(direction)) {
@ -228,6 +245,15 @@ public class PipeWorldRenderer implements ISimpleBlockRenderingHandler {
renderblocks.setRenderBoundsFromBlock(block); renderblocks.setRenderBoundsFromBlock(block);
renderblocks.renderStandardBlock(block, x, y, z); renderblocks.renderStandardBlock(block, x, y, z);
} }
if (renderBlock.getRenderType() == 31) {
renderblocks.uvRotateSouth = 0;
renderblocks.uvRotateEast = 0;
renderblocks.uvRotateWest = 0;
renderblocks.uvRotateNorth = 0;
renderblocks.uvRotateTop = 0;
renderblocks.uvRotateBottom = 0;
}
} }
} }