mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-22 04:33:28 +01:00
Fix fox drops on death (#8862)
This commit is contained in:
parent
8b0207ac93
commit
bda56c82ff
1 changed files with 41 additions and 7 deletions
|
@ -237,6 +237,27 @@ diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/n
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
--- a/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Paper start
|
||||||
|
+ protected boolean shouldSkipLoot(EquipmentSlot slot) { // method to avoid to fallback into the global mob loot logic (i.e fox)
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
protected void dropCustomDeathLoot(DamageSource source, int lootingMultiplier, boolean allowDrops) {
|
||||||
|
super.dropCustomDeathLoot(source, lootingMultiplier, allowDrops);
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||||
|
|
||||||
|
for (int k = 0; k < j; ++k) {
|
||||||
|
EquipmentSlot enumitemslot = aenumitemslot[k];
|
||||||
|
+ if (this.shouldSkipLoot(enumitemslot)) continue; // Paper
|
||||||
|
ItemStack itemstack = this.getItemBySlot(enumitemslot);
|
||||||
|
float f = this.getEquipmentDropChance(enumitemslot);
|
||||||
|
boolean flag1 = f > 1.0F;
|
||||||
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
@@ -0,0 +0,0 @@ public abstract class Mob extends LivingEntity implements Targeting {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,14 +277,28 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
|
||||||
@@ -0,0 +0,0 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
|
@@ -0,0 +0,0 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
|
||||||
|
return this.getTrustedUUIDs().contains(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ // Paper start - handle the bitten item separately like vanilla
|
||||||
@Override
|
@Override
|
||||||
- protected void dropAllDeathLoot(DamageSource source) {
|
- protected void dropAllDeathLoot(DamageSource source) {
|
||||||
- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND);
|
+ protected boolean shouldSkipLoot(EquipmentSlot slot) {
|
||||||
|
+ return slot == EquipmentSlot.MAINHAND;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
+ // Paper start - Cancellable death event
|
+ // Paper start - Cancellable death event
|
||||||
+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) {
|
+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) {
|
||||||
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND).copy(); // Paper - modified by supercall
|
ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND);
|
||||||
|
|
||||||
|
- if (!itemstack.isEmpty()) {
|
||||||
|
+ boolean releaseMouth = false;
|
||||||
|
+ if (!itemstack.isEmpty() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Fix MC-153010
|
||||||
|
this.spawnAtLocation(itemstack);
|
||||||
|
+ releaseMouth = true;
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = super.dropAllDeathLoot(source);
|
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = super.dropAllDeathLoot(source);
|
||||||
+
|
+
|
||||||
|
@ -272,15 +307,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
+ if (deathEvent == null || deathEvent.isCancelled()) {
|
+ if (deathEvent == null || deathEvent.isCancelled()) {
|
||||||
+ return deathEvent;
|
+ return deathEvent;
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+
|
||||||
|
+ if (releaseMouth) {
|
||||||
if (!itemstack.isEmpty()) {
|
+ // Paper end - Cancellable death event
|
||||||
this.spawnAtLocation(itemstack);
|
|
||||||
this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
|
this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
- super.dropAllDeathLoot(source);
|
- super.dropAllDeathLoot(source);
|
||||||
+ return deathEvent; // Paper
|
+ return deathEvent; // Paper - Cancellable death event
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue