From b453e6bb2cf0342dde70a6bb6825708ee7f0d15f Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 1 Feb 2020 11:13:15 +0100 Subject: [PATCH] Wrench usage and Smart Cogwheel Placement - Wrench can now be used properly on most kinetic components - Cogwheels now offset their placement to correct locations automatically - Hand cranks have to be attached to a block now - Mixer and Press can no longer be placed directly above a basin --- .../base/DirectionalAxisKineticBlock.java | 24 ++++++- .../base/DirectionalKineticBlock.java | 29 ++++++++ .../base/HorizontalKineticBlock.java | 22 ++++++ .../modules/contraptions/base/IRotate.java | 6 +- .../contraptions/base/KineticBlock.java | 5 +- .../components/actors/DrillBlock.java | 5 +- .../bearing/MechanicalBearingBlock.java | 8 ++- .../piston/MechanicalPistonBlock.java | 14 ++++ .../crafter/MechanicalCrafterBlock.java | 3 +- .../components/crank/HandCrankBlock.java | 50 ++++++++++--- .../crusher/CrushingWheelBlock.java | 2 +- .../components/fan/EncasedFanBlock.java | 3 +- .../mixer/BasinOperatorBlockItem.java | 33 +++++++++ .../mixer/MechanicalMixerBlock.java | 38 +++------- .../components/motor/MotorBlock.java | 4 +- .../press/MechanicalPressBlock.java | 22 ++++-- .../contraptions/components/saw/SawBlock.java | 3 +- .../components/turntable/TurntableBlock.java | 3 +- .../waterwheel/WaterWheelBlock.java | 2 +- .../contraptions/relays/belt/BeltBlock.java | 3 +- .../relays/elementary/CogWheelBlock.java | 21 ++++-- .../relays/elementary/CogwheelBlockItem.java | 71 +++++++++++++++++++ .../relays/elementary/ShaftBlock.java | 4 +- .../relays/encased/EncasedBeltBlock.java | 19 ++++- .../relays/encased/EncasedShaftBlock.java | 4 +- .../relays/encased/GearshiftBlock.java | 3 +- .../relays/gearbox/GearboxBlock.java | 4 +- 27 files changed, 331 insertions(+), 74 deletions(-) create mode 100644 src/main/java/com/simibubi/create/modules/contraptions/components/mixer/BasinOperatorBlockItem.java create mode 100644 src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogwheelBlockItem.java diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalAxisKineticBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalAxisKineticBlock.java index 8081ed6ae..16bba1fbb 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalAxisKineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalAxisKineticBlock.java @@ -3,11 +3,14 @@ package com.simibubi.create.modules.contraptions.base; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemUseContext; import net.minecraft.state.BooleanProperty; import net.minecraft.state.StateContainer.Builder; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBlock { @@ -30,7 +33,7 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc facing = facing.getOpposite(); return facing; } - + protected boolean getAxisAlignmentForPlacement(BlockItemUseContext context) { return context.getPlacementHorizontalFacing().getAxis() == Axis.X; } @@ -82,6 +85,23 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc return this.getDefaultState().with(FACING, facing).with(AXIS_ALONG_FIRST_COORDINATE, alongFirst); } + @Override + public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + World world = context.getWorld(); + Direction face = context.getFace(); + if ((turnBackOnWrenched() ? face.getOpposite() : face) == state.get(FACING)) { + if (!world.isRemote) { + BlockPos pos = context.getPos(); + world.removeTileEntity(pos); + world.setBlockState(pos, state.cycle(AXIS_ALONG_FIRST_COORDINATE), 3); + KineticTileEntity tileEntity = (KineticTileEntity) world.getTileEntity(pos); + tileEntity.attachKinetics(); + } + return ActionResultType.SUCCESS; + } + return super.onWrenched(state, context); + } + @Override public Axis getRotationAxis(BlockState state) { Axis pistonAxis = state.get(FACING).getAxis(); @@ -98,7 +118,7 @@ public abstract class DirectionalAxisKineticBlock extends DirectionalKineticBloc } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == getRotationAxis(state); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalKineticBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalKineticBlock.java index f299ee454..cb80899ec 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalKineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/DirectionalKineticBlock.java @@ -3,12 +3,16 @@ package com.simibubi.create.modules.contraptions.base; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemUseContext; import net.minecraft.state.DirectionProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; public abstract class DirectionalKineticBlock extends KineticBlock { @@ -42,6 +46,31 @@ public abstract class DirectionalKineticBlock extends KineticBlock { return prefferedSide; } + @Override + public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + Direction facing = turnBackOnWrenched() ? context.getFace().getOpposite() : context.getFace(); + World world = context.getWorld(); + if (facing == state.get(FACING)) + return ActionResultType.PASS; + + BlockState with = state.with(FACING, facing); + if (!with.isValidPosition(world, context.getPos())) + return ActionResultType.PASS; + + if (!world.isRemote) { + BlockPos pos = context.getPos(); + world.removeTileEntity(pos); + world.setBlockState(pos, with, 3); + KineticTileEntity tileEntity = (KineticTileEntity) world.getTileEntity(pos); + tileEntity.attachKinetics(); + } + return ActionResultType.SUCCESS; + } + + protected boolean turnBackOnWrenched() { + return false; + } + @Override public BlockState getStateForPlacement(BlockItemUseContext context) { Direction preferred = getPreferredFacing(context); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/HorizontalKineticBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/base/HorizontalKineticBlock.java index 2fbc3a639..538dbdd77 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/HorizontalKineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/HorizontalKineticBlock.java @@ -3,12 +3,16 @@ package com.simibubi.create.modules.contraptions.base; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemUseContext; import net.minecraft.state.IProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; public abstract class HorizontalKineticBlock extends KineticBlock { @@ -49,6 +53,24 @@ public abstract class HorizontalKineticBlock extends KineticBlock { return prefferedSide; } + @Override + public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + Direction facing = context.getFace(); + if (facing.getAxis().isVertical()) + return ActionResultType.PASS; + World world = context.getWorld(); + if (facing == state.get(HORIZONTAL_FACING)) + return ActionResultType.PASS; + if (!world.isRemote) { + BlockPos pos = context.getPos(); + world.removeTileEntity(pos); + world.setBlockState(pos, state.with(HORIZONTAL_FACING, facing), 3); + KineticTileEntity tileEntity = (KineticTileEntity) world.getTileEntity(pos); + tileEntity.attachKinetics(); + } + return ActionResultType.SUCCESS; + } + @Override public BlockState rotate(BlockState state, Rotation rot) { return state.with(HORIZONTAL_FACING, rot.rotate(state.get(HORIZONTAL_FACING))); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java b/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java index 5ce7cb632..5a674862f 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/IRotate.java @@ -8,7 +8,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; -import net.minecraft.world.World; +import net.minecraft.world.IWorldReader; public interface IRotate extends IWrenchable { @@ -61,9 +61,9 @@ public interface IRotate extends IWrenchable { } } - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face); + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face); - public boolean hasCogsTowards(World world, BlockPos pos, BlockState state, Direction face); + public boolean hasCogsTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face); public Axis getRotationAxis(BlockState state); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticBlock.java index 400317c28..4fe29a070 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/base/KineticBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/base/KineticBlock.java @@ -16,6 +16,7 @@ import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraftforge.common.ToolType; @@ -49,12 +50,12 @@ public abstract class KineticBlock extends Block implements IRotate { // IRotate @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return false; } @Override - public boolean hasCogsTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasCogsTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return false; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java index 27cbc4ea3..654a80c5b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/actors/DrillBlock.java @@ -26,6 +26,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; import net.minecraftforge.api.distmarker.Dist; @@ -65,7 +66,7 @@ public class DrillBlock extends DirectionalKineticBlock } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face == state.get(FACING).getOpposite(); } @@ -78,7 +79,7 @@ public class DrillBlock extends DirectionalKineticBlock protected boolean hasStaticPart() { return true; } - + @Override @OnlyIn(value = Dist.CLIENT) public SuperByteBuffer renderInContraption(MovementContext context) { diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/bearing/MechanicalBearingBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/bearing/MechanicalBearingBlock.java index 1d237fe5c..d5161d6e3 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/bearing/MechanicalBearingBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/bearing/MechanicalBearingBlock.java @@ -11,6 +11,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class MechanicalBearingBlock extends DirectionalKineticBlock @@ -35,7 +36,7 @@ public class MechanicalBearingBlock extends DirectionalKineticBlock } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face == state.get(FACING).getOpposite(); } @@ -44,6 +45,11 @@ public class MechanicalBearingBlock extends DirectionalKineticBlock return true; } + @Override + protected boolean turnBackOnWrenched() { + return true; + } + @Override public Axis getRotationAxis(BlockState state) { return state.get(FACING).getAxis(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonBlock.java index d58f02b30..5f0b1c75d 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonBlock.java @@ -10,11 +10,13 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemUseContext; import net.minecraft.particles.ParticleTypes; import net.minecraft.state.EnumProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.IStringSerializable; @@ -84,6 +86,18 @@ public class MechanicalPistonBlock extends DirectionalAxisKineticBlock { return true; } + @Override + public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + if (state.get(STATE) != PistonState.RETRACTED) + return ActionResultType.PASS; + return super.onWrenched(state, context); + } + + @Override + protected boolean turnBackOnWrenched() { + return true; + } + public enum PistonState implements IStringSerializable { RETRACTED, MOVING, EXTENDED; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterBlock.java index d34381c0f..0a76bf009 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crafter/MechanicalCrafterBlock.java @@ -33,6 +33,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.Vec3d; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraftforge.items.ItemHandlerHelper; @@ -62,7 +63,7 @@ public class MechanicalCrafterBlock extends HorizontalKineticBlock } @Override - public boolean hasCogsTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasCogsTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return state.get(HORIZONTAL_FACING).getAxis() != face.getAxis(); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crank/HandCrankBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crank/HandCrankBlock.java index 7deb1ee0a..1d455aa0a 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crank/HandCrankBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crank/HandCrankBlock.java @@ -5,8 +5,10 @@ import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.modules.contraptions.base.DirectionalKineticBlock; +import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItemUseContext; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; @@ -16,6 +18,7 @@ import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class HandCrankBlock extends DirectionalKineticBlock implements IWithTileEntity { @@ -23,7 +26,7 @@ public class HandCrankBlock extends DirectionalKineticBlock implements IWithTile public HandCrankBlock() { super(Properties.from(AllBlocks.COGWHEEL.get())); } - + @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { return AllShapes.CRANK.get(state.get(FACING)); @@ -33,29 +36,60 @@ public class HandCrankBlock extends DirectionalKineticBlock implements IWithTile public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { boolean handEmpty = player.getHeldItem(handIn).isEmpty(); - + if (!handEmpty && player.isSneaking()) return false; - + withTileEntityDo(worldIn, pos, te -> te.turn(player.isSneaking())); return true; } - + + @Override + public BlockState getStateForPlacement(BlockItemUseContext context) { + Direction preferred = getPreferredFacing(context); + if (preferred == null || context.isPlacerSneaking()) + return getDefaultState().with(FACING, context.getFace()); + return getDefaultState().with(FACING, preferred.getOpposite()); + } + + @Override + public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { + Direction facing = state.get(FACING).getOpposite(); + BlockPos neighbourPos = pos.offset(facing); + BlockState neighbour = worldIn.getBlockState(neighbourPos); + return !neighbour.getCollisionShape(worldIn, neighbourPos).isEmpty(); + } + + @Override + public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, + boolean isMoving) { + if (worldIn.isRemote) + return; + + Direction blockFacing = state.get(FACING); + if (fromPos.equals(pos.offset(blockFacing.getOpposite()))) { + if (!isValidPosition(state, worldIn, pos)) { + worldIn.destroyBlock(pos, true); + return; + } + } + } + @Override public TileEntity createTileEntity(BlockState state, IBlockReader world) { return new HandCrankTileEntity(); } - + @Override protected boolean hasStaticPart() { return false; } - + @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face == state.get(FACING).getOpposite(); } - + @Override public Axis getRotationAxis(BlockState state) { return state.get(FACING).getAxis(); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelBlock.java index 82f41e7e5..41f7c4557 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelBlock.java @@ -145,7 +145,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock { } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.get(AXIS); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/EncasedFanBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/EncasedFanBlock.java index 4e501d553..56bf5616c 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/fan/EncasedFanBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/fan/EncasedFanBlock.java @@ -14,6 +14,7 @@ import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class EncasedFanBlock extends DirectionalKineticBlock implements IWithTileEntity { @@ -74,7 +75,7 @@ public class EncasedFanBlock extends DirectionalKineticBlock implements IWithTil } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face == state.get(FACING).getOpposite(); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/BasinOperatorBlockItem.java b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/BasinOperatorBlockItem.java new file mode 100644 index 000000000..e210d7597 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/BasinOperatorBlockItem.java @@ -0,0 +1,33 @@ +package com.simibubi.create.modules.contraptions.components.mixer; + +import com.simibubi.create.AllBlocks; + +import net.minecraft.block.BlockState; +import net.minecraft.item.BlockItem; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Direction; +import net.minecraft.util.math.BlockPos; + +public class BasinOperatorBlockItem extends BlockItem { + + public BasinOperatorBlockItem(AllBlocks block, Properties builder) { + super(block.get(), builder); + } + + @Override + public ActionResultType tryPlace(BlockItemUseContext context) { + + BlockPos placedOnPos = context.getPos().offset(context.getFace().getOpposite()); + BlockState placedOnState = context.getWorld().getBlockState(placedOnPos); + if (AllBlocks.BASIN.typeOf(placedOnState)) { + if (context.getWorld().getBlockState(placedOnPos.up(2)).getMaterial().isReplaceable()) + context = BlockItemUseContext.func_221536_a(context, placedOnPos.up(2), Direction.UP); + else + return ActionResultType.FAIL; + } + + return super.tryPlace(context); + } + +} \ No newline at end of file diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerBlock.java index a37295810..f0c7f87f6 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/mixer/MechanicalMixerBlock.java @@ -12,9 +12,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.BlockItem; -import net.minecraft.item.BlockItemUseContext; import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.ActionResultType; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; @@ -24,7 +22,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.IWorldReader; public class MechanicalMixerBlock extends KineticBlock implements IWithTileEntity, IHaveScrollableValue, IHaveCustomBlockItem { @@ -44,6 +42,11 @@ public class MechanicalMixerBlock extends KineticBlock protected boolean hasStaticPart() { return true; } + + @Override + public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { + return !AllBlocks.BASIN.typeOf(worldIn.getBlockState(pos.down())); + } @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { @@ -64,38 +67,15 @@ public class MechanicalMixerBlock extends KineticBlock } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return false; } @Override - public boolean hasCogsTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasCogsTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis().isHorizontal(); } - public static class MechanicalMixerBlockItem extends BlockItem { - - public MechanicalMixerBlockItem(Properties builder) { - super(AllBlocks.MECHANICAL_MIXER.get(), builder); - } - - @Override - public ActionResultType tryPlace(BlockItemUseContext context) { - - BlockPos placedOnPos = context.getPos().offset(context.getFace().getOpposite()); - BlockState placedOnState = context.getWorld().getBlockState(placedOnPos); - if (AllBlocks.BASIN.typeOf(placedOnState)) { - if (context.getWorld().getBlockState(placedOnPos.up(2)).getMaterial().isReplaceable()) - context = BlockItemUseContext.func_221536_a(context, placedOnPos.up(2), Direction.UP); - else - return ActionResultType.FAIL; - } - - return super.tryPlace(context); - } - - } - @Override public String getValueName(BlockState state, IWorld world, BlockPos pos) { return Lang.translate("mechanical_mixer.min_ingredients"); @@ -156,7 +136,7 @@ public class MechanicalMixerBlock extends KineticBlock @Override public BlockItem getCustomItem(net.minecraft.item.Item.Properties properties) { - return new MechanicalMixerBlockItem(properties); + return new BasinOperatorBlockItem(AllBlocks.MECHANICAL_MIXER, properties); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java index 7d03e9c1a..07fa317cc 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/motor/MotorBlock.java @@ -18,7 +18,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.IWorldReader; public class MotorBlock extends HorizontalKineticBlock implements IWithTileEntity, IHaveScrollableValue { @@ -50,7 +50,7 @@ public class MotorBlock extends HorizontalKineticBlock // IRotate: @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face == state.get(HORIZONTAL_FACING); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressBlock.java index 476c1235f..c964e5e71 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/press/MechanicalPressBlock.java @@ -5,12 +5,14 @@ import java.util.List; import java.util.Optional; import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.block.IHaveCustomBlockItem; import com.simibubi.create.foundation.block.IRenderUtilityBlock; import com.simibubi.create.foundation.block.IWithTileEntity; import com.simibubi.create.foundation.block.SyncedTileEntity; import com.simibubi.create.foundation.item.ItemHelper; import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.modules.contraptions.base.HorizontalKineticBlock; +import com.simibubi.create.modules.contraptions.components.mixer.BasinOperatorBlockItem; import com.simibubi.create.modules.contraptions.components.press.MechanicalPressTileEntity.Mode; import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.BeltAttachmentState; import com.simibubi.create.modules.contraptions.relays.belt.AllBeltAttachments.IBeltAttachment; @@ -24,6 +26,7 @@ import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.HorizontalBlock; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemStack; import net.minecraft.state.StateContainer.Builder; @@ -35,10 +38,11 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class MechanicalPressBlock extends HorizontalKineticBlock - implements IWithTileEntity, IBeltAttachment { + implements IWithTileEntity, IBeltAttachment, IHaveCustomBlockItem { public MechanicalPressBlock() { super(Properties.from(Blocks.PISTON)); @@ -52,6 +56,11 @@ public class MechanicalPressBlock extends HorizontalKineticBlock return AllShapes.MECHANICAL_PROCESSOR_SHAPE; } + @Override + public boolean isValidPosition(BlockState state, IWorldReader worldIn, BlockPos pos) { + return !AllBlocks.BASIN.typeOf(worldIn.getBlockState(pos.down())); + } + @Override public void neighborChanged(BlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving) { @@ -89,7 +98,7 @@ public class MechanicalPressBlock extends HorizontalKineticBlock } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.get(HORIZONTAL_FACING).getAxis(); } @@ -157,10 +166,10 @@ public class MechanicalPressBlock extends HorizontalKineticBlock if (pressTe.running) { if (pressTe.runningTicks == 30) { Optional recipe = pressTe.getRecipe(transportedStack.stack); - + pressTe.pressedItems.clear(); pressTe.pressedItems.add(transportedStack.stack); - + if (!recipe.isPresent()) return false; ItemStack out = recipe.get().getRecipeOutput().copy(); @@ -192,5 +201,10 @@ public class MechanicalPressBlock extends HorizontalKineticBlock super.fillStateContainer(builder); } } + + @Override + public BlockItem getCustomItem(net.minecraft.item.Item.Properties properties) { + return new BasinOperatorBlockItem(AllBlocks.MECHANICAL_PRESS, properties); + } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java index 29dccda1b..c3b139e76 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/saw/SawBlock.java @@ -26,6 +26,7 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class SawBlock extends DirectionalAxisKineticBlock @@ -112,7 +113,7 @@ public class SawBlock extends DirectionalAxisKineticBlock } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return isHorizontal(state) ? face == state.get(FACING).getOpposite() : super.hasShaftTowards(world, pos, state, face); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableBlock.java index 7a28376b5..f61cc151b 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/turntable/TurntableBlock.java @@ -19,6 +19,7 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class TurntableBlock extends KineticBlock { @@ -85,7 +86,7 @@ public class TurntableBlock extends KineticBlock { // IRotate: @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face == Direction.DOWN; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/waterwheel/WaterWheelBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/waterwheel/WaterWheelBlock.java index 2dc75ab48..78610f736 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/waterwheel/WaterWheelBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/waterwheel/WaterWheelBlock.java @@ -125,7 +125,7 @@ public class WaterWheelBlock extends HorizontalKineticBlock { } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return state.get(HORIZONTAL_FACING).getAxis() == face.getAxis(); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java index 7c5a8c26e..032e7aac3 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java @@ -46,6 +46,7 @@ import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.util.math.shapes.VoxelShapes; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; import net.minecraftforge.common.Tags; import net.minecraftforge.items.CapabilityItemHandler; @@ -63,7 +64,7 @@ public class BeltBlock extends HorizontalKineticBlock implements IHaveNoBlockIte } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { if (face.getAxis() != getRotationAxis(state)) return false; BeltTileEntity beltEntity = (BeltTileEntity) world.getTileEntity(pos); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogWheelBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogWheelBlock.java index 98c333d26..2305f7b49 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogWheelBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogWheelBlock.java @@ -1,25 +1,27 @@ package com.simibubi.create.modules.contraptions.relays.elementary; import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.block.IHaveCustomBlockItem; import com.simibubi.create.foundation.utility.AllShapes; import com.simibubi.create.modules.contraptions.base.IRotate; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItemUseContext; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.Direction; import net.minecraft.util.NonNullList; +import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorldReader; -import net.minecraft.world.World; -public class CogWheelBlock extends ShaftBlock { +public class CogWheelBlock extends ShaftBlock implements IHaveCustomBlockItem { private boolean isLarge; @@ -53,8 +55,12 @@ public class CogWheelBlock extends ShaftBlock { Block block = placedAgainst.getBlock(); if (!(block instanceof IRotate) || !(((IRotate) block).hasCogsTowards(context.getWorld(), placedOnPos, - placedAgainst, context.getFace()))) - return super.getStateForPlacement(context); + placedAgainst, context.getFace()))) { + Axis preferredAxis = getPreferredAxis(context); + if (preferredAxis != null) + return this.getDefaultState().with(AXIS, preferredAxis); + return this.getDefaultState().with(AXIS, context.getFace().getAxis()); + } return getDefaultState().with(AXIS, ((IRotate) block).getRotationAxis(placedAgainst)); } @@ -76,8 +82,13 @@ public class CogWheelBlock extends ShaftBlock { // IRotate @Override - public boolean hasCogsTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasCogsTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return !isLarge && face.getAxis() != state.get(AXIS); } + @Override + public BlockItem getCustomItem(net.minecraft.item.Item.Properties properties) { + return new CogwheelBlockItem(this, properties, isLarge); + } + } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogwheelBlockItem.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogwheelBlockItem.java new file mode 100644 index 000000000..0dd2c8432 --- /dev/null +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/CogwheelBlockItem.java @@ -0,0 +1,71 @@ +package com.simibubi.create.modules.contraptions.relays.elementary; + +import com.simibubi.create.AllBlocks; +import com.simibubi.create.foundation.utility.Debug; +import com.simibubi.create.foundation.utility.VecHelper; + +import net.minecraft.block.Block; +import net.minecraft.block.BlockState; +import net.minecraft.item.BlockItem; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Direction; +import net.minecraft.util.Direction.Axis; +import net.minecraft.util.Direction.AxisDirection; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; + +public class CogwheelBlockItem extends BlockItem { + + boolean large; + + public CogwheelBlockItem(Block block, Properties builder, boolean isLarge) { + super(block, builder); + large = isLarge; + } + + @Override + public ActionResultType tryPlace(BlockItemUseContext context) { + Direction face = context.getFace(); + BlockPos placedOnPos = context.getPos().offset(face.getOpposite()); + BlockState placedOnState = context.getWorld().getBlockState(placedOnPos); + + if (!(placedOnState.getBlock() instanceof CogWheelBlock)) + return super.tryPlace(context); + if (face.getAxis() == placedOnState.get(CogWheelBlock.AXIS)) + return super.tryPlace(context); + + boolean placedOnLarge = AllBlocks.LARGE_COGWHEEL.typeOf(placedOnState); + if (placedOnLarge || large) { + + boolean largeOnLarge = placedOnLarge && large; + Axis offsetAxis = Axis.X; + for (Axis axis : Axis.values()) { + if (placedOnState.get(CogWheelBlock.AXIS) == axis) + continue; + if (axis == face.getAxis()) + continue; + offsetAxis = axis; + } + + if (largeOnLarge) + offsetAxis = placedOnState.get(CogWheelBlock.AXIS); + + Vec3d hitVec = context.getHitVec().subtract(VecHelper.getCenterOf(placedOnPos)); + hitVec = hitVec + .mul(new Vec3d(Direction.getFacingFromAxis(AxisDirection.POSITIVE, offsetAxis).getDirectionVec())); + + BlockPos correctPos = context.getPos().add(Math.signum(hitVec.x), Math.signum(hitVec.y), + Math.signum(hitVec.z)); + + if (context.getWorld().getBlockState(correctPos).getMaterial().isReplaceable()) + context = BlockItemUseContext.func_221536_a(context, correctPos, largeOnLarge ? face + : Direction.getFacingFromAxis(AxisDirection.POSITIVE, placedOnState.get(CogWheelBlock.AXIS))); + else + return ActionResultType.FAIL; + } + + return super.tryPlace(context); + } + +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/ShaftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/ShaftBlock.java index 9e49dd1e7..bfac13f95 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/ShaftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/elementary/ShaftBlock.java @@ -15,7 +15,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.shapes.ISelectionContext; import net.minecraft.util.math.shapes.VoxelShape; import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.IWorldReader; public class ShaftBlock extends RotatedPillarKineticBlock { @@ -57,7 +57,7 @@ public class ShaftBlock extends RotatedPillarKineticBlock { // IRotate: @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.get(AXIS); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedBeltBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedBeltBlock.java index 383b027c0..cf6f20cf7 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedBeltBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedBeltBlock.java @@ -7,11 +7,13 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.item.BlockItemUseContext; +import net.minecraft.item.ItemUseContext; import net.minecraft.state.BooleanProperty; import net.minecraft.state.EnumProperty; import net.minecraft.state.IProperty; import net.minecraft.state.StateContainer.Builder; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.AxisDirection; @@ -19,7 +21,7 @@ import net.minecraft.util.IStringSerializable; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; -import net.minecraft.world.World; +import net.minecraft.world.IWorldReader; public class EncasedBeltBlock extends RotatedPillarKineticBlock { @@ -106,7 +108,7 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.get(AXIS); } @@ -144,6 +146,19 @@ public class EncasedBeltBlock extends RotatedPillarKineticBlock { return new EncasedShaftTileEntity(); } + @Override + public ActionResultType onWrenched(BlockState state, ItemUseContext context) { + Axis axis = state.get(AXIS); + boolean connectionAlongFirst = state.get(CONNECTED_ALONG_FIRST_COORDINATE); + Axis connectionAxis = connectionAlongFirst ? (axis == Axis.X ? Axis.Y : Axis.X) + : (axis == Axis.Z ? Axis.Y : Axis.Z); + + if (context.getFace().getAxis() == connectionAxis) + return ActionResultType.PASS; + + return super.onWrenched(state, context); + } + @Override protected boolean hasStaticPart() { return true; diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java index 1cf10ccfc..db6e02bb3 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/EncasedShaftBlock.java @@ -11,7 +11,7 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.IWorldReader; public class EncasedShaftBlock extends RotatedPillarKineticBlock { @@ -44,7 +44,7 @@ public class EncasedShaftBlock extends RotatedPillarKineticBlock { } @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() == state.get(AXIS); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java index e520d4410..6558663a9 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/encased/GearshiftBlock.java @@ -14,6 +14,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; +import net.minecraft.world.IWorldReader; import net.minecraft.world.World; public class GearshiftBlock extends EncasedShaftBlock { @@ -55,7 +56,7 @@ public class GearshiftBlock extends EncasedShaftBlock { } } - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return super.hasShaftTowards(world, pos, state, face); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/gearbox/GearboxBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/gearbox/GearboxBlock.java index 4ec151abb..8162005f9 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/gearbox/GearboxBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/gearbox/GearboxBlock.java @@ -20,7 +20,7 @@ import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.IBlockReader; -import net.minecraft.world.World; +import net.minecraft.world.IWorldReader; import net.minecraft.world.storage.loot.LootContext.Builder; public class GearboxBlock extends RotatedPillarKineticBlock { @@ -69,7 +69,7 @@ public class GearboxBlock extends RotatedPillarKineticBlock { // IRotate: @Override - public boolean hasShaftTowards(World world, BlockPos pos, BlockState state, Direction face) { + public boolean hasShaftTowards(IWorldReader world, BlockPos pos, BlockState state, Direction face) { return face.getAxis() != state.get(AXIS); }