Class CyclopsBlockEntity
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity
- All Implemented Interfaces:
net.neoforged.neoforge.attachment.IAttachmentHolder
,net.neoforged.neoforge.common.extensions.IBlockEntityExtension
,net.neoforged.neoforge.common.util.INBTSerializable<net.minecraft.nbt.CompoundTag>
,IBlockEntityDelayedTickable
,IDirtyMarkListener
,INBTProvider
public class CyclopsBlockEntity
extends net.minecraft.world.level.block.entity.BlockEntity
implements INBTProvider, IDirtyMarkListener, IBlockEntityDelayedTickable
A base class for all the block entities.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
net.neoforged.neoforge.attachment.AttachmentHolder.AsField
-
Field Summary
Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPosition
Fields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY
-
Constructor Summary
ConstructorDescriptionCyclopsBlockEntity
(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canInteractWith
(net.minecraft.world.entity.player.Player entityPlayer) If this entity is interactable with a player.net.minecraft.core.Direction
int
int
net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
net.minecraft.nbt.CompoundTag
final void
load
(net.minecraft.nbt.CompoundTag tag) void
onDataPacket
(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet) void
onDirty()
Called when the target is marked as dirty.void
This method is called when the block entity receives an update (ie a data packet) from the server.void
read
(net.minecraft.nbt.CompoundTag tag) protected void
registerCapabilities
(net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent event) void
saveAdditional
(net.minecraft.nbt.CompoundTag tag) void
Send a world update for the coordinates of this block entity.void
setUpdateBackoff
(int updateBackoff) Set the update backoff delay.boolean
protected net.minecraft.core.Direction
transformFacingForRotation
(net.minecraft.core.Direction facing) void
Reset the send update flag.net.minecraft.nbt.CompoundTag
writeToItemStack
(net.minecraft.nbt.CompoundTag tag) Write this block entity to the given NBT tag that will be attached to an item.Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, clearRemoved, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, hasLevel, isRemoved, loadStatic, onlyOpCanSetNbt, removeData, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setData, setLevel, setRemoved, triggerEvent
Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
areAttachmentsCompatible, deserializeAttachments, getData, hasAttachments, hasData, serializeAttachments
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, hasData, removeData, setData
Methods inherited from interface org.cyclops.cyclopscore.blockentity.IBlockEntityDelayedTickable
reduceUpdateBackoff, sendImmediateUpdate
Methods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
deserializeNBT, getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onLoad, requestModelDataUpdate, serializeNBT
Methods inherited from interface org.cyclops.cyclopscore.persist.nbt.INBTProvider
readGeneratedFieldsFromNBT, writeGeneratedFieldsToNBT
-
Constructor Details
-
CyclopsBlockEntity
public CyclopsBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> type, net.minecraft.core.BlockPos blockPos, net.minecraft.world.level.block.state.BlockState blockState)
-
-
Method Details
-
registerCapabilities
protected void registerCapabilities(net.neoforged.neoforge.capabilities.RegisterCapabilitiesEvent event) -
getUpdateBackoffTicks
public int getUpdateBackoffTicks()- Specified by:
getUpdateBackoffTicks
in interfaceIBlockEntityDelayedTickable
- Returns:
- The minimum amount of ticks between two consecutive sent packets.
-
sendUpdate
public void sendUpdate()Description copied from interface:IBlockEntityDelayedTickable
Send a world update for the coordinates of this block entity. This will always send lag-safe updates, so calling this many times per tick will not cause multiple packets to be sent, more info in the class javadoc.- Specified by:
sendUpdate
in interfaceIBlockEntityDelayedTickable
-
shouldSendUpdate
public boolean shouldSendUpdate()- Specified by:
shouldSendUpdate
in interfaceIBlockEntityDelayedTickable
- Returns:
- If an update should be sent.
-
unsetSendUpdate
public void unsetSendUpdate()Description copied from interface:IBlockEntityDelayedTickable
Reset the send update flag.- Specified by:
unsetSendUpdate
in interfaceIBlockEntityDelayedTickable
-
setUpdateBackoff
public void setUpdateBackoff(int updateBackoff) Description copied from interface:IBlockEntityDelayedTickable
Set the update backoff delay.- Specified by:
setUpdateBackoff
in interfaceIBlockEntityDelayedTickable
- Parameters:
updateBackoff
- The new delay in ticks.
-
getUpdateBackoff
public int getUpdateBackoff()- Specified by:
getUpdateBackoff
in interfaceIBlockEntityDelayedTickable
- Returns:
- The current update backoff in ticks.
-
getUpdatePacket
public net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket getUpdatePacket()- Overrides:
getUpdatePacket
in classnet.minecraft.world.level.block.entity.BlockEntity
-
onDataPacket
public void onDataPacket(net.minecraft.network.Connection net, net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket packet) - Specified by:
onDataPacket
in interfacenet.neoforged.neoforge.common.extensions.IBlockEntityExtension
-
onUpdateReceived
public void onUpdateReceived()This method is called when the block entity receives an update (ie a data packet) from the server. If this block entity uses NBT, then the NBT will have already been updated when this method is called. -
canInteractWith
public boolean canInteractWith(net.minecraft.world.entity.player.Player entityPlayer) If this entity is interactable with a player.- Parameters:
entityPlayer
- The player that is checked.- Returns:
- If the given player can interact.
-
saveAdditional
public void saveAdditional(net.minecraft.nbt.CompoundTag tag) - Overrides:
saveAdditional
in classnet.minecraft.world.level.block.entity.BlockEntity
-
writeToItemStack
public net.minecraft.nbt.CompoundTag writeToItemStack(net.minecraft.nbt.CompoundTag tag) Write this block entity to the given NBT tag that will be attached to an item. By default,saveAdditional(CompoundTag)
} will be called.- Parameters:
tag
- The tag to write to.- Returns:
- The written tag.
-
load
public final void load(net.minecraft.nbt.CompoundTag tag) - Overrides:
load
in classnet.minecraft.world.level.block.entity.BlockEntity
-
read
public void read(net.minecraft.nbt.CompoundTag tag) -
getUpdateTag
public net.minecraft.nbt.CompoundTag getUpdateTag()- Overrides:
getUpdateTag
in classnet.minecraft.world.level.block.entity.BlockEntity
-
transformFacingForRotation
protected net.minecraft.core.Direction transformFacingForRotation(net.minecraft.core.Direction facing) -
getRotation
public net.minecraft.core.Direction getRotation() -
onDirty
public void onDirty()Description copied from interface:IDirtyMarkListener
Called when the target is marked as dirty.- Specified by:
onDirty
in interfaceIDirtyMarkListener
-