gummby8 26 Report post Posted September 1, 2017 I am making a block that generates a sort of force field when powered and breaks it back down when not powered All the magic happens in the onNeighborBlockChange /** * Called when a neighboring block changes. */ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); EnumFacing enumfacingY = enumfacing.getOpposite(); if( worldIn.getStrongPower(pos.offset(enumfacing), enumfacing) > 0){ worldIn.setBlockState(pos, state.withProperty(FACING, (EnumFacing)state.getValue(FACING)).withProperty(STATE, true), 3); } else { worldIn.setBlockState(pos, state.withProperty(FACING, (EnumFacing)state.getValue(FACING)).withProperty(STATE, false), 3); } if (((Boolean)state.getValue(POWERED)).booleanValue()){ System.out.println("Building"); worldIn.setBlockState(pos.up(2), ModBlocks.force_field_blue.getDefaultState().withProperty(BlockForceFieldBlue.FACING, (EnumFacing)state.getValue(FACING)).withProperty(BlockForceFieldBlue.DAMAGE, 1), 3); }else{ System.out.println("Teardown"); worldIn.setBlockToAir(pos.up(2)); worldIn.setBlockState(pos.up(2), ModBlocks.force_field_blue.getDefaultState().withProperty(BlockForceFieldBlue.FACING, (EnumFacing)state.getValue(FACING)).withProperty(BlockForceFieldBlue.DAMAGE, 0), 3); } } If there is redstone power on the "input side" it sets the powered state to true. if powered is true, it builds the forcefield. STATE 1 = on, STATE 0 = off The issue that I am running into is in the console whenever I give redstone power to the input side. I see 1 building, followed by 5-6 Teardown messages. The POWERED state appears to stay true, because the output side continues to output redstone signal @Override public int isProvidingWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side) { EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == side && ((Boolean)state.getValue(POWERED)).booleanValue()) { return 15; } else { return 0; } } So my thought is that it is getting neighborchanges from other blocks that are around it, which are messing up my POWERED state?. How can I change this so it is only checking once, on the block on the input side to see if it should be powered or not ? Share this post Link to post Share on other sites
gummby8 26 Report post Posted September 1, 2017 So I think I fixed this in a roundabout way. Rather than putting the build and teardown in the onNeighborBlockChange I put it in updateTick /** * Called when a neighboring block changes. */ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) { worldIn.scheduleUpdate(pos, this, 1); } @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { System.out.println(state.getValue(POWERED)); EnumFacing enumfacing = (EnumFacing) state.getValue(FACING); EnumFacing enumfacingY = enumfacing.getOpposite(); if (worldIn.getStrongPower(pos.offset(enumfacing), enumfacing) > 0) { worldIn.setBlockState(pos, state.withProperty(FACING, (EnumFacing) state.getValue(FACING)).withProperty(POWERED, true), 3); } else { worldIn.setBlockState(pos, state.withProperty(FACING, (EnumFacing) state.getValue(FACING)).withProperty(POWERED, false), 3); } if (((Boolean) state.getValue(POWERED)).booleanValue()) { // System.out.println("Building"); worldIn.setBlockState(pos.up(2), ModBlocks.force_field_blue.getDefaultState().withProperty(BlockForceFieldBlue.FACING, (EnumFacing) state.getValue(FACING)).withProperty(BlockForceFieldBlue.STATE, 1), 3); } else { // System.out.println("Teardown"); worldIn.setBlockToAir(pos.up(2)); worldIn.setBlockState(pos.up(2), ModBlocks.force_field_blue.getDefaultState().withProperty(BlockForceFieldBlue.FACING, (EnumFacing) state.getValue(FACING)).withProperty(BlockForceFieldBlue.STATE, 0), 3); } } This works, not sure if this is the best way to do it, but it is working Share this post Link to post Share on other sites