Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix proposal for Fabricators-of-Create/Create#1096 #64

Closed
wants to merge 15 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ private Packet<ClientGamePacketListener> useExtendedSpawnPacket(Packet<ClientGam

@Unique
private List<ItemEntity> capturedDrops = null;
@Unique
private int capturedDropsCount = 0;

@WrapWithCondition(
method = "spawnAtLocation(Lnet/minecraft/world/item/ItemStack;F)Lnet/minecraft/world/entity/item/ItemEntity;",
Expand All @@ -111,7 +113,8 @@ public boolean captureDroppedItem(Level level, Entity entity) {

@Override
public void startCapturingDrops() {
capturedDrops = new ArrayList<>();
if (capturedDrops == null) capturedDrops = new ArrayList<ItemEntity>();
capturedDropsCount++;
}

@Override
Expand All @@ -122,7 +125,8 @@ public List<ItemEntity> getCapturedDrops() {
@Override
public List<ItemEntity> finishCapturingDrops() {
List<ItemEntity> captured = capturedDrops;
capturedDrops = null;
if (capturedDropsCount > 0) capturedDropsCount--;
if (capturedDropsCount == 0) capturedDrops = null;
return captured;
}

Expand Down