Paper/patches/server/0594-Add-more-WanderingTrader-API.patch

66 lines
3.3 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
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
2023-06-08 03:13:54 +02:00
index 65592c41b1519eff77ccd7ddd3c885058f3ed138..2e7de2378e01aed514e237029d6d64e78871c9b4 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTrader.java
2023-06-08 03:13:54 +02:00
@@ -56,6 +56,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
2021-06-11 14:02:28 +02:00
@Nullable
private BlockPos wanderTarget;
2021-06-11 14:02:28 +02:00
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);
2023-06-08 03:13:54 +02:00
@@ -66,10 +70,10 @@ public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVill
2021-06-11 14:02:28 +02:00
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) -> {
2023-06-08 03:13:54 +02:00
- return this.level().isNight() && !entityvillagertrader.isInvisible();
+ return this.canDrinkPotion && this.level().isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API
2021-06-11 14:02:28 +02:00
}));
this.goalSelector.addGoal(0, new UseItemGoal<>(this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> {
2023-06-08 03:13:54 +02:00
- return this.level().isDay() && entityvillagertrader.isInvisible();
+ return this.canDrinkMilk && this.level().isDay() && entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API
2021-06-11 14:02:28 +02:00
}));
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
2021-06-11 14:02:28 +02:00
--- 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
2021-06-11 14:02:28 +02:00
public void setDespawnDelay(int despawnDelay) {
2021-06-15 04:59:31 +02:00
this.getHandle().setDespawnDelay(despawnDelay);
2021-06-11 14:02:28 +02:00
}
+
+ // 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
}