mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 15:49:00 +01:00
Fix cancelling EntityPickupItemEvent for villagers (#6091)
Remove's Billy's fix as upstream implemented a (broken) fix and then fixed their fix
This commit is contained in:
parent
351a2c38b5
commit
bb44da8420
20 changed files with 1 additions and 55 deletions
|
@ -1,54 +0,0 @@
|
||||||
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 502e29644504aabe3834351d3b479e21bd8f4be7..4e47ea7359ae56efeb2b74161dc9e7387589415b 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/SimpleContainer.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/SimpleContainer.java
|
|
||||||
@@ -34,6 +34,16 @@ 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) {
|
|
||||||
this.transaction.add(who);
|
|
||||||
}
|
|
||||||
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 2ad93ff0bb46a282df706438b7c039c46323979a..43bb055f0f9ecb82c25e0f47258f45ce4182a75d 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/npc/Villager.java
|
|
||||||
@@ -888,15 +888,19 @@ 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.discard();
|
|
|
@ -126,7 +126,7 @@ index 0000000000000000000000000000000000000000..69b17fe56f28f8978abc3f363a9e805d
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
||||||
index 46ce973ca68420825316352ad4df907edf52bfec..65e9ecda0df8a22f93f5979a8c9ac74e9f0ba042 100644
|
index bc25c0f466f8cc5662f01f38a38713570c1e5bfc..eff743042c9b6536f1d5001260ab04b42dfd21bd 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
--- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
|
||||||
@@ -191,6 +191,12 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
@@ -191,6 +191,12 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
Loading…
Reference in a new issue