geforkt von Mirrors/Paper
abca14ff96
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 6f9fe1d9 #562: Add API to set equipment silently bcddb754 SPIGOT-6256: Add method to check if the entity is in water CraftBukkit Changes: 878b4375 #772: Add API to set equipment silently 22d7fcc9 SPIGOT-6256: Add method to check if the entity is in water
104 Zeilen
6.3 KiB
Diff
104 Zeilen
6.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sat, 25 Apr 2020 06:46:35 -0400
|
|
Subject: [PATCH] Fix numerous item duplication issues and teleport issues
|
|
|
|
This notably fixes the newest "Donkey Dupe", but also fixes a lot
|
|
of dupe bugs in general around nether portals and entity world transfer
|
|
|
|
We also fix item duplication generically by anytime we clone an item
|
|
to drop it on the ground, destroy the source item.
|
|
|
|
This avoid an itemstack ever existing twice in the world state pre
|
|
clean up stage.
|
|
|
|
So even if something NEW comes up, it would be impossible to drop the
|
|
same item twice because the source was destroyed.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index 4eb37ac65e80569979544c71c71ed192740535a2..c5106449fc0196cdba8ad0325dd0c247e9d9040f 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1880,11 +1880,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
} else {
|
|
// CraftBukkit start - Capture drops for death event
|
|
if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
|
|
- ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
|
+ ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // Paper - mirror so we can destroy it later
|
|
return null;
|
|
}
|
|
// CraftBukkit end
|
|
- EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY() + (double) f, this.locZ(), itemstack);
|
|
+ EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY() + (double) f, this.locZ(), itemstack.cloneItemStack()); // Paper - clone so we can destroy original
|
|
+ itemstack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe
|
|
|
|
entityitem.defaultPickupDelay();
|
|
// CraftBukkit start
|
|
@@ -2534,6 +2535,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
@Nullable
|
|
public Entity teleportTo(WorldServer worldserver, BlockPosition location) {
|
|
// CraftBukkit end
|
|
+ // Paper start - fix bad state entities causing dupes
|
|
+ if (!isAlive() || !valid) {
|
|
+ LOGGER.warn("Illegal Entity Teleport " + this + " to " + worldserver + ":" + location, new Throwable());
|
|
+ return null;
|
|
+ }
|
|
+ // Paper end
|
|
if (this.world instanceof WorldServer && !this.dead) {
|
|
this.world.getMethodProfiler().enter("changeDimension");
|
|
// CraftBukkit start
|
|
@@ -2569,7 +2576,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
entity.bukkitEntity = this.getBukkitEntity();
|
|
|
|
if (this instanceof EntityInsentient) {
|
|
- ((EntityInsentient) this).unleash(true, false); // Unleash to prevent duping of leads.
|
|
+ ((EntityInsentient) this).unleash(true, true); // Paper drop lead
|
|
}
|
|
// CraftBukkit end
|
|
}
|
|
@@ -2689,7 +2696,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
}
|
|
|
|
public boolean canPortal() {
|
|
- return true;
|
|
+ return isAlive() && valid; // Paper
|
|
}
|
|
|
|
public float a(Explosion explosion, IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata, Fluid fluid, float f) {
|
|
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
|
index 7a061f1f072f57042bb32ff187b0f916545e2e48..0fd3a7ebddfd22d6640307452f525d1c2aaf4439 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
|
|
@@ -567,7 +567,7 @@ public class EntityArmorStand extends EntityLiving {
|
|
for (i = 0; i < this.handItems.size(); ++i) {
|
|
itemstack = (ItemStack) this.handItems.get(i);
|
|
if (!itemstack.isEmpty()) {
|
|
- drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
|
|
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe
|
|
this.handItems.set(i, ItemStack.b);
|
|
}
|
|
}
|
|
@@ -575,7 +575,7 @@ public class EntityArmorStand extends EntityLiving {
|
|
for (i = 0; i < this.armorItems.size(); ++i) {
|
|
itemstack = (ItemStack) this.armorItems.get(i);
|
|
if (!itemstack.isEmpty()) {
|
|
- drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
|
|
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); // CraftBukkit - add to drops // Paper - mirror so we can destroy it later - though this call site was safe
|
|
this.armorItems.set(i, ItemStack.b);
|
|
}
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
index 9c67045920efe05c9acba5a40062358255dbfeac..0f19205376fa0948dbba4a18f1bc68a5115cf05f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
@@ -811,7 +811,8 @@ public class CraftEventFactory {
|
|
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
|
|
if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue;
|
|
|
|
- world.dropItem(entity.getLocation(), stack);
|
|
+ world.dropItem(entity.getLocation(), stack); // Paper - note: dropItem already clones due to this being bukkit -> NMS
|
|
+ if (stack instanceof CraftItemStack) stack.setAmount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe, but don't nuke bukkit stacks of manually added items
|
|
}
|
|
|
|
return event;
|