| Constructor and Description |
|---|
CasingImpl(CasingBlockEntity blockEntity) |
| Modifier and Type | Method and Description |
|---|---|
net.minecraft.world.World |
getCasingWorld()
The world this casing resides in.
|
Module |
getModule(Face face)
Get the module installed on the specified face of the casing.
|
net.minecraft.util.math.BlockPos |
getPosition()
The position of the casing in the world it exists in.
|
Pipe |
getReceivingPipe(Face face,
Port port)
Get the receiving pipe on the specified port of a module in this casing.
|
Pipe |
getSendingPipe(Face face,
Port port)
Get the sending pipe on the specified port of a module in this casing.
|
boolean |
isEnabled()
Get whether the casing is currently enabled, i.e.
|
boolean |
isLocked()
Get whether the casing is locked.
|
void |
lock(net.minecraft.item.ItemStack stack)
Locks the casing and returns the key for unlocking it.
|
void |
markDirty()
Flag the casing as dirty so it is saved when the chunk containing it
saved next.
|
void |
onDisabled()
Calls
Module.onDisabled() on all modules and resets all pipes. |
void |
onDisposed()
Calls
Module.onDisposed() on all modules. |
void |
onEnabled()
Calls
Module.onEnabled() on all modules. |
void |
readFromNBT(net.minecraft.nbt.CompoundTag nbt)
Restore data of all modules and pipes from the specified NBT tag.
|
void |
sendData(Face face,
io.netty.buffer.ByteBuf data)
Call this to send some data from a module to it's other representation.
|
void |
sendData(Face face,
io.netty.buffer.ByteBuf data,
byte type)
Call this to send some data from a module to it's other representation.
|
void |
sendData(Face face,
net.minecraft.nbt.CompoundTag data)
Call this to send some data from a module to it's other representation.
|
void |
sendData(Face face,
net.minecraft.nbt.CompoundTag data,
byte type)
Call this to send some data from a module to it's other representation.
|
void |
setLocked(boolean locked) |
void |
setModule(Face face,
Module module)
Set the module for the specified face of the casing.
|
void |
stepModules()
Advance the logic of all modules by calling
Module.step() on them. |
boolean |
unlock(net.minecraft.item.ItemStack stack)
Try to unlock the casing with the key stored on the specified item.
|
boolean |
unlock(java.util.UUID key)
Try to unlock the casing with the specified key.
|
void |
writeToNBT(net.minecraft.nbt.CompoundTag nbt)
Write the state of all modules and pipes to the specified NBT tag.
|
public CasingImpl(CasingBlockEntity blockEntity)
public void onEnabled()
Module.onEnabled() on all modules.
Used by the controller when its state changes to ControllerBlockEntity.ControllerState#RUNNING.
public void onDisabled()
Module.onDisabled() on all modules and resets all pipes.
Used by the controller when its state changes from ControllerBlockEntity.ControllerState#RUNNING,
or the controller is reset (scan scheduled), or the controller is unloaded.
public void onDisposed()
Module.onDisposed() on all modules.
Used by the casing when it is being unloaded.
public void stepModules()
Module.step() on them.public void setModule(Face face, @Nullable Module module)
This is automatically called by the casing tile entity when items are added or removed and as a special case directly for forwarder modules.
This calls Module.onEnabled() and Module.onDisabled()
appropriately if the casing is enabled or disabled, respectively.
face - the face to install the module on.module - the module to install on the face, or null for none.public void setLocked(boolean locked)
public void lock(net.minecraft.item.ItemStack stack)
stack - the item to store the key for unlocking on.java.lang.IllegalStateException - if the casing is already locked.public boolean unlock(net.minecraft.item.ItemStack stack)
stack - the item containing the key.true if the casing was successfully unlocked; false otherwise.public boolean unlock(java.util.UUID key)
key - the key to use to unlock the casing.true if the casing was successfully unlocked; false otherwise.public void readFromNBT(net.minecraft.nbt.CompoundTag nbt)
nbt - the data to load.public void writeToNBT(net.minecraft.nbt.CompoundTag nbt)
nbt - the tag to write the data to.public net.minecraft.world.World getCasingWorld()
CasinggetCasingWorld in interface Casingpublic net.minecraft.util.math.BlockPos getPosition()
CasinggetPosition in interface Casingpublic void markDirty()
Casingpublic boolean isEnabled()
CasingA controller is considered active when a positive non-zero redstone signal is applied to it. This in particular includes the paused state at a signal strength one.
This is useful for contextual behavior in modules while rendering or in
the activation callback Module.onActivate(PlayerEntity, Hand, Vec3d).
public boolean isLocked()
Casing
Casings can be locked, preventing players to remove modules from the
casing or add modules to the casing. Some modules may choose to also
ignore Module.onActivate(PlayerEntity, Hand, Vec3d)
calls while their casing is locks (such as the execution module to
prevent reprogramming).
@Nullable public Module getModule(Face face)
Casingpublic Pipe getReceivingPipe(Face face, Port port)
Casing
There are two Pipes between every pair of Modules
in a case. Specifically, each edge of a Casing has two
Pipes, going into opposite directions. This method is used
to to get a Pipe based on its sink.
getReceivingPipe in interface Casingface - the face to get the port for.port - the port for which to get the port.public Pipe getSendingPipe(Face face, Port port)
Casing
There are two Pipes between every pair of Modules
in a case. Specifically, each edge of a Casing has two
Pipes, going into opposite directions. This method is used
to to get a Pipe based on its source.
getSendingPipe in interface Casingface - the face to get the port for.port - the port for which to get the port.public void sendData(Face face, net.minecraft.nbt.CompoundTag data, byte type)
CasingThat is, when called from the client, it will send the data to the instance representing the module on the specified face on the server, when called on the server it will send the data to the client.
Data is collected each tick, and sent in one big packet. If more than one send request is performed in one tick with the same type, the data will replace the previously queued data. A negative value indicates that no specific type is set and data should not be replaced in the send queue.
Note that this is a convenience alternative for Casing.sendData(Face, ByteBuf, byte)
that is meant to be used for non-frequent data, i.e. data
that's only sent every so often. For data you expect may be sent
each tick, prefer using the more light-weight ByteBuf.
Important: the passed NBT tag is not copied, it is stored by reference. If you intend to modify the tag after passing it to this method, pass a copy of it instead.
public void sendData(Face face, net.minecraft.nbt.CompoundTag data)
Casing
This behaves like Casing.sendData(Face, ByteBuf, byte), except
with no specific type associated, so new data will never replace old
data. Where at all possible, providing a type is strongly recommended,
to reduce generated network traffic.
Note that this is a convenience alternative for Casing.sendData(Face, ByteBuf)
that is meant to be used for non-frequent data, i.e. data
that's only sent every so often. For data you expect may be sent
each tick, prefer using the more light-weight ByteBuf.
Important: the passed NBT tag is not copied, it is stored by reference. If you intend to modify the tag after passing it to this method, pass a copy of it instead.
public void sendData(Face face, io.netty.buffer.ByteBuf data, byte type)
CasingThat is, when called from the client, it will send the data to the instance representing the module on the specified face on the server, when called on the server it will send the data to the client.
Data is collected each tick, and sent in one big packet. If more than one send request is performed in one tick with the same type, the data will replace the previously queued data. A negative value indicates that no specific type is set and data should not be replaced in the send queue.
Important: the passed buffer is not copied, it is stored by reference. If you intend to modify the buffer after passing it to this method, pass a copy of it instead.
public void sendData(Face face, io.netty.buffer.ByteBuf data)
Casing
This behaves like Casing.sendData(Face, ByteBuf, byte), except
with no specific type associated, so new data will never replace old
data. Where at all possible, providing a type is strongly recommended,
to reduce generated network traffic.
Important: the passed buffer is not copied, it is stored by reference. If you intend to modify the buffer after passing it to this method, pass a copy of it instead.