Class NPCEntity
java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.entity.Entity>
net.minecraft.world.entity.Entity
net.minecraft.world.entity.LivingEntity
net.minecraft.world.entity.Mob
net.minecraft.world.entity.PathfinderMob
com.pixelmonmod.pixelmon.entities.npcs.NPCEntity
- All Implemented Interfaces:
net.minecraft.commands.CommandSource
,net.minecraft.world.entity.Attackable
,net.minecraft.world.entity.npc.Npc
,net.minecraft.world.entity.Targeting
,net.minecraft.world.level.entity.EntityAccess
,net.minecraft.world.Nameable
,net.minecraftforge.common.capabilities.ICapabilityProvider
,net.minecraftforge.common.capabilities.ICapabilityProviderImpl<net.minecraft.world.entity.Entity>
,net.minecraftforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>
,net.minecraftforge.common.extensions.IForgeEntity
,net.minecraftforge.common.extensions.IForgeLivingEntity
,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- Direct Known Subclasses:
IndexedNPCEntity
,NPCNurseJoy
,NPCRelearner
,NPCTrader
,NPCTrainer
,NPCTutor
public abstract class NPCEntity
extends net.minecraft.world.entity.PathfinderMob
implements net.minecraft.world.entity.npc.Npc
Superclass for all NPCs.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.entity.LivingEntity
net.minecraft.world.entity.LivingEntity.Fallsounds
Nested classes/interfaces inherited from class net.minecraft.world.entity.Entity
net.minecraft.world.entity.Entity.MoveFunction, net.minecraft.world.entity.Entity.MovementEmission, net.minecraft.world.entity.Entity.RemovalReason
Nested classes/interfaces inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
net.minecraftforge.common.capabilities.CapabilityProvider.AsField<B extends net.minecraftforge.common.capabilities.ICapabilityProviderImpl<B>>
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
The random index to get the NPC's default messages from.protected EntityDataSyncManager
int
The despawn counter for the NPC.Commands to execute when the Player forfeits.static int
The maximum number of ticks to wait before despawning the NPC.static int
The minimum number of ticks to wait before despawning the NPC.The NPC's spawn location.static final org.joml.Vector3f
static final org.joml.Vector3f
static final DataSync<NPCEntity,
BaseTrainer> static final int
The number of ticks per second in Minecraft.protected BaseTrainer
Fields inherited from class net.minecraft.world.entity.PathfinderMob
DEFAULT_WALK_TARGET_VALUE
Fields inherited from class net.minecraft.world.entity.Mob
ambientSoundTime, armorDropChances, DEFAULT_EQUIPMENT_DROP_CHANCE, goalSelector, handDropChances, jumpControl, LEASH_TAG, lookControl, MAX_ENCHANTED_ARMOR_CHANCE, MAX_ENCHANTED_WEAPON_CHANCE, MAX_PICKUP_LOOT_CHANCE, MAX_WEARING_ARMOR_CHANCE, moveControl, navigation, PICKUP_REACH, PRESERVE_ITEM_DROP_CHANCE, targetSelector, UPDATE_GOAL_SELECTOR_EVERY_N_TICKS, xpReward
Fields inherited from class net.minecraft.world.entity.LivingEntity
animStep, animStepO, ARMOR_SLOT_OFFSET, ARMOR_SLOTS, attackAnim, attackStrengthTicker, autoSpinAttackTicks, brain, DATA_HEALTH_ID, DATA_LIVING_ENTITY_FLAGS, dead, DEATH_DURATION, deathScore, deathTime, DEFAULT_BASE_GRAVITY, DEFAULT_EYE_HEIGHT, EQUIPMENT_SLOT_OFFSET, EXTRA_RENDER_CULLING_SIZE_WITH_BIG_HAT, fallFlyTicks, HAND_SLOTS, hurtDuration, hurtTime, invulnerableDuration, jumping, lastHurt, lastHurtByPlayer, lastHurtByPlayerTime, lerpHeadSteps, lerpSteps, lerpX, lerpXRot, lerpY, lerpYHeadRot, lerpYRot, lerpZ, LIVING_ENTITY_FLAG_IS_USING, LIVING_ENTITY_FLAG_OFF_HAND, LIVING_ENTITY_FLAG_SPIN_ATTACK, MIN_MOVEMENT_DISTANCE, noActionTime, noJumpDelay, oAttackAnim, oRun, PLAYER_HURT_EXPERIENCE_TIME, removeArrowTime, removeStingerTime, rotA, rotOffs, run, SLEEPING_DIMENSIONS, SWING_DURATION, swinging, swingingArm, swingTime, timeOffs, USE_ITEM_INTERVAL, useItem, useItemRemaining, walkAnimation, xxa, yBodyRot, yBodyRotO, yHeadRot, yHeadRotO, yya, zza
Fields inherited from class net.minecraft.world.entity.Entity
BASE_TICKS_REQUIRED_TO_FREEZE, blocksBuilding, BOARDING_COOLDOWN, boardingCooldown, BREATHING_DISTANCE_BELOW_EYES, DATA_POSE, DATA_SHARED_FLAGS_ID, DEFAULT_BB_HEIGHT, DEFAULT_BB_WIDTH, DELTA_AFFECTED_BY_BLOCKS_BELOW_0_2, DELTA_AFFECTED_BY_BLOCKS_BELOW_0_5, DELTA_AFFECTED_BY_BLOCKS_BELOW_1_0, dimensions, ENTITY_COUNTER, entityData, eyeHeight, fallDistance, firstTick, FLAG_FALL_FLYING, FLAG_GLOWING, FLAG_ONFIRE, fluidHeight, flyDist, forgeFluidTypeHeight, FREEZE_HURT_FREQUENCY, hasImpulse, horizontalCollision, hurtMarked, ID_TAG, invulnerableTime, isInPowderSnow, isInsidePortal, level, mainSupportingBlockPos, MAX_ENTITY_TAG_COUNT, minorHorizontalCollision, moveDist, noCulling, noPhysics, onGround, PASSENGERS_TAG, portalEntrancePos, portalTime, random, stringUUID, stuckSpeedMultiplier, tickCount, TOTAL_AIR_SUPPLY, uuid, UUID_TAG, verticalCollision, verticalCollisionBelow, walkDist, walkDistO, wasEyeInWater, wasInPowderSnow, wasOnFire, wasTouchingWater, xo, xOld, xRot, xRotO, yo, yOld, yRot, yRotO, zo, zOld
Fields inherited from interface net.minecraft.commands.CommandSource
NULL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAdditionalSaveData
(net.minecraft.nbt.CompoundTag nbt) boolean
Binds a texture to the NPC.boolean
canBeLeashed
(net.minecraft.world.entity.player.Player player) protected void
Keeps track of when to despawn the NPC.boolean
checkSpawnRules
(net.minecraft.world.level.LevelAccessor p_21686_, net.minecraft.world.entity.MobSpawnType p_21687_) protected void
Randomly changes the NPC's current action.protected <A> void
protected void
Gets the tutor's AI mode.Gets the base NPC Trainer data from the NPC.Gets the boss tier of the NPC.Gets the NPC's Steve texture.abstract String
Gets the text that displays above the NPC.int
org.joml.Vector3f
Gets the scale of the NPC's model.net.minecraft.network.chat.MutableComponent
getName()
Gets the NPC's name.int
getNPCID()
Gets the NPC's ID.net.minecraft.world.Container
Gets the NPC's inventory.int
Gets the ID of the NPC's profession.Gets the subtitle for the text that displays above the NPC.Gets the NPC's texture.int
Gets the texture index of the NPC.boolean
Checks if the NPC can plant an item.boolean
hurt
(net.minecraft.world.damagesource.DamageSource p_21016_, float p_21017_) void
Initializes the NPC with its name and health.void
initAI()
Initializes the NPC's AI.void
Initializes the NPC's AI to stand still.void
Initializes the NPC's AI to act like a villager.void
Initializes the NPC's AI to wander.net.minecraft.world.InteractionResult
interactAt
(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 p_19981_, net.minecraft.world.InteractionHand hand) boolean
interactWithNPC
(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand) Handles a player interacting with the NPC.boolean
Returns true if the NPC has seeds, potatoes or carrots in its inventory.boolean
locateNPCClient
(net.minecraft.world.level.Level world, int id, Class<T> type) Finds the NPC in the world from its ID.locateNPCServer
(net.minecraft.world.level.Level world, int id, Class<T> type) locateNPCServer
(net.minecraft.world.level.Level world, String name, Class<T> type, String langCode) Finds an NPC from its name.void
onSyncedDataUpdated
(net.minecraft.network.syncher.EntityDataAccessor<?> key) protected void
pickUpItem
(net.minecraft.world.entity.item.ItemEntity itemEntity) Tests if this entity should pick up a weapon or an armor.protected boolean
Checks whether there are players near the NPC.void
readAdditionalSaveData
(net.minecraft.nbt.CompoundTag nbt) boolean
removeWhenFarAway
(double p_213397_1_) boolean
save
(net.minecraft.nbt.CompoundTag p_70039_1_) void
setAIMode
(EnumTrainerAI mode) Sets the Trainer's AI mode.void
setBaseTrainer
(BaseTrainer trainer) Sets the base NPC Trainer data for the NPC.void
Sets the NPC's Steve texture.void
Sets the NPC's name.void
setNickName
(String nickName) void
setProfession
(int professionId) Sets the NPC's profession.void
setTextureIndex
(int index) Sets the texture index of the NPC.boolean
void
tick()
void
Despawns the NPC.Methods inherited from class net.minecraft.world.entity.PathfinderMob
followLeashSpeed, getWalkTargetValue, getWalkTargetValue, isPanicking, isPathFinding, onLeashDistance, shouldStayCloseToLeashHolder, tickLeash
Methods inherited from class net.minecraft.world.entity.Mob
aiStep, ate, baseTick, canAttackType, canFireProjectileWeapon, canHoldItem, canPickUpLoot, canReplaceCurrentItem, canReplaceEqualItem, canTakeItem, checkAndHandleImportantInteractions, checkDespawn, checkMobSpawnRules, checkSpawnObstruction, clearRestriction, convertTo, createBodyControl, createMobAttributes, createNavigation, doHurtTarget, dropCustomDeathLoot, dropFromLootTable, dropLeash, enchantSpawnedArmor, enchantSpawnedWeapon, equipItemIfPossible, finalizeSpawn, getAmbientSound, getAmbientSoundInterval, getArmorSlots, getAttackBoundingBox, getControllingPassenger, getDefaultLootTable, getEquipmentDropChance, getEquipmentForSlot, getExperienceReward, getHandSlots, getHeadRotSpeed, getItemBySlot, getJumpControl, getLeashHolder, getLookControl, getLootTable, getLootTableSeed, getMainArm, getMaxFallDistance, getMaxHeadXRot, getMaxHeadYRot, getMoveControl, getNavigation, getPathfindingMalus, getPickResult, getPickupReach, getRestrictCenter, getRestrictRadius, getSensing, getSpawnType, getTarget, handleEntityEvent, hasRestriction, interact, isAggressive, isEffectiveAi, isLeashed, isLeftHanded, isMaxGroupSizeReached, isNoAi, isPersistenceRequired, isSpawnCancelled, isSunBurnTick, isWithinMeleeAttackRange, isWithinRestriction, isWithinRestriction, jumpInFluid, jumpInLiquid, lookAt, mobInteract, onOffspringSpawnedFromEgg, onPathfindingDone, onPathfindingStart, playAmbientSound, playHurtSound, populateDefaultEquipmentEnchantments, populateDefaultEquipmentSlots, registerGoals, removeAfterChangingDimensions, removeAllGoals, removeFreeWill, requiresCustomPersistence, restrictTo, sendDebugPackets, serverAiStep, setAggressive, setBaby, setCanPickUpLoot, setDelayedLeashHolderId, setDropChance, setGuaranteedDrop, setItemSlot, setItemSlotAndDropWhenKilled, setLeashedTo, setLeftHanded, setNoAi, setPathfindingMalus, setPersistenceRequired, setSpawnCancelled, setSpeed, setTarget, setXxa, setYya, setZza, shouldDespawnInPeaceful, shouldPassengersInheritMalus, spawnAnim, startRiding, tickHeadTurn, updateControlFlags, wantsToPickUp
Methods inherited from class net.minecraft.world.entity.LivingEntity
actuallyHurt, addEffect, addEffect, animateHurt, areAllEffectsAmbient, attackable, blockedByShield, blockUsingShield, brainProvider, broadcastBreakEvent, broadcastBreakEvent, calculateEntityAnimation, calculateFallDamage, canAttack, canAttack, canBeAffected, canBeSeenAsEnemy, canBeSeenByAnyone, canBreatheUnderwater, canChangeDimensions, canDisableShield, canFreeze, canSpawnSoulSpeedParticle, canStandOnFluid, causeFallDamage, checkAutoSpinAttack, checkFallDamage, clearSleepingPos, completeUsingItem, createLivingAttributes, createWitherRose, curePotionEffects, decreaseAirSupply, die, doAutoAttackOnTouch, doesEmitEquipEvent, doPush, dropAllDeathLoot, dropEquipment, dropExperience, eat, equipmentHasChanged, forceAddEffect, getAbsorptionAmount, getActiveEffects, getActiveEffectsMap, getArmorCoverPercentage, getArmorValue, getArrowCount, getAttackAnim, getAttribute, getAttributeBaseValue, getAttributeBaseValue, getAttributes, getAttributeValue, getAttributeValue, getBedOrientation, getBlockSpeedFactor, getBoundingBoxForCulling, getBrain, getCapability, getCombatTracker, getDamageAfterArmorAbsorb, getDamageAfterMagicAbsorb, getDeathSound, getDimensions, getDismountPoses, getDrinkingSound, getEatingSound, getEffect, getEquipmentSlotForItem, getEyeHeight, getFallDamageSound, getFallFlyingTicks, getFallSounds, getFluidFallingAdjustedMovement, getFlyingSpeed, getHealth, getHitbox, getHurtDir, getHurtSound, getItemInHand, getJumpBoostPower, getJumpPower, getKillCredit, getLastAttacker, getLastClimbablePos, getLastDamageSource, getLastHurtByMob, getLastHurtByMobTimestamp, getLastHurtMob, getLastHurtMobTimestamp, getLocalBoundsForPose, getMainHandItem, getMaxAbsorption, getMaxHealth, getMobType, getMyRidingOffset, getNoActionTime, getOffhandItem, getPassengerRidingPosition, getProjectile, getRandom, getRelativePortalPosition, getRiddenInput, getRiddenSpeed, getScale, getSleepingPos, getSlot, getSoundVolume, getSpeed, getStandingEyeHeight, getStingerCount, getSwimAmount, getTicksUsingItem, getUsedItemHand, getUseItem, getUseItemRemainingTicks, getViewYRot, getVisibilityPercent, getVisualRotationYInDegrees, getVoicePitch, getWaterSlowDown, getYHeadRot, goDownInWater, handleDamageEvent, handleRelativeFrictionAndCalculateMovement, hasEffect, hasItemInSlot, hasLineOfSight, heal, hurtArmor, hurtCurrentlyUsedShield, hurtHelmet, increaseAirSupply, indicateDamage, internalSetAbsorptionAmount, invalidateCaps, isAffectedByFluids, isAffectedByPotions, isAlive, isAlwaysExperienceDropper, isAutoSpinAttack, isBaby, isBlocking, isCurrentlyGlowing, isDamageSourceBlocked, isDeadOrDying, isFallFlying, isHolding, isHolding, isImmobile, isInvertedHealAndHarm, isInWall, isPickable, isSensitiveToWater, isSleeping, isSuppressingSlidingDownLadder, isUsingItem, isVisuallySwimming, jumpFromGround, kill, knockback, lerpHeadRotationStep, lerpHeadTo, lerpTargetX, lerpTargetXRot, lerpTargetY, lerpTargetYRot, lerpTargetZ, lerpTo, lookAt, makeBrain, maxUpStep, onBelowWorld, onChangedBlock, onClimbable, onEffectAdded, onEffectRemoved, onEffectUpdated, onEnterCombat, onEquipItem, onItemPickup, onLeaveCombat, onSoulSpeedBlock, playBlockFallSound, push, pushEntities, randomTeleport, recreateFromPacket, releaseUsingItem, remove, removeAllEffects, removeEffect, removeEffectNoUpdate, removeEffectParticles, removeFrost, removeSoulSpeed, resetForwardDirectionOfRelativePortalPosition, reviveCaps, rideTick, sendEffectToPassengers, setAbsorptionAmount, setArrowCount, setDiscardFriction, setHealth, setItemInHand, setJumping, setLastHurtByMob, setLastHurtByPlayer, setLastHurtMob, setLivingEntityFlag, setNoActionTime, setRecordPlayingNearby, setSleepingPos, setSprinting, setStingerCount, setYBodyRot, setYHeadRot, shouldDiscardFriction, shouldDropExperience, shouldDropLoot, shouldRemoveSoulSpeed, shouldRiderFaceForward, shouldShowName, skipDropExperience, spawnSoulSpeedParticle, startSleeping, startUsingItem, stopRiding, stopSleeping, stopUsingItem, swing, swing, take, tickDeath, tickEffects, tickRidden, travel, travelRidden, triggerItemUseEffects, tryAddFrost, tryAddSoulSpeed, updateEffectVisibility, updateFallFlying, updateInvisibilityStatus, updateSwingTime, updateUsingItem, updateWalkAnimation, verifyEquippedItem, wasExperienceConsumed, wouldNotSuffocateAtTargetPose
Methods inherited from class net.minecraft.world.entity.Entity
absMoveTo, absMoveTo, acceptsFailure, acceptsSuccess, addDeltaMovement, addPassenger, addTag, awardKillScore, blockPosition, broadcastToPlayer, calculateUpVector, calculateViewVector, canAddPassenger, canBeCollidedWith, canBeHitByProjectile, canCollideWith, canControlVehicle, canRide, canSpawnSprintParticle, canSprint, canTrample, canUpdate, canUpdate, captureDrops, captureDrops, changeDimension, changeDimension, checkBelowWorld, checkInsideBlocks, checkSlowFallDistance, checkSupportingBlock, chunkPosition, clearFire, closerThan, closerThan, collideBoundingBox, copyPosition, couldAcceptPassenger, createCommandSourceStack, createHoverEvent, damageSources, dampensVibrations, discard, dismountsUnderwater, dismountTo, displayFireAnimation, distanceTo, distanceToSqr, distanceToSqr, distanceToSqr, doEnchantDamageEffects, doWaterSplashEffect, ejectPassengers, equals, extinguishFire, fillCrashReportCategory, findDimensionEntryPoint, fireImmune, fixupDimensions, gameEvent, gameEvent, getAddEntityPacket, getAirSupply, getAllSlots, getBbHeight, getBbWidth, getBlockExplosionResistance, getBlockJumpFactor, getBlockPosBelowThatAffectsMyMovement, getBlockStateOn, getBlockStateOnLegacy, getBlockX, getBlockY, getBlockZ, getBoundingBox, getCollisionHorizontalEscapeVector, getCommandSenderWorld, getControlledVehicle, getCustomName, getDeltaMovement, getDimensionChangingDelay, getDimensionsForge, getDirection, getDismountLocationForPassenger, getDisplayName, getEncodeId, getEntityData, getExitPortal, getEyeHeight, getEyeHeight, getEyeHeightAccess, getEyeInFluidType, getEyePosition, getEyePosition, getEyeY, getFeetBlockState, getFireImmuneTicks, getFirstPassenger, getFluidHeight, getFluidJumpThreshold, getFluidTypeHeight, getForward, getHandHoldingItemAngle, getId, getIndirectPassengers, getLeashOffset, getLeashOffset, getLightLevelDependentMagicValue, getLightProbePosition, getLookAngle, getMaxAirSupply, getMaxHeightFluidType, getMotionDirection, getMovementEmission, getNameTagOffsetY, getOnPos, getOnPos, getOnPosLegacy, getPassengerAttachmentPoint, getPassengers, getPassengersAndSelf, getPercentFrozen, getPermissionLevel, getPersistentData, getPickRadius, getPistonPushReaction, getPortalCooldown, getPortalWaitTime, getPose, getPosition, getPositionCodec, getPrimaryStepSoundBlockPos, getRandomX, getRandomY, getRandomZ, getRemainingFireTicks, getRemovalReason, getRootVehicle, getRopeHoldPosition, getRotationVector, getScoreboardName, getSelfAndPassengers, getServer, getSharedFlag, getSoundSource, getStringUUID, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTags, getTeam, getTeamColor, getTicksFrozen, getTicksRequiredToFreeze, getType, getTypeName, getUpVector, getUUID, getVehicle, getViewScale, getViewVector, getViewXRot, getX, getX, getXRot, getY, getY, getYRot, getZ, getZ, handleInsidePortal, handleNetherPortal, hasControllingPassenger, hasCustomName, hasExactlyOnePlayerPassenger, hasGlowingTag, hashCode, hasIndirectPassenger, hasPassenger, hasPassenger, hasPermissions, hasPose, ignoreExplosion, is, isAddedToWorld, isAlliedTo, isAlliedTo, isAlwaysTicking, isAttackable, isColliding, isControlledByLocalInstance, isCrouching, isCustomNameVisible, isDescending, isDiscrete, isEyeInFluid, isFlapping, isFree, isFreezing, isFullyFrozen, isHorizontalCollisionMinor, isIgnoringBlockTriggers, isInFluidType, isInFluidType, isInLava, isInLiquid, isInvisible, isInvisibleTo, isInvulnerable, isInvulnerableTo, isInWater, isInWaterOrBubble, isInWaterOrRain, isInWaterRainOrBubble, isNoGravity, isOnFire, isOnPortalCooldown, isOnRails, isPassenger, isPassengerOfSameVehicle, isPushedByFluid, isRemoved, isShiftKeyDown, isSilent, isSpectator, isSprinting, isSteppingCarefully, isSupportedBy, isSuppressingBounce, isSwimming, isUnderWater, isVehicle, isVisuallyCrawling, killedEntity, lavaHurt, lerpMotion, lerpPositionAndRotationStep, level, limitPistonMovement, load, makeBoundingBox, makeStuckInBlock, markHurt, maybeBackOffFromEdge, mayInteract, mirror, move, moveRelative, moveTo, moveTo, moveTo, moveTo, moveTowardsClosestSpace, newDoubleList, newFloatList, nextStep, onAboveBubbleCol, onAddedToWorld, onClientRemoval, onFlap, onGround, onInsideBlock, onInsideBubbleColumn, onlyOpCanSetNbt, onPassengerTurned, onRemovedFromWorld, onSyncedDataUpdated, pick, playCombinationStepSounds, playEntityOnFireExtinguishedSound, playerTouch, playMuffledStepSound, playSound, playSound, playStepSound, playSwimSound, position, positionRider, positionRider, processFlappingMovement, processPortalCooldown, push, reapplyPosition, refreshDimensions, removePassenger, removeTag, removeVehicle, repositionEntityAfterLoad, resetFallDistance, restoreFrom, revive, ridingOffset, rotate, saveAsPassenger, saveWithoutId, sendSystemMessage, setAirSupply, setBoundingBox, setCustomName, setCustomNameVisible, setDeltaMovement, setDeltaMovement, setFluidTypeHeight, setGlowingTag, setId, setInvisible, setInvulnerable, setIsInPowderSnow, setLevel, setLevelCallback, setMaxUpStep, setNoGravity, setOldPosAndRot, setOnGround, setOnGroundWithKnownMovement, setPortalCooldown, setPortalCooldown, setPos, setPos, setPose, setPosRaw, setRemainingFireTicks, setRemoved, setRot, setSecondsOnFire, setSharedFlag, setSharedFlagOnFire, setShiftKeyDown, setSilent, setSwimming, setTicksFrozen, setUUID, setViewScale, setXRot, setYRot, shouldBeSaved, shouldBlockExplode, shouldInformAdmins, shouldRender, shouldRenderAtSqrDistance, showVehicleHealth, skipAttackInteraction, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnSprintParticle, startRiding, startSeenByPlayer, stopSeenByPlayer, syncPacketPositionCodec, teleportRelative, teleportTo, teleportTo, teleportToWithTicket, thunderHit, toString, touchingUnloadedChunk, trackingPosition, tryCheckInsideBlocks, turn, unRide, unsetRemoved, updateDynamicGameEventListener, updateFluidHeightAndDoFluidPushing, updateFluidHeightAndDoFluidPushing, updateFluidHeightAndDoFluidPushing, updateInWaterStateAndDoFluidPushing, updateSwimming, waterSwimSound
Methods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, serializeCaps
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.minecraft.commands.CommandSource
alwaysAccepts
Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
Methods inherited from interface net.minecraftforge.common.extensions.IForgeEntity
canBeRiddenUnderFluidType, canFluidExtinguish, canHydrateInFluidType, canRiderInteract, canStartSwimming, canTrample, canUpdate, canUpdate, captureDrops, captureDrops, deserializeNBT, getClassification, getEyeHeightForge, getEyeInFluidType, getFluidFallDistanceModifier, getFluidMotionScale, getFluidTypeHeight, getMaxHeightFluidType, getParts, getPersistentData, getPickedResult, getSoundFromFluidType, getStepHeight, hasCustomOutlineRendering, isAddedToWorld, isEyeInFluidType, isInFluidType, isInFluidType, isInFluidType, isInFluidType, isInFluidType, isMultipartEntity, isPushedByFluid, onAddedToWorld, onRemovedFromWorld, revive, serializeNBT, shouldRiderSit, shouldUpdateFluidWhileBoating
Methods inherited from interface net.minecraftforge.common.extensions.IForgeLivingEntity
canDrownInFluidType, canSwimInFluidType, moveInFluid, self, sinkInFluid
-
Field Details
-
ONE
public static final org.joml.Vector3f ONE -
SMALLER
public static final org.joml.Vector3f SMALLER -
TICKSPERSECOND
public static final int TICKSPERSECONDThe number of ticks per second in Minecraft.- See Also:
-
intMinTicksToDespawn
public static int intMinTicksToDespawnThe minimum number of ticks to wait before despawning the NPC. -
intMaxTicksToDespawn
public static int intMaxTicksToDespawnThe maximum number of ticks to wait before despawning the NPC. -
SYNC_NAME
-
SYNC_NICKNAME
-
SYNC_MODEL
-
SYNC_TEXTURE_INDEX
-
SYNC_CUSTOM_STEVE_TEXTURE
-
SYNC_PROFESSION
-
trainer
-
npcLocation
The NPC's spawn location. -
despawnCounter
public int despawnCounterThe despawn counter for the NPC. -
chatIndex
protected int chatIndexThe random index to get the NPC's default messages from. -
interactCommands
Commands to execute when the Player forfeits. -
dataSyncManager
-
-
Constructor Details
-
NPCEntity
public NPCEntity(net.minecraft.world.entity.EntityType<? extends NPCEntity> type, net.minecraft.world.level.Level world) Initializes the NPC and its data watcher attributes.- Parameters:
type
- The entity type.world
- The world to spawn the NPC in.
-
-
Method Details
-
defineSynchedData
protected void defineSynchedData()- Overrides:
defineSynchedData
in classnet.minecraft.world.entity.Mob
-
define
-
init
Initializes the NPC with its name and health.- Parameters:
name
- The NPC's name.
-
getNickName
-
setNickName
-
getTexture
Gets the NPC's texture.- Returns:
- The NPC's texture.
-
getCustomSteveTexture
Gets the NPC's Steve texture.- Returns:
- The NPC's Steve texture.
-
setCustomSteveTexture
Sets the NPC's Steve texture.- Parameters:
tex
- The new Steve texture.
-
removeWhenFarAway
public boolean removeWhenFarAway(double p_213397_1_) - Overrides:
removeWhenFarAway
in classnet.minecraft.world.entity.Mob
-
getName
public net.minecraft.network.chat.MutableComponent getName()Gets the NPC's name.- Specified by:
getName
in interfacenet.minecraft.world.Nameable
- Overrides:
getName
in classnet.minecraft.world.entity.Entity
- Returns:
- The NPC's name.
-
setName
Sets the NPC's name.- Parameters:
name
- The NPC's name.
-
hurt
public boolean hurt(net.minecraft.world.damagesource.DamageSource p_21016_, float p_21017_) - Overrides:
hurt
in classnet.minecraft.world.entity.LivingEntity
-
isPushable
public boolean isPushable()- Overrides:
isPushable
in classnet.minecraft.world.entity.LivingEntity
-
canBeLeashed
public boolean canBeLeashed(net.minecraft.world.entity.player.Player player) - Overrides:
canBeLeashed
in classnet.minecraft.world.entity.Mob
-
save
public boolean save(net.minecraft.nbt.CompoundTag p_70039_1_) - Overrides:
save
in classnet.minecraft.world.entity.Entity
-
shouldSave
public boolean shouldSave() -
addAdditionalSaveData
public void addAdditionalSaveData(net.minecraft.nbt.CompoundTag nbt) - Overrides:
addAdditionalSaveData
in classnet.minecraft.world.entity.Mob
-
readAdditionalSaveData
public void readAdditionalSaveData(net.minecraft.nbt.CompoundTag nbt) - Overrides:
readAdditionalSaveData
in classnet.minecraft.world.entity.Mob
-
initAI
public void initAI()Initializes the NPC's AI. -
checkSpawnRules
public boolean checkSpawnRules(net.minecraft.world.level.LevelAccessor p_21686_, net.minecraft.world.entity.MobSpawnType p_21687_) - Overrides:
checkSpawnRules
in classnet.minecraft.world.entity.PathfinderMob
-
interactAt
public net.minecraft.world.InteractionResult interactAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 p_19981_, net.minecraft.world.InteractionHand hand) - Overrides:
interactAt
in classnet.minecraft.world.entity.Entity
-
interactWithNPC
public boolean interactWithNPC(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand) Handles a player interacting with the NPC.- Parameters:
player
- The player interacting with the NPC.- Returns:
- False
-
getMaxSpawnClusterSize
public int getMaxSpawnClusterSize()- Overrides:
getMaxSpawnClusterSize
in classnet.minecraft.world.entity.Mob
-
getNPCID
public int getNPCID()Gets the NPC's ID.- Returns:
- The NPC's ID.
-
getDisplayText
Gets the text that displays above the NPC.- Returns:
- The text that displays above the NPC.
-
getSubTitleText
Gets the subtitle for the text that displays above the NPC.- Returns:
- The subtitle for the text that displays above the NPC.
-
getBossTier
Gets the boss tier of the NPC.- Returns:
- The boss tier of the NPC.
-
getBaseTrainer
Gets the base NPC Trainer data from the NPC.- Returns:
- The base NPC Trainer data from the NPC.
-
setBaseTrainer
Sets the base NPC Trainer data for the NPC.- Parameters:
trainer
- The new base NPC Trainer data.
-
bindTexture
public boolean bindTexture()Binds a texture to the NPC.- Returns:
- Whether a texture was bound to the NPC.
-
getModelScale
public org.joml.Vector3f getModelScale()Gets the scale of the NPC's model.- Returns:
- The scale of the NPC's model.
-
locateNPCClient
public static <T extends NPCEntity> Optional<T> locateNPCClient(net.minecraft.world.level.Level world, int id, Class<T> type) Finds the NPC in the world from its ID.- Parameters:
world
- The world the NPC is in.id
- The ID of the NPC.- Returns:
- The NPC with the corresponding ID, or null if there is no NPC with the ID.
-
locateNPCServer
-
locateNPCServer
public static <T extends NPCEntity> Optional<T> locateNPCServer(net.minecraft.world.level.Level world, String name, Class<T> type, String langCode) Finds an NPC from its name.- Parameters:
world
- The world that the NPC is in.name
- The name of the NPC.type
- The type of NPC to find.langCode
- The language code of the player searching for an NPC.- Returns:
- An Optional contaiing the NPC with the given name.
-
unloadEntity
public void unloadEntity()Despawns the NPC. -
getTextureIndex
public int getTextureIndex()Gets the texture index of the NPC.- Returns:
- The texture index of the NPC.
-
setTextureIndex
public void setTextureIndex(int index) Sets the texture index of the NPC.- Parameters:
index
- The texture index of the NPC.
-
tick
public void tick()- Overrides:
tick
in classnet.minecraft.world.entity.Mob
-
checkForRarityDespawn
protected void checkForRarityDespawn()Keeps track of when to despawn the NPC. -
playersNearby
protected boolean playersNearby()Checks whether there are players near the NPC.- Returns:
- Whether there are players near the NPC.
-
setProfession
public void setProfession(int professionId) Sets the NPC's profession.- Parameters:
professionId
- The ID of the profession to set the NPC to.
-
getProfession
public int getProfession()Gets the ID of the NPC's profession.- Returns:
- The ID of the NPC's profession.
-
initDefaultAI
public void initDefaultAI()Initializes the NPC's AI to stand still. -
initWanderingAI
public void initWanderingAI()Initializes the NPC's AI to wander. -
initVilagerAI
public void initVilagerAI()Initializes the NPC's AI to act like a villager. -
isFarmItemInInventory
public boolean isFarmItemInInventory()Returns true if the NPC has seeds, potatoes or carrots in its inventory.- Returns:
- True if the NPC has seeds, potatoes or carrots in its inventory.
-
hasItemToPlant
public boolean hasItemToPlant()Checks if the NPC can plant an item.- Returns:
- Whether the NPC can plant an item.
-
getNPCInventory
public net.minecraft.world.Container getNPCInventory()Gets the NPC's inventory.- Returns:
- The NPC's inventory.
-
pickUpItem
protected void pickUpItem(net.minecraft.world.entity.item.ItemEntity itemEntity) Tests if this entity should pick up a weapon or an armor. Entity drops current weapon or armor if the new one is better.- Overrides:
pickUpItem
in classnet.minecraft.world.entity.Mob
-
customServerAiStep
protected void customServerAiStep()Randomly changes the NPC's current action.- Overrides:
customServerAiStep
in classnet.minecraft.world.entity.Mob
-
getAIMode
Gets the tutor's AI mode.- Returns:
- The tutor's AI mode.
-
setAIMode
Sets the Trainer's AI mode.- Parameters:
mode
- The new AI mode.
-
onSyncedDataUpdated
public void onSyncedDataUpdated(net.minecraft.network.syncher.EntityDataAccessor<?> key) - Overrides:
onSyncedDataUpdated
in classnet.minecraft.world.entity.LivingEntity
-