mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-01 01:46:39 +01:00
refactor getDispenseStack to getDispenseLocation, delete unused variable declaration in getUseableLocations, added accidentially removed comment back
This commit is contained in:
parent
7784e5b58d
commit
3d006e7e87
2 changed files with 5 additions and 6 deletions
|
@ -31,7 +31,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void activate(MovementContext context, BlockPos pos) {
|
protected void activate(MovementContext context, BlockPos pos) {
|
||||||
DispenseItemLocation location = getDispenseStack(context);
|
DispenseItemLocation location = getDispenseLocation(context);
|
||||||
if (location.isEmpty()) {
|
if (location.isEmpty()) {
|
||||||
context.world.playEvent(1001, pos, 0);
|
context.world.playEvent(1001, pos, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,7 +56,7 @@ public class DispenserMovementBehaviour extends DropperMovementBehaviour {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (NullPointerException ignored) {
|
} 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
|
setItemStackAt(location, defaultBehaviour.dispense(itemstack, context, pos), context); // the default: launch the item
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class DropperMovementBehaviour extends MovementBehaviour {
|
||||||
private static final Random RNG = new Random();
|
private static final Random RNG = new Random();
|
||||||
|
|
||||||
protected void activate(MovementContext context, BlockPos pos) {
|
protected void activate(MovementContext context, BlockPos pos) {
|
||||||
DispenseItemLocation location = getDispenseStack(context);
|
DispenseItemLocation location = getDispenseLocation(context);
|
||||||
if (location.isEmpty()) {
|
if (location.isEmpty()) {
|
||||||
context.world.playEvent(1001, pos, 0);
|
context.world.playEvent(1001, pos, 0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -56,7 +56,6 @@ public class DropperMovementBehaviour extends MovementBehaviour {
|
||||||
|
|
||||||
private ArrayList<DispenseItemLocation> getUseableLocations(MovementContext context) {
|
private ArrayList<DispenseItemLocation> getUseableLocations(MovementContext context) {
|
||||||
ArrayList<DispenseItemLocation> useable = new ArrayList<>();
|
ArrayList<DispenseItemLocation> useable = new ArrayList<>();
|
||||||
NonNullList<ItemStack> internalStacks = getStacks(context);
|
|
||||||
for (int slot = 0; slot < getInvSize(); slot++) {
|
for (int slot = 0; slot < getInvSize(); slot++) {
|
||||||
DispenseItemLocation location = new DispenseItemLocation(true, slot);
|
DispenseItemLocation location = new DispenseItemLocation(true, slot);
|
||||||
ItemStack testStack = getItemStackAt(location, context);
|
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));
|
location = new DispenseItemLocation(false, ItemHelper.findFirstMatchingSlotIndex(context.contraption.inventory, testStack::isItemEqual));
|
||||||
if (!getItemStackAt(location, context).isEmpty())
|
if (!getItemStackAt(location, context).isEmpty())
|
||||||
useable.add(location);
|
useable.add(location);
|
||||||
} else if (internalStacks.get(slot).getCount() >= 2)
|
} else if (testStack.getCount() >= 2)
|
||||||
useable.add(location);
|
useable.add(location);
|
||||||
}
|
}
|
||||||
return useable;
|
return useable;
|
||||||
|
@ -86,7 +85,7 @@ public class DropperMovementBehaviour extends MovementBehaviour {
|
||||||
writeExtraData(context);
|
writeExtraData(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected DispenseItemLocation getDispenseStack(MovementContext context) {
|
protected DispenseItemLocation getDispenseLocation(MovementContext context) {
|
||||||
int i = -1;
|
int i = -1;
|
||||||
int j = 1;
|
int j = 1;
|
||||||
List<DispenseItemLocation> useableLocations = getUseableLocations(context);
|
List<DispenseItemLocation> useableLocations = getUseableLocations(context);
|
||||||
|
|
Loading…
Reference in a new issue