diff --git a/src/main/java/techreborn/blocks/cable/CableBlock.java b/src/main/java/techreborn/blocks/cable/CableBlock.java index c16413107..1dba38a64 100644 --- a/src/main/java/techreborn/blocks/cable/CableBlock.java +++ b/src/main/java/techreborn/blocks/cable/CableBlock.java @@ -102,9 +102,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { public BooleanProperty getProperty(Direction facing) { switch (facing) { - case EAST: - return EAST; - case WEST: + case WEST: return WEST; case NORTH: return NORTH; @@ -120,18 +118,18 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { } private BlockState makeConnections(World world, BlockPos pos) { - Boolean down = canConnectTo(world, pos.offset(Direction.DOWN, 1), Direction.UP); - Boolean up = canConnectTo(world, pos.up(), Direction.DOWN); - Boolean north = canConnectTo(world, pos.north(), Direction.SOUTH); - Boolean east = canConnectTo(world, pos.east(), Direction.WEST); - Boolean south = canConnectTo(world, pos.south(), Direction.NORTH); - Boolean west = canConnectTo(world, pos.west(), Direction.WEST); + Boolean down = canConnectTo(world, pos.down()); + Boolean up = canConnectTo(world, pos.up()); + Boolean north = canConnectTo(world, pos.north()); + Boolean east = canConnectTo(world, pos.east()); + Boolean south = canConnectTo(world, pos.south()); + Boolean west = canConnectTo(world, pos.west()); return this.getDefaultState().with(DOWN, down).with(UP, up).with(NORTH, north).with(EAST, east) .with(SOUTH, south).with(WEST, west); } - private Boolean canConnectTo(WorldAccess world, BlockPos pos, Direction facing) { + private Boolean canConnectTo(WorldAccess world, BlockPos pos) { BlockEntity blockEntity = world.getBlockEntity(pos); if (blockEntity != null && (Energy.valid(blockEntity) || blockEntity instanceof CableBlockEntity)) { return Boolean.TRUE; @@ -152,6 +150,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { } // Block + @SuppressWarnings("deprecation") @Override public ActionResult onUse(BlockState state, World worldIn, BlockPos pos, PlayerEntity playerIn, Hand hand, BlockHitResult hitResult) { ItemStack stack = playerIn.getStackInHand(Hand.MAIN_HAND); @@ -199,16 +198,18 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { .with(WATERLOGGED, context.getWorld().getFluidState(context.getBlockPos()).getFluid() == Fluids.WATER); } + @SuppressWarnings("deprecation") @Override public BlockState getStateForNeighborUpdate(BlockState ourState, Direction ourFacing, BlockState otherState, WorldAccess worldIn, BlockPos ourPos, BlockPos otherPos) { if (ourState.get(WATERLOGGED)) { worldIn.getFluidTickScheduler().schedule(ourPos, Fluids.WATER, Fluids.WATER.getTickRate(worldIn)); } - Boolean value = canConnectTo(worldIn, otherPos, ourFacing.getOpposite()); + Boolean value = canConnectTo(worldIn, otherPos); return ourState.with(getProperty(ourFacing), value); } + @SuppressWarnings("deprecation") @Override public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext shapeContext) { if (state.get(COVERED)) { @@ -217,6 +218,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { return cableShapeUtil.getShape(state); } + @SuppressWarnings("deprecation") @Override public void onEntityCollision(BlockState state, World worldIn, BlockPos pos, Entity entityIn) { super.onEntityCollision(state, worldIn, pos, entityIn); @@ -245,6 +247,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { entityIn.setOnFireFor(1); } entityIn.damage(new ElectrialShockSource(), 1F); + blockEntityCable.setEnergy(0d); } if (TechRebornConfig.uninsulatedElectrocutionSound) { worldIn.playSound(null, entityIn.getX(), entityIn.getY(), entityIn.getZ(), ModSounds.CABLE_SHOCK, SoundCategory.BLOCKS, @@ -265,6 +268,7 @@ public class CableBlock extends BlockWithEntity implements Waterloggable { return !state.get(COVERED) && Waterloggable.super.canFillWithFluid(view, pos, state, fluid); } + @SuppressWarnings("deprecation") @Override public FluidState getFluidState(BlockState state) { return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);