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 Classes
    Modifier and Type
    Class
    Description
    class 
     

    Nested 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, worldPosition

    Fields inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity

    INFINITE_EXTENT_AABB
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractPneumaticCraftBlockEntity(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 Type
    Method
    Description
    void
    Called lazily to populate the method registry with the methods.
    int
    Get the number of players who have a GUI open for this block entity.
    net.minecraft.world.level.block.entity.BlockEntity
    getCachedNeighbor(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)
     
    void
    getContentsToDrop(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 purposes
    net.minecraft.network.chat.Component
     
     
    net.minecraft.network.chat.Component
     
    net.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.IModelData
     
    net.minecraft.network.chat.Component
     
    Get a unique identifier for this type of method provider.
    net.minecraft.core.BlockPos
    We don't override getUpdatePacket() or onDataPacket() because BE sync'ing is all handled by our custom PacketDescription and the @DescSynced system
    abstract net.minecraftforge.items.IItemHandler
     
    net.minecraft.core.Direction
     
    float
     
    float
     
    net.minecraft.nbt.CompoundTag
     
     
     
    int
     
    void
    handleGUIButtonPress(String tag, boolean shiftHeld, net.minecraft.server.level.ServerPlayer player)
     
    void
    handleUpdateTag(net.minecraft.nbt.CompoundTag tag)
     
    boolean
    isGuiUseableByPlayer(net.minecraft.world.entity.player.Player player)
     
    void
    load(net.minecraft.nbt.CompoundTag tag)
     
    net.minecraft.world.level.Level
     
    void
     
    void
     
    void
    Called when a key is synced in the container.
    void
     
    void
    onNeighborBlockUpdate(net.minecraft.core.BlockPos fromPos)
    Called when a neighboring block changes state (i.e.
    void
    onNeighborTileUpdate(net.minecraft.core.BlockPos tilePos)
    Called when a neighboring block entity changes state (specifically when Level.updateNeighbourForOutputSignal(BlockPos, Block) is called.
    void
    Called when a machine's upgrades have changed in any way.
    void
    readFromPacket(net.minecraft.nbt.CompoundTag tag)
    Encoded into the description packet.
    void
     
    void
    saveAdditional(net.minecraft.nbt.CompoundTag tag)
     
    final void
    Force a sync of this BE to the client right now.
    void
    serializeExtraItemData(net.minecraft.nbt.CompoundTag blockEntityTag, boolean preserveState)
    Get any extra data to be serialized onto a dropped item stack.
    void
     
    void
    setCustomName(net.minecraft.network.chat.Component customName)
     
    void
    setPreserveStateOnBreak(boolean preserveStateOnBreak)
     
    void
     
    boolean
    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.
    protected boolean
     
    boolean
    shouldSyncField(int idx)
     
    protected void
     
    void
    writeToPacket(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, triggerEvent

    Methods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider

    areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, invalidateCaps, reviveCaps, serializeCaps

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider

    getCapability

    Methods inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity

    deserializeNBT, getRenderBoundingBox, onDataPacket, serializeNBT

    Methods 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:
      getName in interface net.minecraft.world.Nameable
    • getCustomName

      @Nullable public net.minecraft.network.chat.Component getCustomName()
      Specified by:
      getCustomName in interface net.minecraft.world.Nameable
    • setCustomName

      public void setCustomName(net.minecraft.network.chat.Component customName)
    • getDisplayName

      public net.minecraft.network.chat.Component getDisplayName()
      Specified by:
      getDisplayName in interface net.minecraft.world.Nameable
    • getUpdateTag

      public net.minecraft.nbt.CompoundTag getUpdateTag()
      Overrides:
      getUpdateTag in class net.minecraft.world.level.block.entity.BlockEntity
    • handleUpdateTag

      public void handleUpdateTag(net.minecraft.nbt.CompoundTag tag)
      Specified by:
      handleUpdateTag in interface net.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:
      getPosition in interface IDescSynced
    • shouldSyncField

      public boolean shouldSyncField(int idx)
      Specified by:
      shouldSyncField in interface IDescSynced
    • getDescriptionFields

      public List<SyncedField<?>> getDescriptionFields()
      Specified by:
      getDescriptionFields in interface IDescSynced
    • sendDescriptionPacket

      public final void sendDescriptionPacket()
      Force a sync of this BE to the client right now.
    • setRemoved

      public void setRemoved()
      Overrides:
      setRemoved in class net.minecraft.world.level.block.entity.BlockEntity
    • setChanged

      public void setChanged()
      Overrides:
      setChanged in class net.minecraft.world.level.block.entity.BlockEntity
    • onLoad

      public void onLoad()
      Specified by:
      onLoad in interface net.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 by BlockEntity.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:
      writeToPacket in interface IDescSynced
      Parameters:
      tag - NBT tag
    • readFromPacket

      public void readFromPacket(net.minecraft.nbt.CompoundTag tag)
      Encoded into the description packet. Also included in saved data read by load(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:
      readFromPacket in interface IDescSynced
      Parameters:
      tag - NBT tag
    • saveAdditional

      public void saveAdditional(net.minecraft.nbt.CompoundTag tag)
      Overrides:
      saveAdditional in class net.minecraft.world.level.block.entity.BlockEntity
    • load

      public void load(net.minecraft.nbt.CompoundTag tag)
      Overrides:
      load in class net.minecraft.world.level.block.entity.BlockEntity
    • onDescUpdate

      public void onDescUpdate()
      Specified by:
      onDescUpdate in interface IDescSynced
    • getModelData

      @Nonnull public net.minecraftforge.client.model.data.IModelData getModelData()
      Specified by:
      getModelData in interface net.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

      public int getUpgrades(PNCUpgrade upgrade)
    • getSpeedMultiplierFromUpgrades

      public float getSpeedMultiplierFromUpgrades()
    • getSpeedUsageMultiplierFromUpgrades

      public float getSpeedUsageMultiplierFromUpgrades()
    • handleGUIButtonPress

      public void handleGUIButtonPress(String tag, boolean shiftHeld, net.minecraft.server.level.ServerPlayer player)
      Specified by:
      handleGUIButtonPress in interface IGUIButtonSensitive
    • 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 when Level.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

      public void addLuaMethods(LuaMethodRegistry registry)
      Description copied from interface: ILuaMethodProvider
      Called lazily to populate the method registry with the methods.
      Specified by:
      addLuaMethods in interface ILuaMethodProvider
      Parameters:
      registry - the registry to populate
    • getLuaMethodRegistry

      public LuaMethodRegistry getLuaMethodRegistry()
      Description copied from interface: ILuaMethodProvider
      Get this BE's method registry object. This should be created in the BE constructor, but not populated with methods yet.
      Specified by:
      getLuaMethodRegistry in interface ILuaMethodProvider
      Returns:
      the method registry
    • getPeripheralType

      public String getPeripheralType()
      Description copied from interface: ILuaMethodProvider
      Get a unique identifier for this type of method provider. The BE's type (a registry ID) is a good choice.
      Specified by:
      getPeripheralType in interface ILuaMethodProvider
      Returns:
      a unique string identifier
    • getPrimaryInventory

      public abstract net.minecraftforge.items.IItemHandler getPrimaryInventory()
    • getUpgradeHandler

      Specified by:
      getUpgradeHandler in interface IUpgradeHolder
    • 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:
      getCapability in interface net.minecraftforge.common.capabilities.ICapabilityProvider
      Overrides:
      getCapability in class net.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

      public String 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:
      onUpgradesChanged in interface IUpgradeHolder
    • getUpgradeCache

      public UpgradeCache 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 to BlockEntity.load(CompoundTag) method) when the itemblock is next placed.
      Parameters:
      blockEntityTag - the existing "BlockEntityTag" subtag to add data to
      preserveState - 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:
      requestModelDataUpdate in interface net.minecraftforge.common.extensions.IForgeBlockEntity