@@ -1,7 +1,6 @@
|
||||
package gamer.noir.curseenc
|
||||
|
||||
import gamer.noir.curseenc.command.ModCommands
|
||||
import gamer.noir.curseenc.data.ModComponents
|
||||
import gamer.noir.curseenc.effect.Effect
|
||||
import gamer.noir.curseenc.item.ModItems
|
||||
import net.fabricmc.api.ModInitializer
|
||||
@@ -18,7 +17,8 @@ object CurseOfEienNoChi : ModInitializer {
|
||||
ModItems.initialize()
|
||||
Effect.initialize()
|
||||
ModCommands.initialize()
|
||||
ModComponents.initialize() // 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.
|
||||
// Proceed with mild caution.
|
||||
LOGGER.info("Hello Fabric world!")
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package gamer.noir.curseenc.client
|
||||
|
||||
class AttachmentsClient {
|
||||
var Nighte_vision = true
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package gamer.noir.curseenc.client
|
||||
|
||||
import net.fabricmc.api.ClientModInitializer
|
||||
|
||||
object FabricClient: ClientModInitializer {
|
||||
override fun onInitializeClient() {
|
||||
//nop
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,15 @@
|
||||
package gamer.noir.curseenc.command
|
||||
|
||||
import com.mojang.brigadier.CommandDispatcher
|
||||
import com.mojang.brigadier.arguments.BoolArgumentType
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType
|
||||
import com.mojang.brigadier.arguments.StringArgumentType
|
||||
import com.mojang.brigadier.context.CommandContext
|
||||
import gamer.noir.curseenc.data.AttachmentsServer
|
||||
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback
|
||||
import net.minecraft.commands.CommandBuildContext
|
||||
import net.minecraft.commands.CommandSourceStack
|
||||
import net.minecraft.commands.Commands
|
||||
import net.minecraft.commands.Commands.CommandSelection
|
||||
import net.minecraft.network.chat.Component
|
||||
import java.util.function.Supplier
|
||||
|
||||
|
||||
object ModCommands {
|
||||
@@ -20,7 +18,12 @@ object ModCommands {
|
||||
return 1
|
||||
}
|
||||
private fun executePowerAdd(context: CommandContext<CommandSourceStack?>): Int {
|
||||
context.getSource()!!.sendSuccess( { Component.literal("Power !!!") }, false)
|
||||
val player = context.source?.player
|
||||
val Power = StringArgumentType.getString(context, "Power")
|
||||
if (player != null) {
|
||||
player.setAttached(AttachmentsServer.EXEMPLE,"$Power")
|
||||
context.getSource()!!.sendSuccess( { Component.literal("Power set to $Power") }, false)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
private fun executePowerRemove(context: CommandContext<CommandSourceStack?>): Int {
|
||||
@@ -28,8 +31,16 @@ object ModCommands {
|
||||
return 1
|
||||
}
|
||||
private fun executePowerQuary(context: CommandContext<CommandSourceStack?>): Int {
|
||||
val Power = StringArgumentType.getString(context, "Power")
|
||||
context.getSource()!!.sendSuccess( { Component.literal("Power $Power is ") }, false)
|
||||
val player = context.source?.player
|
||||
if (player != null && player.hasAttached(AttachmentsServer.EXEMPLE)) {
|
||||
val Power = player.getAttached(AttachmentsServer.EXEMPLE)
|
||||
context.getSource()!!.sendSuccess( { Component.literal("Power is $Power") }, false)
|
||||
}
|
||||
else {
|
||||
context.getSource()!!.sendSuccess( { Component.literal("nop") }, false)
|
||||
}
|
||||
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -37,9 +48,9 @@ object ModCommands {
|
||||
|
||||
val argument_power = Commands.argument("Power", StringArgumentType.string()).suggests { context, builder ->
|
||||
builder.suggest("Night_vision")
|
||||
.suggest("Hyper_speed")
|
||||
.suggest("Bat_mod")
|
||||
.suggest("...")
|
||||
.suggest("Hyper_speed")
|
||||
.suggest("Bat_mod")
|
||||
.suggest("...")
|
||||
builder.buildFuture()
|
||||
}
|
||||
|
||||
@@ -53,11 +64,11 @@ object ModCommands {
|
||||
.then(Commands.literal("power")
|
||||
.then(Commands.literal("add")
|
||||
.then(argument_power
|
||||
.executes(ModCommands::executePowerAdd)))
|
||||
.executes(ModCommands::executePowerAdd)))
|
||||
|
||||
.then(Commands.literal("remove")
|
||||
.then(argument_power
|
||||
.executes(ModCommands::executePowerRemove)))
|
||||
.executes(ModCommands::executePowerRemove)))
|
||||
|
||||
.then(Commands.literal("quary")
|
||||
.then(argument_power
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package gamer.noir.curseenc.data
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import gamer.noir.curseenc.CurseOfEienNoChi
|
||||
import net.fabricmc.fabric.api.attachment.v1.AttachmentRegistry
|
||||
import net.fabricmc.fabric.api.attachment.v1.AttachmentSyncPredicate
|
||||
import net.minecraft.network.codec.ByteBufCodecs
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
object AttachmentsServer {
|
||||
var EXEMPLE = AttachmentRegistry.create<String>(
|
||||
ResourceLocation.fromNamespaceAndPath(CurseOfEienNoChi.MOD_ID, "example_block_pos_attachment")){
|
||||
builder -> builder.initializer { "" }.syncWith(ByteBufCodecs.STRING_UTF8, AttachmentSyncPredicate.all()).persistent(
|
||||
Codec.STRING).copyOnDeath()
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package gamer.noir.curseenc.data
|
||||
|
||||
import com.mojang.serialization.Codec
|
||||
import gamer.noir.curseenc.CurseOfEienNoChi
|
||||
import net.minecraft.core.Registry
|
||||
import net.minecraft.core.component.DataComponentType
|
||||
import net.minecraft.core.registries.BuiltInRegistries
|
||||
import net.minecraft.resources.ResourceLocation
|
||||
|
||||
|
||||
object ModComponents {
|
||||
|
||||
|
||||
val CLICK_COUNT_COMPONENT: DataComponentType<Int?>? = Registry.register(
|
||||
BuiltInRegistries.DATA_COMPONENT_TYPE,
|
||||
ResourceLocation.fromNamespaceAndPath(CurseOfEienNoChi.MOD_ID, "click_count"),
|
||||
DataComponentType.builder<Int?>().persistent(Codec.INT).build()
|
||||
)
|
||||
|
||||
internal fun initialize() {
|
||||
CurseOfEienNoChi.LOGGER.info("Registering {} components", CurseOfEienNoChi.MOD_ID)
|
||||
// Technically this method can stay empty, but some developers like to notify
|
||||
// the console, that certain parts of the mod have been successfully initialized
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user