Posted November 28, 201410 yr Hello all! I am building a mod that contains a 3D model "multiblock". Basically, its a table. But as you add more tables, it changes what model gets rendered to make it look connected. I know I am going to have to do something with onNeighborBlockChange() but when I do simple tests printing the block parameter, I'm getting what was there before I placed the block IE Air, not the block that was just added. So my question is, how would I go about detecting all four sides for a specific block? Thanks in advance.
November 28, 201410 yr Author I may have not understood your answer then. If you are saying to use onNeighborBlockChange, when I tried doing my tests, it wouldn't show the block I had placed until I removed it. For example, I had a table, and when I put a table next to it, the read out on the console said tile.block.air. It wasn't until I broke the table I put down that it returned, tile.block.table.
November 28, 201410 yr Author package com.misccraft.mod.blocks; import com.misccraft.mod.Misccraft; import com.misccraft.mod.tileentity.TileEntityOfficeDesk; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; public class OfficeDesk extends BlockContainer { private int side; public OfficeDesk(Material material) { super(material); this.setHardness(1.0F); this.setResistance(5.0F); // To be changed this.setBlockBounds(0F, 0F, 0F, 1F, 0.8125F, 1F); // To be changed this.setCreativeTab(Misccraft.misccraftTab); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } @Override public TileEntity createNewTileEntity(World var1, int var2) { return new TileEntityOfficeDesk(); } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityplayer, ItemStack itemstack) { if(entityplayer == null) { return; } TileEntityOfficeDesk perf = (TileEntityOfficeDesk)world.getTileEntity(x,y,z); perf.direction = MathHelper.floor_double((double)((entityplayer.rotationYaw*4F)/360F) + 0.5D) & 3; perf.side = 2; // Static for testing } public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { System.out.println(block.getLocalizedName()); // Test to check neighboring block. } }
November 28, 201410 yr Author So I take it onNeighborBlockChange is usually used last then. So what method would I use to get the block that was just placed?
November 28, 201410 yr Author You said that onNeighborBlockChange is intended to work via re-checking your surroundings. I assumed this is done at the end of whatever you are processing. I don't get how what I want to do is not possible. Chest's do the same thing I'm trying to do, they detect a chest next to themselves, and alter their model accordingly. I'm new to the modding scene and not as experienced in Java as others, so when I look at the Chest/Fence/Pane source code, I see the code, but I don't understand what it is doing. I guess what I am trying to say is, how would I go about detecting a CERTAIN block when its placed next to my block?
November 28, 201410 yr Author Thank you for being patient with me. You have solved my question. Thanks again!
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.