Class PistonMovingBlockEntity
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
net.minecraft.world.level.block.piston.PistonMovingBlockEntity
- All Implemented Interfaces:
IAttachmentHolder
,IBlockEntityExtension
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.level.block.entity.BlockEntity
BlockEntity.DataComponentInput
Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
AttachmentHolder.AsField
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private Direction
private boolean
Whether this piston is extending.private boolean
private long
private BlockState
private static final ThreadLocal
<Direction> private float
private float
The extension / retraction progressprivate static final double
static final double
private static final int
Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPosition
Fields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY
-
Constructor Summary
ConstructorsConstructorDescriptionPistonMovingBlockEntity
(BlockPos pPos, BlockState pBlockState) PistonMovingBlockEntity
(BlockPos pPos, BlockState pBlockState, BlockState pMovedState, Direction pDirection, boolean pExtending, boolean pIsSourcePiston) -
Method Summary
Modifier and TypeMethodDescriptionvoid
private static void
fixEntityWithinPistonBase
(BlockPos pPos, Entity pEntity, Direction pDir, double pProgress) private BlockState
getCollisionShape
(BlockGetter pLevel, BlockPos pPos) private float
getExtendedProgress
(float pProgress) long
private static double
getMovement
(AABB pHeadShape, Direction pDirection, AABB pFacing) float
getProgress
(float pPartialTicks) getUpdateTag
(HolderLookup.Provider pRegistries) float
getXOff
(float pPartialTicks) float
getYOff
(float pPartialTicks) float
getZOff
(float pPartialTicks) boolean
boolean
private boolean
protected void
loadAdditional
(CompoundTag pTag, HolderLookup.Provider pRegistries) private static boolean
matchesStickyCritera
(AABB pBox, Entity pEntity, BlockPos pPos) private static AABB
moveByPositionAndProgress
(BlockPos pPos, AABB pAabb, PistonMovingBlockEntity pPistonMovingBlockEntity) private static void
moveCollidedEntities
(Level pLevel, BlockPos pPos, float pPartialTick, PistonMovingBlockEntity pPiston) private static void
moveEntityByPiston
(Direction pNoClipDirection, Entity pEntity, double pProgress, Direction pDirection) private static void
moveStuckEntities
(Level pLevel, BlockPos pPos, float pPartialTick, PistonMovingBlockEntity pPiston) protected void
saveAdditional
(CompoundTag pTag, HolderLookup.Provider pRegistries) void
static void
tick
(Level pLevel, BlockPos pPos, BlockState pState, PistonMovingBlockEntity pBlockEntity) Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, applyComponents, applyComponentsFromItemStack, applyImplicitComponents, clearRemoved, collectComponents, collectImplicitComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, getUpdatePacket, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, onlyOpCanSetNbt, parseCustomNameSafe, removeComponentsFromTag, removeData, saveCustomAndMetadata, saveCustomOnly, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setComponents, setData, setRemoved, triggerEvent
Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachments
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
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.IBlockEntityExtension
getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdate
-
Field Details
-
TICKS_TO_EXTEND
private static final int TICKS_TO_EXTEND- See Also:
-
PUSH_OFFSET
private static final double PUSH_OFFSET- See Also:
-
TICK_MOVEMENT
public static final double TICK_MOVEMENT- See Also:
-
movedState
-
direction
-
extending
private boolean extendingWhether this piston is extending. -
isSourcePiston
private boolean isSourcePiston -
NOCLIP
-
progress
private float progress -
progressO
private float progressOThe extension / retraction progress -
lastTicked
private long lastTicked -
deathTicks
private int deathTicks
-
-
Constructor Details
-
PistonMovingBlockEntity
-
PistonMovingBlockEntity
public PistonMovingBlockEntity(BlockPos pPos, BlockState pBlockState, BlockState pMovedState, Direction pDirection, boolean pExtending, boolean pIsSourcePiston)
-
-
Method Details
-
getUpdateTag
- Overrides:
getUpdateTag
in classBlockEntity
-
isExtending
public boolean isExtending() -
getDirection
-
isSourcePiston
public boolean isSourcePiston() -
getProgress
public float getProgress(float pPartialTicks) - Returns:
- interpolated progress value (between lastProgress and progress) given the partialTicks
-
getXOff
public float getXOff(float pPartialTicks) -
getYOff
public float getYOff(float pPartialTicks) -
getZOff
public float getZOff(float pPartialTicks) -
getExtendedProgress
private float getExtendedProgress(float pProgress) -
getCollisionRelatedBlockState
-
moveCollidedEntities
private static void moveCollidedEntities(Level pLevel, BlockPos pPos, float pPartialTick, PistonMovingBlockEntity pPiston) -
moveEntityByPiston
-
moveStuckEntities
private static void moveStuckEntities(Level pLevel, BlockPos pPos, float pPartialTick, PistonMovingBlockEntity pPiston) -
matchesStickyCritera
-
isStickyForEntities
private boolean isStickyForEntities() -
getMovementDirection
-
getMovement
-
moveByPositionAndProgress
private static AABB moveByPositionAndProgress(BlockPos pPos, AABB pAabb, PistonMovingBlockEntity pPistonMovingBlockEntity) -
fixEntityWithinPistonBase
-
getMovedState
-
finalTick
public void finalTick() -
tick
public static void tick(Level pLevel, BlockPos pPos, BlockState pState, PistonMovingBlockEntity pBlockEntity) -
loadAdditional
- Overrides:
loadAdditional
in classBlockEntity
-
saveAdditional
- Overrides:
saveAdditional
in classBlockEntity
-
getCollisionShape
-
getLastTicked
public long getLastTicked() -
setLevel
- Overrides:
setLevel
in classBlockEntity
-