mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Add more Wandering Trader API (#5020)
This commit is contained in:
parent
62edbcf9db
commit
28d6fe5def
2 changed files with 106 additions and 0 deletions
41
Spigot-API-Patches/Add-more-WanderingTrader-API.patch
Normal file
41
Spigot-API-Patches/Add-more-WanderingTrader-API.patch
Normal file
|
@ -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
|
||||
}
|
65
Spigot-Server-Patches/Add-more-WanderingTrader-API.patch
Normal file
65
Spigot-Server-Patches/Add-more-WanderingTrader-API.patch
Normal file
|
@ -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<? extends EntityVillagerTrader> 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
|
||||
}
|
Loading…
Reference in a new issue