类 Mob

所有已实现的接口:
CommandSource, Attackable, Targeting, EntityAccess, Nameable, ICapabilityProvider, ICapabilityProviderImpl<Entity>, ICapabilitySerializable<CompoundTag>, IForgeEntity, IForgeLivingEntity, INBTSerializable<CompoundTag>
直接已知子类:
AmbientCreature, EnderDragon, FlyingMob, PathfinderMob, Slime

public abstract class Mob extends LivingEntity implements Targeting
  • 字段详细资料

    • 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
      另请参阅:
    • MOB_FLAG_LEFTHANDED

      private static final int MOB_FLAG_LEFTHANDED
      另请参阅:
    • MOB_FLAG_AGGRESSIVE

      private static final int MOB_FLAG_AGGRESSIVE
      另请参阅:
    • PICKUP_REACH

      protected static final int PICKUP_REACH
      另请参阅:
    • ITEM_PICKUP_REACH

      private static final Vec3i ITEM_PICKUP_REACH
    • MAX_WEARING_ARMOR_CHANCE

      public static final float MAX_WEARING_ARMOR_CHANCE
      另请参阅:
    • MAX_PICKUP_LOOT_CHANCE

      public static final float MAX_PICKUP_LOOT_CHANCE
      另请参阅:
    • MAX_ENCHANTED_ARMOR_CHANCE

      public static final float MAX_ENCHANTED_ARMOR_CHANCE
      另请参阅:
    • MAX_ENCHANTED_WEAPON_CHANCE

      public static final float MAX_ENCHANTED_WEAPON_CHANCE
      另请参阅:
    • LEASH_TAG

      public static final String LEASH_TAG
      另请参阅:
    • DEFAULT_EQUIPMENT_DROP_CHANCE

      public static final float DEFAULT_EQUIPMENT_DROP_CHANCE
      另请参阅:
    • PRESERVE_ITEM_DROP_CHANCE

      public static final int PRESERVE_ITEM_DROP_CHANCE
      另请参阅:
    • UPDATE_GOAL_SELECTOR_EVERY_N_TICKS

      public static final int UPDATE_GOAL_SELECTOR_EVERY_N_TICKS
      另请参阅:
    • 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

      @Nullable 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

      @Nullable 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
    • spawnType

      @Nullable private MobSpawnType spawnType
    • spawnCancelled

      private boolean spawnCancelled
  • 构造器详细资料

  • 方法详细资料

    • registerGoals

      protected void registerGoals()
    • createMobAttributes

      public static AttributeSupplier.Builder createMobAttributes()
    • createNavigation

      protected PathNavigation createNavigation(Level pLevel)
    • shouldPassengersInheritMalus

      protected boolean shouldPassengersInheritMalus()
    • getPathfindingMalus

      public float getPathfindingMalus(BlockPathTypes pNodeType)
    • setPathfindingMalus

      public void setPathfindingMalus(BlockPathTypes pNodeType, float pMalus)
    • onPathfindingStart

      public void onPathfindingStart()
    • onPathfindingDone

      public void onPathfindingDone()
    • createBodyControl

      protected BodyRotationControl createBodyControl()
    • getLookControl

      public LookControl getLookControl()
    • getMoveControl

      public MoveControl getMoveControl()
    • getJumpControl

      public JumpControl getJumpControl()
    • getNavigation

      public PathNavigation getNavigation()
    • getControllingPassenger

      @Nullable public LivingEntity getControllingPassenger()
      覆盖:
      getControllingPassenger 在类中 Entity
    • getSensing

      public Sensing getSensing()
    • getTarget

      @Nullable public LivingEntity getTarget()
      指定者:
      getTarget 在接口中 Targeting
    • setTarget

      public void setTarget(@Nullable LivingEntity pTarget)
    • canAttackType

      public boolean canAttackType(EntityType<?> pType)
      覆盖:
      canAttackType 在类中 LivingEntity
    • canFireProjectileWeapon

      public boolean canFireProjectileWeapon(ProjectileWeaponItem pProjectileWeapon)
    • ate

      public void ate()
    • defineSynchedData

      protected void defineSynchedData()
      覆盖:
      defineSynchedData 在类中 LivingEntity
    • getAmbientSoundInterval

      public int getAmbientSoundInterval()
    • playAmbientSound

      public void playAmbientSound()
    • baseTick

      public void baseTick()
      覆盖:
      baseTick 在类中 LivingEntity
    • playHurtSound

      protected void playHurtSound(DamageSource pSource)
      覆盖:
      playHurtSound 在类中 LivingEntity
    • resetAmbientSoundTime

      private void resetAmbientSoundTime()
    • getExperienceReward

      public int getExperienceReward()
      覆盖:
      getExperienceReward 在类中 LivingEntity
    • spawnAnim

      public void spawnAnim()
    • handleEntityEvent

      public void handleEntityEvent(byte pId)
      覆盖:
      handleEntityEvent 在类中 LivingEntity
    • tick

      public void tick()
      覆盖:
      tick 在类中 LivingEntity
    • updateControlFlags

      protected void updateControlFlags()
    • tickHeadTurn

      protected float tickHeadTurn(float pYRot, float pAnimStep)
      覆盖:
      tickHeadTurn 在类中 LivingEntity
    • getAmbientSound

      @Nullable protected SoundEvent getAmbientSound()
    • addAdditionalSaveData

      public void addAdditionalSaveData(CompoundTag pCompound)
      覆盖:
      addAdditionalSaveData 在类中 LivingEntity
    • readAdditionalSaveData

      public void readAdditionalSaveData(CompoundTag pCompound)
      覆盖:
      readAdditionalSaveData 在类中 LivingEntity
    • dropFromLootTable

      protected void dropFromLootTable(DamageSource pDamageSource, boolean pAttackedRecently)
      覆盖:
      dropFromLootTable 在类中 LivingEntity
    • getLootTable

      public final ResourceLocation getLootTable()
      覆盖:
      getLootTable 在类中 LivingEntity
    • getDefaultLootTable

      protected ResourceLocation getDefaultLootTable()
    • getLootTableSeed

      public long getLootTableSeed()
      覆盖:
      getLootTableSeed 在类中 LivingEntity
    • setZza

      public void setZza(float pAmount)
    • setYya

      public void setYya(float pAmount)
    • setXxa

      public void setXxa(float pAmount)
    • setSpeed

      public void setSpeed(float pSpeed)
      覆盖:
      setSpeed 在类中 LivingEntity
    • aiStep

      public void aiStep()
      覆盖:
      aiStep 在类中 LivingEntity
    • getPickupReach

      protected Vec3i getPickupReach()
    • pickUpItem

      protected void pickUpItem(ItemEntity pItemEntity)
    • equipItemIfPossible

      public ItemStack equipItemIfPossible(ItemStack pStack)
    • setItemSlotAndDropWhenKilled

      protected void setItemSlotAndDropWhenKilled(EquipmentSlot pSlot, ItemStack pStack)
    • setGuaranteedDrop

      public void setGuaranteedDrop(EquipmentSlot pSlot)
    • canReplaceCurrentItem

      protected boolean canReplaceCurrentItem(ItemStack pCandidate, ItemStack pExisting)
    • canReplaceEqualItem

      public boolean canReplaceEqualItem(ItemStack pCandidate, ItemStack pExisting)
    • canHoldItem

      public boolean canHoldItem(ItemStack pStack)
    • wantsToPickUp

      public boolean wantsToPickUp(ItemStack pStack)
    • removeWhenFarAway

      public boolean removeWhenFarAway(double pDistanceToClosestPlayer)
    • requiresCustomPersistence

      public boolean requiresCustomPersistence()
    • shouldDespawnInPeaceful

      protected boolean shouldDespawnInPeaceful()
    • checkDespawn

      public void checkDespawn()
      覆盖:
      checkDespawn 在类中 Entity
    • serverAiStep

      protected final void serverAiStep()
      覆盖:
      serverAiStep 在类中 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 pEntity, float pMaxYRotIncrease, float pMaxXRotIncrease)
    • rotlerp

      private float rotlerp(float pAngle, float pTargetAngle, float pMaxIncrease)
    • checkMobSpawnRules

      public static boolean checkMobSpawnRules(EntityType<? extends Mob> pType, LevelAccessor pLevel, MobSpawnType pSpawnType, BlockPos pPos, RandomSource pRandom)
    • checkSpawnRules

      public boolean checkSpawnRules(LevelAccessor pLevel, MobSpawnType pReason)
    • checkSpawnObstruction

      public boolean checkSpawnObstruction(LevelReader pLevel)
    • getMaxSpawnClusterSize

      public int getMaxSpawnClusterSize()
    • isMaxGroupSizeReached

      public boolean isMaxGroupSizeReached(int pSize)
    • getMaxFallDistance

      public int getMaxFallDistance()
      覆盖:
      getMaxFallDistance 在类中 Entity
    • getHandSlots

      public Iterable<ItemStack> getHandSlots()
      覆盖:
      getHandSlots 在类中 Entity
    • getArmorSlots

      public Iterable<ItemStack> getArmorSlots()
      指定者:
      getArmorSlots 在类中 LivingEntity
    • getItemBySlot

      public ItemStack getItemBySlot(EquipmentSlot pSlot)
      指定者:
      getItemBySlot 在类中 LivingEntity
    • setItemSlot

      public void setItemSlot(EquipmentSlot pSlot, ItemStack pStack)
      指定者:
      setItemSlot 在类中 LivingEntity
    • dropCustomDeathLoot

      protected void dropCustomDeathLoot(DamageSource pSource, int pLooting, boolean pRecentlyHit)
      覆盖:
      dropCustomDeathLoot 在类中 LivingEntity
    • getEquipmentDropChance

      protected float getEquipmentDropChance(EquipmentSlot pSlot)
    • populateDefaultEquipmentSlots

      protected void populateDefaultEquipmentSlots(RandomSource pRandom, DifficultyInstance pDifficulty)
    • getEquipmentForSlot

      @Nullable public static Item getEquipmentForSlot(EquipmentSlot pSlot, int pChance)
    • populateDefaultEquipmentEnchantments

      protected void populateDefaultEquipmentEnchantments(RandomSource pRandom, DifficultyInstance pDifficulty)
    • enchantSpawnedWeapon

      protected void enchantSpawnedWeapon(RandomSource pRandom, float pChanceMultiplier)
    • enchantSpawnedArmor

      protected void enchantSpawnedArmor(RandomSource pRandom, float pChanceMultiplier, EquipmentSlot pSlot)
    • finalizeSpawn

      @Deprecated @OverrideOnly @Nullable public SpawnGroupData finalizeSpawn(ServerLevelAccessor pLevel, DifficultyInstance pDifficulty, MobSpawnType pReason, @Nullable SpawnGroupData pSpawnData, @Nullable CompoundTag pDataTag)
      已过时。
      Forge: Override-Only, call via ForgeEventFactory.onFinalizeSpawn.
      Overrides are allowed. Do not wrap super calls within override (as that will cause stack overflows).
      Vanilla calls are replaced with a transformer, and are not visible in source.

      Be certain to either call super.finalizeSpawn or set the spawnType field from within your override.

    • setPersistenceRequired

      public void setPersistenceRequired()
    • setDropChance

      public void setDropChance(EquipmentSlot pSlot, float pChance)
    • canPickUpLoot

      public boolean canPickUpLoot()
    • setCanPickUpLoot

      public void setCanPickUpLoot(boolean pCanPickUpLoot)
    • canTakeItem

      public boolean canTakeItem(ItemStack pItemstack)
      覆盖:
      canTakeItem 在类中 LivingEntity
    • isPersistenceRequired

      public boolean isPersistenceRequired()
    • interact

      public final InteractionResult interact(Player pPlayer, InteractionHand pHand)
      覆盖:
      interact 在类中 Entity
    • checkAndHandleImportantInteractions

      private InteractionResult checkAndHandleImportantInteractions(Player pPlayer, InteractionHand pHand)
    • onOffspringSpawnedFromEgg

      protected void onOffspringSpawnedFromEgg(Player pPlayer, Mob pChild)
    • mobInteract

      protected InteractionResult mobInteract(Player pPlayer, InteractionHand pHand)
    • isWithinRestriction

      public boolean isWithinRestriction()
    • isWithinRestriction

      public boolean isWithinRestriction(BlockPos pPos)
    • restrictTo

      public void restrictTo(BlockPos pPos, int pDistance)
    • 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> pEntityType, boolean pTransferInventory)
    • tickLeash

      protected void tickLeash()
    • dropLeash

      public void dropLeash(boolean pBroadcastPacket, boolean pDropLeash)
    • canBeLeashed

      public boolean canBeLeashed(Player pPlayer)
    • isLeashed

      public boolean isLeashed()
    • getLeashHolder

      @Nullable public Entity getLeashHolder()
    • setLeashedTo

      public void setLeashedTo(Entity pLeashHolder, boolean pBroadcastPacket)
    • setDelayedLeashHolderId

      public void setDelayedLeashHolderId(int pLeashHolderID)
    • startRiding

      public boolean startRiding(Entity pEntity, boolean pForce)
      覆盖:
      startRiding 在类中 Entity
    • restoreLeashFromSave

      private void restoreLeashFromSave()
    • isEffectiveAi

      public boolean isEffectiveAi()
      覆盖:
      isEffectiveAi 在类中 Entity
    • setNoAi

      public void setNoAi(boolean pNoAi)
    • setLeftHanded

      public void setLeftHanded(boolean pLeftHanded)
    • setAggressive

      public void setAggressive(boolean pAggressive)
    • isNoAi

      public boolean isNoAi()
    • isLeftHanded

      public boolean isLeftHanded()
    • isAggressive

      public boolean isAggressive()
    • setBaby

      public void setBaby(boolean pBaby)
    • getMainArm

      public HumanoidArm getMainArm()
      指定者:
      getMainArm 在类中 LivingEntity
    • getMeleeAttackRangeSqr

      public double getMeleeAttackRangeSqr(LivingEntity pEntity)
    • getPerceivedTargetDistanceSquareForMeleeAttack

      public double getPerceivedTargetDistanceSquareForMeleeAttack(LivingEntity pEntity)
    • isWithinMeleeAttackRange

      public boolean isWithinMeleeAttackRange(LivingEntity pEntity)
    • doHurtTarget

      public boolean doHurtTarget(Entity pEntity)
      覆盖:
      doHurtTarget 在类中 LivingEntity
    • maybeDisableShield

      private void maybeDisableShield(Player pPlayer, ItemStack pMobItemStack, ItemStack pPlayerItemStack)
    • isSunBurnTick

      protected boolean isSunBurnTick()
    • jumpInLiquid

      @Deprecated protected void jumpInLiquid(TagKey<Fluid> pFluidTag)
      已过时。
      覆盖:
      jumpInLiquid 在类中 LivingEntity
    • jumpInLiquidInternal

      private void jumpInLiquidInternal(Runnable onSuper)
    • jumpInFluid

      public void jumpInFluid(FluidType type)
      从接口复制的说明: IForgeLivingEntity
      Performs what to do when an entity attempts to go up or "jump" in a fluid.
      指定者:
      jumpInFluid 在接口中 IForgeLivingEntity
      参数:
      type - the type of the fluid
    • removeFreeWill

      public void removeFreeWill()
    • removeAllGoals

      public void removeAllGoals(Predicate<Goal> pFilter)
    • removeAfterChangingDimensions

      protected void removeAfterChangingDimensions()
      覆盖:
      removeAfterChangingDimensions 在类中 Entity
    • getPickResult

      @Nullable public ItemStack getPickResult()
      覆盖:
      getPickResult 在类中 Entity
    • getSpawnType

      @Nullable public final MobSpawnType getSpawnType()
      Returns the type of spawn that created this mob, if applicable. If it could not be determined, this will return null.

      This is set via finalizeSpawn(net.minecraft.world.level.ServerLevelAccessor, net.minecraft.world.DifficultyInstance, net.minecraft.world.entity.MobSpawnType, net.minecraft.world.entity.SpawnGroupData, net.minecraft.nbt.CompoundTag), so you should not call this from within that method, instead using the parameter.

    • isSpawnCancelled

      @Internal public final boolean isSpawnCancelled()
      This method exists so that spawns can be cancelled from the FinalizeSpawnEvent without needing to hook up an additional handler for the EntityJoinLevelEvent.
      返回:
      if this mob will be blocked from spawning during LevelWriter.addFreshEntity(Entity)
      API Note:
      Not public-facing API.
    • setSpawnCancelled

      @Internal public final void setSpawnCancelled(boolean cancel)
      Marks this mob as being disallowed to spawn during LevelWriter.addFreshEntity(Entity).

      抛出:
      UnsupportedOperationException - if this entity has already been added to the world.
      API Note:
      Not public-facing API.