From 932b0a5bf6cb323cd88eded058d47640eb664693 Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Mon, 15 Feb 2021 19:30:15 +1100 Subject: [PATCH] #802: Add methods to modify despawn delay for wandering villagers By: DiamondDagger590 --- paper-server/nms-patches/EntityVillagerTrader.patch | 10 +++++++++- paper-server/nms-patches/MobSpawnerTrader.patch | 9 +++++++++ .../craftbukkit/entity/CraftWanderingTrader.java | 10 ++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/paper-server/nms-patches/EntityVillagerTrader.patch b/paper-server/nms-patches/EntityVillagerTrader.patch index 30d07d0cb1..0ed4a7a054 100644 --- a/paper-server/nms-patches/EntityVillagerTrader.patch +++ b/paper-server/nms-patches/EntityVillagerTrader.patch @@ -13,7 +13,15 @@ public class EntityVillagerTrader extends EntityVillagerAbstract { -@@ -89,7 +95,16 @@ +@@ -12,6 +18,7 @@ + public EntityVillagerTrader(EntityTypes entitytypes, World world) { + super(entitytypes, world); + this.attachedToPlayer = true; ++ this.u(48000); // CraftBukkit - set default from MobSpawnerTrader + } + + @Override +@@ -89,7 +96,16 @@ MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random); if (merchantrecipe != null) { diff --git a/paper-server/nms-patches/MobSpawnerTrader.patch b/paper-server/nms-patches/MobSpawnerTrader.patch index 7065f27da6..f7d580debf 100644 --- a/paper-server/nms-patches/MobSpawnerTrader.patch +++ b/paper-server/nms-patches/MobSpawnerTrader.patch @@ -9,6 +9,15 @@ if (entityvillagertrader != null) { for (int i = 0; i < 2; ++i) { +@@ -91,7 +91,7 @@ + } + + this.b.a(entityvillagertrader.getUniqueID()); +- entityvillagertrader.u(48000); ++ // entityvillagertrader.u(48000); // CraftBukkit - moved to EntityVillagerTrader constructor. This lets the value be modified by plugins on CreatureSpawnEvent + entityvillagertrader.g(blockposition1); + entityvillagertrader.a(blockposition1, 16); + return true; @@ -106,7 +106,7 @@ BlockPosition blockposition = this.a((IWorldReader) worldserver, entityvillagertrader.getChunkCoordinates(), i); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java index 795e6afd81..21cdd7fa7b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -25,4 +25,14 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande public EntityType getType() { return EntityType.WANDERING_TRADER; } + + @Override + public int getDespawnDelay() { + return getHandle().eX(); + } + + @Override + public void setDespawnDelay(int despawnDelay) { + getHandle().u(despawnDelay); + } }