aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0587-Add-more-WanderingTrader-API.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0587-Add-more-WanderingTrader-API.patch')
-rw-r--r--patches/server/0587-Add-more-WanderingTrader-API.patch65
1 files changed, 65 insertions, 0 deletions
diff --git a/patches/server/0587-Add-more-WanderingTrader-API.patch b/patches/server/0587-Add-more-WanderingTrader-API.patch
new file mode 100644
index 0000000000..e7542c5ef9
--- /dev/null
+++ b/patches/server/0587-Add-more-WanderingTrader-API.patch
@@ -0,0 +1,65 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: HexedHero <[email protected]>
+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 0321b4bb622930bfe57661b0e6b893d7635668fb..96115fe8a8c32ce5992d779b5db540b9d81e3b82 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 08194a78c2170e971ee8ff440b276ed3590e8c4a..0e597394a3dd08f022614fc9777302fea581eb55 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
+ }