Paper/patches/server/0646-Add-a-bunch-of-missing-forceDrop-toggles.patch
Emilia Kond 2d09115b3a
Use net.kyori.ansi for console logging (#9313)
Uses the new ANSIComponentSerializer introduced in Adventure 4.14.0 to
serialize components when logging them via the ComponentLogger, or when
sending messages to the console.

This replaces the old solution which uses legacy jank and custom color
conversions, with a new library that handles the conversion and config
2023-06-12 15:00:12 -07:00

107 lines
5.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 20 Jul 2021 21:25:35 -0700
Subject: [PATCH] Add a bunch of missing forceDrop toggles
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java b/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
index ac0cfdef53ec82665acf362235842de4f17bfdd1..05c1e8c9f013547d4fcdbbd299329166a8ece1b0 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/WorkAtComposter.java
@@ -87,7 +87,9 @@ public class WorkAtComposter extends WorkAtPoi {
simpleContainer.removeItemType(Items.WHEAT, m);
ItemStack itemStack = simpleContainer.addItem(new ItemStack(Items.BREAD, l));
if (!itemStack.isEmpty()) {
+ entity.forceDrops = true; // Paper
entity.spawnAtLocation(itemStack, 0.5F);
+ entity.forceDrops = false; // Paper
}
}
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 7f4ff9658b0eca2034333810fd2b199a3d186e72..a0933b8467bf81333dc103055e73bb75069dcb36 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Panda.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Panda.java
@@ -528,7 +528,9 @@ public class Panda extends Animal {
}
if (!this.level().isClientSide() && this.random.nextInt(700) == 0 && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+ this.forceDrops = true; // Paper
this.spawnAtLocation((ItemLike) Items.SLIME_BALL);
+ this.forceDrops = false; // Paper
}
}
@@ -652,7 +654,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));
@@ -929,7 +933,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 2c012e8d314e8b785300de3f810f95c7452b7348..7ef04ef7995b093eef022b397cda8c27c8faede0 100644
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/Piglin.java
@@ -322,7 +322,9 @@ public class Piglin extends AbstractPiglin implements CrossbowAttackMob, Invento
@Override
protected void finishConversion(ServerLevel world) {
PiglinAi.cancelAdmiring(this);
+ this.forceDrops = true; // Paper
this.inventory.removeAllItems().forEach(this::spawnAtLocation);
+ this.forceDrops = false; // Paper
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 7611481c7e469a3b9eb4d00f4816adb7b190127e..092cdb889564903102dccfe7bf2e320a1eba5efe 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
@@ -270,7 +270,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);
@@ -330,7 +332,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 06d4c1787b1ee4976e6ed1773d3ff7130aebc2d0..9948085f51659f9b896622251739343d658dd0b2 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);