Fix a bunch more forceDrops for dropping items (#8095)

This commit is contained in:
Jake Potrebic 2022-10-26 17:32:03 -07:00 committed by GitHub
parent 2432233d24
commit 954e6f00f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 5 deletions

View File

@ -19,7 +19,7 @@ index e47f3092b6bd6b86b577de705db1a575d0952348..490212cfe4e5cea7219eaf4304e14bfa
}
diff --git a/src/main/java/net/minecraft/world/entity/animal/Panda.java b/src/main/java/net/minecraft/world/entity/animal/Panda.java
index 9c07e3f5554b3b9cf2a2c4d9239a72342567d7f1..39c26f486d6392eb0a9b623cdb2161846357174b 100644
index 9c07e3f5554b3b9cf2a2c4d9239a72342567d7f1..a5633cb6824e801732f5ca2dbc01691794a6975b 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
@@ -522,7 +522,9 @@ public class Panda extends Animal {
@ -32,6 +32,26 @@ index 9c07e3f5554b3b9cf2a2c4d9239a72342567d7f1..39c26f486d6392eb0a9b623cdb216184
}
}
@@ -646,7 +648,9 @@ public class Panda extends Animal {
ItemStack itemstack1 = this.getItemBySlot(EquipmentSlot.MAINHAND);
if (!itemstack1.isEmpty() && !player.getAbilities().instabuild) {
+ this.forceDrops = true; // Paper
this.spawnAtLocation(itemstack1);
+ this.forceDrops = false; // Paper
}
this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemstack.getItem(), 1));
@@ -938,7 +942,9 @@ public class Panda extends Animal {
ItemStack itemstack = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND);
if (!itemstack.isEmpty()) {
+ Panda.this.forceDrops = true; // Paper
Panda.this.spawnAtLocation(itemstack);
+ Panda.this.forceDrops = false; // Paper
Panda.this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
int i = Panda.this.isLazy() ? Panda.this.random.nextInt(50) + 10 : Panda.this.random.nextInt(150) + 10;
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
index d733bcf1049a21009c2548679a51563c15f79523..793576928dad6752dddd86e62d4c0800d8515fc4 100644
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
@ -46,3 +66,41 @@ index d733bcf1049a21009c2548679a51563c15f79523..793576928dad6752dddd86e62d4c0800
super.finishConversion(world);
}
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
index 8aecd15cfb915f44bc6208b656e7db309270c132..5c6b4676c2020b358f8057e9a583eb176c826cb3 100644
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
@@ -260,7 +260,9 @@ public class PiglinAi {
private static void holdInOffhand(Piglin piglin, ItemStack stack) {
if (PiglinAi.isHoldingItemInOffHand(piglin)) {
+ piglin.forceDrops = true; // Paper
piglin.spawnAtLocation(piglin.getItemInHand(InteractionHand.OFF_HAND));
+ piglin.forceDrops = false; // Paper
}
piglin.holdInOffHand(stack);
@@ -320,7 +322,9 @@ public class PiglinAi {
protected static void cancelAdmiring(Piglin piglin) {
if (PiglinAi.isAdmiringItem(piglin) && !piglin.getOffhandItem().isEmpty()) {
+ piglin.forceDrops = true; // Paper
piglin.spawnAtLocation(piglin.getOffhandItem());
+ piglin.forceDrops = false; // Paper
piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY);
}
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java
index 4bb9730b6a42702e91467f980b9f045585039db3..5f68945264d138ae04d6bcbd5bde310b42e30713 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java
@@ -250,7 +250,9 @@ public abstract class Raider extends PatrollingMonster {
double d0 = (double) this.getEquipmentDropChance(enumitemslot);
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
+ this.forceDrops = true; // Paper
this.spawnAtLocation(itemstack1);
+ this.forceDrops = false; // Paper
}
this.onItemPickup(item);

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Config option for Piglins guarding chests
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
index 8aecd15cfb915f44bc6208b656e7db309270c132..9f220cf0668b5153c419215e8e25e418e765a1d6 100644
index 5c6b4676c2020b358f8057e9a583eb176c826cb3..20c234e29e7c1f64a0fdbbe92e06efe8c99e6172 100644
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
@@ -463,6 +463,7 @@ public class PiglinAi {
@@ -467,6 +467,7 @@ public class PiglinAi {
}
public static void angerNearbyPiglins(Player player, boolean blockOpen) {

View File

@ -7,10 +7,10 @@ Upstream didn't modify the isLovedItem check in wantsToPickup
so piglins never actually tried to pickup interestItems
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
index 9f220cf0668b5153c419215e8e25e418e765a1d6..bf133cd7f6187253616fec331762e55dce73487c 100644
index 20c234e29e7c1f64a0fdbbe92e06efe8c99e6172..0ee023afcf5673df4b069f70ce90a2c3417d71b6 100644
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
@@ -388,7 +388,7 @@ public class PiglinAi {
@@ -392,7 +392,7 @@ public class PiglinAi {
} else {
boolean flag = piglin.canAddToInventory(stack);