Horizontal Crushers Bugfix

-Fix bug where horizontal crushers would input items they just output when the belt was 'facing' the opposite direction.
This commit is contained in:
_0Steven 2021-01-25 16:39:47 +01:00
parent 7b5737cf82
commit f1c8e92686
2 changed files with 7 additions and 18 deletions

View file

@ -137,7 +137,7 @@ public class CrushingWheelControllerTileEntity extends SmartTileEntity {
//Output Items //Output Items
if (facing.getAxis().isHorizontal() || facing == Direction.DOWN) { if (facing.getAxis().isHorizontal() || facing == Direction.DOWN) {
BlockPos nextPos = pos.add(facing.getAxis() == Axis.X ? 1f * offset : 0f 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); , facing.getAxis() == Axis.Z ? 1f * offset : 0f);
DirectBeltInputBehaviour behaviour = TileEntityBehaviour.get(world, nextPos, DirectBeltInputBehaviour.TYPE); DirectBeltInputBehaviour behaviour = TileEntityBehaviour.get(world, nextPos, DirectBeltInputBehaviour.TYPE);
if (behaviour != null) { if (behaviour != null) {

View file

@ -32,18 +32,17 @@ public class BeltCrusherInteractionHandler {
continue; continue;
Direction crusherFacing = crusherState.get(CrushingWheelControllerBlock.FACING); Direction crusherFacing = crusherState.get(CrushingWheelControllerBlock.FACING);
Direction movementFacing = beltInventory.belt.getMovementFacing(); Direction movementFacing = beltInventory.belt.getMovementFacing();
boolean blocking = crusherFacing == movementFacing;
if (crusherFacing != movementFacing) if (crusherFacing != movementFacing)
continue; continue;
float crusherEntry = segment + .5f; float crusherEntry = segment + .5f;
crusherEntry += .399f * (beltMovementPositive ? -1 : 1); crusherEntry += .399f * (beltMovementPositive ? -1 : 1);
float postCrusherEntry = crusherEntry + .199f * (!beltMovementPositive ? -1 : 1);
boolean hasCrossed = nextOffset > crusherEntry && beltMovementPositive boolean hasCrossed = nextOffset > crusherEntry && nextOffset < postCrusherEntry && beltMovementPositive
|| nextOffset < crusherEntry && !beltMovementPositive; || nextOffset < crusherEntry && nextOffset > postCrusherEntry && !beltMovementPositive;
if (!hasCrossed) if (!hasCrossed)
return false; return false;
if (blocking)
currentItem.beltPosition = crusherEntry; currentItem.beltPosition = crusherEntry;
TileEntity te = world.getTileEntity(crusherPos); TileEntity te = world.getTileEntity(crusherPos);
@ -52,20 +51,11 @@ public class BeltCrusherInteractionHandler {
CrushingWheelControllerTileEntity crusherTE = (CrushingWheelControllerTileEntity) te; CrushingWheelControllerTileEntity crusherTE = (CrushingWheelControllerTileEntity) te;
int amountToExtract = -1;
ItemStack toInsert = currentItem.stack.copy(); ItemStack toInsert = currentItem.stack.copy();
if (amountToExtract > toInsert.getCount())
if (blocking)
return true;
else
continue;
ItemStack remainder = ItemHandlerHelper.insertItemStacked(crusherTE.inventory, toInsert, false); ItemStack remainder = ItemHandlerHelper.insertItemStacked(crusherTE.inventory, toInsert, false);
if (toInsert.equals(remainder, false)) if (toInsert.equals(remainder, false))
if (blocking)
return true; return true;
else
continue;
int notFilled = currentItem.stack.getCount() - toInsert.getCount(); int notFilled = currentItem.stack.getCount() - toInsert.getCount();
if (!remainder.isEmpty()) { if (!remainder.isEmpty()) {
@ -75,7 +65,6 @@ public class BeltCrusherInteractionHandler {
currentItem.stack = remainder; currentItem.stack = remainder;
beltInventory.belt.sendData(); beltInventory.belt.sendData();
if (blocking)
return true; return true;
} }