Class CavalryHorseEntity

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.entity.Entity
net.minecraft.world.entity.LivingEntity
net.minecraft.world.entity.Mob
net.minecraft.world.entity.PathfinderMob
net.minecraft.world.entity.AgeableMob
net.minecraft.world.entity.animal.Animal
net.minecraft.world.entity.animal.horse.AbstractHorse
net.minecraft.world.entity.animal.horse.Horse
com.minecolonies.core.entity.other.cavalry.CavalryHorseEntity
All Implemented Interfaces:
IManagedAnimal<CavalryHorseEntity>, net.minecraft.commands.CommandSource, net.minecraft.network.syncher.SyncedDataHolder, net.minecraft.world.ContainerListener, net.minecraft.world.entity.Attackable, net.minecraft.world.entity.EquipmentUser, net.minecraft.world.entity.HasCustomInventoryScreen, net.minecraft.world.entity.Leashable, net.minecraft.world.entity.OwnableEntity, net.minecraft.world.entity.PlayerRideable, net.minecraft.world.entity.PlayerRideableJumping, net.minecraft.world.entity.Saddleable, net.minecraft.world.entity.Targeting, net.minecraft.world.entity.VariantHolder<net.minecraft.world.entity.animal.horse.Variant>, net.minecraft.world.level.entity.EntityAccess, net.minecraft.world.Nameable, net.minecraft.world.scores.ScoreHolder, net.neoforged.neoforge.attachment.IAttachmentHolder, net.neoforged.neoforge.common.extensions.IEntityExtension, net.neoforged.neoforge.common.extensions.ILivingEntityExtension, net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>

public class CavalryHorseEntity extends net.minecraft.world.entity.animal.horse.Horse implements IManagedAnimal<CavalryHorseEntity>
Cavalry Horse Entity class for Minecolonies. Extends the vanilla Horse entity with custom behavior for cavalry units.
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.entity.animal.horse.Horse

    net.minecraft.world.entity.animal.horse.Horse.HorseGroupData

    Nested classes/interfaces inherited from class net.minecraft.world.entity.AgeableMob

    net.minecraft.world.entity.AgeableMob.AgeableMobGroupData

    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.neoforged.neoforge.attachment.AttachmentHolder

    net.neoforged.neoforge.attachment.AttachmentHolder.AsField

    Nested classes/interfaces inherited from interface net.minecraft.world.entity.Leashable

    net.minecraft.world.entity.Leashable.LeashData
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final float
     
    static final float
     
    static final net.minecraft.network.syncher.EntityDataAccessor<Integer>
     
    static final net.minecraft.network.syncher.EntityDataAccessor<Integer>
     
    static final int
    The cooldown for logging when debugging.
    static final float
    The base width and height of the horse entity.

    Fields inherited from class net.minecraft.world.entity.animal.horse.AbstractHorse

    allowStandSliding, BREEDING_CROSS_FACTOR, canGallop, CHEST_SLOT_OFFSET, EQUIPMENT_SLOT_OFFSET, gallopSoundCounter, INV_BASE_COUNT, INV_SLOT_SADDLE, inventory, INVENTORY_SLOT_OFFSET, isJumping, playerJumpPendingScale, sprintCounter, tailCounter, temper

    Fields inherited from class net.minecraft.world.entity.animal.Animal

    PARENT_AGE_AFTER_BREEDING

    Fields inherited from class net.minecraft.world.entity.AgeableMob

    age, BABY_START_AGE, forcedAge, forcedAgeTimer

    Fields inherited from class net.minecraft.world.entity.PathfinderMob

    DEFAULT_WALK_TARGET_VALUE

    Fields inherited from class net.minecraft.world.entity.Mob

    ambientSoundTime, armorDropChances, bodyArmorDropChance, DEFAULT_EQUIPMENT_DROP_CHANCE, goalSelector, handDropChances, jumpControl, 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, PRESERVE_ITEM_DROP_CHANCE_THRESHOLD, RANDOM_SPAWN_BONUS_ID, targetSelector, UPDATE_GOAL_SELECTOR_EVERY_N_TICKS, xpReward

    Fields inherited from class net.minecraft.world.entity.LivingEntity

    animStep, animStepO, appliedScale, ARMOR_SLOT_OFFSET, ARMOR_SLOTS, attackAnim, attackStrengthTicker, ATTRIBUTES_FIELD, autoSpinAttackDmg, autoSpinAttackItemStack, autoSpinAttackTicks, BASE_JUMP_POWER, BODY_ARMOR_OFFSET, brain, damageContainers, DATA_LIVING_ENTITY_FLAGS, dead, DEATH_DURATION, deathScore, deathTime, DEFAULT_BABY_SCALE, DEFAULT_BASE_GRAVITY, 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, 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_SAFE_FALL_DISTANCE, BASE_TICKS_REQUIRED_TO_FREEZE, blocksBuilding, BOARDING_COOLDOWN, boardingCooldown, CONTENTS_SLOT_INDEX, 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, fallDistance, firstTick, FLAG_FALL_FLYING, FLAG_GLOWING, FLAG_ONFIRE, fluidHeight, flyDist, forgeFluidTypeHeight, FREEZE_HURT_FREQUENCY, hasImpulse, horizontalCollision, hurtMarked, ID_TAG, invulnerableTime, isInPowderSnow, mainSupportingBlockPos, MAX_ENTITY_TAG_COUNT, minorHorizontalCollision, moveDist, noCulling, noPhysics, PASSENGERS_TAG, portalProcess, random, stringUUID, stuckSpeedMultiplier, tickCount, TOTAL_AIR_SUPPLY, uuid, UUID_TAG, verticalCollision, verticalCollisionBelow, walkDist, walkDistO, wasEyeInWater, wasInPowderSnow, wasOnFire, wasTouchingWater, xo, xOld, xRotO, yo, yOld, yRotO, zo, zOld

    Fields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    ATTACHMENTS_NBT_KEY

    Fields inherited from interface net.minecraft.commands.CommandSource

    NULL

    Fields inherited from interface net.minecraft.world.entity.Leashable

    LEASH_ELASTIC_DIST, LEASH_TAG, LEASH_TOO_FAR_DIST

    Fields inherited from interface net.minecraft.world.scores.ScoreHolder

    WILDCARD, WILDCARD_NAME
  • Constructor Summary

    Constructors
    Constructor
    Description
    CavalryHorseEntity(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.animal.horse.Horse> type, net.minecraft.world.level.Level level)
    Constructor for CavalryHorseEntity.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAdditionalSaveData(net.minecraft.nbt.CompoundTag tag)
    Adds additional data to the CompoundTag that is specific to this entity type.
    protected void
    addPassenger(net.minecraft.world.entity.Entity passenger)
    Adds a passenger to the horse, dropping the leash and clearing the recent dismount cooldown.
    void
    This method is called by the entity every tick to update its state.
    boolean
    canMate(net.minecraft.world.entity.animal.Animal other)
    Allow breeding even when not tamed.
    boolean
    clearFor(@NotNull net.minecraft.world.entity.Entity reserver)
    Clears the reservation on the horse if it is reserved by the entity with the given UUID.
    void
    Clears the reservation on the horse.
    createFromVanilla(IColony colony, net.minecraft.world.level.Level level, net.minecraft.world.entity.animal.horse.AbstractHorse vanilla)
    Creates a new CavalryHorseEntity from a vanilla AbstractHorse, attempting to preserve as much information as possible.
    protected net.minecraft.world.entity.ai.navigation.PathNavigation
    createNavigation(net.minecraft.world.level.Level level)
    Creates a new PathNavigation for this horse entity, overriding the default vanilla horse navigation.
    protected void
    defineSynchedData(net.minecraft.network.syncher.SynchedEntityData.Builder builder)
    Defines the synced data for this entity.
    void
    dropLeash(boolean broadcastPacket, boolean dropLeadItem)
    Drops the leash for this horse, optionally sending a packet to clients and dropping the lead item.
    Returns the animal data associated with this horse.
    Returns the animal data view associated with this horse.
    net.minecraft.network.syncher.EntityDataAccessor<Integer>
    Gets the accessor for the animal ID of this entity.
    int
    Get the colony associated with this managed animal.
    net.minecraft.network.syncher.EntityDataAccessor<Integer>
    Gets the accessor for the colony ID of this entity.
    float
    Returns the current combat cooldown of the horse.
    Returns the entity itself.
    long
    Gets the last time this horse was dismounted from, in game ticks.
    int
    Get the managed animal ID of this entity.
    protected net.minecraft.world.phys.Vec3
    getPassengerAttachmentPoint(net.minecraft.world.entity.Entity passenger, net.minecraft.world.entity.EntityDimensions dims, float partialTick)
    Returns the attachment point for the given passenger entity, taking into account the entity dimensions and the partial tick.
    Returns the stable building of the horse if it exists.
    boolean
    Whether the horse collided in the last 10 ticks
    boolean
    Check if the horse has a valid cavalry rider.
    boolean
    Checks if the horse has a reservation by another entity.
    boolean
    Checks if the horse has a trainer entity (i.e.
    boolean
    hurt(net.minecraft.world.damagesource.DamageSource damageSource, float damageAmount)
    Applies damage to this entity.
    protected boolean
    isHorizontalCollisionMinor(net.minecraft.world.phys.Vec3 vec3)
    A minor horizontal collision is one that occurs when the horse has moved into a solid block.
    boolean
    Checks if the horse is currently within the boundaries of its stable building.
    boolean
    Returns whether the horse is ready for combat.
    void
    Logs all active goals for this horse, including both the wrapped goal selector goals and the target selector goals.
    void
    onSyncedDataUpdated(net.minecraft.network.syncher.EntityDataAccessor<?> dataAccessor)
    Called when the entity's data is updated from the server.
    void
    prepareForCombat(float combatReadiness)
    Prepares the horse for combat by reducing its combat cooldown by the specified amount of combat readiness.
    void
    readAdditionalSaveData(net.minecraft.nbt.CompoundTag tag)
    Reads additional data from the given CompoundTag that is specific to this entity type.
    void
    Registers the goals for this entity.
    protected void
    removePassenger(net.minecraft.world.entity.Entity passenger)
    Called when a passenger is removed from this horse.
    void
    reserve(@NotNull net.minecraft.world.entity.Entity reserver)
    Reserves the horse for the given entity.
    @Nullable UUID
    Returns the UUID of the entity that has reserved this horse, or null if it is not reserved.
    void
    Sets the animal data associated with this horse.
    void
    setColonyId(int colonyId)
    Set the colony associated with this managed animal.
    void
    setLeashedTo(net.minecraft.world.entity.Entity entity, boolean sendPacket)
    Sets the entity that this horse is leashed to.
    void
    setManagedAnimalId(int managedAnimalId)
    Set the managed animal ID of this entity.
    boolean
    Whether this entity should be saved to disk.
    void
    Called every tick to update the horse.

    Methods inherited from class net.minecraft.world.entity.animal.horse.Horse

    canUseSlot, containerChanged, finalizeSpawn, getAmbientSound, getAngrySound, getBreedOffspring, getDeathSound, getDefaultDimensions, getEatingSound, getHurtSound, getMarkings, getVariant, isBodyArmorItem, mobInteract, playGallopSound, randomizeAttributes, setVariant

    Methods inherited from class net.minecraft.world.entity.animal.horse.AbstractHorse

    addBehaviourGoals, canEatGrass, canJump, canParent, canPerformRearing, causeFallDamage, createBaseHorseAttributes, createInventory, doPlayerRide, dropEquipment, equipBodyArmor, equipSaddle, executeRidersJump, fedFood, followMommy, generateJumpStrength, generateMaxHealth, generateSpeed, getAmbientSoundInterval, getAmbientStandInterval, getAmbientStandSound, getBodyArmorAccess, getControllingPassenger, getDismountLocationForPassenger, getEatAnim, getFlag, getInventory, getInventoryColumns, getInventorySize, getInventorySize, getMaxSpawnClusterSize, getMaxTemper, getMouthAnim, getOwnerUUID, getRiddenInput, getRiddenRotation, getRiddenSpeed, getSlot, getSoundVolume, getStandAnim, getTemper, handleEating, handleEntityEvent, handleLeashAtDistance, handleStartJump, handleStopJump, hasInventoryChanged, isBred, isEating, isFood, isImmobile, isJumping, isPushable, isSaddleable, isSaddled, isStanding, isTamed, makeMad, modifyTemper, onClimbable, onPlayerJump, openCustomInventoryScreen, playJumpSound, playStepSound, positionRider, setBred, setEating, setFlag, setIsJumping, setOffspringAttributes, setOwnerUUID, setStanding, setTamed, setTemper, spawnTamingParticles, standIfPossible, syncSaddleToClients, tameWithName, tickRidden

    Methods inherited from class net.minecraft.world.entity.animal.Animal

    actuallyHurt, canFallInLove, checkAnimalSpawnRules, customServerAiStep, finalizeSpawnChildFromBreeding, getBaseExperienceReward, getInLoveTime, getLoveCause, getWalkTargetValue, isBrightEnoughToSpawn, isInLove, removeWhenFarAway, resetLove, setInLove, setInLoveTime, spawnChildFromBreeding, usePlayerItem

    Methods inherited from class net.minecraft.world.entity.AgeableMob

    ageBoundaryReached, ageUp, ageUp, canBreed, getAge, getSpeedUpSecondsWhenFeeding, isBaby, setAge, setBaby

    Methods inherited from class net.minecraft.world.entity.PathfinderMob

    checkSpawnRules, closeRangeLeashBehaviour, followLeashSpeed, getWalkTargetValue, isPanicking, isPathFinding, shouldStayCloseToLeashHolder

    Methods inherited from class net.minecraft.world.entity.Mob

    ate, baseTick, canAttackType, canBeLeashed, canFireProjectileWeapon, canHoldItem, canPickUpLoot, canReplaceCurrentItem, canReplaceEqualItem, canTakeItem, checkAndHandleImportantInteractions, checkDespawn, checkMobSpawnRules, checkSpawnObstruction, clampHeadRotationToBody, clearRestriction, convertTo, createBodyControl, createMobAttributes, doHurtTarget, dropCustomDeathLoot, dropFromLootTable, dropPreservedEquipment, dropPreservedEquipment, enchantSpawnedArmor, enchantSpawnedWeapon, equip, equip, equipItemIfPossible, getArmorAndBodyArmorSlots, getArmorSlots, getAttackBoundingBox, getBodyArmorItem, getDefaultLootTable, getEquipmentDropChance, getEquipmentForSlot, getHandSlots, getHeadRotSpeed, getItemBySlot, getJumpControl, getLeashData, getLookControl, getLootTable, getLootTableSeed, getMainArm, getMaxFallDistance, getMaxHeadXRot, getMaxHeadYRot, getMoveControl, getNavigation, getPathfindingMalus, getPickResult, getPickupReach, getRestrictCenter, getRestrictRadius, getSensing, getSpawnType, getTarget, getTargetFromBrain, hasRestriction, interact, isAggressive, isEffectiveAi, isLeftHanded, isMaxGroupSizeReached, isNoAi, isPersistenceRequired, isSpawnCancelled, isSunBurnTick, isWearingBodyArmor, isWithinMeleeAttackRange, isWithinRestriction, isWithinRestriction, jumpInFluid, jumpInLiquid, leashTooFarBehaviour, lookAt, onOffspringSpawnedFromEgg, onPathfindingDone, onPathfindingStart, pickUpItem, playAmbientSound, playAttackSound, playHurtSound, populateDefaultEquipmentEnchantments, populateDefaultEquipmentSlots, removeAfterChangingDimensions, removeAllGoals, removeFreeWill, requiresCustomPersistence, restrictTo, sendDebugPackets, serverAiStep, setAggressive, setBodyArmorItem, setCanPickUpLoot, setDropChance, setGuaranteedDrop, setItemSlot, setItemSlotAndDropWhenKilled, setLeashData, setLeftHanded, setNoAi, setPathfindingMalus, setPersistenceRequired, setSpawnCancelled, setSpeed, setTarget, setXxa, setYya, setZza, shouldDespawnInPeaceful, shouldPassengersInheritMalus, spawnAnim, startRiding, stopInPlace, tickHeadTurn, updateControlFlags, wantsToPickUp

    Methods inherited from class net.minecraft.world.entity.LivingEntity

    activeLocationDependentEnchantments, addEffect, addEffect, animateHurt, areAllEffectsAmbient, attackable, blockedByShield, blockUsingShield, brainProvider, calculateEntityAnimation, calculateFallDamage, canAttack, canAttack, canBeAffected, canBeSeenAsEnemy, canBeSeenByAnyone, canBreatheUnderwater, canDisableShield, canFreeze, canStandOnFluid, canUsePortal, checkAutoSpinAttack, checkBedExists, checkFallDamage, clearSleepingPos, completeUsingItem, createLivingAttributes, createWitherRose, decreaseAirSupply, detectEquipmentUpdates, die, doAutoAttackOnTouch, doesEmitEquipEvent, doHurtEquipment, doPush, dropAllDeathLoot, dropExperience, eat, eat, equipmentHasChanged, forceAddEffect, getAbsorptionAmount, getActiveEffects, getActiveEffectsMap, getAgeScale, getAllSlots, getArmorCoverPercentage, getArmorValue, getArrowCount, getAttackAnim, getAttribute, getAttributeBaseValue, getAttributes, getAttributeValue, getBedOrientation, getBlockSpeedFactor, getBoundingBoxForCulling, getBrain, getCombatTracker, getComfortableFallDistance, getCurrentSwingDuration, getDamageAfterArmorAbsorb, getDamageAfterMagicAbsorb, getDefaultGravity, getDimensions, getDismountPoses, getDrinkingSound, getEatingSound, getEffect, getEquipmentSlotForItem, getExperienceReward, getFallFlyingTicks, getFallSounds, getFluidFallingAdjustedMovement, getFlyingSpeed, getHealth, getHitbox, getHurtDir, getItemInHand, getJumpBoostPower, getJumpPower, getJumpPower, getKillCredit, getKnockback, getLastAttacker, getLastClimbablePos, getLastDamageSource, getLastHurtByMob, getLastHurtByMobTimestamp, getLastHurtMob, getLastHurtMobTimestamp, getLocalBoundsForPose, getMainHandItem, getMaxAbsorption, getMaxHeadRotationRelativeToBody, getMaxHealth, getNoActionTime, getOffhandItem, getPassengerRidingPosition, getPreciseBodyRotation, getProjectile, getRelativePortalPosition, getScale, getSleepingPos, getSlotForHand, getSpeed, getStingerCount, getSwimAmount, getTicksUsingItem, getUsedItemHand, getUseItem, getUseItemRemainingTicks, getViewYRot, getVisibilityPercent, getVisualRotationYInDegrees, getVoicePitch, getWaterSlowDown, getWeaponItem, getYHeadRot, goDownInWater, handleDamageEvent, handleRelativeFrictionAndCalculateMovement, hasEffect, hasInfiniteMaterials, hasItemInSlot, hasLandedInLiquid, hasLineOfSight, heal, hurtArmor, hurtCurrentlyUsedShield, hurtHelmet, igniteForTicks, increaseAirSupply, indicateDamage, internalSetAbsorptionAmount, isAffectedByFluids, isAffectedByPotions, isAlive, isAlwaysExperienceDropper, isAutoSpinAttack, isBlocking, isCurrentlyGlowing, isDamageSourceBlocked, isDeadOrDying, isFallFlying, isHolding, isHolding, isInvertedHealAndHarm, isInvulnerableTo, isInWall, isPickable, isSensitiveToWater, isSleeping, isSuppressingSlidingDownLadder, isUsingItem, isVisuallySwimming, jumpFromGround, kill, knockback, lerpHeadRotationStep, lerpHeadTo, lerpTargetX, lerpTargetXRot, lerpTargetY, lerpTargetYRot, lerpTargetZ, lerpTo, lookAt, makeBrain, makeSound, maxUpStep, onBelowWorld, onChangedBlock, onEffectAdded, onEffectRemoved, onEffectUpdated, onEnterCombat, onEquipItem, onEquippedItemBroken, onItemPickup, onLeaveCombat, playBlockFallSound, push, pushEntities, randomTeleport, recreateFromPacket, releaseUsingItem, remove, removeAllEffects, removeEffect, removeEffectNoUpdate, removeEffectParticles, removeEffectsCuredBy, removeFrost, resetForwardDirectionOfRelativePortalPosition, rideTick, sanitizeScale, sendEffectToPassengers, setAbsorptionAmount, setArrowCount, setDiscardFriction, setHealth, setItemInHand, setJumping, setLastHurtByMob, setLastHurtByPlayer, setLastHurtMob, setLivingEntityFlag, setNoActionTime, setRecordPlayingNearby, setSleepingPos, setSprinting, setStingerCount, setYBodyRot, setYHeadRot, shouldDiscardFriction, shouldDropExperience, shouldDropLoot, shouldRiderFaceForward, shouldShowName, skipDropExperience, startSleeping, startUsingItem, stopRiding, stopSleeping, stopUsingItem, swing, swing, take, tickDeath, tickEffects, travel, triggerItemUseEffects, triggerOnDeathMobEffects, tryAddFrost, updateEffectVisibility, updateFallFlying, updateInvisibilityStatus, updateSwimAmount, updateSwingTime, updateUsingItem, updateWalkAnimation, verifyEquippedItem, wasExperienceConsumed, wouldNotSuffocateAtTargetPose

    Methods inherited from class net.minecraft.world.entity.Entity

    absMoveTo, absMoveTo, absRotateTo, acceptsFailure, acceptsSuccess, addDeltaMovement, addTag, adjustSpawnLocation, applyGravity, awardKillScore, blockPosition, broadcastToPlayer, calculateUpVector, calculateViewVector, canAddPassenger, canBeCollidedWith, canBeHitByProjectile, canChangeDimensions, canCollideWith, canControlVehicle, canRide, canSpawnSprintParticle, canSprint, canTrample, captureDrops, captureDrops, changeDimension, checkBelowWorld, checkInsideBlocks, checkSlowFallDistance, checkSupportingBlock, chunkPosition, clearFire, closerThan, closerThan, collideBoundingBox, copyPosition, couldAcceptPassenger, countPlayerPassengers, createCommandSourceStack, createHoverEvent, damageSources, dampensVibrations, deflection, discard, dismountsUnderwater, dismountTo, displayFireAnimation, distanceTo, distanceToSqr, distanceToSqr, distanceToSqr, doWaterSplashEffect, ejectPassengers, equals, extinguishFire, fillCrashReportCategory, fireImmune, fixupDimensions, fudgePositionAfterSizeChange, gameEvent, gameEvent, getAddEntityPacket, getAirSupply, getAttachments, getBbHeight, getBbWidth, getBlockExplosionResistance, getBlockJumpFactor, getBlockPosBelowThatAffectsMyMovement, getBlockStateOn, getBlockStateOnLegacy, getBlockX, getBlockY, getBlockZ, getBoundingBox, getCapability, getCapability, getCollisionHorizontalEscapeVector, getCommandSenderWorld, getControlledVehicle, getCustomName, getDefaultPassengerAttachmentPoint, getDeltaMovement, getDimensionChangingDelay, getDirection, getDisplayName, getEncodeId, getEntityData, getEyeHeight, getEyeHeight, getEyeInFluidType, getEyePosition, getEyePosition, getEyeY, getFireImmuneTicks, getFirstPassenger, getFluidHeight, getFluidJumpThreshold, getFluidTypeHeight, getForward, getGravity, getHandHoldingItemAngle, getId, getInBlockState, getIndirectPassengers, getKnownMovement, getLeashOffset, getLeashOffset, getLightLevelDependentMagicValue, getLightProbePosition, getLookAngle, getMaxAirSupply, getMaxHeightFluidType, getMotionDirection, getMovementEmission, getName, getNearestViewDirection, getOnPos, getOnPos, getOnPosLegacy, getPassengers, getPassengersAndSelf, getPercentFrozen, getPermissionLevel, getPersistentData, getPickRadius, getPistonPushReaction, getPortalCooldown, getPose, getPosition, getPositionCodec, getPrimaryStepSoundBlockPos, getRandom, 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, getVehicleAttachmentPoint, getViewScale, getViewVector, getViewXRot, getX, getX, getXRot, getY, getY, getYRot, getZ, getZ, handlePortal, hasControllingPassenger, hasCustomName, hasExactlyOnePlayerPassenger, hasGlowingTag, hashCode, hasIndirectPassenger, hasPassenger, hasPassenger, hasPermissions, hasPose, igniteForSeconds, ignoreExplosion, interactAt, is, isAddedToLevel, isAlliedTo, isAlliedTo, isAlwaysTicking, isAttackable, isColliding, isControlledByLocalInstance, isCrouching, isCustomNameVisible, isDescending, isDiscrete, isEyeInFluid, isFlapping, isFree, isFreezing, isFullyFrozen, isIgnoringBlockTriggers, isInFluidType, isInFluidType, isInLava, isInLiquid, isInvisible, isInvisibleTo, isInvulnerable, 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, moveTo, moveTowardsClosestSpace, newDoubleList, newFloatList, nextStep, onAboveBubbleCol, onAddedToLevel, onClientRemoval, onExplosionHit, onFlap, onGround, onInsideBlock, onInsideBubbleColumn, onlyOpCanSetNbt, onPassengerTurned, onRemovedFromLevel, onSyncedDataUpdated, pick, placePortalTicket, playCombinationStepSounds, playEntityOnFireExtinguishedSound, playerTouch, playMuffledStepSound, playSound, playSound, playSwimSound, position, positionRider, processFlappingMovement, processPortalCooldown, push, push, reapplyPosition, refreshDimensions, registryAccess, removeTag, removeVehicle, repositionEntityAfterLoad, resetFallDistance, restoreFrom, revive, rotate, save, saveAsPassenger, saveWithoutId, sendSystemMessage, setAirSupply, setAsInsidePortal, setBoundingBox, setCustomName, setCustomNameVisible, setData, setDeltaMovement, setDeltaMovement, setFluidTypeHeight, setGlowingTag, setId, setInvisible, setInvulnerable, setIsInPowderSnow, setLevel, setLevelCallback, setNoGravity, setOldPosAndRot, setOnGround, setOnGroundWithMovement, setPortalCooldown, setPortalCooldown, setPos, setPos, setPose, setPosRaw, setRemainingFireTicks, setRemoved, setRot, setSharedFlag, setSharedFlagOnFire, setShiftKeyDown, setSilent, setSwimming, setTicksFrozen, setUUID, setViewScale, setXRot, setYRot, shouldBlockExplode, shouldInformAdmins, shouldRender, shouldRenderAtSqrDistance, showVehicleHealth, skipAttackInteraction, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnSprintParticle, startRiding, startSeenByPlayer, stopSeenByPlayer, syncPacketPositionCodec, teleportRelative, teleportTo, teleportTo, thunderHit, toString, touchingUnloadedChunk, trackingPosition, tryCheckInsideBlocks, turn, unRide, unsetRemoved, updateDynamicGameEventListener, updateFluidHeightAndDoFluidPushing, updateFluidHeightAndDoFluidPushing, updateFluidOnEyes, updateInWaterStateAndDoFluidPushing, updateSwimming, waterSwimSound

    Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder

    deserializeAttachments, getData, getExistingData, hasAttachments, hasData, removeData, serializeAttachments

    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.minecraft.world.entity.EquipmentUser

    equip, equip, equip, resolveSlot

    Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder

    getData, getExistingData, hasData, removeData, setData

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IEntityExtension

    canBeRiddenUnderFluidType, canFluidExtinguish, canHydrateInFluidType, canRiderInteract, canStartSwimming, canTrample, captureDrops, captureDrops, copyAttachmentsFrom, deserializeNBT, getClassification, getEyeInFluidType, getFluidFallDistanceModifier, getFluidMotionScale, getFluidTypeHeight, getMaxHeightFluidType, getParts, getPersistentData, getPickedResult, getSoundFromFluidType, hasCustomOutlineRendering, isAddedToLevel, isEyeInFluidType, isInFluidType, isInFluidType, isInFluidType, isInFluidType, isInFluidType, isMultipartEntity, isPushedByFluid, onAddedToLevel, onRemovedFromLevel, revive, sendPairingData, serializeNBT, shouldRiderSit

    Methods inherited from interface net.neoforged.neoforge.common.extensions.ILivingEntityExtension

    canDrownInFluidType, canSwimInFluidType, moveInFluid, onDamageTaken, self, sinkInFluid

    Methods inherited from interface com.minecolonies.api.colony.managers.interfaces.IManagedAnimal

    getOffsetTicks

    Methods inherited from interface net.minecraft.world.entity.Leashable

    canHaveALeashAttachedToIt, elasticRangeLeashBehaviour, getLeashHolder, isLeashed, mayBeLeashed, readLeashData, setDelayedLeashHolderId, writeLeashData

    Methods inherited from interface net.minecraft.world.entity.OwnableEntity

    getOwner, level

    Methods inherited from interface net.minecraft.world.entity.PlayerRideableJumping

    getJumpCooldown

    Methods inherited from interface net.minecraft.world.entity.Saddleable

    getSaddleSoundEvent

    Methods inherited from interface net.minecraft.world.scores.ScoreHolder

    getFeedbackDisplayName
  • Field Details

    • DATA_COLONY_ID

      public static final net.minecraft.network.syncher.EntityDataAccessor<Integer> DATA_COLONY_ID
    • DATA_MANAGED_ANIMAL_ID

      public static final net.minecraft.network.syncher.EntityDataAccessor<Integer> DATA_MANAGED_ANIMAL_ID
    • SLIM_W

      public static final float SLIM_W
      The base width and height of the horse entity. Note that the width is deliberately slim to allow 1-wide pathing for cavalry units. Base height matches vanilla horse height.
      See Also:
    • BASE_H

      public static final float BASE_H
      See Also:
    • LOG_COOLDOWN_INTERVAL

      public static final int LOG_COOLDOWN_INTERVAL
      The cooldown for logging when debugging.
      See Also:
    • COMBAT_READINESS_THRESHOLD

      public static final float COMBAT_READINESS_THRESHOLD
      See Also:
  • Constructor Details

    • CavalryHorseEntity

      public CavalryHorseEntity(net.minecraft.world.entity.EntityType<? extends net.minecraft.world.entity.animal.horse.Horse> type, net.minecraft.world.level.Level level)
      Constructor for CavalryHorseEntity.
      Parameters:
      type - The entity type
      level - The level the entity is in
  • Method Details

    • registerGoals

      public void registerGoals()
      Registers the goals for this entity.

      This sets the float goal, follow parent goal, breed goal, validate stable goal, return to stable goal, water avoiding random stroll goal, look at player goal, and random look around goal. If the entity can perform rearing, it also sets the random stand goal.

      Overrides:
      registerGoals in class net.minecraft.world.entity.animal.horse.AbstractHorse
    • onSyncedDataUpdated

      public void onSyncedDataUpdated(net.minecraft.network.syncher.EntityDataAccessor<?> dataAccessor)
      Called when the entity's data is updated from the server. If the entity has a citizen colony handler, it calls the handler's onSyncDataUpdate method. If the entity is on the client side and the data accessor is DATA_STYLE, it checks if the entity's style is in the list of valid styles and if not, it sets the style to the first valid style in the list.
      Specified by:
      onSyncedDataUpdated in interface net.minecraft.network.syncher.SyncedDataHolder
      Overrides:
      onSyncedDataUpdated in class net.minecraft.world.entity.AgeableMob
      Parameters:
      dataAccessor - The data accessor which contains the updated data.
    • aiStep

      public void aiStep()
      This method is called by the entity every tick to update its state. It handles registration of the entity to the closest colony if it was summoned into the world via an ops command. It also handles updating the client side of the managed animal data and the animal colony handler.
      Overrides:
      aiStep in class net.minecraft.world.entity.animal.horse.AbstractHorse
    • defineSynchedData

      protected void defineSynchedData(net.minecraft.network.syncher.SynchedEntityData.Builder builder)
      Defines the synced data for this entity.
      Overrides:
      defineSynchedData in class net.minecraft.world.entity.animal.horse.Horse
    • getColonyIdAccessor

      public net.minecraft.network.syncher.EntityDataAccessor<Integer> getColonyIdAccessor()
      Gets the accessor for the colony ID of this entity.
      Specified by:
      getColonyIdAccessor in interface IManagedAnimal<CavalryHorseEntity>
      Returns:
      the accessor for the colony ID
    • getColonyId

      public int getColonyId()
      Description copied from interface: IManagedAnimal
      Get the colony associated with this managed animal.
      Specified by:
      getColonyId in interface IManagedAnimal<CavalryHorseEntity>
    • setColonyId

      public void setColonyId(int colonyId)
      Description copied from interface: IManagedAnimal
      Set the colony associated with this managed animal.
      Specified by:
      setColonyId in interface IManagedAnimal<CavalryHorseEntity>
    • getAnimalIdAccessor

      public net.minecraft.network.syncher.EntityDataAccessor<Integer> getAnimalIdAccessor()
      Gets the accessor for the animal ID of this entity.
      Specified by:
      getAnimalIdAccessor in interface IManagedAnimal<CavalryHorseEntity>
      Returns:
      the accessor for the animal ID
    • getManagedAnimalId

      public int getManagedAnimalId()
      Get the managed animal ID of this entity.
      Specified by:
      getManagedAnimalId in interface IManagedAnimal<CavalryHorseEntity>
      Returns:
      the managed animal ID
    • setManagedAnimalId

      public void setManagedAnimalId(int managedAnimalId)
      Set the managed animal ID of this entity. This method is also called whenever the entity is registered to a new colony.
      Specified by:
      setManagedAnimalId in interface IManagedAnimal<CavalryHorseEntity>
      Parameters:
      managedAnimalId - the managed animal ID to set
    • hasCavalryRider

      public boolean hasCavalryRider()
      Check if the horse has a valid cavalry rider. The rider must be an instance of EntityCitizen and have a valid job handler. The job handler must also be an instance of JobCavalry.
      Returns:
      true if the horse has a valid cavalry rider, false otherwise.
    • hasTrainer

      public boolean hasTrainer()
      Checks if the horse has a trainer entity (i.e. an entity which is leashing the horse) and if that entity is a citizen. This is used to determine if the horse should be slim (using the vanilla width/height) or can be wide (using the custom width/height).
      Returns:
      true if the horse has a trainer citizen, false otherwise.
    • addPassenger

      protected void addPassenger(@Nonnull net.minecraft.world.entity.Entity passenger)
      Adds a passenger to the horse, dropping the leash and clearing the recent dismount cooldown.
      Overrides:
      addPassenger in class net.minecraft.world.entity.Entity
      Parameters:
      passenger - the passenger to add
    • removePassenger

      protected void removePassenger(@Nonnull net.minecraft.world.entity.Entity passenger)
      Called when a passenger is removed from this horse.
      Overrides:
      removePassenger in class net.minecraft.world.entity.Entity
      Parameters:
      passenger - the passenger being removed
    • setLeashedTo

      public void setLeashedTo(@Nonnull net.minecraft.world.entity.Entity entity, boolean sendPacket)
      Sets the entity that this horse is leashed to.
      Specified by:
      setLeashedTo in interface net.minecraft.world.entity.Leashable
      Parameters:
      entity - the entity to leash to
      sendPacket - whether to send a packet to clients
    • dropLeash

      public void dropLeash(boolean broadcastPacket, boolean dropLeadItem)
      Drops the leash for this horse, optionally sending a packet to clients and dropping the lead item.
      Specified by:
      dropLeash in interface net.minecraft.world.entity.Leashable
      Overrides:
      dropLeash in class net.minecraft.world.entity.Mob
      Parameters:
      broadcastPacket - whether to send a packet to clients
      dropLeadItem - whether to drop the lead item
    • getPassengerAttachmentPoint

      protected net.minecraft.world.phys.Vec3 getPassengerAttachmentPoint(@Nonnull net.minecraft.world.entity.Entity passenger, @Nonnull net.minecraft.world.entity.EntityDimensions dims, float partialTick)
      Returns the attachment point for the given passenger entity, taking into account the entity dimensions and the partial tick. This method is overridden to lower the attachment point by SEATING_OFFSET to line up with the saddle visuals.
      Overrides:
      getPassengerAttachmentPoint in class net.minecraft.world.entity.animal.horse.AbstractHorse
      Parameters:
      passenger - the passenger entity
      dims - the entity dimensions
      partialTick - the partial tick
      Returns:
      the attachment point
    • getLastDismountTime

      public long getLastDismountTime()
      Gets the last time this horse was dismounted from, in game ticks.
      Returns:
      the last time this horse was dismounted from, in game ticks
    • createNavigation

      protected net.minecraft.world.entity.ai.navigation.PathNavigation createNavigation(@Nonnull net.minecraft.world.level.Level level)
      Creates a new PathNavigation for this horse entity, overriding the default vanilla horse navigation. This allows the horse to navigate the world in a way that is more suitable for guards.
      Overrides:
      createNavigation in class net.minecraft.world.entity.Mob
      Parameters:
      level - the level to spawn the new entity in
      Returns:
      the new PathNavigation for this horse entity
    • canMate

      public boolean canMate(@Nonnull net.minecraft.world.entity.animal.Animal other)
      Allow breeding even when not tamed. Keep vanilla species rules.
      Overrides:
      canMate in class net.minecraft.world.entity.animal.horse.Horse
    • tick

      public void tick()
      Called every tick to update the horse.
      Overrides:
      tick in class net.minecraft.world.entity.animal.horse.AbstractHorse
    • logActiveGoals

      public void logActiveGoals()
      Logs all active goals for this horse, including both the wrapped goal selector goals and the target selector goals. This is useful for debugging purposes. This function will only be executed every LOG_COOLDOWN_INTERVAL ticks.
    • createFromVanilla

      public static CavalryHorseEntity createFromVanilla(IColony colony, net.minecraft.world.level.Level level, net.minecraft.world.entity.animal.horse.AbstractHorse vanilla)
      Creates a new CavalryHorseEntity from a vanilla AbstractHorse, attempting to preserve as much information as possible.
      Parameters:
      level - the level to spawn the new entity in
      vanilla - the vanilla horse to convert
      Returns:
      the new CavalryHorseEntity, or null if the conversion failed
    • shouldBeSaved

      public boolean shouldBeSaved()
      Whether this entity should be saved to disk.

      As CavalryHorse entities are always saved to disk, this method always returns true.

      Specified by:
      shouldBeSaved in interface net.minecraft.world.level.entity.EntityAccess
      Overrides:
      shouldBeSaved in class net.minecraft.world.entity.Entity
    • hurt

      public boolean hurt(@Nonnull net.minecraft.world.damagesource.DamageSource damageSource, float damageAmount)
      Applies damage to this entity. A portion of that damage is also applied to the combat cooldown counter.
      Overrides:
      hurt in class net.minecraft.world.entity.animal.horse.AbstractHorse
      Parameters:
      damageSource - the source of the damage
      damageAmount - the amount of damage to apply
      Returns:
      true if the damage was applied, false otherwise
    • addAdditionalSaveData

      public void addAdditionalSaveData(@Nonnull net.minecraft.nbt.CompoundTag tag)
      Adds additional data to the CompoundTag that is specific to this entity type. This data is saved to disk and can be read back in when the entity is loaded. The data added is as follows: - stablePos: The position of the stable block, or null if not set. - stableDim: The dimension of the stable block, or null if not set.
      Overrides:
      addAdditionalSaveData in class net.minecraft.world.entity.animal.horse.Horse
    • readAdditionalSaveData

      public void readAdditionalSaveData(@Nonnull net.minecraft.nbt.CompoundTag tag)
      Reads additional data from the given CompoundTag that is specific to this entity type.

      This method is called when the entity is loaded from disk, and the data read is used to initialize the entity.

      The data that is read is as follows: - TAG_COLONY_ID: The id of the colony that the entity is associated with. - TAG_MANAGED_ANIMALID: The id of the managed animal data that is associated with the entity.

      If the TAG_MANAGED_ANIMALID is not present, then a new managed animal data is created and associated with the entity. Other persisted data is managed through the associated IAnimalData.

      Overrides:
      readAdditionalSaveData in class net.minecraft.world.entity.animal.horse.Horse
    • prepareForCombat

      public void prepareForCombat(float combatReadiness)
      Prepares the horse for combat by reducing its combat cooldown by the specified amount of combat readiness. This amount is subtracted from the horse's current combat cooldown.
      Parameters:
      combatReadiness - the amount of combat readiness to subtract from the horse's combat cooldown.
    • isReadyForCombat

      public boolean isReadyForCombat()
      Returns whether the horse is ready for combat. This is calculated by seeing if the combat cooldown is less than or equal to the readiness threshold relative to the maximum health of the horse.
      Returns:
      true if the horse is ready for combat, false otherwise.
    • getCombatCooldown

      public float getCombatCooldown()
      Returns the current combat cooldown of the horse. This is the amount of time until the horse is ready for combat. A higher value means the horse is currently less ready for combat.
      Returns:
      the current combat cooldown of the horse
    • isHorizontalCollisionMinor

      protected boolean isHorizontalCollisionMinor(@Nonnull net.minecraft.world.phys.Vec3 vec3)
      A minor horizontal collision is one that occurs when the horse has moved into a solid block. This is different from a major collision, which is when the horse has moved into another entity. This method is overridden to set the lastHorizontalCollision field to the current game time when a minor collision occurs.
      Overrides:
      isHorizontalCollisionMinor in class net.minecraft.world.entity.Entity
      Parameters:
      vec3 - the movement vector of the horse
      Returns:
      true if the horse moved into a solid block, false otherwise
    • hadHorizontalCollission

      public boolean hadHorizontalCollission()
      Whether the horse collided in the last 10 ticks
      Returns:
    • reserve

      public void reserve(@NotNull @NotNull net.minecraft.world.entity.Entity reserver)
      Reserves the horse for the given entity. When the horse is reserved, it will not be able to be mounted or interacted with by other entities until the reservation is cleared.
      Parameters:
      reserver - the entity to reserve the horse for
    • clearReservation

      public void clearReservation()
      Clears the reservation on the horse. When the reservation is cleared, the horse can once again be mounted and interacted with by other entities.
    • clearFor

      public boolean clearFor(@NotNull @NotNull net.minecraft.world.entity.Entity reserver)
      Clears the reservation on the horse if it is reserved by the entity with the given UUID.
      Parameters:
      reserver - the entity to check against
      Returns:
      true if the reservation was cleared, false otherwise
    • reservedBy

      @Nullable public @Nullable UUID reservedBy()
      Returns the UUID of the entity that has reserved this horse, or null if it is not reserved.
      Returns:
      the UUID of the entity that has reserved this horse, or null if it is not reserved.
    • hasReservation

      public boolean hasReservation()
      Checks if the horse has a reservation by another entity. If the horse has a reservation, it will not be available as a cavalry mountn to other entities until the reservation is cleared.
      Returns:
      true if the horse has a reservation, false otherwise
    • getStableBuilding

      public IBuilding getStableBuilding()
      Returns the stable building of the horse if it exists. If the horse does not have a stable block position, or if the block position is not a stable building, this method returns null.
      Returns:
      the stable building of the horse, or null if the horse does not have one.
    • isInStable

      public boolean isInStable()
      Checks if the horse is currently within the boundaries of its stable building.

      If the horse does not have a stable, returns false.

      If the horse is currently within the boundaries of its stable building, returns true. Otherwise, returns false.

      Returns:
      true if the horse is within its stable building, false otherwise
    • getAnimalData

      public IAnimalData getAnimalData()
      Returns the animal data associated with this horse.
      Specified by:
      getAnimalData in interface IManagedAnimal<CavalryHorseEntity>
      Returns:
      the animal data associated with this horse.
    • getAnimalDataView

      public IAnimalDataView getAnimalDataView()
      Returns the animal data view associated with this horse.
      Specified by:
      getAnimalDataView in interface IManagedAnimal<CavalryHorseEntity>
      Returns:
      the animal data view associated with this horse.
    • setAnimalData

      public void setAnimalData(IAnimalData data)
      Sets the animal data associated with this horse.
      Specified by:
      setAnimalData in interface IManagedAnimal<CavalryHorseEntity>
      Parameters:
      data - The animal data associated with this horse.
    • getEntity

      public CavalryHorseEntity getEntity()
      Returns the entity itself. This is used in the IManagedAnimal interface to get the entity associated with the managed animal.

      This method is used to get the entity associated with the managed animal, which in this case is the horse entity.

      Specified by:
      getEntity in interface IManagedAnimal<CavalryHorseEntity>
      Returns:
      the horse entity associated with the managed animal.