Class AbstractPneumaticCraftBlockEntity
java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.level.block.entity.BlockEntity>
net.minecraft.world.level.block.entity.BlockEntity
me.desht.pneumaticcraft.common.block.entity.AbstractPneumaticCraftBlockEntity
- All Implemented Interfaces:
IGUIButtonSensitive,ILuaMethodProvider,IDescSynced,IUpgradeHolder,net.minecraft.world.Nameable,net.minecraftforge.common.capabilities.ICapabilityProvider,net.minecraftforge.common.capabilities.ICapabilityProviderImpl<net.minecraft.world.level.block.entity.BlockEntity>,net.minecraftforge.common.capabilities.ICapabilitySerializable<net.minecraft.nbt.CompoundTag>,net.minecraftforge.common.extensions.IForgeBlockEntity,net.minecraftforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
- Direct Known Subclasses:
AbstractTickingBlockEntity,AphorismTileBlockEntity,DisplayTableBlockEntity,ElevatorFrameBlockEntity,ReinforcedChestBlockEntity
public abstract class AbstractPneumaticCraftBlockEntity
extends net.minecraft.world.level.block.entity.BlockEntity
implements net.minecraft.world.Nameable, IGUIButtonSensitive, IDescSynced, IUpgradeHolder, ILuaMethodProvider
-
Nested Class Summary
Nested ClassesNested 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.level.block.entity.BlockEntity
level, remove, worldPositionFields inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity
INFINITE_EXTENT_AABB -
Constructor Summary
ConstructorsConstructorDescriptionAbstractPneumaticCraftBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) AbstractPneumaticCraftBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int upgradeSize) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddLuaMethods(LuaMethodRegistry registry) Called lazily to populate the method registry with the methods.intGet the number of players who have a GUI open for this block entity.net.minecraft.world.level.block.entity.BlockEntitygetCachedNeighbor(net.minecraft.core.Direction dir) <T> net.minecraftforge.common.util.LazyOptional<T>getCapability(net.minecraftforge.common.capabilities.Capability<T> cap, net.minecraft.core.Direction side) voidgetContentsToDrop(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> drops) Collect all items which should be dropped when this BE is broken.For machines which use recipes, get the synced recipe ID client-side for informational purposesnet.minecraft.network.chat.ComponentList<SyncedField<?>>net.minecraft.network.chat.Componentnet.minecraftforge.common.util.LazyOptional<IHeatExchangerLogic>getHeatCap(net.minecraft.core.Direction side) protected net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler>Get this BE's method registry object.net.minecraftforge.client.model.data.IModelDatanet.minecraft.network.chat.ComponentgetName()Get a unique identifier for this type of method provider.net.minecraft.core.BlockPosWe don't override getUpdatePacket() or onDataPacket() because BE sync'ing is all handled by our custom PacketDescription and the @DescSynced systemabstract net.minecraftforge.items.IItemHandlernet.minecraft.core.Directionfloatfloatnet.minecraft.nbt.CompoundTagintgetUpgrades(PNCUpgrade upgrade) voidhandleGUIButtonPress(String tag, boolean shiftHeld, net.minecraft.server.level.ServerPlayer player) voidhandleUpdateTag(net.minecraft.nbt.CompoundTag tag) booleanisGuiUseableByPlayer(net.minecraft.world.entity.player.Player player) voidload(net.minecraft.nbt.CompoundTag tag) net.minecraft.world.level.LevelvoidvoidvoidCalled when a key is synced in the container.voidonLoad()voidonNeighborBlockUpdate(net.minecraft.core.BlockPos fromPos) Called when a neighboring block changes state (i.e.voidonNeighborTileUpdate(net.minecraft.core.BlockPos tilePos) Called when a neighboring block entity changes state (specifically whenLevel.updateNeighbourForOutputSignal(BlockPos, Block)is called.voidCalled when a machine's upgrades have changed in any way.voidreadFromPacket(net.minecraft.nbt.CompoundTag tag) Encoded into the description packet.voidvoidsaveAdditional(net.minecraft.nbt.CompoundTag tag) final voidForce a sync of this BE to the client right now.voidserializeExtraItemData(net.minecraft.nbt.CompoundTag blockEntityTag, boolean preserveState) Get any extra data to be serialized onto a dropped item stack.voidvoidsetCustomName(net.minecraft.network.chat.Component customName) voidsetPreserveStateOnBreak(boolean preserveStateOnBreak) voidbooleanShould this block entity preserve its state (currently: upgrades and stored air) when broken? By default this is true when sneak-wrenched, and false when broken by pick.protected booleanbooleanshouldSyncField(int idx) protected voidvoidwriteToPacket(net.minecraft.nbt.CompoundTag tag) Encoded into the description packet.Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, clearRemoved, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPosFromTag, getTileData, getType, getUpdatePacket, hasLevel, isRemoved, loadStatic, onChunkUnloaded, onlyOpCanSetNbt, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setLevel, triggerEventMethods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, invalidateCaps, reviveCaps, serializeCapsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapabilityMethods inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity
deserializeNBT, getRenderBoundingBox, onDataPacket, serializeNBTMethods inherited from interface net.minecraft.world.Nameable
hasCustomName
-
Constructor Details
-
AbstractPneumaticCraftBlockEntity
public AbstractPneumaticCraftBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state) -
AbstractPneumaticCraftBlockEntity
public AbstractPneumaticCraftBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state, int upgradeSize)
-
-
Method Details
-
nonNullLevel
@Nonnull public net.minecraft.world.level.Level nonNullLevel() -
getName
public net.minecraft.network.chat.Component getName()- Specified by:
getNamein interfacenet.minecraft.world.Nameable
-
getCustomName
@Nullable public net.minecraft.network.chat.Component getCustomName()- Specified by:
getCustomNamein interfacenet.minecraft.world.Nameable
-
setCustomName
public void setCustomName(net.minecraft.network.chat.Component customName) -
getDisplayName
public net.minecraft.network.chat.Component getDisplayName()- Specified by:
getDisplayNamein interfacenet.minecraft.world.Nameable
-
getUpdateTag
public net.minecraft.nbt.CompoundTag getUpdateTag()- Overrides:
getUpdateTagin classnet.minecraft.world.level.block.entity.BlockEntity
-
handleUpdateTag
public void handleUpdateTag(net.minecraft.nbt.CompoundTag tag) - Specified by:
handleUpdateTagin interfacenet.minecraftforge.common.extensions.IForgeBlockEntity
-
getPosition
public net.minecraft.core.BlockPos getPosition()We don't override getUpdatePacket() or onDataPacket() because BE sync'ing is all handled by our custom PacketDescription and the @DescSynced system- Specified by:
getPositionin interfaceIDescSynced
-
shouldSyncField
public boolean shouldSyncField(int idx) - Specified by:
shouldSyncFieldin interfaceIDescSynced
-
getDescriptionFields
- Specified by:
getDescriptionFieldsin interfaceIDescSynced
-
sendDescriptionPacket
public final void sendDescriptionPacket()Force a sync of this BE to the client right now. -
setRemoved
public void setRemoved()- Overrides:
setRemovedin classnet.minecraft.world.level.block.entity.BlockEntity
-
setChanged
public void setChanged()- Overrides:
setChangedin classnet.minecraft.world.level.block.entity.BlockEntity
-
onLoad
public void onLoad()- Specified by:
onLoadin interfacenet.minecraftforge.common.extensions.IForgeBlockEntity
-
updateNeighbours
protected void updateNeighbours() -
onBlockRotated
public void onBlockRotated() -
shouldRerenderChunkOnDescUpdate
protected boolean shouldRerenderChunkOnDescUpdate() -
writeToPacket
public void writeToPacket(net.minecraft.nbt.CompoundTag tag) Encoded into the description packet. Also included in saved data written byBlockEntity.saveAdditional(CompoundTag)Prefer to use @DescSynced where possible - use this either for complex fields not handled by @DescSynced, or for non-ticking tile entities.- Specified by:
writeToPacketin interfaceIDescSynced- Parameters:
tag- NBT tag
-
readFromPacket
public void readFromPacket(net.minecraft.nbt.CompoundTag tag) Encoded into the description packet. Also included in saved data read byload(CompoundTag). Prefer to use @DescSynced where possible - use this either for complex fields not handled by @DescSynced, or for non-ticking tile entities.- Specified by:
readFromPacketin interfaceIDescSynced- Parameters:
tag- NBT tag
-
saveAdditional
public void saveAdditional(net.minecraft.nbt.CompoundTag tag) - Overrides:
saveAdditionalin classnet.minecraft.world.level.block.entity.BlockEntity
-
load
public void load(net.minecraft.nbt.CompoundTag tag) - Overrides:
loadin classnet.minecraft.world.level.block.entity.BlockEntity
-
onDescUpdate
public void onDescUpdate()- Specified by:
onDescUpdatein interfaceIDescSynced
-
getModelData
@Nonnull public net.minecraftforge.client.model.data.IModelData getModelData()- Specified by:
getModelDatain interfacenet.minecraftforge.common.extensions.IForgeBlockEntity
-
onGuiUpdate
public void onGuiUpdate()Called when a key is synced in the container. -
getRotation
public net.minecraft.core.Direction getRotation() -
getUpgrades
-
getSpeedMultiplierFromUpgrades
public float getSpeedMultiplierFromUpgrades() -
getSpeedUsageMultiplierFromUpgrades
public float getSpeedUsageMultiplierFromUpgrades() -
handleGUIButtonPress
public void handleGUIButtonPress(String tag, boolean shiftHeld, net.minecraft.server.level.ServerPlayer player) - Specified by:
handleGUIButtonPressin interfaceIGUIButtonSensitive
-
isGuiUseableByPlayer
public boolean isGuiUseableByPlayer(net.minecraft.world.entity.player.Player player) -
getCachedNeighbor
public net.minecraft.world.level.block.entity.BlockEntity getCachedNeighbor(net.minecraft.core.Direction dir) -
onNeighborTileUpdate
public void onNeighborTileUpdate(net.minecraft.core.BlockPos tilePos) Called when a neighboring block entity changes state (specifically whenLevel.updateNeighbourForOutputSignal(BlockPos, Block)is called.- Parameters:
tilePos- the blockpos of the neighboring block entity
-
onNeighborBlockUpdate
public void onNeighborBlockUpdate(net.minecraft.core.BlockPos fromPos) Called when a neighboring block changes state (i.e. blockstate update)- Parameters:
fromPos- the blockpos of the block that caused this update
-
addLuaMethods
Description copied from interface:ILuaMethodProviderCalled lazily to populate the method registry with the methods.- Specified by:
addLuaMethodsin interfaceILuaMethodProvider- Parameters:
registry- the registry to populate
-
getLuaMethodRegistry
Description copied from interface:ILuaMethodProviderGet this BE's method registry object. This should be created in the BE constructor, but not populated with methods yet.- Specified by:
getLuaMethodRegistryin interfaceILuaMethodProvider- Returns:
- the method registry
-
getPeripheralType
Description copied from interface:ILuaMethodProviderGet a unique identifier for this type of method provider. The BE's type (a registry ID) is a good choice.- Specified by:
getPeripheralTypein interfaceILuaMethodProvider- Returns:
- a unique string identifier
-
getPrimaryInventory
public abstract net.minecraftforge.items.IItemHandler getPrimaryInventory() -
getUpgradeHandler
- Specified by:
getUpgradeHandlerin interfaceIUpgradeHolder
-
getCapability
@Nonnull public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(@Nonnull net.minecraftforge.common.capabilities.Capability<T> cap, @Nullable net.minecraft.core.Direction side) - Specified by:
getCapabilityin interfacenet.minecraftforge.common.capabilities.ICapabilityProvider- Overrides:
getCapabilityin classnet.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.level.block.entity.BlockEntity>
-
getInventoryCap
@Nonnull protected net.minecraftforge.common.util.LazyOptional<net.minecraftforge.items.IItemHandler> getInventoryCap() -
getHeatCap
@Nonnull public net.minecraftforge.common.util.LazyOptional<IHeatExchangerLogic> getHeatCap(net.minecraft.core.Direction side) -
getContentsToDrop
public void getContentsToDrop(net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> drops) Collect all items which should be dropped when this BE is broken. Override and extend this in subclassing BE's which have extra inventories to be dropped.- Parameters:
drops- list in which to collect dropped items
-
shouldPreserveStateOnBreak
public boolean shouldPreserveStateOnBreak()Should this block entity preserve its state (currently: upgrades and stored air) when broken? By default this is true when sneak-wrenched, and false when broken by pick.- Returns:
- true if state should be preserved, false otherwise
-
setPreserveStateOnBreak
public void setPreserveStateOnBreak(boolean preserveStateOnBreak) -
getCurrentRecipeIdSynced
For machines which use recipes, get the synced recipe ID client-side for informational purposes- Returns:
- the recipe id (in string form), or the empty string if no current recipe or not applicable
-
onUpgradesChanged
public void onUpgradesChanged()Called when a machine's upgrades have changed in any way. This is also called from readNBT() when saved upgrades are deserialized, so it is not guaranteed that the world field is non-null - beware. If you override this, remember to call the super method!- Specified by:
onUpgradesChangedin interfaceIUpgradeHolder
-
getUpgradeCache
-
serializeExtraItemData
public void serializeExtraItemData(net.minecraft.nbt.CompoundTag blockEntityTag, boolean preserveState) Get any extra data to be serialized onto a dropped item stack. The supplied tag is the "BlockEntityTag" subtag of the item's NBT data, so will be automatically deserialized into the BE (i.e. available toBlockEntity.load(CompoundTag)method) when the itemblock is next placed.- Parameters:
blockEntityTag- the existing "BlockEntityTag" subtag to add data topreserveState- true when dropped with a wrench, false when broken with a pickaxe etc.
-
countPlayersUsing
public int countPlayersUsing()Get the number of players who have a GUI open for this block entity. Only use this server-side.- Returns:
- the player count
-
requestModelDataUpdate
public void requestModelDataUpdate()- Specified by:
requestModelDataUpdatein interfacenet.minecraftforge.common.extensions.IForgeBlockEntity
-