From 3d006e7e8739f4e0f39ba338064be51fb6d4b4a3 Mon Sep 17 00:00:00 2001 From: grimmauld Date: Thu, 10 Sep 2020 13:28:33 +0200 Subject: [PATCH] refactor getDispenseStack to getDispenseLocation, delete unused variable declaration in getUseableLocations, added accidentially removed comment back --- .../actors/dispenser/DispenserMovementBehaviour.java | 4 ++-- .../actors/dispenser/DropperMovementBehaviour.java | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java index d7453ae60..1af570dc3 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DispenserMovementBehaviour.java @@ -31,7 +31,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { @Override protected void activate(MovementContext context, BlockPos pos) { - DispenseItemLocation location = getDispenseStack(context); + DispenseItemLocation location = getDispenseLocation(context); if (location.isEmpty()) { context.world.playEvent(1001, pos, 0); } else { @@ -56,7 +56,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour { return; } } catch (NullPointerException ignored) { - itemstack = backup; + itemstack = backup; // Something went wrong with the TE being null in ContraptionBlockSource, reset the stack } setItemStackAt(location, defaultBehaviour.dispense(itemstack, context, pos), context); // the default: launch the item diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DropperMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DropperMovementBehaviour.java index f733c35f8..29ddec09b 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DropperMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/actors/dispenser/DropperMovementBehaviour.java @@ -19,7 +19,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { private static final Random RNG = new Random(); protected void activate(MovementContext context, BlockPos pos) { - DispenseItemLocation location = getDispenseStack(context); + DispenseItemLocation location = getDispenseLocation(context); if (location.isEmpty()) { context.world.playEvent(1001, pos, 0); } else { @@ -56,7 +56,6 @@ public class DropperMovementBehaviour extends MovementBehaviour { private ArrayList getUseableLocations(MovementContext context) { ArrayList useable = new ArrayList<>(); - NonNullList internalStacks = getStacks(context); for (int slot = 0; slot < getInvSize(); slot++) { DispenseItemLocation location = new DispenseItemLocation(true, slot); ItemStack testStack = getItemStackAt(location, context); @@ -66,7 +65,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { location = new DispenseItemLocation(false, ItemHelper.findFirstMatchingSlotIndex(context.contraption.inventory, testStack::isItemEqual)); if (!getItemStackAt(location, context).isEmpty()) useable.add(location); - } else if (internalStacks.get(slot).getCount() >= 2) + } else if (testStack.getCount() >= 2) useable.add(location); } return useable; @@ -86,7 +85,7 @@ public class DropperMovementBehaviour extends MovementBehaviour { writeExtraData(context); } - protected DispenseItemLocation getDispenseStack(MovementContext context) { + protected DispenseItemLocation getDispenseLocation(MovementContext context) { int i = -1; int j = 1; List useableLocations = getUseableLocations(context);