Remap CraftBukkit to Mojang+Yarn Mappings

By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
CraftBukkit/Spigot
2024-12-11 22:26:55 +01:00
parent a265d64138
commit 30e4583dbe
1780 changed files with 44628 additions and 41274 deletions

View File

@@ -0,0 +1,60 @@
--- a/net/minecraft/world/entity/npc/AbstractVillager.java
+++ b/net/minecraft/world/entity/npc/AbstractVillager.java
@@ -40,8 +40,21 @@
import net.minecraft.world.phys.Vec3;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.inventory.CraftMerchant;
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
+// CraftBukkit end
+
public abstract class AbstractVillager extends AgeableMob implements InventoryCarrier, Npc, Merchant {
+ // CraftBukkit start
+ @Override
+ public CraftMerchant getCraftMerchant() {
+ return (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity();
+ }
+ // CraftBukkit end
private static final EntityDataAccessor<Integer> DATA_UNHAPPY_COUNTER = SynchedEntityData.defineId(AbstractVillager.class, EntityDataSerializers.INT);
private static final Logger LOGGER = LogUtils.getLogger();
public static final int VILLAGER_SLOT_OFFSET = 300;
@@ -50,7 +63,7 @@
private Player tradingPlayer;
@Nullable
protected MerchantOffers offers;
- private final SimpleContainer inventory = new SimpleContainer(8);
+ private final SimpleContainer inventory = new SimpleContainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit add argument
public AbstractVillager(EntityType<? extends AbstractVillager> type, Level world) {
super(type, world);
@@ -179,7 +192,7 @@
public void readAdditionalSaveData(CompoundTag nbt) {
super.readAdditionalSaveData(nbt);
if (nbt.contains("Offers")) {
- DataResult dataresult = MerchantOffers.CODEC.parse(this.registryAccess().createSerializationContext(NbtOps.INSTANCE), nbt.get("Offers"));
+ DataResult<MerchantOffers> dataresult = MerchantOffers.CODEC.parse(this.registryAccess().createSerializationContext(NbtOps.INSTANCE), nbt.get("Offers")); // CraftBukkit - decompile error
Logger logger = AbstractVillager.LOGGER;
Objects.requireNonNull(logger);
@@ -246,7 +259,16 @@
MerchantOffer merchantrecipe = ((VillagerTrades.ItemListing) arraylist.remove(this.random.nextInt(arraylist.size()))).getOffer(this, this.random);
if (merchantrecipe != null) {
- recipeList.add(merchantrecipe);
+ // CraftBukkit start
+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((org.bukkit.entity.AbstractVillager) this.getBukkitEntity(), merchantrecipe.asBukkit());
+ // Suppress during worldgen
+ if (this.valid) {
+ Bukkit.getPluginManager().callEvent(event);
+ }
+ if (!event.isCancelled()) {
+ recipeList.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft());
+ }
+ // CraftBukkit end
++j;
}
}

View File

@@ -1,120 +0,0 @@
--- a/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/net/minecraft/world/entity/npc/EntityVillager.java
@@ -93,6 +93,15 @@
import net.minecraft.world.phys.AxisAlignedBB;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Villager;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
+import org.bukkit.event.entity.VillagerReplenishTradeEvent;
+// CraftBukkit end
+
public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -150,7 +159,7 @@
@Override
public BehaviorController<EntityVillager> getBrain() {
- return super.getBrain();
+ return (BehaviorController<EntityVillager>) super.getBrain(); // CraftBukkit - decompile error
}
@Override
@@ -235,7 +244,7 @@
this.increaseProfessionLevelOnUpdate = false;
}
- this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0));
+ this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.VILLAGER_TRADE); // CraftBukkit
}
}
@@ -360,7 +369,13 @@
while (iterator.hasNext()) {
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
- merchantrecipe.resetUses();
+ // CraftBukkit start
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
+ Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ merchantrecipe.resetUses();
+ }
+ // CraftBukkit end
}
this.resendOffersToTradingPlayer();
@@ -429,7 +444,13 @@
while (iterator.hasNext()) {
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
- merchantrecipe.resetUses();
+ // CraftBukkit start
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
+ Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ merchantrecipe.resetUses();
+ }
+ // CraftBukkit end
}
}
@@ -489,7 +510,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
- DataResult dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData());
+ DataResult<NBTBase> dataresult = VillagerData.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
Logger logger = EntityVillager.LOGGER;
Objects.requireNonNull(logger);
@@ -512,7 +533,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("VillagerData", 10)) {
- DataResult dataresult = VillagerData.CODEC.parse(DynamicOpsNBT.INSTANCE, nbttagcompound.get("VillagerData"));
+ DataResult<VillagerData> dataresult = VillagerData.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("VillagerData")));
Logger logger = EntityVillager.LOGGER;
Objects.requireNonNull(logger);
@@ -808,7 +829,7 @@
entitywitch1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entitywitch1.blockPosition()), EntitySpawnReason.CONVERSION, (GroupDataEntity) null);
entitywitch1.setPersistenceRequired();
this.releaseAllPois();
- });
+ }, EntityTransformEvent.TransformReason.LIGHTNING, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
if (entitywitch == null) {
super.thunderHit(worldserver, entitylightning);
@@ -906,7 +927,7 @@
}).limit(5L).toList();
if (list1.size() >= j) {
- if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, false).isEmpty()) {
+ if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit
list.forEach(SensorGolemLastSeen::golemDetected);
}
}
@@ -963,7 +984,7 @@
@Override
public void startSleeping(BlockPosition blockposition) {
super.startSleeping(blockposition);
- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level().getGameTime());
+ this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level().getGameTime()); // CraftBukkit - decompile error
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
}
@@ -971,7 +992,7 @@
@Override
public void stopSleeping() {
super.stopSleeping();
- this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level().getGameTime());
+ this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level().getGameTime()); // CraftBukkit - decompile error
}
private boolean golemSpawnConditionsMet(long i) {

View File

@@ -1,61 +0,0 @@
--- a/net/minecraft/world/entity/npc/EntityVillagerAbstract.java
+++ b/net/minecraft/world/entity/npc/EntityVillagerAbstract.java
@@ -40,8 +40,22 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.inventory.CraftMerchant;
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
+import org.bukkit.entity.AbstractVillager;
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
+// CraftBukkit end
+
public abstract class EntityVillagerAbstract extends EntityAgeable implements InventoryCarrier, NPC, IMerchant {
+ // CraftBukkit start
+ @Override
+ public CraftMerchant getCraftMerchant() {
+ return (org.bukkit.craftbukkit.entity.CraftAbstractVillager) getBukkitEntity();
+ }
+ // CraftBukkit end
private static final DataWatcherObject<Integer> DATA_UNHAPPY_COUNTER = DataWatcher.defineId(EntityVillagerAbstract.class, DataWatcherRegistry.INT);
private static final Logger LOGGER = LogUtils.getLogger();
public static final int VILLAGER_SLOT_OFFSET = 300;
@@ -50,7 +64,7 @@
private EntityHuman tradingPlayer;
@Nullable
protected MerchantRecipeList offers;
- private final InventorySubcontainer inventory = new InventorySubcontainer(8);
+ private final InventorySubcontainer inventory = new InventorySubcontainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit add argument
public EntityVillagerAbstract(EntityTypes<? extends EntityVillagerAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -179,7 +193,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("Offers")) {
- DataResult dataresult = MerchantRecipeList.CODEC.parse(this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("Offers"));
+ DataResult<MerchantRecipeList> dataresult = MerchantRecipeList.CODEC.parse(this.registryAccess().createSerializationContext(DynamicOpsNBT.INSTANCE), nbttagcompound.get("Offers")); // CraftBukkit - decompile error
Logger logger = EntityVillagerAbstract.LOGGER;
Objects.requireNonNull(logger);
@@ -246,7 +260,16 @@
MerchantRecipe merchantrecipe = ((VillagerTrades.IMerchantRecipeOption) arraylist.remove(this.random.nextInt(arraylist.size()))).getOffer(this, this.random);
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
++j;
}
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/npc/InventoryCarrier.java
+++ b/net/minecraft/world/entity/npc/InventoryCarrier.java
@@ -8,6 +8,10 @@
import net.minecraft.world.entity.item.EntityItem;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.item.ItemStack;
+// CraftBukkit start
@@ -16,20 +16,20 @@
}
+ // CraftBukkit start
+ ItemStack remaining = new InventorySubcontainer(inventorysubcontainer).addItem(itemstack);
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entityinsentient, entityitem, remaining.getCount(), false).isCancelled()) {
+ ItemStack remaining = new SimpleContainer(inventorysubcontainer).addItem(itemstack);
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entity, item, remaining.getCount(), false).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
entityinsentient.onItemPickup(entityitem);
entity.onItemPickup(item);
int i = itemstack.getCount();
ItemStack itemstack1 = inventorysubcontainer.addItem(itemstack);
entityinsentient.take(entityitem, i - itemstack1.getCount());
entity.take(item, i - itemstack1.getCount());
if (itemstack1.isEmpty()) {
- entityitem.discard();
+ entityitem.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
- item.discard();
+ item.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
} else {
itemstack.setCount(itemstack1.getCount());
}

View File

@@ -1,29 +0,0 @@
--- a/net/minecraft/world/entity/npc/MobSpawnerTrader.java
+++ b/net/minecraft/world/entity/npc/MobSpawnerTrader.java
@@ -110,7 +110,7 @@
return false;
}
- EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EntitySpawnReason.EVENT);
+ EntityVillagerTrader entityvillagertrader = (EntityVillagerTrader) EntityTypes.WANDERING_TRADER.spawn(worldserver, blockposition2, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
if (entityvillagertrader != null) {
for (int i = 0; i < 2; ++i) {
@@ -118,7 +118,7 @@
}
this.serverLevelData.setWanderingTraderId(entityvillagertrader.getUUID());
- entityvillagertrader.setDespawnDelay(48000);
+ // entityvillagertrader.setDespawnDelay(48000); // CraftBukkit - moved to EntityVillagerTrader constructor. This lets the value be modified by plugins on CreatureSpawnEvent
entityvillagertrader.setWanderTarget(blockposition1);
entityvillagertrader.restrictTo(blockposition1, 16);
return true;
@@ -133,7 +133,7 @@
BlockPosition blockposition = this.findSpawnPositionNear(worldserver, entityvillagertrader.blockPosition(), i);
if (blockposition != null) {
- EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EntitySpawnReason.EVENT);
+ EntityLlamaTrader entityllamatrader = (EntityLlamaTrader) EntityTypes.TRADER_LLAMA.spawn(worldserver, blockposition, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
if (entityllamatrader != null) {
entityllamatrader.setLeashedTo(entityvillagertrader, true);

View File

@@ -0,0 +1,119 @@
--- a/net/minecraft/world/entity/npc/Villager.java
+++ b/net/minecraft/world/entity/npc/Villager.java
@@ -93,6 +93,14 @@
import net.minecraft.world.phys.AABB;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
+import org.bukkit.event.entity.VillagerReplenishTradeEvent;
+// CraftBukkit end
+
public class Villager extends AbstractVillager implements ReputationEventHandler, VillagerDataHolder {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -150,7 +158,7 @@
@Override
public Brain<Villager> getBrain() {
- return super.getBrain();
+ return (Brain<Villager>) super.getBrain(); // CraftBukkit - decompile error
}
@Override
@@ -235,7 +243,7 @@
this.increaseProfessionLevelOnUpdate = false;
}
- this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 200, 0));
+ this.addEffect(new MobEffectInstance(MobEffects.REGENERATION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.VILLAGER_TRADE); // CraftBukkit
}
}
@@ -360,7 +368,13 @@
while (iterator.hasNext()) {
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
- merchantrecipe.resetUses();
+ // CraftBukkit start
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
+ Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ merchantrecipe.resetUses();
+ }
+ // CraftBukkit end
}
this.resendOffersToTradingPlayer();
@@ -429,7 +443,13 @@
while (iterator.hasNext()) {
MerchantOffer merchantrecipe = (MerchantOffer) iterator.next();
- merchantrecipe.resetUses();
+ // CraftBukkit start
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantrecipe.asBukkit());
+ Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ merchantrecipe.resetUses();
+ }
+ // CraftBukkit end
}
}
@@ -489,7 +509,7 @@
@Override
public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
- DataResult dataresult = VillagerData.CODEC.encodeStart(NbtOps.INSTANCE, this.getVillagerData());
+ DataResult<Tag> dataresult = VillagerData.CODEC.encodeStart(NbtOps.INSTANCE, this.getVillagerData()); // CraftBukkit - decompile error
Logger logger = Villager.LOGGER;
Objects.requireNonNull(logger);
@@ -512,7 +532,7 @@
public void readAdditionalSaveData(CompoundTag nbt) {
super.readAdditionalSaveData(nbt);
if (nbt.contains("VillagerData", 10)) {
- DataResult dataresult = VillagerData.CODEC.parse(NbtOps.INSTANCE, nbt.get("VillagerData"));
+ DataResult<VillagerData> dataresult = VillagerData.CODEC.parse(new Dynamic(NbtOps.INSTANCE, nbt.get("VillagerData")));
Logger logger = Villager.LOGGER;
Objects.requireNonNull(logger);
@@ -808,7 +828,7 @@
entitywitch1.finalizeSpawn(world, world.getCurrentDifficultyAt(entitywitch1.blockPosition()), EntitySpawnReason.CONVERSION, (SpawnGroupData) null);
entitywitch1.setPersistenceRequired();
this.releaseAllPois();
- });
+ }, EntityTransformEvent.TransformReason.LIGHTNING, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
if (entitywitch == null) {
super.thunderHit(world, lightning);
@@ -906,7 +926,7 @@
}).limit(5L).toList();
if (list1.size() >= requiredCount) {
- if (!SpawnUtil.trySpawnMob(EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, world, this.blockPosition(), 10, 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, false).isEmpty()) {
+ if (!SpawnUtil.trySpawnMob(EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, world, this.blockPosition(), 10, 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit
list.forEach(GolemSensor::golemDetected);
}
}
@@ -963,7 +983,7 @@
@Override
public void startSleeping(BlockPos pos) {
super.startSleeping(pos);
- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level().getGameTime());
+ this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level().getGameTime()); // CraftBukkit - decompile error
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
}
@@ -971,7 +991,7 @@
@Override
public void stopSleeping() {
super.stopSleeping();
- this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level().getGameTime());
+ this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level().getGameTime()); // CraftBukkit - decompile error
}
private boolean golemSpawnConditionsMet(long worldTime) {

View File

@@ -1,9 +1,10 @@
--- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java
+++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java
@@ -48,6 +48,14 @@
import net.minecraft.world.phys.Vec3D;
--- a/net/minecraft/world/entity/npc/WanderingTrader.java
+++ b/net/minecraft/world/entity/npc/WanderingTrader.java
@@ -48,8 +48,16 @@
import net.minecraft.world.phys.Vec3;
import org.apache.commons.lang3.tuple.Pair;
-public class WanderingTrader extends AbstractVillager implements Consumable.OverrideConsumeSound {
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
@@ -11,25 +12,27 @@
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
+// CraftBukkit end
+
public class EntityVillagerTrader extends EntityVillagerAbstract implements Consumable.b {
+public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVillager implements Consumable.OverrideConsumeSound {
+
private static final int NUMBER_OF_TRADE_OFFERS = 5;
@Nullable
private BlockPos wanderTarget;
@@ -57,6 +65,7 @@
public EntityVillagerTrader(EntityTypes<? extends EntityVillagerTrader> entitytypes, World world) {
super(entitytypes, world);
public WanderingTrader(EntityType<? extends WanderingTrader> type, Level world) {
super(type, world);
+ this.setDespawnDelay(48000); // CraftBukkit - set default from MobSpawnerTrader
}
@Override
@@ -137,7 +146,16 @@
MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random);
MerchantOffer merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random);
if (merchantrecipe != null) {
- merchantrecipelist.add(merchantrecipe);
+ // CraftBukkit start
+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) getBukkitEntity(), merchantrecipe.asBukkit());
+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) this.getBukkitEntity(), merchantrecipe.asBukkit());
+ // Suppress during worldgen
+ if (this.valid) {
+ Bukkit.getPluginManager().callEvent(event);

View File

@@ -0,0 +1,29 @@
--- a/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
+++ b/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
@@ -110,7 +110,7 @@
return false;
}
- WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, blockposition2, EntitySpawnReason.EVENT);
+ WanderingTrader entityvillagertrader = (WanderingTrader) EntityType.WANDERING_TRADER.spawn(world, blockposition2, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
if (entityvillagertrader != null) {
for (int i = 0; i < 2; ++i) {
@@ -118,7 +118,7 @@
}
this.serverLevelData.setWanderingTraderId(entityvillagertrader.getUUID());
- entityvillagertrader.setDespawnDelay(48000);
+ // entityvillagertrader.setDespawnDelay(48000); // CraftBukkit - moved to EntityVillagerTrader constructor. This lets the value be modified by plugins on CreatureSpawnEvent
entityvillagertrader.setWanderTarget(blockposition1);
entityvillagertrader.restrictTo(blockposition1, 16);
return true;
@@ -133,7 +133,7 @@
BlockPos blockposition = this.findSpawnPositionNear(world, wanderingTrader.blockPosition(), range);
if (blockposition != null) {
- TraderLlama entityllamatrader = (TraderLlama) EntityType.TRADER_LLAMA.spawn(world, blockposition, EntitySpawnReason.EVENT);
+ TraderLlama entityllamatrader = (TraderLlama) EntityType.TRADER_LLAMA.spawn(world, blockposition, EntitySpawnReason.EVENT, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit
if (entityllamatrader != null) {
entityllamatrader.setLeashedTo(wanderingTrader, true);