mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 05:40:00 +03:00
394 lines
32 KiB
Diff
394 lines
32 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityVillager.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityVillager.java
|
|
@@ -92,6 +92,12 @@
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.craftbukkit.entity.CraftVillager;
|
|
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
|
|
+import org.bukkit.entity.Villager;
|
|
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
|
|
+import org.bukkit.event.entity.VillagerReplenishTradeEvent;
|
|
|
|
public class EntityVillager extends EntityAgeable implements INpc, IMerchant
|
|
{
|
|
@@ -104,18 +110,18 @@
|
|
@Nullable
|
|
private EntityPlayer buyingPlayer;
|
|
@Nullable
|
|
- private MerchantRecipeList buyingList;
|
|
+ public MerchantRecipeList buyingList;
|
|
private int timeUntilReset;
|
|
private boolean needsInitilization;
|
|
private boolean isWillingToMate;
|
|
- private int wealth;
|
|
- private String lastBuyingPlayer;
|
|
- private int careerId;
|
|
+ public int wealth;
|
|
+ private java.util.UUID lastBuyingPlayer;
|
|
+ public int careerId;
|
|
private int careerLevel;
|
|
private boolean isLookingForHome;
|
|
private boolean areAdditionalTasksSet;
|
|
- private final InventoryBasic villagerInventory;
|
|
- private static final EntityVillager.ITradeList[][][][] DEFAULT_TRADE_LIST_MAP = new EntityVillager.ITradeList[][][][] {{{{new EntityVillager.EmeraldForItems(Items.WHEAT, new EntityVillager.PriceInfo(18, 22)), new EntityVillager.EmeraldForItems(Items.POTATO, new EntityVillager.PriceInfo(15, 19)), new EntityVillager.EmeraldForItems(Items.CARROT, new EntityVillager.PriceInfo(15, 19)), new EntityVillager.ListItemForEmeralds(Items.BREAD, new EntityVillager.PriceInfo(-4, -2))}, {new EntityVillager.EmeraldForItems(Item.getItemFromBlock(Blocks.PUMPKIN), new EntityVillager.PriceInfo(8, 13)), new EntityVillager.ListItemForEmeralds(Items.PUMPKIN_PIE, new EntityVillager.PriceInfo(-3, -2))}, {new EntityVillager.EmeraldForItems(Item.getItemFromBlock(Blocks.MELON_BLOCK), new EntityVillager.PriceInfo(7, 12)), new EntityVillager.ListItemForEmeralds(Items.APPLE, new EntityVillager.PriceInfo(-7, -5))}, {new EntityVillager.ListItemForEmeralds(Items.COOKIE, new EntityVillager.PriceInfo(-10, -6)), new EntityVillager.ListItemForEmeralds(Items.CAKE, new EntityVillager.PriceInfo(1, 1))}}, {{new EntityVillager.EmeraldForItems(Items.STRING, new EntityVillager.PriceInfo(15, 20)), new EntityVillager.EmeraldForItems(Items.COAL, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ItemAndEmeraldToItem(Items.FISH, new EntityVillager.PriceInfo(6, 6), Items.COOKED_FISH, new EntityVillager.PriceInfo(6, 6))}, {new EntityVillager.ListEnchantedItemForEmeralds(Items.FISHING_ROD, new EntityVillager.PriceInfo(7, 8))}}, {{new EntityVillager.EmeraldForItems(Item.getItemFromBlock(Blocks.WOOL), new EntityVillager.PriceInfo(16, 22)), new EntityVillager.ListItemForEmeralds(Items.SHEARS, new EntityVillager.PriceInfo(3, 4))}, {new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL)), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 1), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 2), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 3), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 4), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 5), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 6), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 7), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 8), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 9), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 10), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 11), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 12), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 13), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 14), new EntityVillager.PriceInfo(1, 2)), new EntityVillager.ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 15), new EntityVillager.PriceInfo(1, 2))}}, {{new EntityVillager.EmeraldForItems(Items.STRING, new EntityVillager.PriceInfo(15, 20)), new EntityVillager.ListItemForEmeralds(Items.ARROW, new EntityVillager.PriceInfo(-12, -8))}, {new EntityVillager.ListItemForEmeralds(Items.BOW, new EntityVillager.PriceInfo(2, 3)), new EntityVillager.ItemAndEmeraldToItem(Item.getItemFromBlock(Blocks.GRAVEL), new EntityVillager.PriceInfo(10, 10), Items.FLINT, new EntityVillager.PriceInfo(6, 10))}}}, {{{new EntityVillager.EmeraldForItems(Items.PAPER, new EntityVillager.PriceInfo(24, 36)), new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.EmeraldForItems(Items.BOOK, new EntityVillager.PriceInfo(8, 10)), new EntityVillager.ListItemForEmeralds(Items.COMPASS, new EntityVillager.PriceInfo(10, 12)), new EntityVillager.ListItemForEmeralds(Item.getItemFromBlock(Blocks.BOOKSHELF), new EntityVillager.PriceInfo(3, 4))}, {new EntityVillager.EmeraldForItems(Items.WRITTEN_BOOK, new EntityVillager.PriceInfo(2, 2)), new EntityVillager.ListItemForEmeralds(Items.CLOCK, new EntityVillager.PriceInfo(10, 12)), new EntityVillager.ListItemForEmeralds(Item.getItemFromBlock(Blocks.GLASS), new EntityVillager.PriceInfo(-5, -3))}, {new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.ListEnchantedBookForEmeralds()}, {new EntityVillager.ListItemForEmeralds(Items.NAME_TAG, new EntityVillager.PriceInfo(20, 22))}}, {{new EntityVillager.EmeraldForItems(Items.PAPER, new EntityVillager.PriceInfo(24, 36))}, {new EntityVillager.EmeraldForItems(Items.COMPASS, new EntityVillager.PriceInfo(1, 1))}, {new EntityVillager.ListItemForEmeralds(Items.MAP, new EntityVillager.PriceInfo(7, 11))}, {new EntityVillager.TreasureMapForEmeralds(new EntityVillager.PriceInfo(12, 20), "Monument", MapDecoration.Type.MONUMENT), new EntityVillager.TreasureMapForEmeralds(new EntityVillager.PriceInfo(16, 28), "Mansion", MapDecoration.Type.MANSION)}}}, {{{new EntityVillager.EmeraldForItems(Items.ROTTEN_FLESH, new EntityVillager.PriceInfo(36, 40)), new EntityVillager.EmeraldForItems(Items.GOLD_INGOT, new EntityVillager.PriceInfo(8, 10))}, {new EntityVillager.ListItemForEmeralds(Items.REDSTONE, new EntityVillager.PriceInfo(-4, -1)), new EntityVillager.ListItemForEmeralds(new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage()), new EntityVillager.PriceInfo(-2, -1))}, {new EntityVillager.ListItemForEmeralds(Items.ENDER_PEARL, new EntityVillager.PriceInfo(4, 7)), new EntityVillager.ListItemForEmeralds(Item.getItemFromBlock(Blocks.GLOWSTONE), new EntityVillager.PriceInfo(-3, -1))}, {new EntityVillager.ListItemForEmeralds(Items.EXPERIENCE_BOTTLE, new EntityVillager.PriceInfo(3, 11))}}}, {{{new EntityVillager.EmeraldForItems(Items.COAL, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.IRON_HELMET, new EntityVillager.PriceInfo(4, 6))}, {new EntityVillager.EmeraldForItems(Items.IRON_INGOT, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListItemForEmeralds(Items.IRON_CHESTPLATE, new EntityVillager.PriceInfo(10, 14))}, {new EntityVillager.EmeraldForItems(Items.DIAMOND, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.DIAMOND_CHESTPLATE, new EntityVillager.PriceInfo(16, 19))}, {new EntityVillager.ListItemForEmeralds(Items.CHAINMAIL_BOOTS, new EntityVillager.PriceInfo(5, 7)), new EntityVillager.ListItemForEmeralds(Items.CHAINMAIL_LEGGINGS, new EntityVillager.PriceInfo(9, 11)), new EntityVillager.ListItemForEmeralds(Items.CHAINMAIL_HELMET, new EntityVillager.PriceInfo(5, 7)), new EntityVillager.ListItemForEmeralds(Items.CHAINMAIL_CHESTPLATE, new EntityVillager.PriceInfo(11, 15))}}, {{new EntityVillager.EmeraldForItems(Items.COAL, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.IRON_AXE, new EntityVillager.PriceInfo(6, 8))}, {new EntityVillager.EmeraldForItems(Items.IRON_INGOT, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListEnchantedItemForEmeralds(Items.IRON_SWORD, new EntityVillager.PriceInfo(9, 10))}, {new EntityVillager.EmeraldForItems(Items.DIAMOND, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.DIAMOND_SWORD, new EntityVillager.PriceInfo(12, 15)), new EntityVillager.ListEnchantedItemForEmeralds(Items.DIAMOND_AXE, new EntityVillager.PriceInfo(9, 12))}}, {{new EntityVillager.EmeraldForItems(Items.COAL, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListEnchantedItemForEmeralds(Items.IRON_SHOVEL, new EntityVillager.PriceInfo(5, 7))}, {new EntityVillager.EmeraldForItems(Items.IRON_INGOT, new EntityVillager.PriceInfo(7, 9)), new EntityVillager.ListEnchantedItemForEmeralds(Items.IRON_PICKAXE, new EntityVillager.PriceInfo(9, 11))}, {new EntityVillager.EmeraldForItems(Items.DIAMOND, new EntityVillager.PriceInfo(3, 4)), new EntityVillager.ListEnchantedItemForEmeralds(Items.DIAMOND_PICKAXE, new EntityVillager.PriceInfo(12, 15))}}}, {{{new EntityVillager.EmeraldForItems(Items.PORKCHOP, new EntityVillager.PriceInfo(14, 18)), new EntityVillager.EmeraldForItems(Items.CHICKEN, new EntityVillager.PriceInfo(14, 18))}, {new EntityVillager.EmeraldForItems(Items.COAL, new EntityVillager.PriceInfo(16, 24)), new EntityVillager.ListItemForEmeralds(Items.COOKED_PORKCHOP, new EntityVillager.PriceInfo(-7, -5)), new EntityVillager.ListItemForEmeralds(Items.COOKED_CHICKEN, new EntityVillager.PriceInfo(-8, -6))}}, {{new EntityVillager.EmeraldForItems(Items.LEATHER, new EntityVillager.PriceInfo(9, 12)), new EntityVillager.ListItemForEmeralds(Items.LEATHER_LEGGINGS, new EntityVillager.PriceInfo(2, 4))}, {new EntityVillager.ListEnchantedItemForEmeralds(Items.LEATHER_CHESTPLATE, new EntityVillager.PriceInfo(7, 12))}, {new EntityVillager.ListItemForEmeralds(Items.SADDLE, new EntityVillager.PriceInfo(8, 10))}}}, {new EntityVillager.ITradeList[0][]}};
|
|
+ public final InventoryBasic villagerInventory;
|
|
+ private static final ITradeList[][][][] DEFAULT_TRADE_LIST_MAP = new ITradeList[][][][] {{{{new EmeraldForItems(Items.WHEAT, new PriceInfo(18, 22)), new EmeraldForItems(Items.POTATO, new PriceInfo(15, 19)), new EmeraldForItems(Items.CARROT, new PriceInfo(15, 19)), new ListItemForEmeralds(Items.BREAD, new PriceInfo(-4, -2))}, {new EmeraldForItems(Item.getItemFromBlock(Blocks.PUMPKIN), new PriceInfo(8, 13)), new ListItemForEmeralds(Items.PUMPKIN_PIE, new PriceInfo(-3, -2))}, {new EmeraldForItems(Item.getItemFromBlock(Blocks.MELON_BLOCK), new PriceInfo(7, 12)), new ListItemForEmeralds(Items.APPLE, new PriceInfo(-7, -5))}, {new ListItemForEmeralds(Items.COOKIE, new PriceInfo(-10, -6)), new ListItemForEmeralds(Items.CAKE, new PriceInfo(1, 1))}}, {{new EmeraldForItems(Items.STRING, new PriceInfo(15, 20)), new EmeraldForItems(Items.COAL, new PriceInfo(16, 24)), new ItemAndEmeraldToItem(Items.FISH, new PriceInfo(6, 6), Items.COOKED_FISH, new PriceInfo(6, 6))}, {new ListEnchantedItemForEmeralds(Items.FISHING_ROD, new PriceInfo(7, 8))}}, {{new EmeraldForItems(Item.getItemFromBlock(Blocks.WOOL), new PriceInfo(16, 22)), new ListItemForEmeralds(Items.SHEARS, new PriceInfo(3, 4))}, {new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL)), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 1), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 2), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 3), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 4), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 5), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 6), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 7), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 8), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 9), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 10), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 11), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 12), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 13), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 14), new PriceInfo(1, 2)), new ListItemForEmeralds(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, 15), new PriceInfo(1, 2))}}, {{new EmeraldForItems(Items.STRING, new PriceInfo(15, 20)), new ListItemForEmeralds(Items.ARROW, new PriceInfo(-12, -8))}, {new ListItemForEmeralds(Items.BOW, new PriceInfo(2, 3)), new ItemAndEmeraldToItem(Item.getItemFromBlock(Blocks.GRAVEL), new PriceInfo(10, 10), Items.FLINT, new PriceInfo(6, 10))}}}, {{{new EmeraldForItems(Items.PAPER, new PriceInfo(24, 36)), new ListEnchantedBookForEmeralds()}, {new EmeraldForItems(Items.BOOK, new PriceInfo(8, 10)), new ListItemForEmeralds(Items.COMPASS, new PriceInfo(10, 12)), new ListItemForEmeralds(Item.getItemFromBlock(Blocks.BOOKSHELF), new PriceInfo(3, 4))}, {new EmeraldForItems(Items.WRITTEN_BOOK, new PriceInfo(2, 2)), new ListItemForEmeralds(Items.CLOCK, new PriceInfo(10, 12)), new ListItemForEmeralds(Item.getItemFromBlock(Blocks.GLASS), new PriceInfo(-5, -3))}, {new ListEnchantedBookForEmeralds()}, {new ListEnchantedBookForEmeralds()}, {new ListItemForEmeralds(Items.NAME_TAG, new PriceInfo(20, 22))}}, {{new EmeraldForItems(Items.PAPER, new PriceInfo(24, 36))}, {new EmeraldForItems(Items.COMPASS, new PriceInfo(1, 1))}, {new ListItemForEmeralds(Items.MAP, new PriceInfo(7, 11))}, {new TreasureMapForEmeralds(new PriceInfo(12, 20), "Monument", MapDecoration.Type.MONUMENT), new TreasureMapForEmeralds(new PriceInfo(16, 28), "Mansion", MapDecoration.Type.MANSION)}}}, {{{new EmeraldForItems(Items.ROTTEN_FLESH, new PriceInfo(36, 40)), new EmeraldForItems(Items.GOLD_INGOT, new PriceInfo(8, 10))}, {new ListItemForEmeralds(Items.REDSTONE, new PriceInfo(-4, -1)), new ListItemForEmeralds(new ItemStack(Items.DYE, 1, EnumDyeColor.BLUE.getDyeDamage()), new PriceInfo(-2, -1))}, {new ListItemForEmeralds(Items.ENDER_PEARL, new PriceInfo(4, 7)), new ListItemForEmeralds(Item.getItemFromBlock(Blocks.GLOWSTONE), new PriceInfo(-3, -1))}, {new ListItemForEmeralds(Items.EXPERIENCE_BOTTLE, new PriceInfo(3, 11))}}}, {{{new EmeraldForItems(Items.COAL, new PriceInfo(16, 24)), new ListItemForEmeralds(Items.IRON_HELMET, new PriceInfo(4, 6))}, {new EmeraldForItems(Items.IRON_INGOT, new PriceInfo(7, 9)), new ListItemForEmeralds(Items.IRON_CHESTPLATE, new PriceInfo(10, 14))}, {new EmeraldForItems(Items.DIAMOND, new PriceInfo(3, 4)), new ListEnchantedItemForEmeralds(Items.DIAMOND_CHESTPLATE, new PriceInfo(16, 19))}, {new ListItemForEmeralds(Items.CHAINMAIL_BOOTS, new PriceInfo(5, 7)), new ListItemForEmeralds(Items.CHAINMAIL_LEGGINGS, new PriceInfo(9, 11)), new ListItemForEmeralds(Items.CHAINMAIL_HELMET, new PriceInfo(5, 7)), new ListItemForEmeralds(Items.CHAINMAIL_CHESTPLATE, new PriceInfo(11, 15))}}, {{new EmeraldForItems(Items.COAL, new PriceInfo(16, 24)), new ListItemForEmeralds(Items.IRON_AXE, new PriceInfo(6, 8))}, {new EmeraldForItems(Items.IRON_INGOT, new PriceInfo(7, 9)), new ListEnchantedItemForEmeralds(Items.IRON_SWORD, new PriceInfo(9, 10))}, {new EmeraldForItems(Items.DIAMOND, new PriceInfo(3, 4)), new ListEnchantedItemForEmeralds(Items.DIAMOND_SWORD, new PriceInfo(12, 15)), new ListEnchantedItemForEmeralds(Items.DIAMOND_AXE, new PriceInfo(9, 12))}}, {{new EmeraldForItems(Items.COAL, new PriceInfo(16, 24)), new ListEnchantedItemForEmeralds(Items.IRON_SHOVEL, new PriceInfo(5, 7))}, {new EmeraldForItems(Items.IRON_INGOT, new PriceInfo(7, 9)), new ListEnchantedItemForEmeralds(Items.IRON_PICKAXE, new PriceInfo(9, 11))}, {new EmeraldForItems(Items.DIAMOND, new PriceInfo(3, 4)), new ListEnchantedItemForEmeralds(Items.DIAMOND_PICKAXE, new PriceInfo(12, 15))}}}, {{{new EmeraldForItems(Items.PORKCHOP, new PriceInfo(14, 18)), new EmeraldForItems(Items.CHICKEN, new PriceInfo(14, 18))}, {new EmeraldForItems(Items.COAL, new PriceInfo(16, 24)), new ListItemForEmeralds(Items.COOKED_PORKCHOP, new PriceInfo(-7, -5)), new ListItemForEmeralds(Items.COOKED_CHICKEN, new PriceInfo(-8, -6))}}, {{new EmeraldForItems(Items.LEATHER, new PriceInfo(9, 12)), new ListItemForEmeralds(Items.LEATHER_LEGGINGS, new PriceInfo(2, 4))}, {new ListEnchantedItemForEmeralds(Items.LEATHER_CHESTPLATE, new PriceInfo(7, 12))}, {new ListItemForEmeralds(Items.SADDLE, new PriceInfo(8, 10))}}}, {new ITradeList[0][]}};
|
|
|
|
public EntityVillager(World worldIn)
|
|
{
|
|
@@ -125,7 +131,7 @@
|
|
public EntityVillager(World worldIn, int professionId)
|
|
{
|
|
super(worldIn);
|
|
- this.villagerInventory = new InventoryBasic("Items", false, 8);
|
|
+ this.villagerInventory = new InventoryBasic("Items", false, 8, (CraftVillager) this.getBukkitEntity());
|
|
this.setProfession(professionId);
|
|
this.setSize(0.6F, 1.95F);
|
|
((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
|
|
@@ -186,6 +192,22 @@
|
|
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
|
|
}
|
|
|
|
+ // Spigot Start
|
|
+ @Override
|
|
+ public void inactiveTick() {
|
|
+ // SPIGOT-3874
|
|
+ if (world.spigotConfig.tickInactiveVillagers) {
|
|
+ // SPIGOT-3894
|
|
+ net.minecraft.world.chunk.Chunk startingChunk = this.world.getChunkIfLoaded(MathHelper.floor(this.posX) >> 4, MathHelper.floor(this.posZ) >> 4);
|
|
+ if (!(startingChunk != null && startingChunk.areNeighborsLoaded(1))) {
|
|
+ return;
|
|
+ }
|
|
+ this.updateAITasks(); // SPIGOT-3846
|
|
+ }
|
|
+ super.inactiveTick();
|
|
+ }
|
|
+ // Spigot End
|
|
+
|
|
protected void updateAITasks()
|
|
{
|
|
if (--this.randomTickDivider <= 0)
|
|
@@ -224,7 +246,13 @@
|
|
{
|
|
if (merchantrecipe.isRecipeDisabled())
|
|
{
|
|
- merchantrecipe.increaseMaxTradeUses(this.rand.nextInt(6) + this.rand.nextInt(6) + 2);
|
|
+ // merchantrecipe.increaseMaxTradeUses(this.rand.nextInt(6) + this.rand.nextInt(6) + 2);
|
|
+ int bonus = this.rand.nextInt(6) + this.rand.nextInt(6) + 2;
|
|
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus);
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
+ if (!event.isCancelled()) {
|
|
+ merchantrecipe.increaseMaxTradeUses(event.getBonus());
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -255,7 +283,7 @@
|
|
itemstack.interactWithEntity(player, this, hand);
|
|
return true;
|
|
}
|
|
- else if (!this.holdingSpawnEggOfClass(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild())
|
|
+ else if (!this.holdingSpawnEggOfClass(itemstack, this.getClass()) && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking())
|
|
{
|
|
if (this.buyingList == null)
|
|
{
|
|
@@ -327,6 +355,7 @@
|
|
{
|
|
super.writeEntityToNBT(compound);
|
|
compound.setInteger("Profession", this.getProfession());
|
|
+ compound.setString("ProfessionName", this.getProfessionForge().getRegistryName().toString());
|
|
compound.setInteger("Riches", this.wealth);
|
|
compound.setInteger("Career", this.careerId);
|
|
compound.setInteger("CareerLevel", this.careerLevel);
|
|
@@ -356,6 +385,14 @@
|
|
{
|
|
super.readEntityFromNBT(compound);
|
|
this.setProfession(compound.getInteger("Profession"));
|
|
+ if (compound.hasKey("ProfessionName"))
|
|
+ {
|
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession p =
|
|
+ net.minecraftforge.fml.common.registry.ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation(compound.getString("ProfessionName")));
|
|
+ if (p == null)
|
|
+ p = net.minecraftforge.fml.common.registry.ForgeRegistries.VILLAGER_PROFESSIONS.getValue(new ResourceLocation("minecraft:farmer"));
|
|
+ this.setProfession(p);
|
|
+ }
|
|
this.wealth = compound.getInteger("Riches");
|
|
this.careerId = compound.getInteger("Career");
|
|
this.careerLevel = compound.getInteger("CareerLevel");
|
|
@@ -383,7 +420,7 @@
|
|
this.setAdditionalAItasks();
|
|
}
|
|
|
|
- protected boolean canDespawn()
|
|
+ public boolean canDespawn()
|
|
{
|
|
return false;
|
|
}
|
|
@@ -412,13 +449,43 @@
|
|
public void setProfession(int professionId)
|
|
{
|
|
this.dataManager.set(PROFESSION, Integer.valueOf(professionId));
|
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, professionId);
|
|
}
|
|
|
|
+ @Deprecated //Use Forge Variant below
|
|
public int getProfession()
|
|
{
|
|
- return Math.max(((Integer)this.dataManager.get(PROFESSION)).intValue() % 6, 0);
|
|
+ return Math.max(((Integer)this.dataManager.get(PROFESSION)).intValue(), 0);
|
|
}
|
|
|
|
+ private net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof;
|
|
+ public void setProfession(net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession prof)
|
|
+ {
|
|
+ this.prof = prof;
|
|
+ this.setProfession(net.minecraftforge.fml.common.registry.VillagerRegistry.getId(prof));
|
|
+ }
|
|
+
|
|
+ public net.minecraftforge.fml.common.registry.VillagerRegistry.VillagerProfession getProfessionForge()
|
|
+ {
|
|
+ if (this.prof == null)
|
|
+ {
|
|
+ this.prof = net.minecraftforge.fml.common.registry.VillagerRegistry.getById(this.getProfession());
|
|
+ if (this.prof == null)
|
|
+ return net.minecraftforge.fml.common.registry.VillagerRegistry.getById(0); //Farmer
|
|
+ }
|
|
+ return this.prof;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public void notifyDataManagerChange(DataParameter<?> key)
|
|
+ {
|
|
+ super.notifyDataManagerChange(key);
|
|
+ if (key.equals(PROFESSION))
|
|
+ {
|
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.onSetProfession(this, this.dataManager.get(PROFESSION));
|
|
+ }
|
|
+ }
|
|
+
|
|
public boolean isMating()
|
|
{
|
|
return this.isMating;
|
|
@@ -456,7 +523,7 @@
|
|
i = -3;
|
|
}
|
|
|
|
- this.village.modifyPlayerReputation(livingBase.getName(), i);
|
|
+ this.village.modifyPlayerReputation(livingBase.getUniqueID(), i);
|
|
|
|
if (this.isEntityAlive())
|
|
{
|
|
@@ -476,7 +543,7 @@
|
|
{
|
|
if (entity instanceof EntityPlayer)
|
|
{
|
|
- this.village.modifyPlayerReputation(entity.getName(), -2);
|
|
+ this.village.modifyPlayerReputation(entity.getUniqueID(), -2);
|
|
}
|
|
else if (entity instanceof IMob)
|
|
{
|
|
@@ -569,7 +636,7 @@
|
|
|
|
if (this.buyingPlayer != null)
|
|
{
|
|
- this.lastBuyingPlayer = this.buyingPlayer.getName();
|
|
+ this.lastBuyingPlayer = this.buyingPlayer.getUniqueID();
|
|
}
|
|
else
|
|
{
|
|
@@ -612,20 +679,18 @@
|
|
this.populateBuyingList();
|
|
}
|
|
|
|
- return this.buyingList;
|
|
+ return net.minecraftforge.event.ForgeEventFactory.listTradeOffers(this, player, buyingList);
|
|
}
|
|
|
|
- private void populateBuyingList()
|
|
+ public void populateBuyingList()
|
|
{
|
|
- EntityVillager.ITradeList[][][] aentityvillager$itradelist = DEFAULT_TRADE_LIST_MAP[this.getProfession()];
|
|
-
|
|
if (this.careerId != 0 && this.careerLevel != 0)
|
|
{
|
|
++this.careerLevel;
|
|
}
|
|
else
|
|
{
|
|
- this.careerId = this.rand.nextInt(aentityvillager$itradelist.length) + 1;
|
|
+ this.careerId = this.getProfessionForge().getRandomCareer(this.rand) + 1;
|
|
this.careerLevel = 1;
|
|
}
|
|
|
|
@@ -636,19 +701,26 @@
|
|
|
|
int i = this.careerId - 1;
|
|
int j = this.careerLevel - 1;
|
|
+ java.util.List<ITradeList> trades = this.getProfessionForge().getCareer(i).getTrades(j);
|
|
|
|
- if (i >= 0 && i < aentityvillager$itradelist.length)
|
|
+ if (trades != null)
|
|
{
|
|
- EntityVillager.ITradeList[][] aentityvillager$itradelist1 = aentityvillager$itradelist[i];
|
|
-
|
|
- if (j >= 0 && j < aentityvillager$itradelist1.length)
|
|
+ for (ITradeList entityvillager$itradelist : trades)
|
|
{
|
|
- EntityVillager.ITradeList[] aentityvillager$itradelist2 = aentityvillager$itradelist1[j];
|
|
-
|
|
- for (EntityVillager.ITradeList entityvillager$itradelist : aentityvillager$itradelist2)
|
|
- {
|
|
- entityvillager$itradelist.addMerchantRecipe(this, this.buyingList, this.rand);
|
|
+ // CraftBukkit start
|
|
+ // this is a hack. this must be done because otherwise, if
|
|
+ // mojang adds a new type of villager merchant option, it will need to
|
|
+ // have event handling added manually. this is better than having to do that.
|
|
+ MerchantRecipeList list = new MerchantRecipeList();
|
|
+ entityvillager$itradelist.addMerchantRecipe(this, list /*this.buyingList*/, this.rand);
|
|
+ for (MerchantRecipe recipe : list) {
|
|
+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((Villager) getBukkitEntity(), recipe.asBukkit());
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
+ if (!event.isCancelled()) {
|
|
+ this.buyingList.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft());
|
|
+ }
|
|
}
|
|
+ // CraftBukkit end
|
|
}
|
|
}
|
|
}
|
|
@@ -758,7 +830,7 @@
|
|
s1 = "nitwit";
|
|
}
|
|
|
|
- if (s1 != null)
|
|
+ s1 = this.getProfessionForge().getCareer(this.careerId-1).getName();
|
|
{
|
|
ITextComponent itextcomponent = new TextComponentTranslation("entity.Villager." + s1, new Object[0]);
|
|
itextcomponent.getStyle().setHoverEvent(this.getHoverEvent());
|
|
@@ -771,10 +843,6 @@
|
|
|
|
return itextcomponent;
|
|
}
|
|
- else
|
|
- {
|
|
- return super.getDisplayName();
|
|
- }
|
|
}
|
|
}
|
|
|
|
@@ -828,7 +896,7 @@
|
|
|
|
if (p_190672_3_)
|
|
{
|
|
- this.setProfession(this.world.rand.nextInt(6));
|
|
+ net.minecraftforge.fml.common.registry.VillagerRegistry.setRandomProfession(this, this.world.rand);
|
|
}
|
|
|
|
this.setAdditionalAItasks();
|
|
@@ -989,12 +1057,12 @@
|
|
}
|
|
}
|
|
|
|
- public static class EmeraldForItems implements EntityVillager.ITradeList
|
|
+ public static class EmeraldForItems implements ITradeList
|
|
{
|
|
public Item buyingItem;
|
|
- public EntityVillager.PriceInfo price;
|
|
+ public PriceInfo price;
|
|
|
|
- public EmeraldForItems(Item itemIn, EntityVillager.PriceInfo priceIn)
|
|
+ public EmeraldForItems(Item itemIn, PriceInfo priceIn)
|
|
{
|
|
this.buyingItem = itemIn;
|
|
this.price = priceIn;
|
|
@@ -1018,14 +1086,14 @@
|
|
void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random);
|
|
}
|
|
|
|
- public static class ItemAndEmeraldToItem implements EntityVillager.ITradeList
|
|
+ public static class ItemAndEmeraldToItem implements ITradeList
|
|
{
|
|
public ItemStack buyingItemStack;
|
|
- public EntityVillager.PriceInfo buyingPriceInfo;
|
|
+ public PriceInfo buyingPriceInfo;
|
|
public ItemStack sellingItemstack;
|
|
- public EntityVillager.PriceInfo sellingPriceInfo;
|
|
+ public PriceInfo sellingPriceInfo;
|
|
|
|
- public ItemAndEmeraldToItem(Item p_i45813_1_, EntityVillager.PriceInfo p_i45813_2_, Item p_i45813_3_, EntityVillager.PriceInfo p_i45813_4_)
|
|
+ public ItemAndEmeraldToItem(Item p_i45813_1_, PriceInfo p_i45813_2_, Item p_i45813_3_, PriceInfo p_i45813_4_)
|
|
{
|
|
this.buyingItemStack = new ItemStack(p_i45813_1_);
|
|
this.buyingPriceInfo = p_i45813_2_;
|
|
@@ -1041,7 +1109,7 @@
|
|
}
|
|
}
|
|
|
|
- public static class ListEnchantedBookForEmeralds implements EntityVillager.ITradeList
|
|
+ public static class ListEnchantedBookForEmeralds implements ITradeList
|
|
{
|
|
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random)
|
|
{
|
|
@@ -1064,12 +1132,12 @@
|
|
}
|
|
}
|
|
|
|
- public static class ListEnchantedItemForEmeralds implements EntityVillager.ITradeList
|
|
+ public static class ListEnchantedItemForEmeralds implements ITradeList
|
|
{
|
|
public ItemStack enchantedItemStack;
|
|
- public EntityVillager.PriceInfo priceInfo;
|
|
+ public PriceInfo priceInfo;
|
|
|
|
- public ListEnchantedItemForEmeralds(Item p_i45814_1_, EntityVillager.PriceInfo p_i45814_2_)
|
|
+ public ListEnchantedItemForEmeralds(Item p_i45814_1_, PriceInfo p_i45814_2_)
|
|
{
|
|
this.enchantedItemStack = new ItemStack(p_i45814_1_);
|
|
this.priceInfo = p_i45814_2_;
|
|
@@ -1089,19 +1157,22 @@
|
|
recipeList.add(new MerchantRecipe(itemstack, itemstack1));
|
|
}
|
|
}
|
|
+ //MODDERS DO NOT USE OR EDIT THIS IN ANY WAY IT WILL HAVE NO EFFECT, THIS IS JUST IN HERE TO ALLOW FORGE TO ACCESS IT
|
|
+ @Deprecated
|
|
+ public static ITradeList[][][][] GET_TRADES_DONT_USE(){ return DEFAULT_TRADE_LIST_MAP; }
|
|
|
|
- public static class ListItemForEmeralds implements EntityVillager.ITradeList
|
|
+ public static class ListItemForEmeralds implements ITradeList
|
|
{
|
|
public ItemStack itemToBuy;
|
|
- public EntityVillager.PriceInfo priceInfo;
|
|
+ public PriceInfo priceInfo;
|
|
|
|
- public ListItemForEmeralds(Item par1Item, EntityVillager.PriceInfo priceInfo)
|
|
+ public ListItemForEmeralds(Item par1Item, PriceInfo priceInfo)
|
|
{
|
|
this.itemToBuy = new ItemStack(par1Item);
|
|
this.priceInfo = priceInfo;
|
|
}
|
|
|
|
- public ListItemForEmeralds(ItemStack stack, EntityVillager.PriceInfo priceInfo)
|
|
+ public ListItemForEmeralds(ItemStack stack, PriceInfo priceInfo)
|
|
{
|
|
this.itemToBuy = stack;
|
|
this.priceInfo = priceInfo;
|
|
@@ -1152,13 +1223,13 @@
|
|
}
|
|
}
|
|
|
|
- static class TreasureMapForEmeralds implements EntityVillager.ITradeList
|
|
+ static class TreasureMapForEmeralds implements ITradeList
|
|
{
|
|
- public EntityVillager.PriceInfo value;
|
|
+ public PriceInfo value;
|
|
public String destination;
|
|
public MapDecoration.Type destinationType;
|
|
|
|
- public TreasureMapForEmeralds(EntityVillager.PriceInfo p_i47340_1_, String p_i47340_2_, MapDecoration.Type p_i47340_3_)
|
|
+ public TreasureMapForEmeralds(PriceInfo p_i47340_1_, String p_i47340_2_, MapDecoration.Type p_i47340_3_)
|
|
{
|
|
this.value = p_i47340_1_;
|
|
this.destination = p_i47340_2_;
|