From 28d6fe5def18fdc27cc8252c4380e456bdb1f44d Mon Sep 17 00:00:00 2001 From: HexedHero <6012891+HexedHero@users.noreply.github.com> Date: Thu, 6 May 2021 15:26:50 +0100 Subject: [PATCH] Add more Wandering Trader API (#5020) --- .../Add-more-WanderingTrader-API.patch | 41 ++++++++++++ .../Add-more-WanderingTrader-API.patch | 65 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 Spigot-API-Patches/Add-more-WanderingTrader-API.patch create mode 100644 Spigot-Server-Patches/Add-more-WanderingTrader-API.patch diff --git a/Spigot-API-Patches/Add-more-WanderingTrader-API.patch b/Spigot-API-Patches/Add-more-WanderingTrader-API.patch new file mode 100644 index 0000000000..7a7ad059ec --- /dev/null +++ b/Spigot-API-Patches/Add-more-WanderingTrader-API.patch @@ -0,0 +1,41 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: HexedHero <6012891+HexedHero@users.noreply.github.com> +Date: Thu, 6 May 2021 14:56:26 +0100 +Subject: [PATCH] Add more WanderingTrader API + + +diff --git a/src/main/java/org/bukkit/entity/WanderingTrader.java b/src/main/java/org/bukkit/entity/WanderingTrader.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/entity/WanderingTrader.java ++++ b/src/main/java/org/bukkit/entity/WanderingTrader.java +@@ -0,0 +0,0 @@ public interface WanderingTrader extends AbstractVillager { + * {@link WanderingTrader} is forcibly despawned + */ + public void setDespawnDelay(int despawnDelay); ++ ++ // Paper start - Add more WanderingTrader API ++ /** ++ * Set if the Wandering Trader can and will drink an invisibility potion. ++ * @param bool whether the mob will drink ++ */ ++ public void setCanDrinkPotion(boolean bool); ++ ++ /** ++ * Get if the Wandering Trader can and will drink an invisibility potion. ++ * @return whether the mob will drink ++ */ ++ public boolean canDrinkPotion(); ++ ++ /** ++ * Set if the Wandering Trader can and will drink milk. ++ * @param bool whether the mob will drink ++ */ ++ public void setCanDrinkMilk(boolean bool); ++ ++ /** ++ * Get if the Wandering Trader can and will drink milk. ++ * @return whether the mob will drink ++ */ ++ public boolean canDrinkMilk(); ++ // Paper end + } diff --git a/Spigot-Server-Patches/Add-more-WanderingTrader-API.patch b/Spigot-Server-Patches/Add-more-WanderingTrader-API.patch new file mode 100644 index 0000000000..df08a10a91 --- /dev/null +++ b/Spigot-Server-Patches/Add-more-WanderingTrader-API.patch @@ -0,0 +1,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/EntityVillagerTrader.java b/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java ++++ b/src/main/java/net/minecraft/world/entity/npc/EntityVillagerTrader.java +@@ -0,0 +0,0 @@ public class EntityVillagerTrader extends EntityVillagerAbstract { + @Nullable + private BlockPosition bp; + private int despawnDelay; ++ // Paper start - Add more WanderingTrader API ++ public boolean canDrinkPotion = true; ++ public boolean canDrinkMilk = true; ++ // Paper end + + public EntityVillagerTrader(EntityTypes entitytypes, World world) { + super(entitytypes, world); +@@ -0,0 +0,0 @@ public class EntityVillagerTrader extends EntityVillagerAbstract { + protected void initPathfinder() { + this.goalSelector.a(0, new PathfinderGoalFloat(this)); + this.goalSelector.a(0, new PathfinderGoalUseItem<>(this, PotionUtil.a(new ItemStack(Items.POTION), Potions.INVISIBILITY), SoundEffects.ENTITY_WANDERING_TRADER_DISAPPEARED, (entityvillagertrader) -> { +- return this.world.isNight() && !entityvillagertrader.isInvisible(); ++ return canDrinkPotion && this.world.isNight() && !entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API + })); + this.goalSelector.a(0, new PathfinderGoalUseItem<>(this, new ItemStack(Items.MILK_BUCKET), SoundEffects.ENTITY_WANDERING_TRADER_REAPPEARED, (entityvillagertrader) -> { +- return this.world.isDay() && entityvillagertrader.isInvisible(); ++ return canDrinkMilk && this.world.isDay() && entityvillagertrader.isInvisible(); // Paper - Add more WanderingTrader API + })); + this.goalSelector.a(1, new PathfinderGoalTradeWithPlayer(this)); + this.goalSelector.a(1, new PathfinderGoalAvoidTarget<>(this, EntityZombie.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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +@@ -0,0 +0,0 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande + public void setDespawnDelay(int despawnDelay) { + 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 + }