Posted August 10, 201510 yr I got a Block with two models. When one of these Blocks is connected to an other one it should change the state to blocked, else unblocked. Sounds simple. Here is the working code for changing the state when the Block is placed and the actual state handling: @Override public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { for(EnumFacing facing : EnumFacing.HORIZONTALS){ if(world.getBlockState(pos.offset(facing)).getBlock() == this){ //Block found -> block TEForgeDistributor distributor = (TEForgeDistributor)world.getTileEntity(pos); if(!distributor.isBlocked()) { distributor.setState(true); distributor.markDirty(); world.markBlockForUpdate(pos); return; } } } //no block found -> unblock TEForgeDistributor distributor = (TEForgeDistributor)world.getTileEntity(pos); if(distributor.isBlocked()) { distributor.setState(false); distributor.markDirty(); world.markBlockForUpdate(pos); } } @Override public IBlockState getActualState(IBlockState state, IBlockAccess world, BlockPos pos) { if(world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TEForgeDistributor){ TEForgeDistributor distributor = (TEForgeDistributor)world.getTileEntity(pos); return state.withProperty(BlockStateProperties.BLOCKED, distributor.isBlocked()); } return state; } So far everything is working good and instant. But when I use the neighbor Block Change method, the state changes also instant, but the Client only updates the model when an other block in a close range produces a update. Neighbor Block Change Method: @Override public void onNeighborBlockChange(World world, BlockPos pos, IBlockState state, Block neighborBlock) { for(EnumFacing facing : EnumFacing.HORIZONTALS){ if(world.getBlockState(pos.offset(facing)).getBlock() == this){ TEForgeDistributor distributor = (TEForgeDistributor)world.getTileEntity(pos); distributor.setState(true); distributor.markDirty(); world.markBlockForUpdate(pos); return; } } TEForgeDistributor distributor = (TEForgeDistributor)world.getTileEntity(pos); distributor.setState(false); distributor.markDirty(); world.markBlockForUpdate(pos); } I'm running out of Ideas, is something missing or is this a bug. When I Output the state on both sides it has the correct state. Only the model is not updating.
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.