-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenExplorer button and loading gui migration.
- Loading branch information
1 parent
6d1f033
commit 764c085
Showing
18 changed files
with
184 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/com/vulpeus/kyoyu/client/gui/ButtonActionListener_OpenExplorer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
//?} |
45 changes: 45 additions & 0 deletions
45
src/main/java/com/vulpeus/kyoyu/client/gui/Gui_LoadingExplorer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); */ | ||
//?} | ||
} | ||
} | ||
//?} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/vulpeus/kyoyu/client/mixins/litematica/GuiMainMenuMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
//?} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,5 @@ side="BOTH" | |
|
||
[[mixins]] | ||
config = "kyoyu.mixins.json" | ||
[[mixins]] | ||
config = "kyoyu.client.mixins.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters