aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch
blob: 7be38ff45b977bf7848decd0fb13ca5eb8a5d953 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- a/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
+++ b/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
@@ -101,16 +110,17 @@
                     return false;
                 }
 
-                WanderingTrader wanderingTrader = EntityType.WANDERING_TRADER.spawn(serverLevel, blockPos2, MobSpawnType.EVENT);
-                if (wanderingTrader != null) {
-                    for (int i1 = 0; i1 < 2; i1++) {
-                        this.tryToSpawnLlamaFor(serverLevel, wanderingTrader, 4);
+                WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(serverLevel, blockposition2, EnumMobSpawn.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
+
+                if (entityvillagertrader != null) {
+                    for (int i = 0; i < 2; ++i) {
+                        this.tryToSpawnLlamaFor(serverLevel, entityvillagertrader, 4);
                     }
 
-                    this.serverLevelData.setWanderingTraderId(wanderingTrader.getUUID());
-                    wanderingTrader.setDespawnDelay(48000);
-                    wanderingTrader.setWanderTarget(blockPos1);
-                    wanderingTrader.restrictTo(blockPos1, 16);
+                    this.serverLevelData.setWanderingTraderId(entityvillagertrader.getUUID());
+                    // entityvillagertrader.setDespawnDelay(48000); // CraftBukkit - moved to EntityVillagerTrader constructor. This lets the value be modified by plugins on CreatureSpawnEvent
+                    entityvillagertrader.setWanderTarget(blockposition1);
+                    entityvillagertrader.restrictTo(blockposition1, 16);
                     return true;
                 }
             }
@@ -120,11 +130,13 @@
     }
 
     private void tryToSpawnLlamaFor(ServerLevel serverLevel, WanderingTrader trader, int maxDistance) {
-        BlockPos blockPos = this.findSpawnPositionNear(serverLevel, trader.blockPosition(), maxDistance);
-        if (blockPos != null) {
-            TraderLlama traderLlama = EntityType.TRADER_LLAMA.spawn(serverLevel, blockPos, MobSpawnType.EVENT);
-            if (traderLlama != null) {
-                traderLlama.setLeashedTo(trader, true);
+        BlockPos blockposition = this.findSpawnPositionNear(serverLevel, trader.blockPosition(), maxDistance);
+
+        if (blockposition != null) {
+            TraderLlama entityllamatrader = (TraderLlama) EntityType.TRADER_LLAMA.spawn(serverLevel, blockposition, EnumMobSpawn.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
+
+            if (entityllamatrader != null) {
+                entityllamatrader.setLeashedTo(trader, true);
             }
         }
     }