public interface Module
Casing.| Modifier and Type | Method and Description |
|---|---|
Casing |
getCasing()
|
Face |
getFace()
|
boolean |
onActivate(net.minecraft.entity.player.PlayerEntity player,
net.minecraft.util.Hand hand,
net.minecraft.util.math.Vec3d hit)
Called when a player right-clicks the module while installed in a casing.
|
void |
onBeforeWriteComplete(Port port)
Called from a pipe this module is writing to when the data is being read.
|
void |
onData(io.netty.buffer.ByteBuf data)
Called with data sent from the remote instance of the module.
|
void |
onData(net.minecraft.nbt.CompoundTag nbt)
Called with NBT data sent from the remote instance of the module.
|
void |
onDisabled()
Called when the multi-block of casings the module is installed in is
disabled, or when the module was removed from an enabled casing.
|
void |
onDisposed()
Called when the
Casing housing the module is being disposed,
e.g. |
void |
onEnabled()
Called when the multi-block of casings the module is installed in is
enabled, or when the module was installed into an enabled casing.
|
void |
onInstalled(net.minecraft.item.ItemStack stack)
Called when the module is being installed into a
Casing. |
void |
onUninstalled(net.minecraft.item.ItemStack stack)
Called after the module was uninstalled from a
Casing. |
void |
onWriteComplete(Port port)
Called from a pipe this module is writing to when the data was read.
|
void |
readFromNBT(net.minecraft.nbt.CompoundTag nbt)
Restore the state of the module from the specified NBT compound.
|
void |
render(net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher rendererDispatcher,
float partialTicks,
net.minecraft.client.util.math.MatrixStack matrices,
net.minecraft.client.render.VertexConsumerProvider vcp,
int light,
int overlay)
Called to allow the module to render dynamic content on the casing it
is installed in.
|
void |
step()
Advance the state of the module.
|
void |
writeToNBT(net.minecraft.nbt.CompoundTag nbt)
Save the state of the module to the specified NBT compound.
|
Casing getCasing()
Face getFace()
void step()
This is called by the controller of the system the module is part of each tick the system is running.
void onInstalled(net.minecraft.item.ItemStack stack)
Casing.
This is mainly for convenience and having things in one place, you could
just as well restore state in your ModuleProvider's
ModuleProvider.createModule(ItemStack, Casing, Face) method.
This is called before the first onEnabled(), and also before
it is actually set in the containing Casing. Particularly
this means Casing.getModule(Face) for the module's Face
will return null in this callback.
Note that this is only called on the server.
stack - the item stack the module was created from.void onUninstalled(net.minecraft.item.ItemStack stack)
Casing.
This allows storing any data that should be persisted onto the module's item representation. For most modules this will not apply, since they are generally stateless / reset state when the computer shuts down.
This is called after the last onDisabled() and is equivalent
to a dispose method (i.e. the module will not be used again
after this).
Note that this is only called on the server.
stack - the stack representing the module.void onEnabled()
Note that this is only called on the server.
void onDisabled()
Modules should use this to reset their state, so that cycling power of a controller resets the whole multi-block system.
Note that this is only called on the server.
void onDisposed()
Casing housing the module is being disposed,
e.g. due to a chunk being unloaded.
This is intended for freeing up resources (e.g. allocated texture or
audio memory). Unlike onDisabled() this is only called once
on a module, at the very end of its life. Avoid world interaction in
this callback to avoid loading the chunk again.
This is called on the server and the client.
void onBeforeWriteComplete(Port port)
The key difference to onWriteComplete(Port) is that this is called
directly during the read operation, so this may be called before or after
the module's step() for the current cycle. As such, no operations
which might influence number of required cycles for the current transfer
operation should be performed in this method. It may be used to cancel
other write operations to write a value only once, for example, or to update
some other internal state before a read operation completes (used by the
stack module for example, to ensure the correct value is being popped).
port - the port on which the write operation will be completed.void onWriteComplete(Port port)
This allows completing the operation in the same tick in which the read operation was completed. This is particularly useful when writing to multiple ports at a time but the written value may only be read once; in this case the remaining writes can be canceled in this callback.
port - the port on which the write operation was completed.boolean onActivate(net.minecraft.entity.player.PlayerEntity player,
net.minecraft.util.Hand hand,
net.minecraft.util.math.Vec3d hit)
The face is implicitly given by the face the module is installed in, as is the world via the casing's world.
Note that there should be some way in which a click can be ignored, e.g. by a player sneaking, otherwise the module cannot be removed from the casing by hand.
player - the player that clicked the module.hand - the hand the player used to activate the module.hit - the relative hit position that was clicked.void onData(net.minecraft.nbt.CompoundTag nbt)
This can be called on both the server and the client, depending on which side sent the message (i.e. the client can send messages to the server this way and vice versa).
nbt - the received data.Casing.sendData(Face, CompoundTag, byte),
Casing.sendData(Face, CompoundTag)void onData(io.netty.buffer.ByteBuf data)
This can be called on both the server and the client, depending on which side sent the message (i.e. the client can send messages to the server this way and vice versa).
data - the received data.Casing.sendData(Face, ByteBuf, byte),
Casing.sendData(Face, ByteBuf)@Environment(value=CLIENT)
void render(net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher rendererDispatcher,
float partialTicks,
net.minecraft.client.util.math.MatrixStack matrices,
net.minecraft.client.render.VertexConsumerProvider vcp,
int light,
int overlay)
The MatrixStack will be adjusted to take into account the face the module is installed in, i.e. rendering from (0, 0, 0) to (1, 1, 0) will render the full quad of face of the casing the module is installed in.
The light value is provided but most modules will want to ignore it
and render at max brightness using RenderUtil.maxLight.
rendererDispatcher - the render context of the tile entity the module sits in.partialTicks - the partial time elapsed in this tick.matrices - the transformation stackvcp - the VertexConsumerProvider to query buffers fromlight - the block-local light value for rendering; usually ignored in favor of RenderUtil.maxLightoverlay - the overlay parameter for renderingvoid readFromNBT(net.minecraft.nbt.CompoundTag nbt)
nbt - the tag to load the state from.void writeToNBT(net.minecraft.nbt.CompoundTag nbt)
nbt - the tag to save the state to.