From f1c8e926861257cc0c61a448ac96c12f6f9bac71 Mon Sep 17 00:00:00 2001 From: _0Steven <42909981+SuicidalSteve@users.noreply.github.com> Date: Mon, 25 Jan 2021 16:39:47 +0100 Subject: [PATCH] Horizontal Crushers Bugfix -Fix bug where horizontal crushers would input items they just output when the belt was 'facing' the opposite direction. --- .../CrushingWheelControllerTileEntity.java | 2 +- .../BeltCrusherInteractionHandler.java | 23 +++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java index 88d2ee50e..147605918 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crusher/CrushingWheelControllerTileEntity.java @@ -137,7 +137,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity { //Output Items if (facing.getAxis().isHorizontal() || facing == Direction.DOWN) { BlockPos nextPos = pos.add(facing.getAxis() == Axis.X ? 1f * offset : 0f - , (facing == Direction.DOWN || facing.getAxis().isHorizontal()) ? -1f : 0f + , (-1f) , facing.getAxis() == Axis.Z ? 1f * offset : 0f); DirectBeltInputBehaviour behaviour = TileEntityBehaviour.get(world, nextPos, DirectBeltInputBehaviour.TYPE); if (behaviour != null) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltCrusherInteractionHandler.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltCrusherInteractionHandler.java index c1c9fae10..61a6b1514 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltCrusherInteractionHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltCrusherInteractionHandler.java @@ -32,19 +32,18 @@ public class BeltCrusherInteractionHandler { continue; Direction crusherFacing = crusherState.get(CrushingWheelControllerBlock.FACING); Direction movementFacing = beltInventory.belt.getMovementFacing(); - boolean blocking = crusherFacing == movementFacing; if (crusherFacing != movementFacing) continue; float crusherEntry = segment + .5f; crusherEntry += .399f * (beltMovementPositive ? -1 : 1); + float postCrusherEntry = crusherEntry + .199f * (!beltMovementPositive ? -1 : 1); - boolean hasCrossed = nextOffset > crusherEntry && beltMovementPositive - || nextOffset < crusherEntry && !beltMovementPositive; + boolean hasCrossed = nextOffset > crusherEntry && nextOffset < postCrusherEntry && beltMovementPositive + || nextOffset < crusherEntry && nextOffset > postCrusherEntry && !beltMovementPositive; if (!hasCrossed) return false; - if (blocking) - currentItem.beltPosition = crusherEntry; + currentItem.beltPosition = crusherEntry; TileEntity te = world.getTileEntity(crusherPos); if (!(te instanceof CrushingWheelControllerTileEntity)) @@ -52,20 +51,11 @@ public class BeltCrusherInteractionHandler { CrushingWheelControllerTileEntity crusherTE = (CrushingWheelControllerTileEntity) te; - int amountToExtract = -1; ItemStack toInsert = currentItem.stack.copy(); - if (amountToExtract > toInsert.getCount()) - if (blocking) - return true; - else - continue; ItemStack remainder = ItemHandlerHelper.insertItemStacked(crusherTE.inventory, toInsert, false); if (toInsert.equals(remainder, false)) - if (blocking) - return true; - else - continue; + return true; int notFilled = currentItem.stack.getCount() - toInsert.getCount(); if (!remainder.isEmpty()) { @@ -75,8 +65,7 @@ public class BeltCrusherInteractionHandler { currentItem.stack = remainder; beltInventory.belt.sendData(); - if (blocking) - return true; + return true; } return false;