CobbleSync Network Handler
This commit is contained in:
3
.idea/gradle.xml
generated
3
.idea/gradle.xml
generated
@@ -1,10 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="#JAVA_HOME" />
|
<option name="gradleJvm" value="ms-21" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
9
.idea/runConfigurations/Minecraft_Client.xml
generated
9
.idea/runConfigurations/Minecraft_Client.xml
generated
@@ -1,16 +1,11 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" factoryName="Application" name="Minecraft Client" type="Application">
|
<configuration default="false" factoryName="Application" name="Minecraft Client" type="Application">
|
||||||
<option name="MAIN_CLASS_NAME" value="dev.architectury.transformer.TransformerRuntime"/>
|
<option name="MAIN_CLASS_NAME" value="dev.architectury.transformer.TransformerRuntime"/>
|
||||||
<module name="Fabric-Kotlin.main"/>
|
<shortenClasspath name="ARGS_FILE"/>
|
||||||
<option name="PROGRAM_PARAMETERS" value=""/>
|
<option name="VM_PARAMETERS" value="-Dfabric.dli.config=$PROJECT_DIR$/../../../../../Com@@0020Sci/Github/Organization/GMU@@0020Craft/Cobblesync/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=client -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotClient "-Darchitectury.main.class=$PROJECT_DIR$/.gradle/architectury/.main_class" "-Darchitectury.runtime.transformer=$PROJECT_DIR$/.gradle/architectury/.transforms" "-Darchitectury.properties=$PROJECT_DIR$/.gradle/architectury/.properties" -Djdk.attach.allowAttachSelf=true "-javaagent:$PROJECT_DIR$/.gradle/architectury/architectury-transformer-agent.jar""/>
|
||||||
<option name="VM_PARAMETERS" value="-Dfabric.dli.config=/home/sirblob/Documents/Com@@0020Sci/Github/Organization/GMU@@0020Craft/Cobblesync/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=client -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotClient "-Darchitectury.main.class=/home/sirblob/Documents/Com Sci/Github/Organization/GMU Craft/Cobblesync/.gradle/architectury/.main_class" "-Darchitectury.runtime.transformer=/home/sirblob/Documents/Com Sci/Github/Organization/GMU Craft/Cobblesync/.gradle/architectury/.transforms" "-Darchitectury.properties=/home/sirblob/Documents/Com Sci/Github/Organization/GMU Craft/Cobblesync/.gradle/architectury/.properties" -Djdk.attach.allowAttachSelf=true "-javaagent:/home/sirblob/Documents/Com Sci/Github/Organization/GMU Craft/Cobblesync/.gradle/architectury/architectury-transformer-agent.jar""/>
|
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/run/"/>
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/run/"/>
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option enabled="true" name="Make"/>
|
<option enabled="true" name="Make"/>
|
||||||
</method>
|
</method>
|
||||||
<envs>
|
|
||||||
|
|
||||||
</envs>
|
|
||||||
<shortenClasspath name="ARGS_FILE"/>
|
|
||||||
<classpathModifications/></configuration>
|
<classpathModifications/></configuration>
|
||||||
</component>
|
</component>
|
||||||
13
.idea/runConfigurations/Minecraft_Server.xml
generated
13
.idea/runConfigurations/Minecraft_Server.xml
generated
@@ -1,16 +1,15 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
<component name="ProjectRunConfigurationManager">
|
||||||
<configuration default="false" factoryName="Application" name="Minecraft Server" type="Application">
|
<configuration default="false" factoryName="Application" name="Minecraft Server" type="Application">
|
||||||
|
<option name="ALTERNATIVE_JRE_PATH" value="ms-21"/>
|
||||||
|
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true"/>
|
||||||
|
|
||||||
<option name="MAIN_CLASS_NAME" value="dev.architectury.transformer.TransformerRuntime"/>
|
<option name="MAIN_CLASS_NAME" value="dev.architectury.transformer.TransformerRuntime"/>
|
||||||
<module name="Fabric-Kotlin.main"/>
|
|
||||||
<option name="PROGRAM_PARAMETERS" value="nogui"/>
|
<option name="PROGRAM_PARAMETERS" value="nogui"/>
|
||||||
<option name="VM_PARAMETERS" value="-Dfabric.dli.config=/home/sirblob/Documents/Com@@0020Sci/Github/Organization/GMU@@0020Craft/Cobblesync/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=server -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotServer "-Darchitectury.main.class=/home/sirblob/Documents/Com Sci/Github/Organization/GMU Craft/Cobblesync/.gradle/architectury/.main_class" "-Darchitectury.runtime.transformer=/home/sirblob/Documents/Com Sci/Github/Organization/GMU Craft/Cobblesync/.gradle/architectury/.transforms" "-Darchitectury.properties=/home/sirblob/Documents/Com Sci/Github/Organization/GMU Craft/Cobblesync/.gradle/architectury/.properties" -Djdk.attach.allowAttachSelf=true "-javaagent:/home/sirblob/Documents/Com Sci/Github/Organization/GMU Craft/Cobblesync/.gradle/architectury/architectury-transformer-agent.jar""/>
|
<shortenClasspath name="ARGS_FILE"/>
|
||||||
|
<option name="VM_PARAMETERS" value="-Dfabric.dli.config=$PROJECT_DIR$/../../../../../Com@@0020Sci/Github/Organization/GMU@@0020Craft/Cobblesync/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=server -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotServer "-Darchitectury.main.class=$PROJECT_DIR$/.gradle/architectury/.main_class" "-Darchitectury.runtime.transformer=$PROJECT_DIR$/.gradle/architectury/.transforms" "-Darchitectury.properties=$PROJECT_DIR$/.gradle/architectury/.properties" -Djdk.attach.allowAttachSelf=true "-javaagent:$PROJECT_DIR$/.gradle/architectury/architectury-transformer-agent.jar""/>
|
||||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/run/"/>
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/run/"/>
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option enabled="true" name="Make"/>
|
<option enabled="true" name="Make"/>
|
||||||
</method>
|
</method>
|
||||||
<envs>
|
<classpathModifications><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-freetype/3.3.3/a0db6c84a8becc8ca05f9dbfa985edc348a824c7/lwjgl-freetype-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-stb/3.3.3/25dd6161988d7e65f71d5065c99902402ee32746/lwjgl-stb-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.jcraft/jorbis/0.0.17/8872d22b293e8f5d7d56ff92be966e6dc28ebdc6/jorbis-0.0.17.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-openal/3.3.3/daada81ceb5fc0c291fbfdd4433cb8d9423577f2/lwjgl-openal-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-compress/1.26.0/659feffdd12280201c8aacb8f7be94f9a883c824/commons-compress-1.26.0.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/com.mojang/blocklist/1.0.10/5c685c5ffa94c4cd39496c7184c1d122e515ecef/blocklist-1.0.10.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.5.13/e5f6cae5ca7ecaac1ec2827a9e2d65ae2869cada/httpclient-4.5.13.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl/3.3.3/29589b5f87ed335a6c7e7ee6a5775f81f97ecb84/lwjgl-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/com.mojang/patchy/2.2.10/da05971b07cbb379d002cf7eaec6a2048211fefc/patchy-2.2.10.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.16.0/4e3eb3d79888d76b54e28b350915b5dc3919c9de/commons-codec-1.16.0.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-tinyfd/3.3.3/82d755ca94b102e9ca77283b9e2dc46d1b15fbe5/lwjgl-tinyfd-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/com.mojang/text2speech/1.17.9/3cad216e3a7f0c19b4b394388bc9ffc446f13b14/text2speech-1.17.9.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.2/4bfc12adfe4842bf07b657f0369c4cb522955686/commons-logging-1.2.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-opengl/3.3.3/2f6b0147078396a58979125a4c947664e98293a/lwjgl-opengl-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-jemalloc/3.3.3/b543467b7ff3c6920539a88ee602d34098628be5/lwjgl-jemalloc-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/com.ibm.icu/icu4j/73.2/61ad4ef7f9131fcf6d25c34b817f90d6da06c9e9/icu4j-73.2.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-glfw/3.3.3/efa1eb78c5ccd840e9f329717109b5e892d72f8e/lwjgl-glfw-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.16/51cf043c87253c9f58b539c9f7e44c8894223850/httpcore-4.4.16.jar"/></classpathModifications></configuration>
|
||||||
|
|
||||||
</envs>
|
|
||||||
<shortenClasspath name="ARGS_FILE"/>
|
|
||||||
<classpathModifications><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/com.mojang/patchy/2.2.10/da05971b07cbb379d002cf7eaec6a2048211fefc/patchy-2.2.10.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-jemalloc/3.3.3/b543467b7ff3c6920539a88ee602d34098628be5/lwjgl-jemalloc-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-tinyfd/3.3.3/82d755ca94b102e9ca77283b9e2dc46d1b15fbe5/lwjgl-tinyfd-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-stb/3.3.3/25dd6161988d7e65f71d5065c99902402ee32746/lwjgl-stb-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-openal/3.3.3/daada81ceb5fc0c291fbfdd4433cb8d9423577f2/lwjgl-openal-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/com.mojang/text2speech/1.17.9/3cad216e3a7f0c19b4b394388bc9ffc446f13b14/text2speech-1.17.9.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.jcraft/jorbis/0.0.17/8872d22b293e8f5d7d56ff92be966e6dc28ebdc6/jorbis-0.0.17.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.2/4bfc12adfe4842bf07b657f0369c4cb522955686/commons-logging-1.2.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-compress/1.26.0/659feffdd12280201c8aacb8f7be94f9a883c824/commons-compress-1.26.0.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.16.0/4e3eb3d79888d76b54e28b350915b5dc3919c9de/commons-codec-1.16.0.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.16/51cf043c87253c9f58b539c9f7e44c8894223850/httpcore-4.4.16.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-opengl/3.3.3/2f6b0147078396a58979125a4c947664e98293a/lwjgl-opengl-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/com.mojang/blocklist/1.0.10/5c685c5ffa94c4cd39496c7184c1d122e515ecef/blocklist-1.0.10.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-glfw/3.3.3/efa1eb78c5ccd840e9f329717109b5e892d72f8e/lwjgl-glfw-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-freetype/3.3.3/a0db6c84a8becc8ca05f9dbfa985edc348a824c7/lwjgl-freetype-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl/3.3.3/29589b5f87ed335a6c7e7ee6a5775f81f97ecb84/lwjgl-3.3.3.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.5.13/e5f6cae5ca7ecaac1ec2827a9e2d65ae2869cada/httpclient-4.5.13.jar"/><entry exclude="true" path="/home/sirblob/.gradle/caches/modules-2/files-2.1/com.ibm.icu/icu4j/73.2/61ad4ef7f9131fcf6d25c34b817f90d6da06c9e9/icu4j-73.2.jar"/></classpathModifications></configuration>
|
|
||||||
</component>
|
</component>
|
||||||
@@ -5,8 +5,8 @@ plugins {
|
|||||||
kotlin("jvm") version ("1.9.23")
|
kotlin("jvm") version ("1.9.23")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "org.example"
|
group = "co.sirblob"
|
||||||
version = "1.0.0-SNAPSHOT"
|
version = "1.0.0"
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
platformSetupLoomIde()
|
platformSetupLoomIde()
|
||||||
@@ -26,7 +26,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
minecraft("net.minecraft:minecraft:1.21.1")
|
minecraft("net.minecraft:minecraft:1.21.1")
|
||||||
mappings(loom.officialMojangMappings())
|
mappings(loom.officialMojangMappings())
|
||||||
modImplementation("net.fabricmc:fabric-loader:0.16.5")
|
modImplementation("net.fabricmc:fabric-loader:0.16.14")
|
||||||
|
|
||||||
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:0.104.0+1.21.1")
|
modRuntimeOnly("net.fabricmc.fabric-api:fabric-api:0.104.0+1.21.1")
|
||||||
modImplementation(fabricApi.module("fabric-command-api-v2", "0.104.0+1.21.1"))
|
modImplementation(fabricApi.module("fabric-command-api-v2", "0.104.0+1.21.1"))
|
||||||
|
|||||||
@@ -1,15 +1,25 @@
|
|||||||
package co.sirblob
|
package co.sirblob
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.Cobblemon
|
||||||
import net.fabricmc.api.ModInitializer
|
import net.fabricmc.api.ModInitializer
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
|
|
||||||
|
import com.cobblemon.mod.common.NetworkManager
|
||||||
|
|
||||||
object CobbleSync : ModInitializer {
|
object CobbleSync : ModInitializer {
|
||||||
|
|
||||||
|
const val ID = "cobblesync"
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger("cobblesync")
|
private val logger = LoggerFactory.getLogger("cobblesync")
|
||||||
|
|
||||||
override fun onInitialize() {
|
val networkManager: NetworkManager = Cobblemon.implementation.networkManager
|
||||||
|
|
||||||
|
override fun onInitialize() {
|
||||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
||||||
// However, some things (like resources) may still be uninitialized.
|
// However, some things (like resources) may still be uninitialized.
|
||||||
// Proceed with mild caution.
|
// Proceed with mild caution.
|
||||||
logger.info("Hello Fabric world!")
|
logger.info("Hello CobbleSync world!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ object CommandHandler {
|
|||||||
fun registerCommands() {
|
fun registerCommands() {
|
||||||
CommandRegistrationCallback.EVENT.register { dispatcher, registryAccess, environment ->
|
CommandRegistrationCallback.EVENT.register { dispatcher, registryAccess, environment ->
|
||||||
// Register your commands here
|
// Register your commands here
|
||||||
MyCommand.register(dispatcher)
|
// MyCommand.register(dispatcher)
|
||||||
// Example: AnotherCommand.register(dispatcher)
|
// Example: AnotherCommand.register(dispatcher)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
package co.sirblob.commands
|
|
||||||
|
|
||||||
import com.mojang.brigadier.Command
|
|
||||||
import com.mojang.brigadier.CommandDispatcher
|
|
||||||
import com.mojang.brigadier.arguments.IntegerArgumentType
|
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder
|
|
||||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder
|
|
||||||
import com.mojang.brigadier.context.CommandContext
|
|
||||||
import net.minecraft.server.commands.ServerCommandSource
|
|
||||||
import net.minecraft.server.commands.CommandManager.* // Required for literal() and argument()
|
|
||||||
import net.minecraft.text.Text
|
|
||||||
|
|
||||||
|
|
||||||
// TEMPLATE CODE DOESN"T WORK BUT MEH
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A template for a simple command.
|
|
||||||
*
|
|
||||||
* This command can be invoked in-game using:
|
|
||||||
* /mycommand
|
|
||||||
* /mycommand <number>
|
|
||||||
*/
|
|
||||||
object SaveParty {
|
|
||||||
|
|
||||||
private const val COMMAND_NAME = "mycommand" // The base name of the command
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers the command and its subcommands/arguments.
|
|
||||||
*
|
|
||||||
* @param dispatcher The command dispatcher used to register commands.
|
|
||||||
*/
|
|
||||||
fun register(dispatcher: CommandDispatcher<>) {
|
|
||||||
// Create the literal argument builder for the base command
|
|
||||||
// A literal argument is a fixed string that must be typed by the user.
|
|
||||||
val commandBuilder = literal<ServerCommandSource>(COMMAND_NAME)
|
|
||||||
.executes(::runBaseCommand) // Action to perform if only /mycommand is typed
|
|
||||||
.then(
|
|
||||||
// Define an argument that follows the base command.
|
|
||||||
// In this case, we expect an integer argument named "number".
|
|
||||||
argument("number", IntegerArgumentType.integer())
|
|
||||||
.executes(::runWithNumberArgument) // Action to perform if /mycommand <number> is typed
|
|
||||||
// You can add more subcommands or arguments here
|
|
||||||
// .then(literal<ServerCommandSource>("subcommand").executes(::runSubCommand))
|
|
||||||
)
|
|
||||||
|
|
||||||
// Register the command
|
|
||||||
dispatcher.register(commandBuilder)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes when the base command is called (e.g., /mycommand).
|
|
||||||
*
|
|
||||||
* @param context The command context, providing information about the command's execution.
|
|
||||||
* @return An integer indicating command success (typically 1 for success, 0 for failure).
|
|
||||||
*/
|
|
||||||
private fun runBaseCommand(context: CommandContext<ServerCommandSource>): Int {
|
|
||||||
val source = context.source
|
|
||||||
source.sendFeedback({ Text.literal("You ran the base MyCommand!") }, false) // Send feedback to the player
|
|
||||||
// false means it won't be broadcast to other ops
|
|
||||||
|
|
||||||
// You can add more logic here, like interacting with the game world, player, etc.
|
|
||||||
// For example, to get the player who executed the command:
|
|
||||||
// val player = source.player
|
|
||||||
// player?.sendMessage(Text.literal("Hello from the command!"), false)
|
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS // Indicates the command was successful
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes when the command is called with a number argument (e.g., /mycommand 123).
|
|
||||||
*
|
|
||||||
* @param context The command context, providing information about the command's execution.
|
|
||||||
* @return An integer indicating command success.
|
|
||||||
*/
|
|
||||||
private fun runWithNumberArgument(context: CommandContext<ServerCommandSource>): Int {
|
|
||||||
val source = context.source
|
|
||||||
val number = IntegerArgumentType.getInteger(context, "number") // Get the value of the "number" argument
|
|
||||||
|
|
||||||
source.sendFeedback({ Text.literal("MyCommand received number: $number") }, false)
|
|
||||||
|
|
||||||
// Add logic that uses the number argument
|
|
||||||
if (number > 100) {
|
|
||||||
source.sendFeedback({ Text.literal("That's a big number!") }, false)
|
|
||||||
} else {
|
|
||||||
source.sendFeedback({ Text.literal("That's a reasonable number.") }, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Example of another subcommand function
|
|
||||||
private fun runSubCommand(context: CommandContext<ServerCommandSource>): Int {
|
|
||||||
val source = context.source
|
|
||||||
source.sendFeedback({ Text.literal("You ran the 'subcommand' of MyCommand!") }, false)
|
|
||||||
return Command.SINGLE_SUCCESS
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
26
src/main/kotlin/co/sirblob/network/CobbleSyncNetwork.kt
Normal file
26
src/main/kotlin/co/sirblob/network/CobbleSyncNetwork.kt
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
package co.sirblob.network
|
||||||
|
|
||||||
|
import co.sirblob.network.handler.OpenPCHandler
|
||||||
|
import co.sirblob.network.packet.OpenPCPacket
|
||||||
|
import com.cobblemon.mod.common.net.PacketRegisterInfo
|
||||||
|
|
||||||
|
object CobbleSyncNetwork {
|
||||||
|
|
||||||
|
val s2cPayloads = generateS2CPacketInfoList()
|
||||||
|
val c2sPayloads = generateC2SPacketInfoList()
|
||||||
|
|
||||||
|
private fun generateS2CPacketInfoList(): List<PacketRegisterInfo<*>> {
|
||||||
|
val list = mutableListOf<PacketRegisterInfo<*>>()
|
||||||
|
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun generateC2SPacketInfoList(): List<PacketRegisterInfo<*>> {
|
||||||
|
val list = mutableListOf<PacketRegisterInfo<*>>()
|
||||||
|
|
||||||
|
list.add(PacketRegisterInfo(OpenPCPacket.ID, OpenPCPacket::decode, OpenPCHandler))
|
||||||
|
|
||||||
|
return list
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
18
src/main/kotlin/co/sirblob/network/handler/OpenPCHandler.kt
Normal file
18
src/main/kotlin/co/sirblob/network/handler/OpenPCHandler.kt
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package co.sirblob.network.handler
|
||||||
|
|
||||||
|
import co.sirblob.network.packet.OpenPCPacket
|
||||||
|
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
|
||||||
|
import com.cobblemon.mod.common.util.pc
|
||||||
|
import net.minecraft.server.MinecraftServer
|
||||||
|
import net.minecraft.server.level.ServerPlayer
|
||||||
|
|
||||||
|
object OpenPCHandler : ServerNetworkPacketHandler<OpenPCPacket> {
|
||||||
|
override fun handle(packet: OpenPCPacket, server: MinecraftServer, player: ServerPlayer) {
|
||||||
|
server.execute {
|
||||||
|
val pc = player.pc()
|
||||||
|
com.cobblemon.mod.common.net.messages.client.storage.pc.OpenPCPacket(pc.uuid, 0).sendToPlayer(player)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package co.sirblob.network.packet
|
||||||
|
|
||||||
|
import co.sirblob.CobbleSync
|
||||||
|
import com.cobblemon.mod.common.api.net.NetworkPacket
|
||||||
|
import net.minecraft.server.level.ServerPlayer
|
||||||
|
|
||||||
|
interface CobbleSyncNetworkPacket<T : NetworkPacket<T>> : NetworkPacket<T> {
|
||||||
|
|
||||||
|
override fun sendToServer() {
|
||||||
|
CobbleSync.networkManager.sendToServer(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun sendToPlayer(player: ServerPlayer) {
|
||||||
|
CobbleSync.networkManager.sendPacketToPlayer(player, this)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
20
src/main/kotlin/co/sirblob/network/packet/OpenPCPacket.kt
Normal file
20
src/main/kotlin/co/sirblob/network/packet/OpenPCPacket.kt
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
package co.sirblob.network.packet
|
||||||
|
|
||||||
|
import co.sirblob.CobbleSync
|
||||||
|
import net.minecraft.network.RegistryFriendlyByteBuf
|
||||||
|
import net.minecraft.resources.ResourceLocation
|
||||||
|
|
||||||
|
class OpenPCPacket: CobbleSyncNetworkPacket<OpenPCPacket> {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val ID = ResourceLocation.fromNamespaceAndPath("open_pc", CobbleSync.ID)
|
||||||
|
fun decode(buffer: RegistryFriendlyByteBuf): OpenPCPacket = OpenPCPacket()
|
||||||
|
}
|
||||||
|
|
||||||
|
override val id = ID
|
||||||
|
|
||||||
|
override fun encode(buffer: RegistryFriendlyByteBuf) {
|
||||||
|
// TO SOMETHING
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
3
src/main/resources/assets/cobblesync/lang/en_us.json
Normal file
3
src/main/resources/assets/cobblesync/lang/en_us.json
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"key.cobblesync.open_pc.desc": "Open PC Storage"
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"name": "CobbleSync",
|
"name": "CobbleSync",
|
||||||
"description": "This is an example description! Tell everyone what your mod is about!",
|
"description": "This is an example description! Tell everyone what your mod is about!",
|
||||||
"authors": [
|
"authors": [
|
||||||
"Me!"
|
"Sir_Blob_"
|
||||||
],
|
],
|
||||||
"contact": {
|
"contact": {
|
||||||
"homepage": "https://fabricmc.net/",
|
"homepage": "https://fabricmc.net/",
|
||||||
|
|||||||
Reference in New Issue
Block a user