Skip to content

Commit

Permalink
Require all drops to fit in the network for annihilation planes to br…
Browse files Browse the repository at this point in the history
…eak a block (#8156)

Previously it would allow the break if one of each type could fit, which
would cause extras to drop on the floor.

The Javadoc implies this was intended behavior, but I can't think of a
use case where you would actually want this.
  • Loading branch information
jpenilla authored Aug 24, 2024
1 parent 1383f58 commit 517568c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/appeng/parts/automation/ItemPickupStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ private void completePickup(IEnergySource energySource, PickupSink sink, List<It
var inserted = storeItemStack(sink, item);
// If inserting the item fully was not possible, drop it as an item entity instead if the storage clears up,
// we'll pick it up that way
// This will mainly be the case with storages like a compacting drawer (where two inserts can simulate
// correctly but only one will succeed)
if (inserted < item.getCount()) {
item.shrink(inserted);
Platform.spawnDrops(level, pos, Collections.singletonList(item));
Expand Down Expand Up @@ -277,20 +279,20 @@ protected float calculateEnergyUsage(ServerLevel level, BlockPos pos, List<ItemS
}

/**
* Checks if the network can store the possible drops.
* Checks if the network can store the drops.
* <p>
* It also sets isAccepting to false, if the item can not be stored.
*
* @param itemStacks an array of {@link ItemStack} to test
* @return true, if the network can store at least a single item of all drops or no drops are reported
* @return true, if the network can store all drops or no drops are reported
*/
private boolean canStoreItemStacks(PickupSink sink, List<ItemStack> itemStacks) {
var canStore = itemStacks.isEmpty();

for (var itemStack : itemStacks) {
var itemToTest = AEItemKey.of(itemStack);
var inserted = sink.insert(itemToTest, itemStack.getCount(), Actionable.SIMULATE);
if (inserted > 0) {
if (inserted == itemStack.getCount()) {
canStore = true;
}
}
Expand Down

0 comments on commit 517568c

Please sign in to comment.