Skip to content

Commit

Permalink
OpenExplorer button and loading gui migration.
Browse files Browse the repository at this point in the history
  • Loading branch information
topi-banana committed Nov 28, 2024
1 parent 6d1f033 commit 764c085
Show file tree
Hide file tree
Showing 18 changed files with 184 additions and 18 deletions.
22 changes: 17 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ repositories {
maven {
url 'https://www.cursemaven.com'
}
maven {
url = "https://api.modrinth.com/maven"
}
maven {
url 'https://maven.neoforged.net/releases'
}
Expand Down Expand Up @@ -51,7 +54,6 @@ Number convertVersion(String version) {
def mcVersion = convertVersion(project.minecraft_version);

String MOD_ICON_PATH = 'assets/kyoyu/icon.png'
String MIXIN_CONFIG_PATH = 'kyoyu.mixins.json'
String LANG_DIR = 'assets/kyoyu/lang'
JavaVersion JAVA_COMPATIBILITY
if (mcVersion >= 12005) {
Expand Down Expand Up @@ -98,6 +100,8 @@ stonecutter.const('QUILT', project.platform == 'quilt')
stonecutter.const('FORGE', project.platform == 'forge')
stonecutter.const('NEOFORGE', project.platform == 'neoforge')
stonecutter.const('PAPER', project.platform == 'paper')
stonecutter.const('client', project.hasProperty('litematica_version') && project.hasProperty('malilib_version'))
stonecutter.swap("mod_version", "\"${fullArtifactVersion}\";")


if (use_architectury_loom) {
Expand Down Expand Up @@ -135,6 +139,14 @@ dependencies {
if (project.platform == 'paper') {
compileOnly "io.papermc.paper:paper-api:${project.minecraft_version}-R0.1-SNAPSHOT"
}
if (project.hasProperty('litematica_version')) {
modImplementation "maven.modrinth:litematica:${project.litematica_version}"
}
if (project.hasProperty('malilib_version')) {
modImplementation "maven.modrinth:malilib:${project.malilib_version}"
include(modImplementation(fabricApi.module("fabric-networking-api-v1", project.fabric_api_version)))
include(modImplementation(fabricApi.module("fabric-resource-loader-v0", project.fabric_api_version)))
}
}

if (use_architectury_loom) {
Expand All @@ -148,7 +160,7 @@ if (use_architectury_loom) {

if (project.platform == 'forge') {
forge {
mixinConfigs = [MIXIN_CONFIG_PATH]
mixinConfigs = ['kyoyu.mixins.json', 'kyoyu.client.mixins.json']
}
}
}
Expand All @@ -168,9 +180,9 @@ processResources {
def good_files = [] as Set
def all_files = [] as Set
[
'fabric': [MIXIN_CONFIG_PATH, 'fabric.mod.json'],
'forge': [MIXIN_CONFIG_PATH, 'META-INF', 'META-INF/mods.toml', 'pack.mcmeta'],
'neoforge': [MIXIN_CONFIG_PATH, 'META-INF', 'META-INF/neoforge.mods.toml', 'pack.mcmeta'],
'fabric': ['kyoyu.mixins.json', 'kyoyu.client.mixins.json', 'fabric.mod.json'],
'forge': ['kyoyu.mixins.json', 'kyoyu.client.mixins.json', 'META-INF', 'META-INF/mods.toml', 'pack.mcmeta'],
'neoforge': ['kyoyu.mixins.json', 'kyoyu.client.mixins.json', 'META-INF', 'META-INF/neoforge.mods.toml', 'pack.mcmeta'],
'paper': ['plugin.yml'],
].forEach { brand, paths ->
all_files.addAll(paths)
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/vulpeus/kyoyu/Kyoyu.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public class Kyoyu
//? if PAPER
/* extends org.bukkit.plugin.java.JavaPlugin */
{
public static final String MOD_ID = "kyoyu";
public static final String MOD_VERSION = /*$ mod_version*/ "unknown";

public static final Logger LOGGER = LogManager.getLogger();

//? if FABRIC
Expand All @@ -30,5 +33,6 @@ public class Kyoyu
/* @Override public void onEnable() */
{
LOGGER.info("Hello, World!");
LOGGER.info("Kyoyu Version : {}", MOD_VERSION);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.vulpeus.kyoyu.client.gui;

//? if client {
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.gui.button.ButtonBase;
import fi.dy.masa.malilib.gui.button.IButtonActionListener;
import net.minecraft.client.gui.screen.Screen;

public class ButtonActionListener_OpenExplorer implements IButtonActionListener {

private final Screen parent;

public ButtonActionListener_OpenExplorer(Screen parent) {
this.parent = parent;
}

@Override
public void actionPerformedWithButton(ButtonBase buttonBase, int i) {

GuiBase loading_gui = new Gui_LoadingExplorer();
loading_gui.setParent(parent);
GuiBase.openGui(loading_gui);

// TODO
// Packet Process on OpenExplorer
}
}
//?}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.vulpeus.kyoyu.client.gui;

//? if client {
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.util.GuiUtils;
import fi.dy.masa.malilib.util.StringUtils;

//? if >=1.20
import net.minecraft.client.gui.DrawContext;
//? elif >=1.16
/* import net.minecraft.client.util.math.MatrixStack; */

import static com.vulpeus.kyoyu.Kyoyu.MOD_VERSION;

public class Gui_LoadingExplorer extends GuiBase {

@Override
public void init() {
this.setParent(GuiUtils.getCurrentScreen());
this.title = StringUtils.translate("kyoyu.gui.title.title", MOD_VERSION);
}

@Override
//? if >=1.20 {
public void drawContents(DrawContext drawContext, int mouseX, int mouseY, float partialTicks) {
//?} elif >=1.16 {
/* public void drawContents(MatrixStack drawContext, int mouseX, int mouseY, float partialTicks) { */
//?} else {
/* public void drawContents(int mouseX, int mouseY, float partialTicks) { */
//?}

String loadingText = StringUtils.translate("kyoyu.message.loading");

int x = this.width / 2 - (getStringWidth(loadingText) + 12) / 2;
int y = this.height / 2 - 12;


//? if >=1.16 {
drawString(drawContext, loadingText, x, y, 0xC0C0C0C0);
//?} else {
/* drawString(loadingText, x, y, 0xC0C0C0C0); */
//?}
}
}
//?}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.vulpeus.kyoyu.client.mixins.litematica;

//? if client {
import com.vulpeus.kyoyu.client.gui.ButtonActionListener_OpenExplorer;
import fi.dy.masa.litematica.gui.GuiMainMenu;
import fi.dy.masa.malilib.gui.GuiBase;
import fi.dy.masa.malilib.gui.button.ButtonGeneric;
import fi.dy.masa.malilib.util.StringUtils;
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(GuiMainMenu.class)
public class GuiMainMenuMixin extends GuiBase {

@Inject(method = "initGui", at = @At("RETURN"), remap = false)
public void initGui(CallbackInfo ci) {
String text = StringUtils.translate("kyoyu.gui.button.open_explorer");
int width = getStringWidth(text) + 12;

// 12 : litematica menu x-border size
// fi.dy.masa.litematica.gui.GuiMainMenu.initGui ~ x = 12
int x = Math.max(this.width / 2, this.width - 12 - width);
int y = this.height - 26;

ButtonGeneric button = new ButtonGeneric(x, y, width, 20, text);
// TODO
// Disable when connecting server is not compatible
// button.setEnabled();
addButton(button, new ButtonActionListener_OpenExplorer(this));
}
}
//?}
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/neoforge.mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ side="BOTH"

[[mixins]]
config = "kyoyu.mixins.json"
[[mixins]]
config = "kyoyu.client.mixins.json"
6 changes: 5 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@
]
},
"mixins": [
"kyoyu.mixins.json"
"kyoyu.mixins.json",
{
"config": "kyoyu.client.mixins.json",
"environment": "client"
}
],

"depends": {
Expand Down
12 changes: 12 additions & 0 deletions src/main/resources/kyoyu.client.mixins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.vulpeus.kyoyu.client.mixins",
"compatibilityLevel": "${java_compatibility_level}",
"client": [
"litematica.GuiMainMenuMixin"
],
"injectors": {
"defaultRequire": 1
}
}
2 changes: 0 additions & 2 deletions src/main/resources/kyoyu.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
"compatibilityLevel": "${java_compatibility_level}",
"mixins": [
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
Expand Down
5 changes: 4 additions & 1 deletion versions/fabric-1.14.4/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ minecraft_dependency=>=1.14 <=1.14.4
game_versions=1.14\n1.14.1\n1.14.2\n1.14.3\n1.14.4

# Dependencies
# fabric_api_version=0.28.5+1.14
fabric_api_version=0.28.5+1.14
modmenu_version=1.7.17
malilib_version=0.10.0-dev.20+arne.2
litematica_version=0.0.0-dev.20200123.linearpaste
5 changes: 4 additions & 1 deletion versions/fabric-1.15.2/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ minecraft_dependency=>=1.15 <=1.15.2
game_versions=1.15\n1.15.1\n1.15.2

# Dependencies
# fabric_api_version=0.28.5+1.15
fabric_api_version=0.28.5+1.15
modmenu_version=1.10.7
malilib_version=0.10.0-dev.21+arne.3
litematica_version=0.0.0-dev.20201006.194726
5 changes: 4 additions & 1 deletion versions/fabric-1.16.5/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ minecraft_dependency=>=1.16 <=1.16.5
game_versions=1.16\n1.16.1\n1.16.2\n1.16.3\n1.16.4\n1.16.5

# Dependencies
# fabric_api_version=0.42.0+1.16
fabric_api_version=0.42.0+1.16
modmenu_version=1.16.23
malilib_version=0.10.0-dev.21+arne.8
litematica_version=0.0.0-dev.20210917.192300
5 changes: 4 additions & 1 deletion versions/fabric-1.17.1/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ minecraft_dependency=>=1.17 <=1.17.1
game_versions=1.17\n1.17.1

# Dependencies
# fabric_api_version=0.46.1+1.17
fabric_api_version=0.46.1+1.17
modmenu_version=2.0.17
malilib_version=HljUtdhE
litematica_version=0.9.0
5 changes: 4 additions & 1 deletion versions/fabric-1.18.2/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ minecraft_dependency=>=1.18 <=1.18.2
game_versions=1.18\n1.18.1\n1.18.2\n1.18.3\n1.18.4

# Dependencies
# fabric_api_version=0.77.0+1.18.2
fabric_api_version=0.77.0+1.18.2
modmenu_version=3.2.5
malilib_version=0.12.1
litematica_version=0.11.6
5 changes: 4 additions & 1 deletion versions/fabric-1.19.4/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ minecraft_dependency=>=1.19 <=1.19.4
game_versions=1.19\n1.19.1\n1.19.2\n1.19.3\n1.19.4

# Dependencies
# fabric_api_version=0.87.2+1.19.4
fabric_api_version=0.87.2+1.19.4
modmenu_version=6.3.1
malilib_version=0.15.4
litematica_version=0.14.7
5 changes: 4 additions & 1 deletion versions/fabric-1.20.4/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ minecraft_dependency=>=1.20 <=1.20.4
game_versions=1.20\n1.20.1\n1.20.2\n1.20.3\n1.20.4

# Dependencies
# fabric_api_version=0.97.2+1.20.4
fabric_api_version=0.97.2+1.20.4
modmenu_version=9.2.0
malilib_version=0.18.4-alpha.1
litematica_version=0.17.3
5 changes: 4 additions & 1 deletion versions/fabric-1.20.6/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ minecraft_dependency=>1.20.4 <=1.20.6
game_versions=1.20.5\n1.20.6

# Dependencies
# fabric_api_version=0.100.8+1.20.6
fabric_api_version=0.100.8+1.20.6
modmenu_version=10.0.0
malilib_version=0.19.0
litematica_version=0.18.1
7 changes: 5 additions & 2 deletions versions/fabric-1.21.3/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ loom.platform=fabric

# Mod Metadata
# https://fabricmc.net/versions.html
fabric_loader_version=0.16.5
fabric_loader_version=0.16.8
minecraft_dependency=>=1.21 <=1.21.3

# Build Information
# The target mc versions for the mod during mod publishing, separated with \n
game_versions=1.21\n1.21.1\n1.21.2\n1.21.3

# Dependencies
# fabric_api_version=0.107.3+1.21.3
fabric_api_version=0.110.0+1.21.3
modmenu_version=12.0.0-beta.1
malilib_version=0.22.0
litematica_version=0.20.0

0 comments on commit 764c085

Please sign in to comment.