SPIGOT-7867: Merchant instanceof AbstractVillager always returns false

By: Miles Holder <mwholder2005@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2024-09-07 18:14:09 +10:00
parent 7657f347d2
commit ac5e815b3e
4 changed files with 32 additions and 86 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/npc/EntityVillagerAbstract.java
+++ b/net/minecraft/world/entity/npc/EntityVillagerAbstract.java
@@ -40,8 +40,24 @@
@@ -40,8 +40,22 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@@ -15,17 +15,15 @@
public abstract class EntityVillagerAbstract extends EntityAgeable implements InventoryCarrier, NPC, IMerchant {
+ // CraftBukkit start
+ private CraftMerchant craftMerchant;
+
+ @Override
+ public CraftMerchant getCraftMerchant() {
+ return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant;
+ 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 +66,7 @@
@@ -50,7 +64,7 @@
private EntityHuman tradingPlayer;
@Nullable
protected MerchantRecipeList offers;
@@ -34,7 +32,7 @@
public EntityVillagerAbstract(EntityTypes<? extends EntityVillagerAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -179,7 +195,7 @@
@@ -179,7 +193,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("Offers")) {
@@ -43,7 +41,7 @@
Logger logger = EntityVillagerAbstract.LOGGER;
Objects.requireNonNull(logger);
@@ -246,7 +262,16 @@
@@ -246,7 +260,16 @@
MerchantRecipe merchantrecipe = ((VillagerTrades.IMerchantRecipeOption) arraylist.remove(this.random.nextInt(arraylist.size()))).getOffer(this, this.random);
if (merchantrecipe != null) {