testserver/patches/server/0592-Only-set-despawnTimer-...

59 lines
4.5 KiB
Diff
Raw Normal View History

2021-06-11 12:02:28 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2021-06-17 09:37:24 +00:00
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2021-06-11 12:02:28 +00:00
Date: Fri, 19 Mar 2021 16:07:21 -0700
Subject: [PATCH] Only set despawnTimer for Wandering Traders spawned by
MobSpawnerTrader
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
2022-11-03 21:03:31 +00:00
index fdefccfa07227f315259f636076e36a120c72917..7e9f2a128639c1b80c008f1203a4a41b783b1f73 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
2022-06-08 07:40:34 +00:00
@@ -347,6 +347,12 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
2021-06-11 12:02:28 +00:00
@Nullable
2021-11-24 20:15:19 +00:00
public T spawn(ServerLevel worldserver, @Nullable CompoundTag nbttagcompound, @Nullable Component ichatbasecomponent, @Nullable Player entityhuman, BlockPos blockposition, MobSpawnType enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
2021-06-11 12:02:28 +00:00
+ // Paper start - add consumer to modify entity before spawn
2021-11-24 20:15:19 +00:00
+ return this.spawn(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, spawnReason, null);
2021-06-11 12:02:28 +00:00
+ }
+ @Nullable
2021-11-24 20:15:19 +00:00
+ public T spawn(ServerLevel worldserver, @Nullable CompoundTag nbttagcompound, @Nullable Component ichatbasecomponent, @Nullable Player entityhuman, BlockPos blockposition, MobSpawnType enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason, @Nullable java.util.function.Consumer<T> op) {
2021-06-11 12:02:28 +00:00
+ // Paper end
// Paper start - Call PreCreatureSpawnEvent
org.bukkit.entity.EntityType type = org.bukkit.entity.EntityType.fromName(EntityType.getKey(this).getPath());
if (type != null) {
2022-06-08 07:40:34 +00:00
@@ -362,6 +368,7 @@ public class EntityType<T extends Entity> implements EntityTypeTest<Entity, T> {
2021-06-11 12:02:28 +00:00
}
// Paper end
T t0 = this.create(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1);
+ if (t0 != null && op != null) op.accept(t0); // Paper
if (t0 != null) {
2021-11-24 20:15:19 +00:00
worldserver.addFreshEntityWithPassengers(t0, spawnReason);
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
2022-11-03 21:03:31 +00:00
index dc1762ad344bf49fda4c891f38ef20639f353a45..9162f3e5752a7bee825e7ae21e9fb950cf4eb644 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
2022-03-01 05:43:03 +00:00
@@ -59,7 +59,7 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
2021-06-15 02:59:31 +00:00
2021-06-11 12:02:28 +00:00
public WanderingTrader(EntityType<? extends WanderingTrader> type, Level world) {
super(type, world);
- this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader
+ //this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader // Paper - move back to MobSpawnerTrader - Vanilla behavior is that only traders spawned by it have this value set.
}
@Override
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
index fcde09e155727fe0b8b6acc79700fe4122fd22f0..daa7c4bd8a3f6c28f02b7117b061f0def29e3743 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
2022-06-08 07:40:34 +00:00
@@ -123,7 +123,7 @@ public class WanderingTraderSpawner implements CustomSpawner {
2021-06-11 12:02:28 +00:00
return false;
}
2021-11-24 20:15:19 +00:00
- WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, (CompoundTag) null, (Component) null, (Player) null, blockposition2, MobSpawnType.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
+ WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, (CompoundTag) null, (Component) null, (Player) null, blockposition2, MobSpawnType.EVENT, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL, trader -> trader.setDespawnDelay(48000)); // CraftBukkit // Paper - set despawnTimer before spawn events called
2021-06-11 12:02:28 +00:00
if (entityvillagertrader != null) {
for (int i = 0; i < 2; ++i) {