inti
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package io.github.jumperonjava.template;
|
||||
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
public class ConfigScreen extends Screen {
|
||||
|
||||
public ConfigScreen(Screen parent) {
|
||||
super(Text.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
addDrawableChild(((context, mouseX, mouseY, delta) -> {
|
||||
context.drawCenteredTextWithShadow(client.textRenderer,
|
||||
"Hello, world",
|
||||
width / 2,
|
||||
height / 2,
|
||||
0xFFFFFFFF);
|
||||
}));
|
||||
}
|
||||
|
||||
public static ConfigScreen createCursorEditScreen(Screen parent) {
|
||||
return new ConfigScreen(parent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.github.jumperonjava.template;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TempLateInit
|
||||
{
|
||||
public static final String MODID = "template";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("Template");
|
||||
private static ModPlatform PLATFORM = null;
|
||||
|
||||
public static void entrypoint(ModPlatform platform) {
|
||||
TempLateInit.PLATFORM = platform;
|
||||
LOGGER.info("Started mod in %s loader", TempLateInit.PLATFORM.getModloader());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package io.github.jumperonjava.template;
|
||||
|
||||
public interface ModPlatform {
|
||||
String getModloader();
|
||||
boolean isModLoaded(String modloader);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package io.github.jumperonjava.template.mixin;
|
||||
|
||||
import io.github.jumperonjava.template.TempLateInit;
|
||||
import net.minecraft.client.gui.screen.TitleScreen;
|
||||
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(TitleScreen.class)
|
||||
public class ExampleMixin {
|
||||
|
||||
@Inject(method = "init",at=@At("HEAD"))
|
||||
void init(CallbackInfo ci){
|
||||
TempLateInit.LOGGER.info("Stonecutter example mixin init");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
//? if fabric {
|
||||
/*package io.github.jumperonjava.customcursor.platforms.fabric;
|
||||
|
||||
import io.github.jumperonjava.customcursor.ModPlatform;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import io.github.jumperonjava.customcursor.CustomCursorInit;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
public class CustomCursorFabric implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
CustomCursorInit.entrypoint(new FabricPlatform());
|
||||
}
|
||||
public static class FabricPlatform implements ModPlatform{
|
||||
|
||||
@Override
|
||||
public String getModloader() {
|
||||
return "Fabric";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modloader) {
|
||||
return FabricLoader.getInstance().isModLoaded(modloader);
|
||||
}
|
||||
}
|
||||
}
|
||||
*///?}
|
||||
@@ -0,0 +1,13 @@
|
||||
//? if fabric {
|
||||
/*package io.github.jumperonjava.customcursor.platforms.fabric;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import io.github.jumperonjava.customcursor.ConfigScreen;
|
||||
|
||||
public class ModMenuIntegration implements ModMenuApi {
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return ConfigScreen::createCursorEditScreen;
|
||||
}
|
||||
}
|
||||
*///?}
|
||||
@@ -0,0 +1,30 @@
|
||||
//? if forge {
|
||||
/*package io.github.jumperonjava.customcursor.platforms.forge;
|
||||
|
||||
import io.github.jumperonjava.customcursor.ConfigScreen;
|
||||
import io.github.jumperonjava.customcursor.CustomCursorInit;
|
||||
import io.github.jumperonjava.customcursor.ModPlatform;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.fml.ModList;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod("customcursor")
|
||||
public class CustomCursorForge {
|
||||
public CustomCursorForge() {
|
||||
CustomCursorInit.entrypoint(new ForgePlatform());
|
||||
MinecraftForge.registerConfigScreen(ConfigScreen::createCursorEditScreen);
|
||||
}
|
||||
public static class ForgePlatform implements ModPlatform {
|
||||
@Override
|
||||
public String getModloader() {
|
||||
return "LexForge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return ModList.get().isLoaded(modId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
*///?}
|
||||
@@ -0,0 +1,44 @@
|
||||
//? if neoforge {
|
||||
package io.github.jumperonjava.customcursor.platforms.neoforge;
|
||||
|
||||
import io.github.jumperonjava.customcursor.ConfigScreen;
|
||||
import io.github.jumperonjava.customcursor.CustomCursorInit;
|
||||
import io.github.jumperonjava.customcursor.ModPlatform;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.neoforged.fml.ModList;
|
||||
import net.neoforged.fml.ModLoadingContext;
|
||||
import net.neoforged.fml.common.Mod;
|
||||
//? if <1.21 {
|
||||
import net.neoforged.neoforge.client.ConfigScreenHandler;
|
||||
//?} else {
|
||||
/*import net.neoforged.neoforge.client.gui.IConfigScreenFactory;
|
||||
*///?}
|
||||
@Mod("customcursor")
|
||||
public class CustomCursorNeoForge {
|
||||
public CustomCursorNeoForge() {
|
||||
CustomCursorInit.entrypoint(new NeoForgePlatform());
|
||||
ModLoadingContext.get().registerExtensionPoint(
|
||||
//? if <1.21 {
|
||||
ConfigScreenHandler.ConfigScreenFactory.class,
|
||||
() -> new ConfigScreenHandler.ConfigScreenFactory(
|
||||
((client, parent) -> ConfigScreen.createCursorEditScreen(parent))
|
||||
)
|
||||
//?} else {
|
||||
/*IConfigScreenFactory.class,
|
||||
() -> (client, parent) -> CursorEditScreen.createCursorEditScreen(parent)
|
||||
*///?}
|
||||
);
|
||||
}
|
||||
public static class NeoForgePlatform implements ModPlatform {
|
||||
@Override
|
||||
public String getModloader() {
|
||||
return "NeoForge";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModLoaded(String modId) {
|
||||
return ModList.get().isLoaded(modId);
|
||||
}
|
||||
}
|
||||
}
|
||||
//?}
|
||||
@@ -0,0 +1,44 @@
|
||||
package io.github.jumperonjava.customcursor.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class FileReadWrite {
|
||||
|
||||
/**
|
||||
* Writes text to file, throws runtime exception if something goes wrong
|
||||
* @param file
|
||||
* @param text
|
||||
*/
|
||||
public static void write(File file, String text) {
|
||||
try{
|
||||
file.getParentFile().mkdirs();
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
byte[] strToBytes = text.getBytes();
|
||||
outputStream.write(strToBytes);
|
||||
outputStream.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to read file, creates empty file if it does not exist and returns empty string
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static String read(File file) {
|
||||
try{
|
||||
return new String(Files.readAllBytes(file.toPath()));
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
write(file,"");
|
||||
return read(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user