Paper/patches/server/0333-Implement-alternative-item-despawn-rate.patch
Jake Potrebic 1e7dd72f15
Remove 'fix Vanilla Minecart speed' patch (#10068)
The game uses 0.95d now
2023-12-22 17:44:36 -08:00

64 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: kickash32 <kickash32@gmail.com>
Date: Mon, 3 Jun 2019 02:02:39 -0400
Subject: [PATCH] Implement alternative item-despawn-rate
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index bbd0d161f27d0e061c14ad87990e44492bb7fe3d..36ccb7701cc5f6648940256b62321034eff964c6 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -56,6 +56,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
public final float bobOffs;
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
public boolean canMobPickup = true; // Paper
+ private int despawnRate = -1; // Paper
public ItemEntity(EntityType<? extends ItemEntity> type, Level world) {
super(type, world);
@@ -208,7 +209,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
}
}
- if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot
+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper
// CraftBukkit start - fire ItemDespawnEvent
if (CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
this.age = 0;
@@ -232,7 +233,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
this.lastTick = MinecraftServer.currentTick;
// CraftBukkit end
- if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot
+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper
// CraftBukkit start - fire ItemDespawnEvent
if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
this.age = 0;
@@ -288,7 +289,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
private boolean isMergable() {
ItemStack itemstack = this.getItem();
- return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < 6000 && itemstack.getCount() < itemstack.getMaxStackSize();
+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - respect despawn rate in pickup check.
}
private void tryToMerge(ItemEntity other) {
@@ -531,6 +532,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
public void setItem(ItemStack stack) {
this.getEntityData().set(ItemEntity.DATA_ITEM, stack);
+ this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper
}
@Override
@@ -585,7 +587,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
public void makeFakeItem() {
this.setNeverPickUp();
- this.age = this.level().spigotConfig.itemDespawnRate - 1; // Spigot
+ this.age = this.despawnRate - 1; // Spigot // Paper
}
public float getSpin(float tickDelta) {