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, worldPositionFields inherited from interface net.fabricmc.fabric.api.attachment.v1.AttachmentTarget
NBT_ATTACHMENT_KEY -
Constructor Summary
ConstructorsConstructorDescriptionUBlockEntity(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 TypeMethodDescriptionnet.minecraft.network.protocol.game.ClientboundBlockEntityDataPacketnet.minecraft.nbt.CompoundTagdefault voidhandleChunkLoadData(net.minecraft.nbt.CompoundTag tag) The data from the chunk load is received here.default voidhandleUpdateStateData(net.minecraft.nbt.CompoundTag tag) The data from the block update is received here.voidload(net.minecraft.nbt.CompoundTag tag) voidloadNBT(net.minecraft.nbt.CompoundTag tag) Reads data from disk.voidreceiveUpdatePacket(net.minecraft.network.Connection connection, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet) voidreceiveUpdateTag(net.minecraft.nbt.CompoundTag tag) voidsaveAdditional(net.minecraft.nbt.CompoundTag tag) voidsaveNBT(net.minecraft.nbt.CompoundTag tag) Save data to disk.voidCallssendChangesToClient(int)with flag 2 (send changes to client)voidsendChangesToClient(int flags) Triggers a block update to send the data from the server to the client.default voidsendChunkLoadData(net.minecraft.nbt.CompoundTag tag) Data here will be send to the client side when the chunk is loaded.default voidsendUpdateStateData(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, triggerEventMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.fabricmc.fabric.api.attachment.v1.AttachmentTarget
getAttached, getAttachedOrCreate, getAttachedOrCreate, getAttachedOrElse, getAttachedOrGet, getAttachedOrSet, getAttachedOrThrow, hasAttached, modifyAttached, removeAttached, setAttachedMethods 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:
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
-
saveNBT
public void saveNBT(net.minecraft.nbt.CompoundTag tag) Save data to disk. To mark the block entity to save dataBlockEntity.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:
getUpdateTagin classnet.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:
getUpdatePacketin classnet.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()CallssendChangesToClient(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 inSyncedBlockEntity.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 fromSyncedBlockEntity.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 inSyncedBlockEntity.handleUpdateStateData(CompoundNBT). To trigger an update callLevel.sendBlockUpdated(BlockPos, BlockState, BlockState, int)orsendChangesToClient(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 fromSyncedBlockEntity.sendUpdateStateData(CompoundNBT)- Parameters:
tag-
-