Class UBlockEntity

java.lang.Object
net.minecraft.world.level.block.entity.BlockEntity
info.u_team.u_team_core.blockentity.UBlockEntity
All Implemented Interfaces:
net.fabricmc.fabric.api.attachment.v1.AttachmentTarget, net.fabricmc.fabric.api.blockview.v2.RenderDataBlockEntity

public abstract class UBlockEntity extends net.minecraft.world.level.block.entity.BlockEntity
Basic implementation of BlockEntity with some extra data synchronization methods.
  • Field Summary

    Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity

    level, remove, worldPosition

    Fields inherited from interface net.fabricmc.fabric.api.attachment.v1.AttachmentTarget

    NBT_ATTACHMENT_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    UBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
     
    net.minecraft.nbt.CompoundTag
     
    default void
    handleChunkLoadData(net.minecraft.nbt.CompoundTag tag)
    The data from the chunk load is received here.
    default void
    handleUpdateStateData(net.minecraft.nbt.CompoundTag tag)
    The data from the block update is received here.
    void
    load(net.minecraft.nbt.CompoundTag tag)
     
    void
    loadNBT(net.minecraft.nbt.CompoundTag tag)
    Reads data from disk.
    void
    receiveUpdatePacket(net.minecraft.network.Connection connection, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet)
     
    void
    receiveUpdateTag(net.minecraft.nbt.CompoundTag tag)
     
    void
    saveAdditional(net.minecraft.nbt.CompoundTag tag)
     
    void
    saveNBT(net.minecraft.nbt.CompoundTag tag)
    Save data to disk.
    void
    Calls sendChangesToClient(int) with flag 2 (send changes to client)
    void
    Triggers a block update to send the data from the server to the client.
    default void
    sendChunkLoadData(net.minecraft.nbt.CompoundTag tag)
    Data here will be send to the client side when the chunk is loaded.
    default void
    sendUpdateStateData(net.minecraft.nbt.CompoundTag tag)
    Data here will be send to the client side when the block is updated.

    Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity

    addEntityType, clearRemoved, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPosFromTag, getType, hasLevel, isRemoved, loadStatic, onlyOpCanSetNbt, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setLevel, setRemoved, triggerEvent

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface net.fabricmc.fabric.api.attachment.v1.AttachmentTarget

    getAttached, getAttachedOrCreate, getAttachedOrCreate, getAttachedOrElse, getAttachedOrGet, getAttachedOrSet, getAttachedOrThrow, hasAttached, modifyAttached, removeAttached, setAttached

    Methods inherited from interface net.fabricmc.fabric.api.blockview.v2.RenderDataBlockEntity

    getRenderData
  • Constructor Details

    • UBlockEntity

      public UBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
  • Method Details

    • 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
    • saveNBT

      public void saveNBT(net.minecraft.nbt.CompoundTag tag)
      Save data to disk. To mark the block entity to save data BlockEntity.setChanged() must be called.
      Parameters:
      tag -
    • loadNBT

      public void loadNBT(net.minecraft.nbt.CompoundTag tag)
      Reads data from disk.
      Parameters:
      tag -
    • getUpdateTag

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

      public void receiveUpdateTag(net.minecraft.nbt.CompoundTag tag)
    • getUpdatePacket

      public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket getUpdatePacket()
      Overrides:
      getUpdatePacket in class net.minecraft.world.level.block.entity.BlockEntity
    • receiveUpdatePacket

      public void receiveUpdatePacket(net.minecraft.network.Connection connection, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet)
    • sendChangesToClient

      public void sendChangesToClient()
      Calls sendChangesToClient(int) with flag 2 (send changes to client)
    • sendChangesToClient

      public void sendChangesToClient(int flags)
      Triggers a block update to send the data from the server to the client. For flags see here: Level.setBlock(BlockPos, BlockState, int)
      Parameters:
      flags - Are described above
    • sendChunkLoadData

      default void sendChunkLoadData(net.minecraft.nbt.CompoundTag tag)
      Data here will be send to the client side when the chunk is loaded. The data is received in SyncedBlockEntity.handleChunkLoadData(CompoundNBT)
      Parameters:
      tag -
    • handleChunkLoadData

      default void handleChunkLoadData(net.minecraft.nbt.CompoundTag tag)
      The data from the chunk load is received here. The data is send from SyncedBlockEntity.sendChunkLoadData(CompoundNBT)
      Parameters:
      tag -
    • sendUpdateStateData

      default void sendUpdateStateData(net.minecraft.nbt.CompoundTag tag)
      Data here will be send to the client side when the block is updated. The data is received in SyncedBlockEntity.handleUpdateStateData(CompoundNBT). To trigger an update call Level.sendBlockUpdated(BlockPos, BlockState, BlockState, int) or sendChangesToClient(int)
      Parameters:
      tag -
    • handleUpdateStateData

      default void handleUpdateStateData(net.minecraft.nbt.CompoundTag tag)
      The data from the block update is received here. The data is send from SyncedBlockEntity.sendUpdateStateData(CompoundNBT)
      Parameters:
      tag -