Class AbstractSemiblockEntity
java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.entity.Entity>
net.minecraft.world.entity.Entity
me.desht.pneumaticcraft.common.entity.semiblock.AbstractSemiblockEntity
- All Implemented Interfaces:
ISemiBlock,IGUIButtonSensitive,net.minecraft.commands.CommandSource,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.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- Direct Known Subclasses:
AbstractLogisticsFrameEntity,CropSupportEntity,HeatFrameEntity,SpawnerAgitatorEntity,TransferGadgetEntity
public abstract class AbstractSemiblockEntity
extends net.minecraft.world.entity.Entity
implements ISemiBlock, IGUIButtonSensitive
-
Nested Class Summary
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.RemovalReasonNested 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
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, 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, isInsidePortal, level, MAX_ENTITY_TAG_COUNT, maxUpStep, 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, xRotO, yo, yOld, yRotO, zo, zOldFields inherited from interface net.minecraft.commands.CommandSource
NULL -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAdditionalSaveData(net.minecraft.nbt.CompoundTag compound) protected net.minecraft.world.phys.AABBGet the bounding box for this entity, which by default is the bounding box of the block we're on.booleancanCoexist(ISemiBlock otherSemiblock) Check if this semiblock can coexist with the other semiblock, in the same block pos.booleancanStay()Check if this semiblock can remain here.protected voidprotected voiddoExtraCleanupTasks(boolean removingSemiblock) Called by onRemovedFromWorld() to finalize semiblock removal.net.minecraft.network.protocol.Packet<net.minecraft.network.protocol.game.ClientGamePacketListener>final net.minecraft.world.phys.AABBGet the bounding box for this entity.net.minecraft.core.BlockPosGet the block position this entity occupies.net.minecraft.world.level.block.state.BlockStateGet the blockstate at the semiblock's positionnet.minecraft.world.level.block.entity.BlockEntityGet the block entity at the semiblock's position.floatprotected net.minecraft.world.item.ItemGet the semiblock item which will be dropped when this semiblock is removed.net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>getDrops()Add any dropped items from this semiblock to the given list.net.minecraft.network.chat.ComponentGet the displayed name for this semiblock.net.minecraft.resources.ResourceLocationGet a unique ID for this semiblock, which should match the corresponding item's registry name.intintGet the tracking for this semiblock; this should only be used for network sync purposes, and is subject to change on a world reload.net.minecraft.world.level.LevelgetWorld()Get the world this semiblock is in.voidhandleGUIButtonPress(String tag, boolean shiftHeld, net.minecraft.server.level.ServerPlayer player) booleanhurt(net.minecraft.world.damagesource.DamageSource source, float amount) net.minecraft.world.InteractionResultinteractAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 hitVec, net.minecraft.world.InteractionHand hand) booleanisAir()booleanbooleanbooleanisValid()Check if this semiblock is still valid, i.e.voidkilledByEntity(net.minecraft.world.entity.Entity entity) Called when an entity has caused this semiblock to be removed; usually, but necessarily, a player wrenching or hitting it.voidvoidprotected voidreadAdditionalSaveData(net.minecraft.nbt.CompoundTag compound) voidreadFromBuf(net.minecraft.network.FriendlyByteBuf payload) Read this semiblock from network buffer for network sync purposes.net.minecraft.nbt.CompoundTagserializeNBT(net.minecraft.nbt.CompoundTag tag) Written to the dropped item (under the "EntityTag" subtag) when the semiblock is broken, to persisted entity data byEntity#writeAdditional(), and displayed by info mods such as TOP or Waila.voidsetPos(double x, double y, double z) voidtick()Implement tick logic here.voidwriteToBuf(net.minecraft.network.FriendlyByteBuf payload) Write this semiblock to network buffer for network sync purposes.Methods inherited from class net.minecraft.world.entity.Entity
absMoveTo, absMoveTo, acceptsFailure, acceptsSuccess, addDeltaMovement, addPassenger, addTag, allowsDismounting, animateHurt, awardKillScore, baseTick, blockPosition, broadcastToPlayer, calculateUpVector, calculateViewVector, canAddPassenger, canBeCollidedWith, canChangeDimensions, canCollideWith, canEnterPose, canFreeze, canRide, canSpawnSprintParticle, canTrample, canUpdate, canUpdate, captureDrops, captureDrops, causeFallDamage, changeDimension, changeDimension, checkDespawn, checkFallDamage, checkInsideBlocks, checkOutOfWorld, checkSlowFallDistance, chunkPosition, clearFire, closerThan, closerThan, collideBoundingBox, copyPosition, createCommandSourceStack, createHoverEvent, dampensVibrations, discard, dismountTo, displayFireAnimation, distanceTo, distanceToSqr, distanceToSqr, distanceToSqr, doEnchantDamageEffects, doWaterSplashEffect, ejectPassengers, equals, extinguishFire, fillCrashReportCategory, findDimensionEntryPoint, fireImmune, fixupDimensions, gameEvent, gameEvent, getAirSupply, getAllSlots, getArmorSlots, getBbHeight, getBbWidth, getBlockExplosionResistance, getBlockJumpFactor, getBlockPosBelowThatAffectsMyMovement, getBlockSpeedFactor, getBlockStateOn, getBlockStateOnLegacy, getBlockX, getBlockY, getBlockZ, getBoundingBox, getBoundingBoxForCulling, getBoundingBoxForPose, getCollisionHorizontalEscapeVector, getCommandSenderWorld, getControllingPassenger, getCustomName, getDeltaMovement, getDimensionChangingDelay, getDimensions, getDirection, getDismountLocationForPassenger, getDisplayName, getEncodeId, getEntityData, getExitPortal, getEyeHeight, getEyeHeight, getEyeHeight, getEyeHeightAccess, getEyeInFluidType, getEyePosition, getEyePosition, getEyeY, getFeetBlockState, getFireImmuneTicks, getFirstPassenger, getFluidHeight, getFluidJumpThreshold, getFluidTypeHeight, getForward, getHandHoldingItemAngle, getHandSlots, getId, getIndirectPassengers, getLeashOffset, getLeashOffset, getLevel, getLightLevelDependentMagicValue, getLightProbePosition, getLookAngle, getMaxAirSupply, getMaxFallDistance, getMaxHeightFluidType, getMotionDirection, getMovementEmission, getMyRidingOffset, getName, getOnPos, getOnPosLegacy, getPassengers, getPassengersAndSelf, getPassengersRidingOffset, getPercentFrozen, getPermissionLevel, getPersistentData, getPickRadius, getPickResult, getPistonPushReaction, getPortalWaitTime, getPose, getPosition, getPositionCodec, getRandomX, getRandomY, getRandomZ, getRelativePortalPosition, 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, getViewScale, getViewVector, getViewXRot, getViewYRot, getVisualRotationYInDegrees, getX, getX, getXRot, getY, getY, getYHeadRot, getYRot, getZ, getZ, handleEntityEvent, handleInsidePortal, handleNetherPortal, hasControllingPassenger, hasCustomName, hasExactlyOnePlayerPassenger, hasGlowingTag, hashCode, hasIndirectPassenger, hasPassenger, hasPassenger, hasPermissions, hasPose, ignoreExplosion, interact, is, isAddedToWorld, isAlive, isAlliedTo, isAlliedTo, isAlwaysTicking, isAttackable, isColliding, isControlledByLocalInstance, isCrouching, isCurrentlyGlowing, isCustomNameVisible, isDescending, isDiscrete, isEyeInFluid, isFlapping, isFree, isFreezing, isFullyFrozen, isHorizontalCollisionMinor, isIgnoringBlockTriggers, isInFluidType, isInFluidType, isInLava, isInvisible, isInvisibleTo, isInvulnerable, isInvulnerableTo, isInWall, isInWater, isInWaterOrBubble, isInWaterOrRain, isInWaterRainOrBubble, isOnFire, isOnGround, isOnPortalCooldown, isPassenger, isPassengerOfSameVehicle, isPushable, isPushedByFluid, isRemoved, isShiftKeyDown, isSilent, isSpectator, isSprinting, isSteppingCarefully, isSuppressingBounce, isSwimming, isUnderWater, isVehicle, isVisuallyCrawling, isVisuallySwimming, kill, lavaHurt, lerpHeadTo, lerpMotion, lerpTo, limitPistonMovement, load, lookAt, makeBoundingBox, makeStuckInBlock, markHurt, maybeBackOffFromEdge, mayInteract, mirror, move, moveRelative, moveTo, moveTo, moveTo, moveTo, moveTowardsClosestSpace, newDoubleList, newFloatList, nextStep, onAboveBubbleCol, onClientRemoval, onFlap, onInsideBlock, onInsideBubbleColumn, onlyOpCanSetNbt, onPassengerTurned, onSyncedDataUpdated, outOfWorld, pick, playEntityOnFireExtinguishedSound, playerTouch, playSound, playSound, playStepSound, playSwimSound, position, positionRider, processFlappingMovement, processPortalCooldown, push, push, reapplyPosition, recreateFromPacket, refreshDimensions, remove, removeAfterChangingDimensions, removePassenger, removeTag, removeVehicle, repositionEntityAfterLoad, resetFallDistance, restoreFrom, revive, rideableUnderWater, rideTick, rotate, save, saveAsPassenger, saveWithoutId, sendSystemMessage, setAirSupply, setBoundingBox, setCustomName, setCustomNameVisible, setDeltaMovement, setDeltaMovement, setFluidTypeHeight, setGlowingTag, setId, setInvisible, setInvulnerable, setIsInPowderSnow, setItemSlot, setLevelCallback, setNoGravity, setOldPosAndRot, setOnGround, setPortalCooldown, setPos, setPose, setPosRaw, setRemainingFireTicks, setRemoved, setRot, setSecondsOnFire, 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, teleportToWithTicket, thunderHit, toString, touchingUnloadedChunk, trackingPosition, tryCheckInsideBlocks, turn, unRide, unsetRemoved, updateDynamicGameEventListener, updateFluidHeightAndDoFluidPushing, updateFluidHeightAndDoFluidPushing, updateInWaterStateAndDoFluidPushing, updateSwimming, wasKilledMethods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, getCapability, invalidateCaps, reviveCaps, serializeCapsMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.commands.CommandSource
alwaysAcceptsMethods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability, getCapabilityMethods inherited from interface net.minecraftforge.common.extensions.IForgeEntity
canBeRiddenUnderFluidType, canFluidExtinguish, canHydrateInFluidType, canRiderInteract, canStartSwimming, canSwimInFluidType, deserializeNBT, getClassification, getFluidFallDistanceModifier, getFluidMotionScale, getParts, getPickedResult, getSoundFromFluidType, getStepHeight, hasCustomOutlineRendering, isEyeInFluidType, isInFluidType, isInFluidType, isInFluidType, isMultipartEntity, isPushedByFluid, serializeNBT, shouldRiderSitMethods inherited from interface me.desht.pneumaticcraft.api.semiblock.ISemiBlock
addTooltip, canPlace, getColor, onPlaced, onRightClickWithConfigurator
-
Method Details
-
getSemiblockDisplayName
public net.minecraft.network.chat.Component getSemiblockDisplayName()Description copied from interface:ISemiBlockGet the displayed name for this semiblock.- Specified by:
getSemiblockDisplayNamein interfaceISemiBlock- Returns:
- the name
-
tick
public void tick()Description copied from interface:ISemiBlockImplement tick logic here. Always be sure to callsuper.tick()in subclass overrides!- Specified by:
tickin interfaceISemiBlock- Overrides:
tickin classnet.minecraft.world.entity.Entity
-
interactAt
public net.minecraft.world.InteractionResult interactAt(net.minecraft.world.entity.player.Player player, net.minecraft.world.phys.Vec3 hitVec, net.minecraft.world.InteractionHand hand) - Overrides:
interactAtin classnet.minecraft.world.entity.Entity
-
defineSynchedData
protected void defineSynchedData()- Specified by:
defineSynchedDatain classnet.minecraft.world.entity.Entity
-
getWorld
public net.minecraft.world.level.Level getWorld()Description copied from interface:ISemiBlockGet the world this semiblock is in.- Specified by:
getWorldin interfaceISemiBlock- Returns:
- the world
-
getBlockPos
public net.minecraft.core.BlockPos getBlockPos()Description copied from interface:ISemiBlockGet the block position this entity occupies.- Specified by:
getBlockPosin interfaceISemiBlock- Returns:
- the block pos
-
setPos
public void setPos(double x, double y, double z) - Overrides:
setPosin classnet.minecraft.world.entity.Entity
-
getBlockState
public net.minecraft.world.level.block.state.BlockState getBlockState()Get the blockstate at the semiblock's position- Returns:
- the blockstate
-
getCachedTileEntity
public net.minecraft.world.level.block.entity.BlockEntity getCachedTileEntity()Description copied from interface:ISemiBlockGet the block entity at the semiblock's position. This is cached for performance.- Specified by:
getCachedTileEntityin interfaceISemiBlock- Returns:
- the block entity, or null if there is none
-
getDroppedItem
protected net.minecraft.world.item.Item getDroppedItem()Get the semiblock item which will be dropped when this semiblock is removed. By default, that item has the same registry name as the corresponding entity; this could be overridden but probably shouldn't be, for the sake of clarity.- Returns:
- the dropped item, or null if nothing should be dropped
-
getDrops
public net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> getDrops()Description copied from interface:ISemiBlockAdd any dropped items from this semiblock to the given list. By default, just the semiblock item itself is added, but this can be overridden to drop extra items if needed.- Specified by:
getDropsin interfaceISemiBlock
-
getBlockBounds
public final net.minecraft.world.phys.AABB getBlockBounds()Get the bounding box for this entity. OverridecalculateBlockBounds()if you need a custom bounding box.- Returns:
- a bounding box
-
calculateBlockBounds
protected net.minecraft.world.phys.AABB calculateBlockBounds()Get the bounding box for this entity, which by default is the bounding box of the block we're on. This should be in a 0->1 coordinate space; it will be offset by the block's blockpos to get the actual entity bounding box as returned byEntity.getBoundingBox().- Returns:
- a bounding box
-
canStay
public boolean canStay()Check if this semiblock can remain here.- Returns:
- true if the semiblock can stay, false if it should be dropped
-
getSemiblockId
public net.minecraft.resources.ResourceLocation getSemiblockId()Description copied from interface:ISemiBlockGet a unique ID for this semiblock, which should match the corresponding item's registry name.- Specified by:
getSemiblockIdin interfaceISemiBlock- Returns:
- a semiblock ID
-
getAddEntityPacket
public net.minecraft.network.protocol.Packet<net.minecraft.network.protocol.game.ClientGamePacketListener> getAddEntityPacket()- Overrides:
getAddEntityPacketin classnet.minecraft.world.entity.Entity
-
serializeNBT
public net.minecraft.nbt.CompoundTag serializeNBT(net.minecraft.nbt.CompoundTag tag) Description copied from interface:ISemiBlockWritten to the dropped item (under the "EntityTag" subtag) when the semiblock is broken, to persisted entity data byEntity#writeAdditional(), and displayed by info mods such as TOP or Waila. Use this method rather thanwriteAdditional()for fields that either need to be serialized to the dropped item, or displayed on TOP/Waila.- Specified by:
serializeNBTin interfaceISemiBlock- Parameters:
tag- NBT tag to write data to
-
readAdditionalSaveData
protected void readAdditionalSaveData(net.minecraft.nbt.CompoundTag compound) - Specified by:
readAdditionalSaveDatain classnet.minecraft.world.entity.Entity
-
addAdditionalSaveData
protected void addAdditionalSaveData(net.minecraft.nbt.CompoundTag compound) - Specified by:
addAdditionalSaveDatain classnet.minecraft.world.entity.Entity
-
isValid
public boolean isValid()Description copied from interface:ISemiBlockCheck if this semiblock is still valid, i.e. the underlying entity is still alive.- Specified by:
isValidin interfaceISemiBlock- Returns:
- true if this semiblock is valid, false otherwise
-
onAddedToWorld
public void onAddedToWorld()- Specified by:
onAddedToWorldin interfacenet.minecraftforge.common.extensions.IForgeEntity- Overrides:
onAddedToWorldin classnet.minecraft.world.entity.Entity
-
onRemovedFromWorld
public void onRemovedFromWorld()- Specified by:
onRemovedFromWorldin interfacenet.minecraftforge.common.extensions.IForgeEntity- Overrides:
onRemovedFromWorldin classnet.minecraft.world.entity.Entity
-
doExtraCleanupTasks
protected void doExtraCleanupTasks(boolean removingSemiblock) Called by onRemovedFromWorld() to finalize semiblock removal. Override in subclasses.- Parameters:
removingSemiblock- true if this semiblock is actually being removed from world, false if removing to chunk unloading
-
isNoGravity
public boolean isNoGravity()- Overrides:
isNoGravityin classnet.minecraft.world.entity.Entity
-
isPickable
public boolean isPickable()- Overrides:
isPickablein classnet.minecraft.world.entity.Entity
-
getTrackingId
public int getTrackingId()Description copied from interface:ISemiBlockGet the tracking for this semiblock; this should only be used for network sync purposes, and is subject to change on a world reload.- Specified by:
getTrackingIdin interfaceISemiBlock- Returns:
- the underlying entity's ID, or -1 if the entity has not been added to the world
- See Also:
-
canCoexist
Description copied from interface:ISemiBlockCheck if this semiblock can coexist with the other semiblock, in the same block pos. By default this is true if at least one of the semiblocks is aIDirectionalSemiblockand both semiblocks have a different side.- Specified by:
canCoexistin interfaceISemiBlock- Parameters:
otherSemiblock- the other semiblock- Returns:
- true if they can coexist, false otherwise
-
killedByEntity
public void killedByEntity(net.minecraft.world.entity.Entity entity) Description copied from interface:ISemiBlockCalled when an entity has caused this semiblock to be removed; usually, but necessarily, a player wrenching or hitting it.- Specified by:
killedByEntityin interfaceISemiBlock- Parameters:
entity- the killer entity
-
hurt
public boolean hurt(net.minecraft.world.damagesource.DamageSource source, float amount) - Overrides:
hurtin classnet.minecraft.world.entity.Entity
-
getDamageTaken
public float getDamageTaken() -
getTimeSinceHit
public int getTimeSinceHit() -
isAir
public boolean isAir() -
handleGUIButtonPress
public void handleGUIButtonPress(String tag, boolean shiftHeld, net.minecraft.server.level.ServerPlayer player) - Specified by:
handleGUIButtonPressin interfaceIGUIButtonSensitive
-
writeToBuf
public void writeToBuf(net.minecraft.network.FriendlyByteBuf payload) Description copied from interface:ISemiBlockWrite this semiblock to network buffer for network sync purposes.- Specified by:
writeToBufin interfaceISemiBlock- Parameters:
payload- the buffer
-
readFromBuf
public void readFromBuf(net.minecraft.network.FriendlyByteBuf payload) Description copied from interface:ISemiBlockRead this semiblock from network buffer for network sync purposes.- Specified by:
readFromBufin interfaceISemiBlock- Parameters:
payload- the buffer
-