Class CyclopsBlockEntity
java.lang.Object
net.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.level.block.entity.BlockEntity>
net.minecraft.world.level.block.entity.BlockEntity
org.cyclops.cyclopscore.blockentity.CyclopsBlockEntity
- All Implemented Interfaces:
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>
,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.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
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 TypeMethodDescription<T> void
addCapabilityInternal
(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraftforge.common.util.LazyOptional<T> value) Add a sideless capability.<T> void
addCapabilitySided
(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.core.Direction facing, net.minecraftforge.common.util.LazyOptional<T> value) Add a sided capability.boolean
canInteractWith
(net.minecraft.world.entity.player.Player entityPlayer) If this entity is interactable with a player.<T> net.minecraftforge.common.util.LazyOptional<T>
getCapability
(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.core.Direction facing) net.minecraft.core.Direction
protected Map<org.apache.commons.lang3.tuple.Pair<net.minecraftforge.common.capabilities.Capability<?>,
net.minecraft.core.Direction>, net.minecraftforge.common.util.LazyOptional<?>> int
int
net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
net.minecraft.nbt.CompoundTag
void
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
onLoad()
When the block entity is loaded or created.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) 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, onChunkUnloaded, onlyOpCanSetNbt, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setLevel, setRemoved, triggerEvent
Methods inherited from class net.minecraftforge.common.capabilities.CapabilityProvider
areCapsCompatible, areCapsCompatible, deserializeCaps, gatherCapabilities, gatherCapabilities, gatherCapabilities, getCapabilities, reviveCaps, serializeCaps
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cyclops.cyclopscore.blockentity.IBlockEntityDelayedTickable
reduceUpdateBackoff, sendImmediateUpdate
Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider
getCapability
Methods inherited from interface net.minecraftforge.common.extensions.IForgeBlockEntity
deserializeNBT, getModelData, getRenderBoundingBox, handleUpdateTag, hasCustomOutlineRendering, 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
-
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.minecraftforge.common.extensions.IForgeBlockEntity
-
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) -
onLoad
public void onLoad()When the block entity is loaded or created.- Specified by:
onLoad
in interfacenet.minecraftforge.common.extensions.IForgeBlockEntity
-
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() -
getCapability
public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.core.Direction facing) - Specified by:
getCapability
in interfacenet.minecraftforge.common.capabilities.ICapabilityProvider
- Overrides:
getCapability
in classnet.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.level.block.entity.BlockEntity>
-
invalidateCaps
public void invalidateCaps()- Specified by:
invalidateCaps
in interfacenet.minecraftforge.common.capabilities.ICapabilityProviderImpl<net.minecraft.world.level.block.entity.BlockEntity>
- Overrides:
invalidateCaps
in classnet.minecraftforge.common.capabilities.CapabilityProvider<net.minecraft.world.level.block.entity.BlockEntity>
-
addCapabilityInternal
public <T> void addCapabilityInternal(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraftforge.common.util.LazyOptional<T> value) Add a sideless capability. This can only be called at block entity construction time!- Type Parameters:
T
- The capability type.- Parameters:
capability
- The capability type.value
- The capability.
-
addCapabilitySided
public <T> void addCapabilitySided(net.minecraftforge.common.capabilities.Capability<T> capability, net.minecraft.core.Direction facing, net.minecraftforge.common.util.LazyOptional<T> value) Add a sided capability. This can only be called at block entity construction time!- Type Parameters:
T
- The capability type.- Parameters:
capability
- The capability type.facing
- The side for the capability.value
- The capability.
-
getStoredCapabilities
protected Map<org.apache.commons.lang3.tuple.Pair<net.minecraftforge.common.capabilities.Capability<?>,net.minecraft.core.Direction>, getStoredCapabilities()net.minecraftforge.common.util.LazyOptional<?>> -
onDirty
public void onDirty()Description copied from interface:IDirtyMarkListener
Called when the target is marked as dirty.- Specified by:
onDirty
in interfaceIDirtyMarkListener
-