mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
This commit is contained in:
parent
bb5486d372
commit
d9aca71bc7
1 changed files with 62 additions and 0 deletions
|
@ -0,0 +1,62 @@
|
|||
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/InventorySubcontainer.java b/src/main/java/net/minecraft/world/InventorySubcontainer.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/InventorySubcontainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/InventorySubcontainer.java
|
||||
@@ -0,0 +0,0 @@ public class InventorySubcontainer implements IInventory, AutoRecipeOutput {
|
||||
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.update();
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
public void onOpen(CraftHumanEntity who) {
|
||||
transaction.add(who);
|
||||
}
|
||||
@@ -0,0 +0,0 @@ public class InventorySubcontainer implements IInventory, AutoRecipeOutput {
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
+ public ItemStack addItem(ItemStack itemstack) { return a(itemstack); } // Paper - OBFHELPER
|
||||
public ItemStack a(ItemStack itemstack) {
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillager.java
|
||||
@@ -0,0 +0,0 @@ public class EntityVillager extends EntityVillagerAbstract implements Reputation
|
||||
}
|
||||
|
||||
// CraftBukkit start
|
||||
- ItemStack remaining = new InventorySubcontainer(inventorysubcontainer).a(itemstack);
|
||||
- if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, remaining.getCount(), false).isCancelled()) {
|
||||
+ // Paper start
|
||||
+ List<ItemStack> contentsSnapshot = new java.util.ArrayList<>(inventorysubcontainer.getContents());
|
||||
+ ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
|
||||
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack1.getCount(), false).isCancelled()) {
|
||||
+ inventorysubcontainer.setContents(contentsSnapshot);
|
||||
+ // Paper end
|
||||
return;
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
this.a(entityitem);
|
||||
this.receive(entityitem, itemstack.getCount());
|
||||
- ItemStack itemstack1 = inventorysubcontainer.a(itemstack);
|
||||
+ // ItemStack itemstack1 = inventorysubcontainer.a(itemstack); // Paper - moved up
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
entityitem.die();
|
Loading…
Reference in a new issue