Posted July 6, 201411 yr So I decided to give multi-block structures a try and thought I would give a simple 3x3x3 a go. I have a couple questions. 1. How can I check whether certain blocks are x and certain blocks are y. For example, say I want the multi-block structure to have a setup like this on each side [X X X] [X Y X] [X X X] Where the X represents one type of block and the Y represents another. I'm confused with this looping system how I can check individual blocks, as it seems with the system I am using it checks with relation to every block in the structure, therefore the coordinates are going to point to different areas based on the current block's position. I simply want the multi-block structure to require each side has this kind of setup before returning that it is in fact a multi-block structure. 2. I seem to have a problem with setting metadata values to my blocks. In the second x3,y3,z3 for loop inside the isMultiBlockStructure function I am setting metadatas with values I am expecting to be 1-28, but instead I am finding that 1-15 or so are being set correctly, but after that the rest of the blocks are set seemingly randomly from 1-15 again. Sorry if these questions are worded poorly, I'm a bit confused on how to explain it all. But please ask if you need more clarification! here is my block file. package skytanic.atomicmanipulation.blocks; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import skytanic.atomicmanipulation.blocks.tileentity.RefineryControllerTileEntity; import skytanic.atomicmanipulation.common.AtomicManipulation; public class BlockRefineryController extends BlockContainer{ public BlockRefineryController(Material material) { super(material); this.setBlockName("RefineryController"); this.setBlockTextureName("atomic:RefineryController"); this.setCreativeTab(AtomicManipulation.TabAtomic); this.setStepSound(soundTypeMetal); this.setHardness(4f); this.setResistance(50f); } public int getRenderType(){ return -1; } public boolean renderAsNormalBlock(){ return false; } public boolean isOpaqueCube(){ return false; } public void onNeighborBlockChange(World world, int x, int y, int z, Block neighborBlock){ updateMultiBlockStructure(world, x, y, z); } public void onBlockAdded(World world, int x, int y, int z){ updateMultiBlockStructure(world, x, y, z); } public void updateMultiBlockStructure(World world, int x, int y, int z){ isMultiBlockStructure(world, x, y, z); } public boolean isMultiBlockStructure(World world, int x1, int y1, int z1){ boolean mStructure = false; boolean currentCheckStructure = true; for(int x2 = 0; x2 < 3; x2++){ for(int y2 = 0; y2 < 3; y2++){ for(int z2 = 0; z2 < 3; z2++){ if(!mStructure){ currentCheckStructure = true; for(int x3 = 0; x3 < 3; x3++){ for(int y3 = 0; y3 < 3; y3++){ for(int z3 = 0; z3 < 3; z3++){ if(currentCheckStructure && !world.getBlock(x1+x2-x3, y1+y2-y3, z1+z2-z3).equals(AtomicManipulation.RefineryController)){ currentCheckStructure = false; } } } } if(currentCheckStructure){ for(int x3 = 0; x3 < 3; x3++){ for(int y3 = 0; y3 < 3; y3++){ for(int z3 = 0; z3 < 3; z3++){ world.setBlockMetadataWithNotify(x1+x2-x3, y1+y2-y3, z1+z2-z3, x3*9+y3*3+z3+1, 2); } } } } } mStructure = currentCheckStructure; } } } if(mStructure) return true; if(world.getBlockMetadata(x1, y1, z1) > 0) world.setBlockMetadataWithNotify(x1, y1, z1, 0, 3); return false; } @Override public TileEntity createNewTileEntity(World var1, int var2) { return new RefineryControllerTileEntity(); } } http://i.imgur.com/bkongSe.png[/img]
July 6, 201411 yr Metadata is only a nibble (4 bits), meaning 16 possible combinations. Only 0-15 are valid metadata values, any larger values will overflow or probably just get truncated to 4 bits.
July 6, 201411 yr Author Hmm I see, so is there a way to do what I am trying to do? Or would I have to do something like turning 1 block into a custom rendered block while removing the rest, then rebuilding the previous structure minus 1 block whenever it is broken? http://i.imgur.com/bkongSe.png[/img]
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.