public final class CasingBlockEntity extends AbstractComputerBlockEntity implements SidedInventoryProxy, CasingProxy
Manages modules installed in it and takes care of maintaining network state with other casings (i.e. injects virtual forwarding module in slots between two casing blocks to relay data between the casings).
Also takes care of notifying a connected controller if some state changed, so that the controller can re-scan for a multi-block.
Casings do not tick. The modules installed in them are driven by a controller (transitively) connected to their casing.
| Modifier and Type | Field and Description |
|---|---|
static net.minecraft.block.entity.BlockEntityType<CasingBlockEntity> |
TYPE |
| Constructor and Description |
|---|
CasingBlockEntity() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canPlayerUseInv(net.minecraft.entity.player.PlayerEntity player) |
void |
fromClientTag(net.minecraft.nbt.CompoundTag nbt) |
Casing |
getCasing() |
ControllerBlockEntity |
getController() |
net.minecraft.inventory.SidedInventory |
getInventory() |
Pipe |
getReceivingPipe(Face face,
Port port)
Receiving pipe for the specified face and port.
|
double |
getSquaredRenderDistance() |
boolean |
isCasingEnabled()
Actual state tracking implementation of enabled state, used in
CasingImpl.isEnabled(). |
boolean |
isReceivingPipeLocked(Face face,
Port port)
Get the current locked state of the specified receiving pipe
on the specified face of the casing.
|
void |
lock(net.minecraft.item.ItemStack stack) |
void |
markRedstoneDirty()
Used to notify the case that redstone inputs may have changed, which
will in turn cause modules implementing
Redstone and/or BundledRedstone
to get notified. |
void |
markRemoved() |
void |
notifyModulesOfBlockChange(net.minecraft.util.math.BlockPos neighborPos) |
void |
onBeforeWriteComplete(Face sendingFace,
Port sendingPort) |
void |
onChunkUnload()
Called when the chunk this block entity sits in is unloaded to allow disposing
state or notifying (still loaded) neighbors and such.
|
void |
onWriteComplete(Face sendingFace,
Port sendingPort) |
protected void |
readFromNBTCommon(net.minecraft.nbt.CompoundTag nbt) |
void |
scheduleScan() |
void |
setCasingLockedClient(boolean locked)
Used for synchronizing state between server and client, letting the
client know the new locked state of a case for overlay rendering.
|
void |
setController(ControllerBlockEntity controller) |
void |
setEnabledClient(boolean value)
Used for synchronizing state between server and client, letting the
client know of the new enabled state of this casing, for rendering.
|
void |
setInventorySlotContents(int index,
net.minecraft.item.ItemStack stack,
Port facing)
Place a module stack into the specified slot, immediately setting the
module's rotation to the specified facing if it is a
Rotatable
module. |
void |
setModule(Face face,
Module module) |
protected void |
setNeighbor(Face face,
AbstractComputerBlockEntity neighbor) |
void |
setReceivingPipeLocked(Face face,
Port port,
boolean value)
Set whether the specified receiving pipe on the specified face
of the casing is locked.
|
void |
setReceivingPipeLockedClient(Face face,
Port port,
boolean value)
Used for synchronizing state between server and client, letting the
client know of the new locked state of a port, for overlay rendering.
|
void |
setStackAndModuleClient(int slot,
net.minecraft.item.ItemStack stack,
net.minecraft.nbt.CompoundTag moduleData)
Used for synchronizing state between server and client, letting the
client know the new item stack installed in a slot, and, if present
initialize its module with the original server state of the module.
|
net.minecraft.nbt.CompoundTag |
toClientTag(net.minecraft.nbt.CompoundTag nbt) |
void |
unlock(net.minecraft.item.ItemStack stack) |
protected void |
writeToNBTCommon(net.minecraft.nbt.CompoundTag nbt) |
checkNeighbors, fromTag, getPipeHostPosition, getPipeHostWorld, getPipes, getSendingPipe, readFromNBTForServer, toInitialChunkDataTag, toTag, writeToNBTForServerapplyMirror, applyRotation, cancelRemoval, createFromTag, getCachedState, getPos, getSquaredDistance, getType, getWorld, hasWorld, isRemoved, markDirty, method_20525, onBlockAction, populateCrashReport, resetBlock, setPos, setWorld, shouldNotCopyTagFromItem, toUpdatePacketclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcanExtractInvStack, canInsertInvStack, getInvAvailableSlotsclear, getInvMaxStackAmount, getInvSize, getInvStack, isInvEmpty, isValidInvStack, markDirty, onInvClose, onInvOpen, removeInvStack, setInvStack, takeInvStackgetCasingWorld, getModule, getPosition, getSendingPipe, isEnabled, isLocked, markDirty, sendData, sendData, sendData, sendDatapublic static net.minecraft.block.entity.BlockEntityType<CasingBlockEntity> TYPE
public boolean isCasingEnabled()
CasingImpl.isEnabled().public void markRedstoneDirty()
Redstone and/or BundledRedstone
to get notified.public void setReceivingPipeLocked(Face face, Port port, boolean value)
Useful for forcing adjacent modules to not communicate when they are omnidirectional, such as the redstone module.
face - the face to set the locked state for.port - the port of the receiving pipe to set the locked state for.value - the locked state to set; true for locked, false for open (default).public boolean isReceivingPipeLocked(Face face, Port port)
face - the face to get the locked state for.port - the port of the receiving pipe to get the locked state for.true if the port is locked; false otherwise.public void setInventorySlotContents(int index,
net.minecraft.item.ItemStack stack,
Port facing)
Rotatable
module.index - the slot to place the module into.stack - the stack representing the module.facing - the rotation of the module.@Nullable public ControllerBlockEntity getController()
public void setController(@Nullable
ControllerBlockEntity controller)
public void scheduleScan()
scheduleScan in class AbstractComputerBlockEntitypublic void lock(net.minecraft.item.ItemStack stack)
public void unlock(net.minecraft.item.ItemStack stack)
public void notifyModulesOfBlockChange(net.minecraft.util.math.BlockPos neighborPos)
protected void setNeighbor(Face face, @Nullable AbstractComputerBlockEntity neighbor)
setNeighbor in class AbstractComputerBlockEntitypublic void onBeforeWriteComplete(Face sendingFace, Port sendingPort)
onBeforeWriteComplete in interface PipeHostpublic void onWriteComplete(Face sendingFace, Port sendingPort)
onWriteComplete in interface PipeHostpublic boolean canPlayerUseInv(net.minecraft.entity.player.PlayerEntity player)
canPlayerUseInv in interface InventoryProxycanPlayerUseInv in interface net.minecraft.inventory.Inventorypublic net.minecraft.inventory.SidedInventory getInventory()
getInventory in interface InventoryProxygetInventory in interface SidedInventoryProxypublic Casing getCasing()
getCasing in interface CasingProxypublic void markRemoved()
markRemoved in class net.minecraft.block.entity.BlockEntitypublic double getSquaredRenderDistance()
getSquaredRenderDistance in class net.minecraft.block.entity.BlockEntitypublic void onChunkUnload()
AbstractComputerBlockEntityonChunkUnload in class AbstractComputerBlockEntitypublic Pipe getReceivingPipe(Face face, Port port)
AbstractComputerBlockEntitygetReceivingPipe in interface CasinggetReceivingPipe in interface CasingProxygetReceivingPipe in class AbstractComputerBlockEntityface - the face to get the port for.port - the port for which to get the port.Casing.getReceivingPipe(Face, Port)public void fromClientTag(net.minecraft.nbt.CompoundTag nbt)
fromClientTag in interface net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializablefromClientTag in class AbstractComputerBlockEntitypublic net.minecraft.nbt.CompoundTag toClientTag(net.minecraft.nbt.CompoundTag nbt)
toClientTag in interface net.fabricmc.fabric.api.block.entity.BlockEntityClientSerializabletoClientTag in class AbstractComputerBlockEntityprotected void readFromNBTCommon(net.minecraft.nbt.CompoundTag nbt)
readFromNBTCommon in class AbstractComputerBlockEntityprotected void writeToNBTCommon(net.minecraft.nbt.CompoundTag nbt)
writeToNBTCommon in class AbstractComputerBlockEntity@Environment(value=CLIENT) public void setCasingLockedClient(boolean locked)
locked - the new locked state of the case.@Environment(value=CLIENT)
public void setStackAndModuleClient(int slot,
net.minecraft.item.ItemStack stack,
net.minecraft.nbt.CompoundTag moduleData)
slot - the slot the item stack changed in.stack - the new item stack in that slot, if any.moduleData - the original state of the module on the server, if present.@Environment(value=CLIENT) public void setEnabledClient(boolean value)
value - the new enabled state of this casing.@Environment(value=CLIENT) public void setReceivingPipeLockedClient(Face face, Port port, boolean value)
face - the face the port belongs to.port - the port to set the locked state of.value - the new enabled state of this casing.