2021-03-16 09:00:00 +11:00
|
|
|
--- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java
|
|
|
|
+++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java
|
2024-02-21 20:55:34 +11:00
|
|
|
@@ -47,6 +47,14 @@
|
2021-03-16 09:00:00 +11:00
|
|
|
import net.minecraft.world.phys.Vec3D;
|
2023-09-22 02:40:00 +10:00
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
2021-03-09 08:47:33 +11:00
|
|
|
|
2019-04-23 12:00:00 +10:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
|
|
|
|
+import org.bukkit.entity.AbstractVillager;
|
2024-02-21 20:55:34 +11:00
|
|
|
+import org.bukkit.event.entity.EntityRemoveEvent;
|
2019-04-23 12:00:00 +10:00
|
|
|
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
|
|
|
|
+// CraftBukkit end
|
2021-03-09 08:47:33 +11:00
|
|
|
+
|
2019-04-23 12:00:00 +10:00
|
|
|
public class EntityVillagerTrader extends EntityVillagerAbstract {
|
|
|
|
|
2021-06-11 15:00:00 +10:00
|
|
|
private static final int NUMBER_OF_TRADE_OFFERS = 5;
|
2024-02-21 20:55:34 +11:00
|
|
|
@@ -56,6 +64,7 @@
|
2021-06-11 15:00:00 +10:00
|
|
|
|
2021-02-15 19:30:15 +11:00
|
|
|
public EntityVillagerTrader(EntityTypes<? extends EntityVillagerTrader> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
2021-03-20 08:55:48 +11:00
|
|
|
+ this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader
|
2021-02-15 19:30:15 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2024-02-21 20:55:34 +11:00
|
|
|
@@ -136,7 +145,16 @@
|
2023-09-22 02:40:00 +10:00
|
|
|
MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random);
|
2019-04-23 12:00:00 +10:00
|
|
|
|
2023-09-22 02:40:00 +10:00
|
|
|
if (merchantrecipe != null) {
|
|
|
|
- merchantrecipelist.add(merchantrecipe);
|
|
|
|
+ // 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
|
|
|
|
}
|
2019-04-23 12:00:00 +10:00
|
|
|
|
2023-09-22 02:40:00 +10:00
|
|
|
}
|
2024-04-24 01:15:00 +10:00
|
|
|
@@ -243,7 +261,7 @@
|
2024-02-21 20:55:34 +11:00
|
|
|
|
|
|
|
private void maybeDespawn() {
|
|
|
|
if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) {
|
|
|
|
- this.discard();
|
|
|
|
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|