Posted July 24, 201312 yr PASTEBIN OF CODE I am trying to make a block with connected textures for its top and bottom faces, and I've got it working except for the orientation of the textures. Using metadata, I can get the right type of texture, but not the right orientation of it. There are too many textures for metadata to handle (using separate textures for each orientation), and this cannot be a tile entity, as it is a decorative block. Can I set something other than metadata, without making the block a tile entity, to get the right orientation of the texture? I tried using an instance variable, but of course that doesn't set per instance; every instance of the block changes when one does. I am starting to think what I want is not possible, only I know that others have done connected textures for decorative blocks, like glass. Quite possibly, there's an obvious, better way to do this. I am still learning Java, so I apologize if I seem obtuse. Certainly this code is not elegant or pretty. Many thanks for any help or advice! New to Java / Programming?
July 26, 201312 yr Author Could anyone point me to an example of connected textures code? Or, alternately, help me to understand this code: Im trying to make this glass block(That im going to make later today, also dont know how to make blocks transparent(yes I need a lot of help on stuff)) have connected texture but I cant find any tutorials that I could follow(yes im a noob, but I like to do things my way, not the professional way, yet) And I also need to update to 1.6 but I dont know how. I read somewhere that you need to make sure you backed up your code, then delete it all and do it again but with the current versions but I dont know. Any help would be greatly appreciated! package f1rSt1k.blocks; import java.util.List; import java.util.Random; import f1rSt1k.Main; import net.minecraft.block.Block; import net.minecraft.block.BlockGlass; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.Icon; import net.minecraft.world.IBlockAccess; public class BlockDecorativeGlass extends BlockGlass { public static boolean connectedTexture = true; public static Icon[] textures = new Icon[47]; public static int[] textureRefByID = { 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 4, 4, 5, 5, 4, 4, 5, 5, 17, 17, 22, 26, 17, 17, 22, 26, 16, 16, 20, 20, 16, 16, 28, 28, 21, 21, 46, 42, 21, 21, 43, 38, 4, 4, 5, 5, 4, 4, 5, 5, 9, 9, 30, 12, 9, 9, 30, 12, 16, 16, 20, 20, 16, 16, 28, 28, 25, 25, 45, 37, 25, 25, 40, 32, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 4, 4, 5, 5, 4, 4, 5, 5, 17, 17, 22, 26, 17, 17, 22, 26, 7, 7, 24, 24, 7, 7, 10, 10, 29, 29, 44, 41, 29, 29, 39, 33, 4, 4, 5, 5, 4, 4, 5, 5, 9, 9, 30, 12, 9, 9, 30, 12, 7, 7, 24, 24, 7, 7, 10, 10, 8, 8, 36, 35, 8, 8, 34, 11 }; public BlockDecorativeGlass() { super(502, Material.glass, false); setHardness(0.6F); setResistance(2.0F); setCreativeTab(Main.f1rSt1kCraftCreativeTab); setStepSound(soundGlassFootstep); } public int idDropped(int par1, Random par2Random, int par3) { return Item.stick.itemID; } public int quantityDropped(Random par1Random) { return 1 + par1Random.nextInt(4); } public void registerIcons(IconRegister iconRegistry) { for (int i = 0; i < 47; i++) textures[i] = iconRegistry.registerIcon("f1rst1kcraft:woodGlass_" + (i+1)); } public Icon getBlockTexture(IBlockAccess world, int x, int y, int z, int side) { if(connectedTexture){ boolean[] bitMatrix = new boolean[8]; if (side == 0 || side == 1) { bitMatrix[0] = world.getBlockId(x-1, y, z-1) == this.blockID; bitMatrix[1] = world.getBlockId(x, y, z-1) == this.blockID; bitMatrix[2] = world.getBlockId(x+1, y, z-1) == this.blockID; bitMatrix[3] = world.getBlockId(x-1, y, z) == this.blockID; bitMatrix[4] = world.getBlockId(x+1, y, z) == this.blockID; bitMatrix[5] = world.getBlockId(x-1, y, z+1) == this.blockID; bitMatrix[6] = world.getBlockId(x, y, z+1) == this.blockID; bitMatrix[7] = world.getBlockId(x+1, y, z+1) == this.blockID; } if (side == 2 || side == 3) { bitMatrix[0] = world.getBlockId(x+(side==2?1:-1), y+1, z) == this.blockID; bitMatrix[1] = world.getBlockId(x, y+1, z) == this.blockID; bitMatrix[2] = world.getBlockId(x+(side==3?1:-1), y+1, z) == this.blockID; bitMatrix[3] = world.getBlockId(x+(side==2?1:-1), y, z) == this.blockID; bitMatrix[4] = world.getBlockId(x+(side==3?1:-1), y, z) == this.blockID; bitMatrix[5] = world.getBlockId(x+(side==2?1:-1), y-1, z) == this.blockID; bitMatrix[6] = world.getBlockId(x, y-1, z) == this.blockID; bitMatrix[7] = world.getBlockId(x+(side==3?1:-1), y-1, z) == this.blockID; } if (side == 4 || side == 5) { bitMatrix[0] = world.getBlockId(x, y+1, z+(side==5?1:-1)) == this.blockID; bitMatrix[1] = world.getBlockId(x, y+1, z) == this.blockID; bitMatrix[2] = world.getBlockId(x, y+1, z+(side==4?1:-1)) == this.blockID; bitMatrix[3] = world.getBlockId(x, y, z+(side==5?1:-1)) == this.blockID; bitMatrix[4] = world.getBlockId(x, y, z+(side==4?1:-1)) == this.blockID; bitMatrix[5] = world.getBlockId(x, y-1, z+(side==5?1:-1)) == this.blockID; bitMatrix[6] = world.getBlockId(x, y-1, z) == this.blockID; bitMatrix[7] = world.getBlockId(x, y-1, z+(side==4?1:-1)) == this.blockID; } int idBuilder = 0; for (int i = 0; i <= 7; i++) idBuilder = idBuilder + (bitMatrix[i]?(i==0?1:(i==1?2:(i==2?4:(i==3?8:(i==4?16:(i==5?32:(i==6?64:128))))))):0); return idBuilder>255||idBuilder<0?textures[0]:textures[textureRefByID[idBuilder]]; } return textures[0]; } public Icon getIcon(int side, int meta) { return textures[0]; } } It just occurred to me: the GetBlockTexture lets you get the surrounding block IDs -- I'm going to see whether I can do it there, without metadata. New to Java / Programming?
July 26, 201312 yr ISimpleBlockRenderinghandler? how to debug 101:http://www.minecraftforge.net/wiki/Debug_101 -hydroflame, author of the forge revolution-
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.