Class EntityVillager

All Implemented Interfaces:
IAnimals, IMerchant, INpc
Direct Known Subclasses:
BlacksmithVillagerEntity, ButcherVillagerEntity, FarmerVillagerEntity, LibrarianVillagerEntity, PriestVillagerEntity

public abstract class EntityVillager extends EntityAgeable implements IMerchant, INpc
  • Field Details

  • Constructor Details

    • EntityVillager

      public EntityVillager(World par1World)
    • EntityVillager

      public EntityVillager(World par1World, int par2)
  • Method Details

    • applyEntityAttributes

      protected void applyEntityAttributes()
      Overrides:
      applyEntityAttributes in class EntityLiving
    • isAIEnabled

      public boolean isAIEnabled()
      Returns true if the newer Entity AI code should be run
      Overrides:
      isAIEnabled in class EntityLiving
    • entityInit

      protected void entityInit()
      Overrides:
      entityInit in class EntityAgeable
    • writeEntityToNBT

      public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound)
      (abstract) Protected helper method to write subclass entity data to NBT.
      Overrides:
      writeEntityToNBT in class EntityAgeable
    • readEntityFromNBT

      public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound)
      (abstract) Protected helper method to read subclass entity data from NBT.
      Overrides:
      readEntityFromNBT in class EntityAgeable
    • canDespawn

      protected boolean canDespawn()
      Determines if an entity can be despawned, used on idle far away entities
      Overrides:
      canDespawn in class EntityLiving
    • getLivingSound

      protected String getLivingSound()
      Returns the sound this mob makes while it's alive.
      Overrides:
      getLivingSound in class EntityLiving
    • getHurtSound

      protected String getHurtSound()
      Returns the sound this mob makes when it is hurt.
      Overrides:
      getHurtSound in class EntityLivingBase
    • getDeathSound

      protected String getDeathSound()
      Returns the sound this mob makes on death.
      Overrides:
      getDeathSound in class EntityLivingBase
    • setProfession

      public void setProfession(int par1)
    • getProfession

      public int getProfession()
    • isMating

      public boolean isMating()
    • setMating

      public void setMating(boolean par1)
    • setPlaying

      public void setPlaying(boolean par1)
    • isPlaying

      public boolean isPlaying()
    • onDeath

      public void onDeath(DamageSource par1DamageSource)
      Called when the mob's health reaches 0.
      Overrides:
      onDeath in class EntityCreature
    • setCustomer

      public void setCustomer(EntityPlayer par1EntityPlayer)
      Specified by:
      setCustomer in interface IMerchant
    • getCustomer

      public EntityPlayer getCustomer()
      Specified by:
      getCustomer in interface IMerchant
    • isTrading

      public boolean isTrading()
    • func_110297_a_

      public void func_110297_a_(ItemStack par1ItemStack)
      Specified by:
      func_110297_a_ in interface IMerchant
    • setRecipes

      public void setRecipes(MerchantRecipeList par1MerchantRecipeList)
      Specified by:
      setRecipes in interface IMerchant
    • onSpawnWithEgg

      public EntityLivingData onSpawnWithEgg(EntityLivingData par1EntityLivingData)
      Overrides:
      onSpawnWithEgg in class EntityLiving
    • func_82187_q

      public void func_82187_q()
    • createChild

      public EntityAgeable createChild(EntityAgeable par1EntityAgeable)
      Specified by:
      createChild in class EntityAgeable
    • updateAITick

      protected void updateAITick()
      Description copied from class: EntityLivingBase
      main AI tick function, replaces updateEntityActionState
      Overrides:
      updateAITick in class EntityLivingBase
    • interact

      public boolean interact(EntityPlayer player)
      Description copied from class: EntityAgeable
      Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
      Overrides:
      interact in class EntityAgeable
    • isTemptingItem

      public boolean isTemptingItem(ItemStack stack)
      Overrides:
      isTemptingItem in class EntityAgeable
    • setRevengeTarget

      public void setRevengeTarget(EntityLivingBase attackingEntity)
      Overrides:
      setRevengeTarget in class EntityLivingBase
    • useRecipe

      public void useRecipe(MerchantRecipe recipe)
      Specified by:
      useRecipe in interface IMerchant
    • getRecipes

      public MerchantRecipeList getRecipes(EntityPlayer player)
      Specified by:
      getRecipes in interface IMerchant
    • onLivingUpdate

      public void onLivingUpdate()
      Description copied from class: EntityAgeable
      Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons use this to react to sunlight and start to burn.
      Overrides:
      onLivingUpdate in class EntityAgeable
    • dropFewItems

      protected void dropFewItems(boolean bKilledByPlayer, int iLootingModifier)
      Description copied from class: EntityLiving
      Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param par2 - Level of Looting used to kill this mob.
      Overrides:
      dropFewItems in class EntityLiving
    • getSoundPitch

      public float getSoundPitch()
      Description copied from class: EntityLivingBase
      Gets the pitch of living sounds in living entities.
      Overrides:
      getSoundPitch in class EntityLivingBase
    • getCanCreatureTypeBePossessed

      public boolean getCanCreatureTypeBePossessed()
      Overrides:
      getCanCreatureTypeBePossessed in class EntityCreature
    • onFullPossession

      public void onFullPossession()
      Overrides:
      onFullPossession in class EntityCreature
    • isValidZombieSecondaryTarget

      public boolean isValidZombieSecondaryTarget(EntityZombie zombie)
      Overrides:
      isValidZombieSecondaryTarget in class Entity
    • isSecondaryTargetForSquid

      public boolean isSecondaryTargetForSquid()
      Overrides:
      isSecondaryTargetForSquid in class Entity
    • getMountedYOffset

      public double getMountedYOffset()
      Description copied from class: Entity
      Returns the Y offset from the entity's position for any entity riding this one.
      Overrides:
      getMountedYOffset in class Entity
    • func_90012_b

      public EntityVillager func_90012_b(EntityAgeable otherParent)
    • createVillager

      public static EntityVillager createVillager(World world)
    • createVillagerFromProfession

      public static EntityVillager createVillagerFromProfession(World world, int profession)
    • spawnBabyVillagerWithProfession

      public EntityVillager spawnBabyVillagerWithProfession(EntityAgeable otherParent, int profession)
    • getProfessionFromClass

      public int getProfessionFromClass()
    • getCasteFromProfession

      public static int getCasteFromProfession(int professionID)
    • checkForNewTrades

      protected void checkForNewTrades(int availableTrades)
    • checkForProfessionTrades

      protected void checkForProfessionTrades(MerchantRecipeList recipeList, int availableTrades)
    • checkForProfessionMandatoryTrades

      protected int checkForProfessionMandatoryTrades(MerchantRecipeList recipeList, int availableTrades, int level)
    • getProfessionLevelUpTrade

      protected VillagerTrade getProfessionLevelUpTrade(int level)
    • doesRecipeListAlreadyContainRecipe

      protected boolean doesRecipeListAlreadyContainRecipe(VillagerTrade trade)
    • getProfessionDefaultTrade

      protected MerchantRecipe getProfessionDefaultTrade()
      Return the default trade to use if no other trade is found
      Returns:
      The default trade
    • getRandomTradeFromAdjustedWeight

      protected VillagerTrade getRandomTradeFromAdjustedWeight(Set<VillagerTrade> tradeList)
    • getCurrentMaxNumTrades

      public int getCurrentMaxNumTrades()
    • isInvalidProfessionTrade

      protected boolean isInvalidProfessionTrade(MerchantRecipe trade)
      Used to clear any invalid trades e.g. that may be left over from previous versions
      Parameters:
      trade - The trade to check
      Returns:
      Whether the trade was invalid and should be removed
    • getTradeFromName

      public Optional<VillagerTrade> getTradeFromName(int profession, ResourceLocation name)
    • addCustomTrade

      public static VillagerTrade addCustomTrade(int profession, VillagerTrade entry)
      Add a trade with a custom-defined WeightedMerchantEntry class
    • addCustomLevelUpTrade

      public static void addCustomLevelUpTrade(int profession, VillagerTrade entry)
    • removeCustomTrade

      public static boolean removeCustomTrade(int profession, VillagerTrade entryToRemove)
    • removeLevelUpTrade

      public static boolean removeLevelUpTrade(int profession, int level)
    • playEffectsForTrade

      public void playEffectsForTrade(MerchantRecipe trade)
    • registerEffectForTrade

      public static void registerEffectForTrade(int profession, VillagerTrade entry, Consumer<EntityVillager> effect)
    • removeEffectForTrade

      public static boolean removeEffectForTrade(int profession, VillagerTrade entry, Consumer<EntityVillager> effect)
    • playEffectsForLevelUp

      public void playEffectsForLevelUp(MerchantRecipe trade)
    • registerEffectForLevelUp

      public static void registerEffectForLevelUp(int profession, int level, Consumer<EntityVillager> effect)
    • removeEffectForLevelUp

      public static boolean removeEffectForLevelUp(int profession, int level)
    • customInteract

      protected boolean customInteract(EntityPlayer player)
    • updateStatusParticles

      protected void updateStatusParticles()
    • spawnCustomParticles

      protected void spawnCustomParticles()
    • generateRandomParticles

      protected void generateRandomParticles(String sParticle)
    • checkForLooseMilk

      public void checkForLooseMilk()
    • getInLove

      public int getInLove()
    • setInLove

      public void setInLove(int iInLove)
    • getCurrentTradeLevel

      public int getCurrentTradeLevel()
      Specified by:
      getCurrentTradeLevel in interface IMerchant
    • setTradeLevel

      public void setTradeLevel(int iTradeLevel)
    • getCurrentTradeXP

      public int getCurrentTradeXP()
      Specified by:
      getCurrentTradeXP in interface IMerchant
    • setTradeExperience

      public void setTradeExperience(int iTradeExperience)
    • getDirtyPeasant

      public int getDirtyPeasant()
    • getCurrentTradeMaxXP

      public int getCurrentTradeMaxXP()
      Specified by:
      getCurrentTradeMaxXP in interface IMerchant
    • setDirtyPeasant

      public void setDirtyPeasant(int iDirtyPeasant)
    • scheduleImmediateTradelistRefresh

      protected void scheduleImmediateTradelistRefresh()
    • handleHealthUpdate

      @Environment(CLIENT) public void handleHealthUpdate(byte bUpdateType)
      Overrides:
      handleHealthUpdate in class EntityLivingBase