This commit is contained in:
ipz233_vvv
2025-01-15 14:25:15 +02:00
parent 8a44dc1fbb
commit 6244e119dd
18 changed files with 44 additions and 42 deletions

View File

@@ -1,5 +1,6 @@
package com.example.template;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
@@ -10,17 +11,16 @@ public class ConfigScreen extends Screen {
}
@Override
protected void init() {
addDrawableChild(((context, mouseX, mouseY, delta) -> {
context.drawCenteredTextWithShadow(client.textRenderer,
"Hello, world",
width / 2,
height / 2,
0xFFFFFFFF);
}));
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);
context.drawCenteredTextWithShadow(client.textRenderer,
"Hello, world",
width / 2,
height / 2,
0xFFFFFFFF);
}
public static ConfigScreen createCursorEditScreen(Screen parent) {
public static ConfigScreen createConfigScreen(Screen parent) {
return new ConfigScreen(parent);
}
}

View File

@@ -7,10 +7,10 @@ public class TempLateInit
{
public static final String MODID = "template";
public static final Logger LOGGER = LoggerFactory.getLogger("Template");
private static ModPlatform PLATFORM = null;
public static ModPlatform PLATFORM = null;
public static void entrypoint(ModPlatform platform) {
TempLateInit.PLATFORM = platform;
LOGGER.info("Started mod in %s loader", TempLateInit.PLATFORM.getModloader());
LOGGER.info("Started mod in %s loader".formatted(TempLateInit.PLATFORM.getModloader()));
}
}

View File

@@ -12,7 +12,7 @@ public class ExampleMixin {
@Inject(method = "init",at=@At("HEAD"))
void init(CallbackInfo ci){
TempLateInit.LOGGER.info("Stonecutter example mixin init");
TempLateInit.LOGGER.info("Stonecutter example mixin init in %s".formatted(TempLateInit.PLATFORM.getModloader()));
}
}

View File

@@ -1,5 +1,5 @@
//? if fabric {
/*package com.example.platforms.fabric;
package com.example.template.platforms.fabric;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
@@ -7,7 +7,7 @@ import com.example.template.ConfigScreen;
public class ModMenuIntegration implements ModMenuApi {
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return ConfigScreen::createCursorEditScreen;
return ConfigScreen::createConfigScreen;
}
}
*///?}
//?}

View File

@@ -1,5 +1,5 @@
//? if fabric {
/*package com.example.platforms.fabric;
package com.example.template.platforms.fabric;
import com.example.template.ModPlatform;
import net.fabricmc.api.ModInitializer;
@@ -24,4 +24,4 @@ public class TempLateFabric implements ModInitializer {
}
}
}
*///?}
//?}

View File

@@ -1,5 +1,5 @@
//? if forge {
/*package com.example.platforms.forge;
/*package com.example.template.platforms.forge;
import com.example.template.ConfigScreen;
import com.example.template.TempLateInit;
@@ -12,7 +12,7 @@ import net.minecraftforge.fml.common.Mod;
public class TempLateForge {
public TempLateForge() {
TempLateInit.entrypoint(new ForgePlatform());
MinecraftForge.registerConfigScreen(ConfigScreen::createCursorEditScreen);
MinecraftForge.registerConfigScreen(ConfigScreen::createConfigScreen);
}
public static class ForgePlatform implements ModPlatform {
@Override

View File

@@ -1,5 +1,5 @@
//? if neoforge {
package com.example.template.platforms.neoforge;
/*package com.example.template.platforms.neoforge;
import com.example.template.ConfigScreen;
import com.example.template.TempLateInit;
@@ -11,8 +11,8 @@ import net.neoforged.fml.common.Mod;
//? if <1.21 {
import net.neoforged.neoforge.client.ConfigScreenHandler;
//?} else {
/*import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
*///?}
/^import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
^///?}
@Mod("template")
public class TempLateNeoForge {
public TempLateNeoForge() {
@@ -21,12 +21,12 @@ public class TempLateNeoForge {
//? if <1.21 {
ConfigScreenHandler.ConfigScreenFactory.class,
() -> new ConfigScreenHandler.ConfigScreenFactory(
((client, parent) -> ConfigScreen.createCursorEditScreen(parent))
((client, parent) -> ConfigScreen.createConfigScreen(parent))
)
//?} else {
/*IConfigScreenFactory.class,
() -> (client, parent) -> CursorEditScreen.createCursorEditScreen(parent)
*///?}
/^IConfigScreenFactory.class,
() -> (client, parent) -> ConfigScreen.createConfigScreen(parent)
^///?}
);
}
public static class NeoForgePlatform implements ModPlatform {
@@ -41,4 +41,4 @@ public class TempLateNeoForge {
}
}
}
//?}
*///?}

View File

@@ -14,10 +14,10 @@
"environment": "*",
"entrypoints": {
"main": [
"com.example.platforms.fabric.TempLateFabric"
"com.example.template.platforms.fabric.TempLateFabric"
],
"modmenu": [
"com.example.platforms.fabric.ModMenuIntegration"
"com.example.template.platforms.fabric.ModMenuIntegration"
]
},
"mixins": [

View File

@@ -1,9 +1,9 @@
{
"required": true,
"package": "com.example.mixin",
"package": "com.example.template.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"com.example.template.mixin.ExampleMixin"
"ExampleMixin"
],
"injectors": {
"defaultRequire": 1

View File

@@ -1,6 +1,6 @@
{
"required": true,
"package": "com.example.platforms.fabric.mixin",
"package": "com.example.template.platforms.fabric.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],

View File

@@ -1,6 +1,6 @@
{
"required": true,
"package": "com.example.platforms.forge.mixin",
"package": "com.example.template.platforms.forge.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],

View File

@@ -1,6 +1,6 @@
{
"required": true,
"package": "com.example.platforms.neoforge.mixin",
"package": "com.example.template.platforms.neoforge.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],