Broken code (test)
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package chickenmanfy.scify.mixin.client;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MinecraftClient.class)
|
||||
public class ExampleClientMixin {
|
||||
@Inject(at = @At("HEAD"), method = "run")
|
||||
private void run(CallbackInfo info) {
|
||||
// This code is injected into the start of MinecraftClient.run()V
|
||||
}
|
||||
}
|
||||
74
src/client/kotlin/chickenmanfy/scify/SciFyClient.kt
Normal file
74
src/client/kotlin/chickenmanfy/scify/SciFyClient.kt
Normal file
@@ -0,0 +1,74 @@
|
||||
package chickenmanfy.scify
|
||||
|
||||
import io.github.prospector.modmenu.ModMenu
|
||||
import io.github.prospector.modmenu.api.ConfigScreenFactory
|
||||
import io.github.prospector.modmenu.api.ModMenuApi
|
||||
import net.fabricmc.api.ClientModInitializer
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents
|
||||
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
|
||||
import net.minecraft.client.MinecraftClient
|
||||
import net.minecraft.client.option.KeyBinding
|
||||
import net.minecraft.client.util.InputUtil
|
||||
import net.minecraft.text.Text
|
||||
import org.lwjgl.glfw.GLFW
|
||||
import net.fabricmc.api.EnvType
|
||||
import net.fabricmc.api.Environment
|
||||
import net.minecraft.client.gui.screen.Screen
|
||||
import net.minecraft.client.gui.widget.ButtonWidget
|
||||
import net.minecraft.client.util.math.MatrixStack
|
||||
|
||||
|
||||
object SciFyClient : ClientModInitializer {
|
||||
override fun onInitializeClient() {
|
||||
|
||||
val menu = KeyBindingHelper.registerKeyBinding(
|
||||
KeyBinding(
|
||||
"Menu",
|
||||
InputUtil.Type.KEYSYM,
|
||||
GLFW.GLFW_KEY_RIGHT_SHIFT,
|
||||
"SciFy"
|
||||
)
|
||||
)
|
||||
ClientTickEvents.END_CLIENT_TICK.register(ClientTickEvents.EndTick { client: MinecraftClient ->
|
||||
while (menu.wasPressed()) {
|
||||
// Debug
|
||||
client.player!!.sendMessage(Text.literal("Button input received."), true)
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
class ScifyModMenu : ModMenuApi {
|
||||
override fun getModConfigScreenFactory(): ConfigScreenFactory<*> {
|
||||
return ConfigScreenFactory<*> { parent -> Menu(parent) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
class menu(private val parent: Screen) : Screen(Text.literal("Your Mod Config")) {
|
||||
override fun init() {
|
||||
// Add a button to open Mod Menu
|
||||
val modMenuButton = ButtonWidget.builder(
|
||||
Text.literal("Mod Menu")
|
||||
) { button: ButtonWidget? ->
|
||||
// Open Mod Menu
|
||||
ModMenu.getInstance().openConfigScreen()
|
||||
}
|
||||
.dimensions(width / 2 - 100, height / 2, 200, 20)
|
||||
.build()
|
||||
|
||||
addDrawableChild(modMenuButton)
|
||||
}
|
||||
|
||||
override fun render(matrices: MatrixStack, mouseX: Int, mouseY: Int, delta: Float) {
|
||||
renderBackground(matrices)
|
||||
super.render(matrices, mouseX, mouseY, delta)
|
||||
}
|
||||
|
||||
fun onClose() {
|
||||
client!!.setScreen(parent)
|
||||
}
|
||||
}
|
||||
11
src/client/resources/scify.client.mixins.json
Normal file
11
src/client/resources/scify.client.mixins.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "chickenmanfy.scify.mixin.client",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"ExampleClientMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
15
src/main/java/chickenmanfy/scify/mixin/ExampleMixin.java
Normal file
15
src/main/java/chickenmanfy/scify/mixin/ExampleMixin.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package chickenmanfy.scify.mixin;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(MinecraftServer.class)
|
||||
public class ExampleMixin {
|
||||
@Inject(at = @At("HEAD"), method = "loadWorld")
|
||||
private void init(CallbackInfo info) {
|
||||
// This code is injected into the start of MinecraftServer.loadWorld()V
|
||||
}
|
||||
}
|
||||
8
src/main/kotlin/chickenmanfy/scify/SciFy.kt
Normal file
8
src/main/kotlin/chickenmanfy/scify/SciFy.kt
Normal file
@@ -0,0 +1,8 @@
|
||||
package chickenmanfy.scify
|
||||
|
||||
import net.fabricmc.api.ModInitializer
|
||||
|
||||
object SciFy : ModInitializer {
|
||||
override fun onInitialize() {
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/scify/icon.png
Normal file
BIN
src/main/resources/assets/scify/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
58
src/main/resources/fabric.mod.json
Normal file
58
src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "scify",
|
||||
"version": "${version}",
|
||||
"name": "SciFy",
|
||||
"description": "The best (and only) client side Dungeonfy mod.",
|
||||
"authors": [
|
||||
"Main Developer: Chickenmanfy",
|
||||
"Server Owner: Enook",
|
||||
"BearCat865 (Just told me to do it)"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://modrinth.com",
|
||||
"sources": "https://github.com/chickenmanfy/scify/",
|
||||
"issues": "https://github.com/chickenmanfy/scify/issues"
|
||||
},
|
||||
"license": "MPL-2.0",
|
||||
"icon": "assets/scify/icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
{
|
||||
"value": "chickenmanfy.scify.SciFy",
|
||||
"adapter": "kotlin"
|
||||
}
|
||||
],
|
||||
"client": [
|
||||
{
|
||||
"value": "chickenmanfy.scify.SciFyClient",
|
||||
"adapter": "kotlin"
|
||||
}
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"scify.mixins.json",
|
||||
{
|
||||
"config": "scify.client.mixins.json",
|
||||
"environment": "client"
|
||||
}
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.15.6",
|
||||
"minecraft": "~1.19.4",
|
||||
"java": ">=17",
|
||||
"fabric-api": "*",
|
||||
"fabric-language-kotlin": ">=1.9.22"
|
||||
},
|
||||
"suggests": {
|
||||
"Dungeonfy+": "*"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu": {
|
||||
"links": {
|
||||
"Discord": "https://discord.gg/yhw4ajkCu8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/main/resources/scify.mixins.json
Normal file
11
src/main/resources/scify.mixins.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "chickenmanfy.scify.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ExampleMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user