Package wtf.choco.veinminer.network
Class FabricServerState
java.lang.Object
wtf.choco.veinminer.network.FabricServerState
- All Implemented Interfaces:
MessageReceiver
,PluginMessageListener
,ClientboundPluginMessageListener
public final class FabricServerState
extends Object
implements ClientboundPluginMessageListener, MessageReceiver
The client's state on a connected server.
-
Constructor Summary
ConstructorDescriptionFabricServerState
(@NotNull net.minecraft.client.Minecraft client) Construct a newFabricServerState
. -
Method Summary
Modifier and TypeMethodDescriptionboolean
changePattern
(boolean next) Change to an adjacent pattern.@NotNull ClientConfig
Get theClientConfig
for the mod.@Nullable net.minecraft.core.Direction
Get the block faceDirection
last looked at by the client, or null if the client has not looked at a block.@Nullable net.minecraft.core.BlockPos
Get theBlockPos
last looked at by the client, or null if the client has not looked at a block.@NotNull NamespacedKey
Get theNamespacedKey
of the next pattern to be selected.@NotNull List<NamespacedKey>
Get aList
of all pattern keys known to the client.@NotNull NamespacedKey
Get theNamespacedKey
of the previous pattern to be selected.@NotNull NamespacedKey
Get theNamespacedKey
of the currently selected pattern.int
Get the index of the currently selected pattern.@Nullable net.minecraft.world.phys.shapes.VoxelShape
Get theVoxelShape
outlining the last vein mine result received from the server.void
handleHandshakeResponse
(@NotNull PluginMessageClientboundHandshakeResponse message) Handles thePluginMessageClientboundHandshakeResponse
message.void
handleSetConfig
(@NotNull PluginMessageClientboundSetConfig message) Handles thePluginMessageClientboundSetConfig
message.void
handleSetPattern
(@NotNull PluginMessageClientboundSetPattern message) Handles thePluginMessageClientboundSetPattern
message.void
handleSyncRegisteredPatterns
(@NotNull PluginMessageClientboundSyncRegisteredPatterns message) Handles thePluginMessageClientboundSyncRegisteredPatterns
message.void
handleVeinMineResults
(@NotNull PluginMessageClientboundVeinMineResults message) Handles thePluginMessageClientboundVeinMineResults
message.boolean
Check whether or not any pattern keys are currently available.boolean
isActive()
Check whether or not vein mine is active.boolean
Check whether or not VeinMiner is enabled on the server.void
Reset the last vein mine result shape.void
sendMessage
(@NotNull NamespacedKey channel, byte[] message) Send a message represented by the given bytes on the specified channel.void
setActive
(boolean active) Set whether or not vein miner is active.void
setLastLookedAt
(@Nullable net.minecraft.core.BlockPos position, @Nullable net.minecraft.core.Direction blockFace) Set the lastBlockPos
andDirection
the client has looked at.
-
Constructor Details
-
FabricServerState
public FabricServerState(@NotNull @NotNull net.minecraft.client.Minecraft client) Construct a newFabricServerState
.- Parameters:
client
- theMinecraft
instance
-
-
Method Details
-
getConfig
Get theClientConfig
for the mod.- Returns:
- the config
-
isEnabledOnServer
public boolean isEnabledOnServer()Check whether or not VeinMiner is enabled on the server.- Returns:
- true if enabled, false otherwise
-
setActive
public void setActive(boolean active) Set whether or not vein miner is active.- Parameters:
active
- the new active state
-
isActive
public boolean isActive()Check whether or not vein mine is active.- Returns:
- true if active, false otherwise
-
getSelectedPatternIndex
public int getSelectedPatternIndex()Get the index of the currently selected pattern.- Returns:
- the selected pattern index
-
getSelectedPattern
Get theNamespacedKey
of the currently selected pattern.- Returns:
- the selected pattern key
-
getNextPattern
Get theNamespacedKey
of the next pattern to be selected.- Returns:
- the next pattern key
-
getPreviousPattern
Get theNamespacedKey
of the previous pattern to be selected.- Returns:
- the previous pattern key
-
changePattern
public boolean changePattern(boolean next) Change to an adjacent pattern.- Parameters:
next
- whether or not to move to the next or previous index- Returns:
- true if the pattern was changed, false if the client does not recognize any pattern yet and could not be changed
-
getPatternKeys
Get aList
of all pattern keys known to the client.- Returns:
- all known pattern keys
-
hasPatternKeys
public boolean hasPatternKeys()Check whether or not any pattern keys are currently available.- Returns:
- true if there are pattern keys, false otherwise
-
setLastLookedAt
public void setLastLookedAt(@Nullable @Nullable net.minecraft.core.BlockPos position, @Nullable @Nullable net.minecraft.core.Direction blockFace) Set the lastBlockPos
andDirection
the client has looked at.- Parameters:
position
- the last looked at positionblockFace
- the last looked at block face
-
getLastLookedAtBlockPos
@Nullable public @Nullable net.minecraft.core.BlockPos getLastLookedAtBlockPos()Get theBlockPos
last looked at by the client, or null if the client has not looked at a block.- Returns:
- the last looked at block position, or null if none
-
getLastLookedAtBlockFace
@Nullable public @Nullable net.minecraft.core.Direction getLastLookedAtBlockFace()Get the block faceDirection
last looked at by the client, or null if the client has not looked at a block.- Returns:
- the last looked at block face, or null if none
-
getVeinMineResultShape
@Nullable public @Nullable net.minecraft.world.phys.shapes.VoxelShape getVeinMineResultShape()Get theVoxelShape
outlining the last vein mine result received from the server.- Returns:
- the last vein mine result shape, or null if none
-
resetShape
public void resetShape()Reset the last vein mine result shape. -
sendMessage
Description copied from interface:MessageReceiver
Send a message represented by the given bytes on the specified channel.- Specified by:
sendMessage
in interfaceMessageReceiver
- Parameters:
channel
- the channel on which the message should be sentmessage
- the message bytes to be sent
-
handleHandshakeResponse
public void handleHandshakeResponse(@NotNull @NotNull PluginMessageClientboundHandshakeResponse message) Description copied from interface:ClientboundPluginMessageListener
Handles thePluginMessageClientboundHandshakeResponse
message.- Specified by:
handleHandshakeResponse
in interfaceClientboundPluginMessageListener
- Parameters:
message
- the message
-
handleSyncRegisteredPatterns
public void handleSyncRegisteredPatterns(@NotNull @NotNull PluginMessageClientboundSyncRegisteredPatterns message) Description copied from interface:ClientboundPluginMessageListener
Handles thePluginMessageClientboundSyncRegisteredPatterns
message.- Specified by:
handleSyncRegisteredPatterns
in interfaceClientboundPluginMessageListener
- Parameters:
message
- the message
-
handleSetConfig
Description copied from interface:ClientboundPluginMessageListener
Handles thePluginMessageClientboundSetConfig
message.- Specified by:
handleSetConfig
in interfaceClientboundPluginMessageListener
- Parameters:
message
- the message
-
handleVeinMineResults
public void handleVeinMineResults(@NotNull @NotNull PluginMessageClientboundVeinMineResults message) Description copied from interface:ClientboundPluginMessageListener
Handles thePluginMessageClientboundVeinMineResults
message.- Specified by:
handleVeinMineResults
in interfaceClientboundPluginMessageListener
- Parameters:
message
- the message
-
handleSetPattern
Description copied from interface:ClientboundPluginMessageListener
Handles thePluginMessageClientboundSetPattern
message.- Specified by:
handleSetPattern
in interfaceClientboundPluginMessageListener
- Parameters:
message
- the message
-