Class AbstractNetworkedRedstoneModule
java.lang.Object
me.desht.pneumaticcraft.common.tubemodules.AbstractTubeModule
me.desht.pneumaticcraft.common.tubemodules.AbstractNetworkedRedstoneModule
- Direct Known Subclasses:
RedstoneModule,ThermostatModule
-
Field Summary
Fields inherited from class me.desht.pneumaticcraft.common.tubemodules.AbstractTubeModule
advancedConfig, dir, higherBound, lowerBound, MAX_VALUE, pressureTube, upgraded -
Method Summary
Modifier and TypeMethodDescriptionprotected intfinal booleancanConnectTo(AbstractTubeModule other) protected final byte[]protected intintprotected booleanisWatchingChannel(int channel) protected final voidnotifyInputLevelsChanged(int channel) Notify all modules in the network about an input level change ofchannel.protected voidonInputLevelChange(int level) Called when this module's input level is changed.static voidonNetworkReform(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) Called when the network is reformed (e.g.voidonPlaced()voidsetInputLevel(int inputLevel) Should only be used on client side Called on client when a sync packet is received, and on server when saved data is loadedvoidfinal booleanChecks and updates the input level.protected voidupdateOutput(byte[] levels) This gets called bynotifyInputLevelsChanged(int)when the input levels of the channels that this module is watching changes.Methods inherited from class me.desht.pneumaticcraft.common.tubemodules.AbstractTubeModule
addInfo, canUpgrade, equals, getDirection, getDrops, getHeight, getItem, getRedstoneLevel, getRenderBoundingBox, getShape, getThreshold, getTube, getType, getWidth, hasGui, hashCode, isFake, isInline, isInlineAndFocused, isUpgraded, isValid, markFake, onActivated, onNeighborBlockUpdate, onNeighborTileUpdate, onRemoved, readFromNBT, sendDescriptionPacket, setChanged, tickClient, tickCommon, updateNeighbors, upgrade, writeToNBT
-
Method Details
-
tickServer
public void tickServer()- Overrides:
tickServerin classAbstractTubeModule
-
getInputChannel
protected int getInputChannel()- Returns:
- the input channel of this module, or -1 if not inputting
-
getInputLevel
public int getInputLevel() -
setInputLevel
public void setInputLevel(int inputLevel) Should only be used on client side Called on client when a sync packet is received, and on server when saved data is loaded -
calculateInputLevel
protected int calculateInputLevel()- Returns:
- the current input signal level
-
updateInputLevel
public final boolean updateInputLevel()Checks and updates the input level.- Returns:
- did the input level change
-
onInputLevelChange
protected void onInputLevelChange(int level) Called when this module's input level is changed.- Parameters:
level- the new input level
-
fetchNetworkInputLevels
protected final byte[] fetchNetworkInputLevels() -
notifyInputLevelsChanged
protected final void notifyInputLevelsChanged(int channel) Notify all modules in the network about an input level change ofchannel. Call this whenever an "inputting" module's input changes.- Parameters:
channel- the changed channel, or -1 to update all channels
-
isWatchingChannel
protected boolean isWatchingChannel(int channel) - Returns:
- if this module is "watching"
channel(ifupdateOutput(byte[])should be called when the respective channels updates)
-
updateOutput
protected void updateOutput(@Nullable byte[] levels) This gets called bynotifyInputLevelsChanged(int)when the input levels of the channels that this module is watching changes.- Parameters:
levels- the input levels of all channels
-
onNetworkReform
public static void onNetworkReform(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos) Called when the network is reformed (e.g. tube place and destroy) -
canConnectTo
- Overrides:
canConnectToin classAbstractTubeModule
-
onPlaced
public void onPlaced()- Overrides:
onPlacedin classAbstractTubeModule
-