Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Fix compatibility with Vanilla Fix, optimization
Browse files Browse the repository at this point in the history
Bump version to 1.0.1
  • Loading branch information
Flamarine committed Jul 16, 2022
1 parent 78fec7b commit 637402c
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 15 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ mixin_version=0.11.4+mixin.0.8.5
loader_version=0.14.6-babric.1

# Mod
mod_version=1.0.0
mod_version=1.0.1
mod_group=io.github.pkstdev
mod_name=BTAModList
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.github.pkstdev.btamodlist.mixin;

import io.github.pkstdev.btamodlist.screen.ScreenModList;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.src.GuiButton;
import net.minecraft.src.GuiIngameMenu;
import net.minecraft.src.GuiScreen;
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(GuiIngameMenu.class)
public class GuiIngameMenuMixin extends GuiScreen {
@Inject(method = "initGui", at = @At("RETURN"))
public void onInitGui(CallbackInfo ci) {
byte byte1 = -16;
this.controlList.add(new GuiButton(9999, this.width / 2 - 100, this.height / 4 + 72 + byte1, "Mods (" + FabricLoader.getInstance().getAllMods().size() + " Loaded)"));
}

@Inject(method = "actionPerformed", at = @At("RETURN"))
public void onActionPerformed(GuiButton button, CallbackInfo ci) {
if (button.id == 9999) {
this.mc.displayGuiScreen(new ScreenModList(this));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

@Mixin(value = GuiMainMenu.class, remap = false)
public class GuiMainMenuMixin extends GuiScreen {
@Inject(method = "initGui", at = @At("RETURN"))
@Inject(method = "initGui", at = @At("HEAD"))
public void onInitGui(CallbackInfo ci) {
int i = this.height / 4 + 48;
this.controlList.add(new GuiButton(9999, this.width / 2 - 100, i + 108, "Mods (" + FabricLoader.getInstance().getAllMods().size() + " Loaded)"));
}

@Inject(method = "actionPerformed", at = @At("RETURN"))
public void onActionPerformed(GuiButton guiButton, CallbackInfo ci) {
if (guiButton.id == 9999) {
public void onActionPerformed(GuiButton button, CallbackInfo ci) {
if (button.id == 9999) {
this.mc.displayGuiScreen(new ScreenModList(this));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,18 @@ public void initGui() {
}

@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton.enabled) {
if (guibutton.id == 10000) {
protected void actionPerformed(GuiButton button) {
if (button.enabled) {
if (button.id == 10000) {
try {
Desktop.getDesktop().open(new File(Minecraft.getMinecraftDir(), "mods").getAbsoluteFile());
} catch (IOException var3) {
var3.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else if (guibutton.id == 6) {
this.mc.renderEngine.refreshTextures();
} else if (button.id == 6) {
this.mc.displayGuiScreen(this.parent);
} else {
this.modList.actionPerformed(guibutton);
this.modList.actionPerformed(button);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ protected void drawBackground() {
protected void drawSlot(int i, int j, int k, int l, Tessellator tessellator) {
ModContainer mod = new ArrayList<>(mods).get(i);
FontRenderer textRenderer = Minecraft.getMinecraft().fontRenderer;
this.parent.drawString(textRenderer, mod.getMetadata().getName(), (this.parent.width - textRenderer.getStringWidth(mod.getMetadata().getName())) / 2, k + 1, 16777215);
this.parent.drawString(textRenderer, mod.getMetadata().getDescription(), (this.parent.width - textRenderer.getStringWidth(mod.getMetadata().getDescription())) / 2, k + 12, 8421504);
String name = mod.getMetadata().getName();
String version = mod.getMetadata().getVersion().getFriendlyString();
String desc = mod.getMetadata().getDescription();
this.parent.drawString(textRenderer, name + " - ", (this.parent.width - textRenderer.getStringWidth(name + " - " + version)) / 2, k + 1, 16777215);
this.parent.drawString(textRenderer, version, (this.parent.width - textRenderer.getStringWidth(name + " - " + version)) / 2 + textRenderer.getStringWidth(name + " - "), k + 1, 5592405);
this.parent.drawString(textRenderer, desc, (this.parent.width - textRenderer.getStringWidth(desc)) / 2, k + 12, 8421504);
}
}
3 changes: 2 additions & 1 deletion src/main/resources/btamodlist.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"mixins": [
],
"client": [
"GuiMainMenuMixin"
"GuiMainMenuMixin",
"GuiIngameMenuMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit 637402c

Please sign in to comment.