Class Mob

All Implemented Interfaces:
CommandSource, EntityAccess, Nameable, ICapabilityProvider, ICapabilitySerializable<CompoundTag>, IForgeEntity, INBTSerializable<CompoundTag>
Direct Known Subclasses:
AmbientCreature, EnderDragon, FlyingMob, PathfinderMob, Slime

public abstract class Mob extends LivingEntity
  • Field Details

    • DATA_MOB_FLAGS_ID

      private static final EntityDataAccessor<Byte> DATA_MOB_FLAGS_ID
    • MOB_FLAG_NO_AI

      private static final int MOB_FLAG_NO_AI
      See Also:
      Constant Field Values
    • MOB_FLAG_LEFTHANDED

      private static final int MOB_FLAG_LEFTHANDED
      See Also:
      Constant Field Values
    • MOB_FLAG_AGGRESSIVE

      private static final int MOB_FLAG_AGGRESSIVE
      See Also:
      Constant Field Values
    • MAX_WEARING_ARMOR_CHANCE

      public static final float MAX_WEARING_ARMOR_CHANCE
      See Also:
      Constant Field Values
    • MAX_PICKUP_LOOT_CHANCE

      public static final float MAX_PICKUP_LOOT_CHANCE
      See Also:
      Constant Field Values
    • MAX_ENCHANTED_ARMOR_CHANCE

      public static final float MAX_ENCHANTED_ARMOR_CHANCE
      See Also:
      Constant Field Values
    • MAX_ENCHANTED_WEAPON_CHANCE

      public static final float MAX_ENCHANTED_WEAPON_CHANCE
      See Also:
      Constant Field Values
    • LEASH_TAG

      public static final String LEASH_TAG
      See Also:
      Constant Field Values
    • PICKUP_REACH

      private static final int PICKUP_REACH
      See Also:
      Constant Field Values
    • DEFAULT_EQUIPMENT_DROP_CHANCE

      public static final float DEFAULT_EQUIPMENT_DROP_CHANCE
      See Also:
      Constant Field Values
    • ambientSoundTime

      public int ambientSoundTime
    • xpReward

      protected int xpReward
    • lookControl

      protected LookControl lookControl
    • moveControl

      protected MoveControl moveControl
    • jumpControl

      protected JumpControl jumpControl
    • bodyRotationControl

      private final BodyRotationControl bodyRotationControl
    • goalSelector

      public final GoalSelector goalSelector
    • targetSelector

      public final GoalSelector targetSelector
    • target

      private LivingEntity target
    • sensing

      private final Sensing sensing
    • handItems

      private final NonNullList<ItemStack> handItems
    • handDropChances

      protected final float[] handDropChances
    • armorItems

      private final NonNullList<ItemStack> armorItems
    • armorDropChances

      protected final float[] armorDropChances
    • canPickUpLoot

      private boolean canPickUpLoot
    • persistenceRequired

      private boolean persistenceRequired
    • pathfindingMalus

      private final Map<BlockPathTypes,​Float> pathfindingMalus
    • lootTable

      private ResourceLocation lootTable
    • lootTableSeed

      private long lootTableSeed
    • leashHolder

      @Nullable private Entity leashHolder
    • delayedLeashHolderId

      private int delayedLeashHolderId
    • leashInfoTag

      @Nullable private CompoundTag leashInfoTag
    • restrictCenter

      private BlockPos restrictCenter
    • restrictRadius

      private float restrictRadius
  • Constructor Details

  • Method Details

    • registerGoals

      protected void registerGoals()
    • createMobAttributes

      public static AttributeSupplier.Builder createMobAttributes()
    • createNavigation

      protected PathNavigation createNavigation(Level p_21480_)
    • shouldPassengersInheritMalus

      protected boolean shouldPassengersInheritMalus()
    • getPathfindingMalus

      public float getPathfindingMalus(BlockPathTypes p_21440_)
    • setPathfindingMalus

      public void setPathfindingMalus(BlockPathTypes p_21442_, float p_21443_)
    • canCutCorner

      public boolean canCutCorner(BlockPathTypes p_21482_)
    • createBodyControl

      protected BodyRotationControl createBodyControl()
    • getLookControl

      public LookControl getLookControl()
    • getMoveControl

      public MoveControl getMoveControl()
    • getJumpControl

      public JumpControl getJumpControl()
    • getNavigation

      public PathNavigation getNavigation()
    • getSensing

      public Sensing getSensing()
    • getTarget

      @Nullable public LivingEntity getTarget()
    • setTarget

      public void setTarget(@Nullable LivingEntity p_21544_)
    • canAttackType

      public boolean canAttackType(EntityType<?> p_21399_)
      Overrides:
      canAttackType in class LivingEntity
    • canFireProjectileWeapon

      public boolean canFireProjectileWeapon(ProjectileWeaponItem p_21430_)
    • ate

      public void ate()
    • defineSynchedData

      protected void defineSynchedData()
      Overrides:
      defineSynchedData in class LivingEntity
    • getAmbientSoundInterval

      public int getAmbientSoundInterval()
    • playAmbientSound

      public void playAmbientSound()
    • baseTick

      public void baseTick()
      Overrides:
      baseTick in class LivingEntity
    • playHurtSound

      protected void playHurtSound(DamageSource p_21493_)
      Overrides:
      playHurtSound in class LivingEntity
    • resetAmbientSoundTime

      private void resetAmbientSoundTime()
    • getExperienceReward

      protected int getExperienceReward(Player p_21511_)
      Overrides:
      getExperienceReward in class LivingEntity
    • spawnAnim

      public void spawnAnim()
    • handleEntityEvent

      public void handleEntityEvent(byte p_21375_)
      Overrides:
      handleEntityEvent in class LivingEntity
    • tick

      public void tick()
      Overrides:
      tick in class LivingEntity
    • updateControlFlags

      protected void updateControlFlags()
    • tickHeadTurn

      protected float tickHeadTurn(float p_21538_, float p_21539_)
      Overrides:
      tickHeadTurn in class LivingEntity
    • getAmbientSound

      @Nullable protected SoundEvent getAmbientSound()
    • addAdditionalSaveData

      public void addAdditionalSaveData(CompoundTag p_21484_)
      Overrides:
      addAdditionalSaveData in class LivingEntity
    • readAdditionalSaveData

      public void readAdditionalSaveData(CompoundTag p_21450_)
      Overrides:
      readAdditionalSaveData in class LivingEntity
    • dropFromLootTable

      protected void dropFromLootTable(DamageSource p_21389_, boolean p_21390_)
      Overrides:
      dropFromLootTable in class LivingEntity
    • createLootContext

      protected LootContext.Builder createLootContext(boolean p_21453_, DamageSource p_21454_)
      Overrides:
      createLootContext in class LivingEntity
    • getLootTable

      public final ResourceLocation getLootTable()
      Overrides:
      getLootTable in class LivingEntity
    • getDefaultLootTable

      protected ResourceLocation getDefaultLootTable()
    • setZza

      public void setZza(float p_21565_)
    • setYya

      public void setYya(float p_21568_)
    • setXxa

      public void setXxa(float p_21571_)
    • setSpeed

      public void setSpeed(float p_21556_)
      Overrides:
      setSpeed in class LivingEntity
    • aiStep

      public void aiStep()
      Overrides:
      aiStep in class LivingEntity
    • pickUpItem

      protected void pickUpItem(ItemEntity p_21471_)
    • equipItemIfPossible

      public boolean equipItemIfPossible(ItemStack p_21541_)
    • setItemSlotAndDropWhenKilled

      protected void setItemSlotAndDropWhenKilled(EquipmentSlot p_21469_, ItemStack p_21470_)
    • setGuaranteedDrop

      public void setGuaranteedDrop(EquipmentSlot p_21509_)
    • canReplaceCurrentItem

      protected boolean canReplaceCurrentItem(ItemStack p_21428_, ItemStack p_21429_)
    • canReplaceEqualItem

      public boolean canReplaceEqualItem(ItemStack p_21478_, ItemStack p_21479_)
    • canHoldItem

      public boolean canHoldItem(ItemStack p_21545_)
    • wantsToPickUp

      public boolean wantsToPickUp(ItemStack p_21546_)
    • removeWhenFarAway

      public boolean removeWhenFarAway(double p_21542_)
    • requiresCustomPersistence

      public boolean requiresCustomPersistence()
    • shouldDespawnInPeaceful

      protected boolean shouldDespawnInPeaceful()
    • checkDespawn

      public void checkDespawn()
      Overrides:
      checkDespawn in class Entity
    • serverAiStep

      protected final void serverAiStep()
      Overrides:
      serverAiStep in class LivingEntity
    • sendDebugPackets

      protected void sendDebugPackets()
    • customServerAiStep

      protected void customServerAiStep()
    • getMaxHeadXRot

      public int getMaxHeadXRot()
    • getMaxHeadYRot

      public int getMaxHeadYRot()
    • getHeadRotSpeed

      public int getHeadRotSpeed()
    • lookAt

      public void lookAt(Entity p_21392_, float p_21393_, float p_21394_)
    • rotlerp

      private float rotlerp(float p_21377_, float p_21378_, float p_21379_)
    • checkMobSpawnRules

      public static boolean checkMobSpawnRules(EntityType<? extends Mob> p_21401_, LevelAccessor p_21402_, MobSpawnType p_21403_, BlockPos p_21404_, Random p_21405_)
    • checkSpawnRules

      public boolean checkSpawnRules(LevelAccessor p_21431_, MobSpawnType p_21432_)
    • checkSpawnObstruction

      public boolean checkSpawnObstruction(LevelReader p_21433_)
    • getMaxSpawnClusterSize

      public int getMaxSpawnClusterSize()
    • isMaxGroupSizeReached

      public boolean isMaxGroupSizeReached(int p_21489_)
    • getMaxFallDistance

      public int getMaxFallDistance()
      Overrides:
      getMaxFallDistance in class Entity
    • getHandSlots

      public Iterable<ItemStack> getHandSlots()
      Overrides:
      getHandSlots in class Entity
    • getArmorSlots

      public Iterable<ItemStack> getArmorSlots()
      Specified by:
      getArmorSlots in class LivingEntity
    • getItemBySlot

      public ItemStack getItemBySlot(EquipmentSlot p_21467_)
      Specified by:
      getItemBySlot in class LivingEntity
    • setItemSlot

      public void setItemSlot(EquipmentSlot p_21416_, ItemStack p_21417_)
      Specified by:
      setItemSlot in class LivingEntity
    • dropCustomDeathLoot

      protected void dropCustomDeathLoot(DamageSource p_21385_, int p_21386_, boolean p_21387_)
      Overrides:
      dropCustomDeathLoot in class LivingEntity
    • getEquipmentDropChance

      protected float getEquipmentDropChance(EquipmentSlot p_21520_)
    • populateDefaultEquipmentSlots

      protected void populateDefaultEquipmentSlots(DifficultyInstance p_21383_)
    • getEquipmentForSlot

      @Nullable public static Item getEquipmentForSlot(EquipmentSlot p_21413_, int p_21414_)
    • populateDefaultEquipmentEnchantments

      protected void populateDefaultEquipmentEnchantments(DifficultyInstance p_21462_)
    • enchantSpawnedWeapon

      protected void enchantSpawnedWeapon(float p_21572_)
    • enchantSpawnedArmor

      protected void enchantSpawnedArmor(float p_21381_, EquipmentSlot p_21382_)
    • finalizeSpawn

      @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor p_21434_, DifficultyInstance p_21435_, MobSpawnType p_21436_, @Nullable SpawnGroupData p_21437_, @Nullable CompoundTag p_21438_)
    • canBeControlledByRider

      public boolean canBeControlledByRider()
    • setPersistenceRequired

      public void setPersistenceRequired()
    • setDropChance

      public void setDropChance(EquipmentSlot p_21410_, float p_21411_)
    • canPickUpLoot

      public boolean canPickUpLoot()
    • setCanPickUpLoot

      public void setCanPickUpLoot(boolean p_21554_)
    • canTakeItem

      public boolean canTakeItem(ItemStack p_21522_)
      Overrides:
      canTakeItem in class LivingEntity
    • isPersistenceRequired

      public boolean isPersistenceRequired()
    • interact

      public final InteractionResult interact(Player p_21420_, InteractionHand p_21421_)
      Overrides:
      interact in class Entity
    • checkAndHandleImportantInteractions

      private InteractionResult checkAndHandleImportantInteractions(Player p_21500_, InteractionHand p_21501_)
    • onOffspringSpawnedFromEgg

      protected void onOffspringSpawnedFromEgg(Player p_21422_, Mob p_21423_)
    • mobInteract

      protected InteractionResult mobInteract(Player p_21472_, InteractionHand p_21473_)
    • isWithinRestriction

      public boolean isWithinRestriction()
    • isWithinRestriction

      public boolean isWithinRestriction(BlockPos p_21445_)
    • restrictTo

      public void restrictTo(BlockPos p_21447_, int p_21448_)
    • getRestrictCenter

      public BlockPos getRestrictCenter()
    • getRestrictRadius

      public float getRestrictRadius()
    • clearRestriction

      public void clearRestriction()
    • hasRestriction

      public boolean hasRestriction()
    • convertTo

      @Nullable public <T extends Mob> T convertTo(EntityType<T> p_21407_, boolean p_21408_)
    • tickLeash

      protected void tickLeash()
    • dropLeash

      public void dropLeash(boolean p_21456_, boolean p_21457_)
    • canBeLeashed

      public boolean canBeLeashed(Player p_21418_)
    • isLeashed

      public boolean isLeashed()
    • getLeashHolder

      @Nullable public Entity getLeashHolder()
    • setLeashedTo

      public void setLeashedTo(Entity p_21464_, boolean p_21465_)
    • setDelayedLeashHolderId

      public void setDelayedLeashHolderId(int p_21507_)
    • startRiding

      public boolean startRiding(Entity p_21396_, boolean p_21397_)
      Overrides:
      startRiding in class Entity
    • restoreLeashFromSave

      private void restoreLeashFromSave()
    • isControlledByLocalInstance

      public boolean isControlledByLocalInstance()
      Overrides:
      isControlledByLocalInstance in class Entity
    • isEffectiveAi

      public boolean isEffectiveAi()
      Overrides:
      isEffectiveAi in class LivingEntity
    • setNoAi

      public void setNoAi(boolean p_21558_)
    • setLeftHanded

      public void setLeftHanded(boolean p_21560_)
    • setAggressive

      public void setAggressive(boolean p_21562_)
    • isNoAi

      public boolean isNoAi()
    • isLeftHanded

      public boolean isLeftHanded()
    • isAggressive

      public boolean isAggressive()
    • setBaby

      public void setBaby(boolean p_21451_)
    • getMainArm

      public HumanoidArm getMainArm()
      Specified by:
      getMainArm in class LivingEntity
    • getMeleeAttackRangeSqr

      public double getMeleeAttackRangeSqr(LivingEntity p_147273_)
    • doHurtTarget

      public boolean doHurtTarget(Entity p_21372_)
      Overrides:
      doHurtTarget in class LivingEntity
    • maybeDisableShield

      private void maybeDisableShield(Player p_21425_, ItemStack p_21426_, ItemStack p_21427_)
    • isSunBurnTick

      protected boolean isSunBurnTick()
    • jumpInLiquid

      protected void jumpInLiquid(Tag<Fluid> p_21491_)
      Overrides:
      jumpInLiquid in class LivingEntity
    • removeFreeWill

      public void removeFreeWill()
    • removeAfterChangingDimensions

      protected void removeAfterChangingDimensions()
      Overrides:
      removeAfterChangingDimensions in class Entity
    • getPickResult

      @Nullable public ItemStack getPickResult()
      Overrides:
      getPickResult in class Entity