aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0589-Add-more-WanderingTrader-API.patch
blob: 5205274499ac64e375ce6c1bb123a1c8f8636fc4 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: HexedHero <6012891+HexedHero@users.noreply.github.com>
Date: Thu, 6 May 2021 14:56:43 +0100
Subject: [PATCH] Add more WanderingTrader API


diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
index 5ea5f424c55f60bf63d3a4d3fe51362939f42f4c..1cef116b692ebdf3ade01cde533d1e5182a05a91 100644
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
@@ -60,6 +60,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
     @Nullable
     private BlockPos wanderTarget;
     private int despawnDelay;
+    // Paper start - Add more WanderingTrader API
+    public boolean canDrinkPotion = true;
+    public boolean canDrinkMilk = true;
+    // Paper end
 
     public WanderingTrader(EntityType<? extends WanderingTrader> type, Level world) {
         super(type, world);
@@ -70,10 +74,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
     protected void registerGoals() {
         this.goalSelector.addGoal(0, new FloatGoal(this));
         this.goalSelector.addGoal(0, new UseItemGoal<>(this, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> {
-            return this.level().isNight() && !entityvillagertrader.isInvisible();
+            return this.canDrinkPotion && this.level().isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API
         }));
         this.goalSelector.addGoal(0, new UseItemGoal<>(this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> {
-            return this.level().isDay() && entityvillagertrader.isInvisible();
+            return this.canDrinkMilk && this.level().isDay() && entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API
         }));
         this.goalSelector.addGoal(1, new TradeWithPlayerGoal(this));
         this.goalSelector.addGoal(1, new AvoidEntityGoal<>(this, Zombie.class, 8.0F, 0.5D, 0.5D));
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java
index 758eb33c565999e6321b96ff0f733478ffbbd9cc..4a6700d7d2f40cf516054e2e3d09049f1ce4fd17 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java
@@ -28,4 +28,26 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande
     public void setDespawnDelay(int despawnDelay) {
         this.getHandle().setDespawnDelay(despawnDelay);
     }
+
+    // Paper start - Add more WanderingTrader API
+    @Override
+    public void setCanDrinkPotion(boolean bool) {
+        getHandle().canDrinkPotion = bool;
+    }
+
+    @Override
+    public boolean canDrinkPotion() {
+        return getHandle().canDrinkPotion;
+    }
+
+    @Override
+    public void setCanDrinkMilk(boolean bool) {
+        getHandle().canDrinkMilk = bool;
+    }
+
+    @Override
+    public boolean canDrinkMilk() {
+        return getHandle().canDrinkMilk;
+    }
+    // Paper end
 }