2022-06-09 10:51:45 +02:00
|
|
|
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
|
2022-12-07 20:22:28 +01:00
|
|
|
index 477c9358a09067ace4d0fe3f519148feb4c7a335..1dc7f3963069313de6b969c44bdd21272483f7be 100644
|
2022-06-09 10:51:45 +02:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
2022-12-07 20:22:28 +01:00
|
|
|
@@ -52,6 +52,7 @@ public class ItemEntity extends Entity {
|
2022-06-09 10:51:45 +02:00
|
|
|
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);
|
2022-12-07 20:22:28 +01:00
|
|
|
@@ -180,7 +181,7 @@ public class ItemEntity extends Entity {
|
2022-06-09 10:51:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- if (!this.level.isClientSide && this.age >= 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;
|
2022-12-07 20:22:28 +01:00
|
|
|
@@ -204,7 +205,7 @@ public class ItemEntity extends Entity {
|
2022-06-09 10:51:45 +02:00
|
|
|
this.lastTick = MinecraftServer.currentTick;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
- if (!this.level.isClientSide && this.age >= 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;
|
2022-12-07 20:22:28 +01:00
|
|
|
@@ -255,7 +256,7 @@ public class ItemEntity extends Entity {
|
2022-06-09 10:51:45 +02:00
|
|
|
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) {
|
2022-12-07 20:22:28 +01:00
|
|
|
@@ -499,6 +500,7 @@ public class ItemEntity extends Entity {
|
2022-06-09 10:51:45 +02:00
|
|
|
com.google.common.base.Preconditions.checkArgument(!stack.isEmpty(), "Cannot drop air"); // CraftBukkit
|
|
|
|
this.getEntityData().set(ItemEntity.DATA_ITEM, stack);
|
|
|
|
this.getEntityData().markDirty(ItemEntity.DATA_ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty
|
|
|
|
+ this.despawnRate = level.paperConfig().entities.spawning.altItemDespawnRate.enabled ? level.paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), level.spigotConfig.itemDespawnRate) : level.spigotConfig.itemDespawnRate; // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-12-07 20:22:28 +01:00
|
|
|
@@ -562,7 +564,7 @@ public class ItemEntity extends Entity {
|
2022-06-09 10:51:45 +02:00
|
|
|
|
|
|
|
public void makeFakeItem() {
|
|
|
|
this.setNeverPickUp();
|
|
|
|
- this.age = level.spigotConfig.itemDespawnRate - 1; // Spigot
|
|
|
|
+ this.age = this.despawnRate - 1; // Spigot
|
|
|
|
}
|
|
|
|
|
|
|
|
public float getSpin(float tickDelta) {
|