Class AbstractMinecart
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.entity.Entity
net.minecraft.world.entity.vehicle.VehicleEntity
net.minecraft.world.entity.vehicle.AbstractMinecart
- All Implemented Interfaces:
CommandSource
,SyncedDataHolder
,EntityAccess
,Nameable
,ScoreHolder
,IAttachmentHolder
,IAbstractMinecartExtension
,IEntityExtension
,INBTSerializable<CompoundTag>
- Direct Known Subclasses:
AbstractMinecartContainer
,Minecart
,MinecartCommandBlock
,MinecartFurnace
,MinecartSpawner
,MinecartTNT
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class net.minecraft.world.entity.Entity
Entity.MoveFunction, Entity.MovementEmission, Entity.RemovalReason
Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
AttachmentHolder.AsField
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private boolean
private static IMinecartCollisionHandler
private float
private static final EntityDataAccessor
<Boolean> private static final EntityDataAccessor
<Integer> private static final EntityDataAccessor
<Integer> private double
private boolean
private int
private double
private double
private double
private double
private double
private static final Vec3
private @Nullable Float
private float
private boolean
private static final com.google.common.collect.ImmutableMap
<Pose, com.google.common.collect.ImmutableList<Integer>> private Vec3
protected static final float
Fields inherited from class net.minecraft.world.entity.vehicle.VehicleEntity
DATA_ID_DAMAGE, DATA_ID_HURT, DATA_ID_HURTDIR
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, 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.neoforged.neoforge.common.extensions.IAbstractMinecartExtension
DEFAULT_AIR_DRAG, DEFAULT_MAX_SPEED_AIR_LATERAL, DEFAULT_MAX_SPEED_AIR_VERTICAL
Fields inherited from interface net.minecraft.world.scores.ScoreHolder
WILDCARD, WILDCARD_NAME
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractMinecart
(EntityType<?> pEntityType, Level pLevel) protected
AbstractMinecart
(EntityType<?> pEntityType, Level pLevel, double pX, double pY, double pZ) -
Method Summary
Modifier and TypeMethodDescriptionvoid
activateMinecart
(int pX, int pY, int pZ, boolean pPowered) Called every tick the minecart is on an activator rail.protected void
addAdditionalSaveData
(CompoundTag pCompound) void
animateHurt
(float pYaw) protected void
boolean
canCollideWith
(Entity pEntity) boolean
Returns true if this cart can currently use rails.protected void
static AbstractMinecart
createMinecart
(ServerLevel pLevel, double pX, double pY, double pZ, AbstractMinecart.Type pType, ItemStack pStack, Player pPlayer) protected void
defineSynchedData
(SynchedEntityData.Builder pBuilder) protected float
float
Returns the current speed cap for the cart when traveling on rails.int
protected double
getDismountLocationForPassenger
(LivingEntity pLivingEntity) int
double
protected double
float
float
double
abstract AbstractMinecart.Type
protected Entity.MovementEmission
protected Vec3
getPassengerAttachmentPoint
(Entity pEntity, EntityDimensions pDimensions, float pPartialTick) getPos
(double pX, double pY, double pZ) getPosOffs
(double pX, double pY, double pZ, double pOffset) getRelativePortalPosition
(Direction.Axis pAxis, BlockUtil.FoundRectangle pPortal) boolean
boolean
boolean
boolean
private boolean
isRedstoneConductor
(BlockPos pPos) void
lerpMotion
(double pX, double pY, double pZ) Updates the entity motion clientside, called by packets from the serverdouble
float
double
float
double
void
lerpTo
(double pX, double pY, double pZ, float pYRot, float pXRot, int pSteps) protected void
moveAlongTrack
(BlockPos pPos, BlockState pState) void
Moved to allow overrides.void
Applies a velocity to the entities, to push them away from each other.protected void
readAdditionalSaveData
(CompoundTag pCompound) (abstract) Protected helper method to read subclass entity data from NBT.static void
void
setCanUseRail
(boolean value) Set whether the minecart can use rails.void
setCurrentCartSpeedCapOnRail
(float value) void
setCustomDisplay
(boolean pCustomDisplay) void
setDisplayBlockState
(BlockState pDisplayState) void
setDisplayOffset
(int pDisplayOffset) void
setDragAir
(double value) void
setMaxSpeedAirLateral
(float value) void
setMaxSpeedAirVertical
(float value) void
tick()
Methods inherited from class net.minecraft.world.entity.vehicle.VehicleEntity
destroy, destroy, getDamage, getDropItem, getHurtDir, getHurtTime, hurt, setDamage, setHurtDir, setHurtTime, shouldSourceDestroy
Methods inherited from class net.minecraft.world.entity.Entity
absMoveTo, absMoveTo, absRotateTo, acceptsFailure, acceptsSuccess, addDeltaMovement, addPassenger, addTag, adjustSpawnLocation, applyGravity, awardKillScore, baseTick, blockPosition, broadcastToPlayer, calculateUpVector, calculateViewVector, canAddPassenger, canBeCollidedWith, canBeHitByProjectile, canChangeDimensions, canControlVehicle, canFreeze, canRide, canSpawnSprintParticle, canSprint, canTrample, canUsePortal, captureDrops, captureDrops, causeFallDamage, changeDimension, checkBelowWorld, checkDespawn, checkFallDamage, 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, getControllingPassenger, getCustomName, getDefaultPassengerAttachmentPoint, getDeltaMovement, getDimensionChangingDelay, getDimensions, 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, getMaxFallDistance, getMaxHeightFluidType, getName, getNearestViewDirection, getOnPos, getOnPos, getOnPosLegacy, getPassengerRidingPosition, getPassengers, getPassengersAndSelf, getPercentFrozen, getPermissionLevel, getPersistentData, getPickRadius, getPistonPushReaction, getPortalCooldown, getPose, getPosition, getPositionCodec, getPreciseBodyRotation, getPrimaryStepSoundBlockPos, getRandom, getRandomX, getRandomY, getRandomZ, getRemainingFireTicks, getRemovalReason, getRootVehicle, getRopeHoldPosition, getRotationVector, getScoreboardName, getSelfAndPassengers, getServer, getSharedFlag, getSlot, getSoundSource, getStringUUID, getSwimHighSpeedSplashSound, getSwimSound, getSwimSplashSound, getTags, getTeam, getTeamColor, getTicksFrozen, getTicksRequiredToFreeze, getType, getTypeName, getUpVector, getUUID, getVehicle, getVehicleAttachmentPoint, getViewScale, getViewVector, getViewXRot, getViewYRot, getVisualRotationYInDegrees, getWeaponItem, getX, getX, getXRot, getY, getY, getYHeadRot, getYRot, getZ, getZ, handleDamageEvent, handleEntityEvent, handlePortal, hasControllingPassenger, hasCustomName, hasExactlyOnePlayerPassenger, hasGlowingTag, hashCode, hasIndirectPassenger, hasPassenger, hasPassenger, hasPermissions, hasPose, igniteForSeconds, igniteForTicks, ignoreExplosion, interact, interactAt, is, isAddedToLevel, isAlive, isAlliedTo, isAlliedTo, isAlwaysTicking, isAttackable, isColliding, isControlledByLocalInstance, isCrouching, isCurrentlyGlowing, isCustomNameVisible, isDescending, isDiscrete, isEffectiveAi, isEyeInFluid, isFlapping, isFree, isFreezing, isFullyFrozen, isHorizontalCollisionMinor, isIgnoringBlockTriggers, isInFluidType, isInFluidType, isInLava, isInLiquid, isInvisible, isInvisibleTo, isInvulnerable, isInvulnerableTo, isInWall, isInWater, isInWaterOrBubble, isInWaterOrRain, isInWaterRainOrBubble, isNoGravity, isOnFire, isOnPortalCooldown, isPassenger, isPassengerOfSameVehicle, isPushedByFluid, isRemoved, isShiftKeyDown, isSilent, isSpectator, isSprinting, isSteppingCarefully, isSupportedBy, isSuppressingBounce, isSwimming, isUnderWater, isVehicle, isVisuallyCrawling, isVisuallySwimming, kill, killedEntity, lavaHurt, lerpHeadTo, lerpPositionAndRotationStep, level, limitPistonMovement, load, lookAt, makeBoundingBox, makeStuckInBlock, markHurt, maxUpStep, maybeBackOffFromEdge, mayInteract, mirror, move, moveRelative, moveTo, moveTo, moveTo, moveTo, moveTo, moveTowardsClosestSpace, newDoubleList, newFloatList, nextStep, onAboveBubbleCol, onAddedToLevel, onBelowWorld, onClientRemoval, onExplosionHit, onFlap, onGround, onInsideBlock, onInsideBubbleColumn, onlyOpCanSetNbt, onPassengerTurned, onRemovedFromLevel, onSyncedDataUpdated, onSyncedDataUpdated, pick, placePortalTicket, playCombinationStepSounds, playEntityOnFireExtinguishedSound, playerTouch, playMuffledStepSound, playSound, playSound, playStepSound, playSwimSound, position, positionRider, positionRider, processFlappingMovement, processPortalCooldown, push, push, reapplyPosition, recreateFromPacket, refreshDimensions, registryAccess, remove, removeAfterChangingDimensions, removePassenger, removeTag, removeVehicle, repositionEntityAfterLoad, resetFallDistance, restoreFrom, revive, rideTick, 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, setSprinting, setSwimming, setTicksFrozen, setUUID, setViewScale, setXRot, setYBodyRot, setYHeadRot, setYRot, shouldBeSaved, shouldBlockExplode, shouldInformAdmins, shouldRender, shouldRenderAtSqrDistance, shouldShowName, showVehicleHealth, skipAttackInteraction, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnAtLocation, spawnSprintParticle, startRiding, startRiding, startSeenByPlayer, stopRiding, stopSeenByPlayer, syncPacketPositionCodec, teleportRelative, teleportTo, teleportTo, thunderHit, toString, touchingUnloadedChunk, trackingPosition, tryCheckInsideBlocks, turn, unRide, unsetRemoved, updateDynamicGameEventListener, updateFluidHeightAndDoFluidPushing, updateFluidHeightAndDoFluidPushing, updateInWaterStateAndDoFluidPushing, updateSwimming, waterSwimSound
Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, 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.neoforged.neoforge.common.extensions.IAbstractMinecartExtension
canBeRidden, getComparatorLevel, getCurrentRailPosition, getMaxCartSpeedOnRail, getSlopeAdjustment, isPoweredCart, shouldDoRailFunctions
Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData
Methods inherited from interface net.neoforged.neoforge.common.extensions.IEntityExtension
canBeRiddenUnderFluidType, canFluidExtinguish, canHydrateInFluidType, canRiderInteract, canStartSwimming, canSwimInFluidType, copyAttachmentsFrom, deserializeNBT, getClassification, getFluidFallDistanceModifier, getFluidMotionScale, getParts, getPickedResult, getSoundFromFluidType, hasCustomOutlineRendering, isEyeInFluidType, isInFluidType, isInFluidType, isInFluidType, isMultipartEntity, isPushedByFluid, sendPairingData, serializeNBT, shouldRiderSit
Methods inherited from interface net.minecraft.world.scores.ScoreHolder
getFeedbackDisplayName
-
Field Details
-
LOWERED_PASSENGER_ATTACHMENT
-
DATA_ID_DISPLAY_BLOCK
-
DATA_ID_DISPLAY_OFFSET
-
DATA_ID_CUSTOM_DISPLAY
-
POSE_DISMOUNT_HEIGHTS
-
WATER_SLOWDOWN_FACTOR
protected static final float WATER_SLOWDOWN_FACTOR- See Also:
-
flipped
private boolean flipped -
onRails
private boolean onRails -
lerpSteps
private int lerpSteps -
lerpX
private double lerpX -
lerpY
private double lerpY -
lerpZ
private double lerpZ -
lerpYRot
private double lerpYRot -
lerpXRot
private double lerpXRot -
targetDeltaMovement
-
canBePushed
private boolean canBePushed -
EXITS
-
COLLISIONS
-
canUseRail
private boolean canUseRail -
currentSpeedCapOnRail
private float currentSpeedCapOnRail -
maxSpeedAirLateral
-
maxSpeedAirVertical
private float maxSpeedAirVertical -
dragAir
private double dragAir
-
-
Constructor Details
-
AbstractMinecart
-
AbstractMinecart
protected AbstractMinecart(EntityType<?> pEntityType, Level pLevel, double pX, double pY, double pZ)
-
-
Method Details
-
getCollisionHandler
-
registerCollisionHandler
-
createMinecart
public static AbstractMinecart createMinecart(ServerLevel pLevel, double pX, double pY, double pZ, AbstractMinecart.Type pType, ItemStack pStack, @Nullable Player pPlayer) -
getMovementEmission
- Overrides:
getMovementEmission
in classEntity
-
defineSynchedData
- Overrides:
defineSynchedData
in classVehicleEntity
-
canCollideWith
- Overrides:
canCollideWith
in classEntity
-
isPushable
public boolean isPushable()- Overrides:
isPushable
in classEntity
-
getRelativePortalPosition
- Overrides:
getRelativePortalPosition
in classEntity
-
getPassengerAttachmentPoint
protected Vec3 getPassengerAttachmentPoint(Entity pEntity, EntityDimensions pDimensions, float pPartialTick) - Overrides:
getPassengerAttachmentPoint
in classEntity
-
getDismountLocationForPassenger
- Overrides:
getDismountLocationForPassenger
in classEntity
-
getBlockSpeedFactor
protected float getBlockSpeedFactor()- Overrides:
getBlockSpeedFactor
in classEntity
-
animateHurt
public void animateHurt(float pYaw) - Overrides:
animateHurt
in classEntity
-
isPickable
public boolean isPickable()- Overrides:
isPickable
in classEntity
-
exits
-
getMotionDirection
- Overrides:
getMotionDirection
in classEntity
-
getDefaultGravity
protected double getDefaultGravity()- Overrides:
getDefaultGravity
in classEntity
-
tick
public void tick() -
getMaxSpeed
protected double getMaxSpeed() -
activateMinecart
public void activateMinecart(int pX, int pY, int pZ, boolean pPowered) Called every tick the minecart is on an activator rail. -
comeOffTrack
protected void comeOffTrack() -
moveAlongTrack
-
isOnRails
public boolean isOnRails() -
isRedstoneConductor
-
applyNaturalSlowdown
protected void applyNaturalSlowdown() -
getPosOffs
-
getPos
-
getBoundingBoxForCulling
- Overrides:
getBoundingBoxForCulling
in classEntity
-
readAdditionalSaveData
(abstract) Protected helper method to read subclass entity data from NBT.- Specified by:
readAdditionalSaveData
in classEntity
-
addAdditionalSaveData
- Specified by:
addAdditionalSaveData
in classEntity
-
push
Applies a velocity to the entities, to push them away from each other. -
lerpTo
public void lerpTo(double pX, double pY, double pZ, float pYRot, float pXRot, int pSteps) -
lerpTargetX
public double lerpTargetX()- Overrides:
lerpTargetX
in classEntity
-
lerpTargetY
public double lerpTargetY()- Overrides:
lerpTargetY
in classEntity
-
lerpTargetZ
public double lerpTargetZ()- Overrides:
lerpTargetZ
in classEntity
-
lerpTargetXRot
public float lerpTargetXRot()- Overrides:
lerpTargetXRot
in classEntity
-
lerpTargetYRot
public float lerpTargetYRot()- Overrides:
lerpTargetYRot
in classEntity
-
lerpMotion
public void lerpMotion(double pX, double pY, double pZ) Updates the entity motion clientside, called by packets from the server- Overrides:
lerpMotion
in classEntity
-
getMinecartType
-
getDisplayBlockState
-
getDefaultDisplayBlockState
-
getDisplayOffset
public int getDisplayOffset() -
getDefaultDisplayOffset
public int getDefaultDisplayOffset() -
setDisplayBlockState
-
setDisplayOffset
public void setDisplayOffset(int pDisplayOffset) -
hasCustomDisplay
public boolean hasCustomDisplay() -
setCustomDisplay
public void setCustomDisplay(boolean pCustomDisplay) -
canUseRail
public boolean canUseRail()Description copied from interface:IAbstractMinecartExtension
Returns true if this cart can currently use rails. This function is mainly used to gracefully detach a minecart from a rail.- Specified by:
canUseRail
in interfaceIAbstractMinecartExtension
- Returns:
- True if the minecart can use rails.
-
setCanUseRail
public void setCanUseRail(boolean value) Description copied from interface:IAbstractMinecartExtension
Set whether the minecart can use rails. This function is mainly used to gracefully detach a minecart from a rail.- Specified by:
setCanUseRail
in interfaceIAbstractMinecartExtension
- Parameters:
value
- Whether the minecart can currently use rails.
-
getCurrentCartSpeedCapOnRail
public float getCurrentCartSpeedCapOnRail()Description copied from interface:IAbstractMinecartExtension
Returns the current speed cap for the cart when traveling on rails. This functions differs from getMaxCartSpeedOnRail() in that it controls current movement and cannot be overridden. The value however can never be higher than getMaxCartSpeedOnRail().- Specified by:
getCurrentCartSpeedCapOnRail
in interfaceIAbstractMinecartExtension
-
setCurrentCartSpeedCapOnRail
public void setCurrentCartSpeedCapOnRail(float value) - Specified by:
setCurrentCartSpeedCapOnRail
in interfaceIAbstractMinecartExtension
-
getMaxSpeedWithRail
public double getMaxSpeedWithRail()- Specified by:
getMaxSpeedWithRail
in interfaceIAbstractMinecartExtension
-
getMaxSpeedAirLateral
public float getMaxSpeedAirLateral()- Specified by:
getMaxSpeedAirLateral
in interfaceIAbstractMinecartExtension
-
setMaxSpeedAirLateral
public void setMaxSpeedAirLateral(float value) - Specified by:
setMaxSpeedAirLateral
in interfaceIAbstractMinecartExtension
-
getMaxSpeedAirVertical
public float getMaxSpeedAirVertical()- Specified by:
getMaxSpeedAirVertical
in interfaceIAbstractMinecartExtension
-
setMaxSpeedAirVertical
public void setMaxSpeedAirVertical(float value) - Specified by:
setMaxSpeedAirVertical
in interfaceIAbstractMinecartExtension
-
getDragAir
public double getDragAir()- Specified by:
getDragAir
in interfaceIAbstractMinecartExtension
-
setDragAir
public void setDragAir(double value) - Specified by:
setDragAir
in interfaceIAbstractMinecartExtension
-
moveMinecartOnRail
Description copied from interface:IAbstractMinecartExtension
Moved to allow overrides. This code handles minecart movement and speed capping when on a rail.- Specified by:
moveMinecartOnRail
in interfaceIAbstractMinecartExtension
-
getPickResult
- Overrides:
getPickResult
in classEntity
-