Jump to content

blueDude-owo

Members
  • Posts

    2
  • Joined

  • Last visited

blueDude-owo's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. i need help with changing the blockstate of my block when a certain block is near it here's the code: package net.blub.blub_mod.block; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorldReader; public class BluestoneWire extends Block { public static final BooleanProperty NORTH = BooleanProperty.create("north"); public static final BooleanProperty SOUTH = BooleanProperty.create("south"); public static final BooleanProperty EAST = BooleanProperty.create("east"); public static final BooleanProperty WEST = BooleanProperty.create("west"); public BluestoneWire(Properties properties) { super(properties); this.registerDefaultState(this.stateDefinition.any().setValue(NORTH, false).setValue(SOUTH, false).setValue(EAST, false).setValue(WEST, false)); } @Override public void onNeighborChange(BlockState state, IWorldReader world, BlockPos pos, BlockPos neighbor) { int x = pos.getX(); int nx = pos.getX()-1; int y = pos.getY(); int ny = pos.getY()-1; int z = pos.getZ(); int nz = pos.getZ()-1; BlockPos posnz = new BlockPos(x, y, nz); if ((world.getBlockState(posnz).getBlock()) == Blocks.ANDESITE) { state.setValue(NORTH, true); } else { state.setValue(NORTH, false); } super.onNeighborChange(state, world, pos, neighbor); } protected void createBlockStateDefinition(StateContainer.Builder<Block, BlockState> stateContainer) { stateContainer.add(NORTH, SOUTH, EAST, WEST); } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.