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);
|
||||
}
|
||||
}
|
||||
}
|
||||
19
src/main/resources/META-INF/mods.toml
Normal file
19
src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "*"
|
||||
license = "LGPLv3"
|
||||
issueTrackerURL="https://JavaJumper/CustomCursor/issues"
|
||||
|
||||
[[mods]]
|
||||
modId = "customcursor"
|
||||
version = "${version}"
|
||||
displayName = "${name}"
|
||||
authors = "JavaJumper"
|
||||
description = ""
|
||||
logoFile = "assets/customcursor/icon.png"
|
||||
logoBlur = false
|
||||
|
||||
[[mixins]]
|
||||
config = "customcursor-common.mixins.json"
|
||||
|
||||
[[mixins]]
|
||||
config = "customcursor-neoforge.mixins.json"
|
||||
19
src/main/resources/META-INF/neoforge.mods.toml
Normal file
19
src/main/resources/META-INF/neoforge.mods.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
modLoader = "javafml"
|
||||
loaderVersion = "*"
|
||||
license = "LGPLv3"
|
||||
issueTrackerURL="https://JavaJumper/CustomCursor/issues"
|
||||
|
||||
[[mods]]
|
||||
modId = "customcursor"
|
||||
version = "${version}"
|
||||
displayName = "${name}"
|
||||
authors = "JavaJumper"
|
||||
description = ""
|
||||
logoFile = "assets/customcursor/icon.png"
|
||||
logoBlur = false
|
||||
|
||||
[[mixins]]
|
||||
config = "customcursor-common.mixins.json"
|
||||
|
||||
[[mixins]]
|
||||
config = "customcursor-neoforge.mixins.json"
|
||||
3
src/main/resources/architectury.common.json
Normal file
3
src/main/resources/architectury.common.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"accessWidener": "customcursor.accesswidener"
|
||||
}
|
||||
BIN
src/main/resources/assets/customcursor/icon.png
Normal file
BIN
src/main/resources/assets/customcursor/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
4
src/main/resources/assets/customcursor/lang/en_us.json
Normal file
4
src/main/resources/assets/customcursor/lang/en_us.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"customcursor.confirm": "Confirm",
|
||||
"customcursor.cancel": "Cancel"
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 594 B |
BIN
src/main/resources/assets/customcursor/textures/gui/pointer.png
Normal file
BIN
src/main/resources/assets/customcursor/textures/gui/pointer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 163 B |
11
src/main/resources/customcursor-common.mixins.json
Normal file
11
src/main/resources/customcursor-common.mixins.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "io.github.jumperonjava.customcursor.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"ExampleMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
10
src/main/resources/customcursor-fabric.mixins.json
Normal file
10
src/main/resources/customcursor-fabric.mixins.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "io.github.jumperonjava.customcursor.platforms.fabric.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
10
src/main/resources/customcursor-forge.mixins.json
Normal file
10
src/main/resources/customcursor-forge.mixins.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "io.github.jumperonjava.customcursor.platforms.forge.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
10
src/main/resources/customcursor-neoforge.mixins.json
Normal file
10
src/main/resources/customcursor-neoforge.mixins.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"required": true,
|
||||
"package": "io.github.jumperonjava.customcursor.platforms.neoforge.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
1
src/main/resources/customcursor.accesswidener
Normal file
1
src/main/resources/customcursor.accesswidener
Normal file
@@ -0,0 +1 @@
|
||||
accessWidener v2 named
|
||||
31
src/main/resources/fabric.mod.json
Normal file
31
src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "${id}",
|
||||
"version": "${version}",
|
||||
"name": "${name}",
|
||||
"description": "",
|
||||
"authors": [
|
||||
"JavaJumper"
|
||||
],
|
||||
"contact": {
|
||||
},
|
||||
"license": "LGPLv3",
|
||||
"icon": "assets/${id}/icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"io.github.jumperonjava.customcursor.platforms.fabric.CustomCursorFabric"
|
||||
],
|
||||
"modmenu": [
|
||||
"io.github.jumperonjava.customcursor.platforms.fabric.ModMenuIntegration"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
"customcursor-common.mixins.json",
|
||||
"customcursor-fabric.mixins.json"
|
||||
],
|
||||
"depends": {
|
||||
"fabricloader": ">=0.15",
|
||||
"minecraft": "${minecraft}"
|
||||
}
|
||||
}
|
||||
6
src/main/resources/pack.mcmeta
Normal file
6
src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "${name}",
|
||||
"pack_format": 15
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user