diff options
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/WanderingTrader.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/WanderingTrader.java.patch | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/WanderingTrader.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/WanderingTrader.java.patch new file mode 100644 index 0000000000..48dd4579db --- /dev/null +++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/entity/npc/WanderingTrader.java.patch @@ -0,0 +1,47 @@ +--- a/net/minecraft/world/entity/npc/WanderingTrader.java ++++ b/net/minecraft/world/entity/npc/WanderingTrader.java +@@ -47,15 +47,21 @@ + import net.minecraft.world.phys.Vec3; + import org.apache.commons.lang3.tuple.Pair; + +-public class WanderingTrader extends AbstractVillager { ++// CraftBukkit start ++import org.bukkit.Bukkit; ++import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; ++import org.bukkit.entity.AbstractVillager; ++import org.bukkit.event.entity.VillagerAcquireTradeEvent; ++// CraftBukkit end + + private static final int NUMBER_OF_TRADE_OFFERS = 5; + @Nullable + private BlockPos wanderTarget; + private int despawnDelay; + +- public WanderingTrader(EntityType<? extends WanderingTrader> entitytype, Level level) { +- super(entitytype, level); ++ public WanderingTrader(EntityType<? extends WanderingTrader> entityType, Level level) { ++ super(entityType, level); ++ this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader + } + + @Override +@@ -140,8 +143,17 @@ + VillagerTrades.ItemListing villagertrades_itemlisting = avillagertrades_itemlisting1[i]; + MerchantOffer merchantoffer = villagertrades_itemlisting.getOffer(this, this.random); + +- if (merchantoffer != null) { +- merchantoffers.add(merchantoffer); ++ if (merchantrecipe != null) { ++ // CraftBukkit start ++ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) getBukkitEntity(), merchantrecipe.asBukkit()); ++ // Suppress during worldgen ++ if (this.valid) { ++ Bukkit.getPluginManager().callEvent(event); ++ } ++ if (!event.isCancelled()) { ++ merchantrecipelist.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); ++ } ++ // CraftBukkit end + } + + } |