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
|
2024-01-21 12:53:04 +01:00
|
|
|
Subject: [PATCH] Alternative item-despawn-rate
|
2022-06-09 10:51:45 +02:00
|
|
|
|
|
|
|
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
|
2024-10-30 14:06:43 +01:00
|
|
|
index c21fa55c62d97d9511e41a1e313e904330a6eee6..9974aec00935a1c3068eceee6d7042f14f15ac56 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
|
2024-06-13 22:14:13 +02:00
|
|
|
@@ -62,6 +62,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
2022-06-09 10:51:45 +02:00
|
|
|
public final float bobOffs;
|
|
|
|
private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
|
2024-01-22 19:01:10 +01:00
|
|
|
public boolean canMobPickup = true; // Paper - Item#canEntityPickup
|
2024-01-21 12:53:04 +01:00
|
|
|
+ private int despawnRate = -1; // Paper - Alternative item-despawn-rate
|
2022-06-09 10:51:45 +02:00
|
|
|
|
|
|
|
public ItemEntity(EntityType<? extends ItemEntity> type, Level world) {
|
|
|
|
super(type, world);
|
2024-10-23 15:54:09 +02:00
|
|
|
@@ -216,7 +217,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
2022-06-09 10:51:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-08 00:12:41 +02:00
|
|
|
- if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot
|
2024-01-21 12:53:04 +01:00
|
|
|
+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate
|
2022-06-09 10:51:45 +02:00
|
|
|
// CraftBukkit start - fire ItemDespawnEvent
|
2023-07-04 10:22:56 +02:00
|
|
|
if (CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
2022-06-09 10:51:45 +02:00
|
|
|
this.age = 0;
|
2024-10-23 15:54:09 +02:00
|
|
|
@@ -239,7 +240,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
2022-06-09 10:51:45 +02:00
|
|
|
this.lastTick = MinecraftServer.currentTick;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2023-06-08 00:12:41 +02:00
|
|
|
- if (!this.level().isClientSide && this.age >= this.level().spigotConfig.itemDespawnRate) { // Spigot
|
2024-01-21 12:53:04 +01:00
|
|
|
+ if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate
|
2022-06-09 10:51:45 +02:00
|
|
|
// CraftBukkit start - fire ItemDespawnEvent
|
|
|
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
|
|
|
this.age = 0;
|
2024-10-23 15:54:09 +02:00
|
|
|
@@ -297,7 +298,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
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();
|
2024-01-21 12:53:04 +01:00
|
|
|
+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - Alternative item-despawn-rate
|
2022-06-09 10:51:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void tryToMerge(ItemEntity other) {
|
2024-10-23 15:54:09 +02:00
|
|
|
@@ -558,6 +559,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
2023-09-23 04:06:03 +02:00
|
|
|
|
2023-07-04 10:22:56 +02:00
|
|
|
public void setItem(ItemStack stack) {
|
2022-06-09 10:51:45 +02:00
|
|
|
this.getEntityData().set(ItemEntity.DATA_ITEM, stack);
|
2024-01-21 12:53:04 +01:00
|
|
|
+ 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 - Alternative item-despawn-rate
|
2022-06-09 10:51:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-10-23 15:54:09 +02:00
|
|
|
@@ -612,7 +614,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
2022-06-09 10:51:45 +02:00
|
|
|
|
|
|
|
public void makeFakeItem() {
|
|
|
|
this.setNeverPickUp();
|
2023-06-08 00:12:41 +02:00
|
|
|
- this.age = this.level().spigotConfig.itemDespawnRate - 1; // Spigot
|
2024-01-21 12:53:04 +01:00
|
|
|
+ this.age = this.despawnRate - 1; // Spigot // Paper - Alternative item-despawn-rate
|
2022-06-09 10:51:45 +02:00
|
|
|
}
|
|
|
|
|
2024-10-23 15:54:09 +02:00
|
|
|
public static float getSpin(float f, float f1) {
|