mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
62 lines
2.9 KiB
Diff
62 lines
2.9 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: BillyGalbreath <blake.galbreath@gmail.com>
|
|
Date: Tue, 1 Jun 2021 22:05:08 -0500
|
|
Subject: [PATCH] Reset villager inventory on cancelled pickup event
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/SimpleContainer.java b/src/main/java/net/minecraft/world/SimpleContainer.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/SimpleContainer.java
|
|
+++ b/src/main/java/net/minecraft/world/SimpleContainer.java
|
|
@@ -0,0 +0,0 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
|
|
return this.items;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ public void setContents(List<ItemStack> items) {
|
|
+ this.items.clear();
|
|
+ for(int i = 0; i < items.size(); i++) {
|
|
+ this.items.set(i, items.get(i));
|
|
+ }
|
|
+ this.setChanged();
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
public void onOpen(CraftHumanEntity who) {
|
|
transaction.add(who);
|
|
}
|
|
@@ -0,0 +0,0 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
|
|
return itemstack;
|
|
}
|
|
|
|
+ public ItemStack addItem(ItemStack itemstack) { return addItem(itemstack); } // Paper - OBFHELPER
|
|
public ItemStack addItem(ItemStack stack) {
|
|
ItemStack itemstack1 = stack.copy();
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/npc/Villager.java b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
@@ -0,0 +0,0 @@ public class Villager extends AbstractVillager implements ReputationEventHandler
|
|
}
|
|
|
|
// CraftBukkit start
|
|
- ItemStack remaining = new SimpleContainer(inventorysubcontainer).addItem(itemstack);
|
|
- if (CraftEventFactory.callEntityPickupItemEvent(this, item, remaining.getCount(), false).isCancelled()) {
|
|
+ // Paper start
|
|
+ List<ItemStack> contentsSnapshot = new java.util.ArrayList<>(inventorysubcontainer.getContents());
|
|
+ ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
|
|
+ if (CraftEventFactory.callEntityPickupItemEvent(this, item, itemstack1.getCount(), false).isCancelled()) {
|
|
+ inventorysubcontainer.setContents(contentsSnapshot);
|
|
+ // Paper end
|
|
return;
|
|
}
|
|
// CraftBukkit end
|
|
|
|
this.onItemPickup(item);
|
|
this.take(item, itemstack.getCount());
|
|
- ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
|
|
+ // ItemStack itemstack1 = inventorysubcontainer.a(itemstack); // Paper - moved up
|
|
|
|
if (itemstack1.isEmpty()) {
|
|
item.remove();
|