public class RandomAccessMemoryModule extends AbstractModuleWithRotation
| Modifier and Type | Class and Description |
|---|---|
protected static class |
RandomAccessMemoryModule.State |
| Modifier and Type | Field and Description |
|---|---|
protected byte |
address |
protected byte[] |
memory |
static int |
MEMORY_SIZE
The size of the memory, in bytes.
|
protected RandomAccessMemoryModule.State |
state |
| Constructor and Description |
|---|
RandomAccessMemoryModule(Casing casing,
Face face) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
beginRead(Pipe pipe)
Called whenever the module tries to start reading.
|
protected void |
clearOnDisabled() |
protected void |
load(byte[] data) |
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 |
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 |
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)
Called to allow the module to render dynamic content on the casing it
is installed in.
|
protected void |
setCellColor(float brightness)
Set the color of the memory cell currently being drawn in the
GlStateManager. |
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.
|
getFacing, hitToUV, rotateForRendering, setFacingcancelRead, cancelWrite, getCasing, getFace, getObserverLookAt, isObserverLookingAt, isVisible, onData, onDisposed, onEnabled, onInstalled, onUninstalledclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCasing, getFace, onData, onDisposed, onEnabled, onInstalled, onUninstalledprotected final byte[] memory
protected byte address
protected RandomAccessMemoryModule.State state
public static final int MEMORY_SIZE
public void step()
ModuleThis is called by the controller of the system the module is part of each tick the system is running.
step in interface Modulestep in class AbstractModulepublic void onDisabled()
ModuleModules 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.
onDisabled in interface ModuleonDisabled in class AbstractModulepublic void onBeforeWriteComplete(Port port)
Module
The key difference to Module.onWriteComplete(Port) is that this is called
directly during the read operation, so this may be called before or after
the module's Module.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).
onBeforeWriteComplete in interface ModuleonBeforeWriteComplete in class AbstractModuleport - the port on which the write operation will be completed.public void onWriteComplete(Port port)
ModuleThis 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.
onWriteComplete in interface ModuleonWriteComplete in class AbstractModuleport - the port on which the write operation was completed.public boolean onActivate(net.minecraft.entity.player.PlayerEntity player,
net.minecraft.util.Hand hand,
net.minecraft.util.math.Vec3d hit)
ModuleThe 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.
onActivate in interface ModuleonActivate in class AbstractModuleplayer - the player that clicked the module.hand - the hand the player used to activate the module.hit - the relative hit position that was clicked.public void onData(io.netty.buffer.ByteBuf data)
ModuleThis 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).
onData in interface ModuleonData in class AbstractModuledata - the received data.Casing.sendData(Face, ByteBuf, byte),
Casing.sendData(Face, ByteBuf)public void render(net.minecraft.client.render.block.entity.BlockEntityRenderDispatcher rendererDispatcher,
float partialTicks)
ModuleThe render state 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.
Note that the enabled is the same as Casing.isEnabled(),
it is merely passed along for backwards compatibility from before the
time that getter existed.
render in interface Modulerender in class AbstractModulerendererDispatcher - the render context of the tile entity the module sits in.partialTicks - the partial time elapsed in this tick.public void readFromNBT(net.minecraft.nbt.CompoundTag nbt)
ModulereadFromNBT in interface ModulereadFromNBT in class AbstractModuleWithRotationnbt - the tag to load the state from.public void writeToNBT(net.minecraft.nbt.CompoundTag nbt)
ModulewriteToNBT in interface ModulewriteToNBT in class AbstractModuleWithRotationnbt - the tag to save the state to.protected void clearOnDisabled()
protected void beginRead(Pipe pipe)
pipe - the pipe to start reading on.protected void setCellColor(float brightness)
GlStateManager.brightness - the brightness the cell is rendered at (the alpha).protected final void load(byte[] data)