From 29a8c7f4b3a5d84ebba6d78ba346f2c0458fb503 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot <noreply+git-craftbukkit@papermc.io> Date: Mon, 14 Oct 2013 19:20:10 +1100 Subject: [PATCH] Arrow Despawn Rate By: md_5 <git@md-5.net> --- .../world/entity/projectile/AbstractArrow.java.patch | 10 ++++++---- .../src/main/java/org/spigotmc/SpigotWorldConfig.java | 9 +++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 26c18f6e4c..f4a154df74 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -49,7 +49,7 @@ + // CraftBukkit start - handle the owner before the rest of things + this(type, x, y, z, world, stack, weapon, null); + } -+ + + protected AbstractArrow(EntityType<? extends AbstractArrow> entitytypes, double d0, double d1, double d2, Level world, ItemStack itemstack, @Nullable ItemStack itemstack1, @Nullable LivingEntity ownerEntity) { + this(entitytypes, world); + this.setOwner(ownerEntity); @@ -57,7 +57,7 @@ + this.pickupItemStack = itemstack.copy(); + this.setCustomName((Component) itemstack.get(DataComponents.CUSTOM_NAME)); + Unit unit = (Unit) itemstack.remove(DataComponents.INTANGIBLE_PROJECTILE); - ++ if (unit != null) { this.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; } @@ -107,11 +107,13 @@ this.hasImpulse = true; if (this.getPierceLevel() > 0 && projectiledeflection == ProjectileDeflection.NONE) { -@@ -357,7 +381,7 @@ +@@ -356,8 +380,8 @@ + protected void tickDespawn() { ++this.life; - if (this.life >= 1200) { +- if (this.life >= 1200) { - this.discard(); ++ if (this.life >= ((this instanceof ThrownTrident) ? this.level().spigotConfig.tridentDespawnRate : this.level().spigotConfig.arrowDespawnRate)) { // Spigot + this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } diff --git a/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java b/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java index 4c64f4833f..0e6ef1f4fc 100644 --- a/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java +++ b/paper-server/src/main/java/org/spigotmc/SpigotWorldConfig.java @@ -246,4 +246,13 @@ public class SpigotWorldConfig this.hopperCanLoadChunks = this.getBoolean( "hopper-can-load-chunks", false ); this.log( "Hopper Transfer: " + this.hopperTransfer + " Hopper Check: " + this.hopperCheck + " Hopper Amount: " + this.hopperAmount + " Hopper Can Load Chunks: " + this.hopperCanLoadChunks ); } + + public int arrowDespawnRate; + public int tridentDespawnRate; + private void arrowDespawnRate() + { + this.arrowDespawnRate = this.getInt( "arrow-despawn-rate", 1200 ); + this.tridentDespawnRate = this.getInt( "trident-despawn-rate", this.arrowDespawnRate ); + this.log( "Arrow Despawn Rate: " + this.arrowDespawnRate + " Trident Respawn Rate:" + this.tridentDespawnRate ); + } }