This repository has been archived by the owner on Nov 6, 2022. It is now read-only.
generated from Flamarine/BTAExampleMod-babric
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
149 additions
and
69 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,5 @@ | ||
# BTA Example Mod - Babric | ||
# BTA Mod List | ||
|
||
A simple mod template for Better Than Adventure, yet this template is for Babric. | ||
This mod adds a simple mod list for BTA. The mod runs on Babric. | ||
|
||
Original version: https://github.com/pkstDev/BTAExampleMod | ||
|
||
### Setup (Same as the original one) | ||
|
||
1. Grab a full BTA jar from the MultiMC instance (or anywhere else you want) and rename it to "bta.jar". | ||
|
||
2. Place the jar in the "libs" folder in your project. | ||
|
||
3. Run the following command: | ||
```shell | ||
gradlew build | ||
``` | ||
|
||
4. Start your modding trip! | ||
|
||
### Extra Tips | ||
|
||
Since BTA is distributed without obfuscation, all Mixin classes must set the 'remap' option to false! | ||
<img src="epicpic.png" width="1920" height="1080" alt="nice pic hahaye"/> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
src/main/java/com/example/examplemod/mixin/ExampleMixin.java
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
src/main/java/io/github/pkstdev/btamodlist/mixin/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,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.GuiMainMenu; | ||
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(value = GuiMainMenu.class, remap = false) | ||
public class GuiMainMenuMixin extends GuiScreen { | ||
@Inject(method = "initGui", at = @At("RETURN")) | ||
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) { | ||
this.mc.displayGuiScreen(new ScreenModList(this)); | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
src/main/java/io/github/pkstdev/btamodlist/screen/ScreenModList.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,60 @@ | ||
package io.github.pkstdev.btamodlist.screen; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.src.GuiButton; | ||
import net.minecraft.src.GuiOptionsButton; | ||
import net.minecraft.src.GuiScreen; | ||
import net.minecraft.src.StringTranslate; | ||
|
||
import java.awt.*; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class ScreenModList extends GuiScreen { | ||
private ScreenModListSlot modList; | ||
private final GuiScreen parent; | ||
|
||
public ScreenModList(GuiScreen parent) { | ||
super(parent); | ||
this.parent = parent; | ||
} | ||
|
||
@Override | ||
public void initGui() { | ||
StringTranslate i18n = StringTranslate.getInstance(); | ||
this.controlList.add(new GuiOptionsButton(10000, this.width / 2 - 154, this.height - 48, "Open Mods Folder")); | ||
this.controlList.add(new GuiOptionsButton(6, this.width / 2 + 4, this.height - 48, i18n.translateKey("gui.done"))); | ||
this.modList = new ScreenModListSlot(this); | ||
this.modList.registerScrollButtons(this.controlList, 10001, 10002); | ||
} | ||
|
||
@Override | ||
protected void actionPerformed(GuiButton guibutton) { | ||
if (guibutton.enabled) { | ||
if (guibutton.id == 10000) { | ||
try { | ||
Desktop.getDesktop().open(new File(Minecraft.getMinecraftDir(), "mods").getAbsoluteFile()); | ||
} catch (IOException var3) { | ||
var3.printStackTrace(); | ||
} | ||
} else if (guibutton.id == 6) { | ||
this.mc.renderEngine.refreshTextures(); | ||
this.mc.displayGuiScreen(this.parent); | ||
} else { | ||
this.modList.actionPerformed(guibutton); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void drawScreen(int x, int y, float renderPartialTicks) { | ||
this.modList.drawScreen(x, y, renderPartialTicks); | ||
this.drawString(mc.fontRenderer, | ||
"Mods (" + FabricLoader.getInstance().getAllMods().size() + " Loaded)", | ||
(this.parent.width - mc.fontRenderer.getStringWidth("Mods (" + FabricLoader.getInstance().getAllMods().size() + " Loaded)")) / 2, | ||
16, | ||
16777215); | ||
super.drawScreen(x, y, renderPartialTicks); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/io/github/pkstdev/btamodlist/screen/ScreenModListSlot.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,49 @@ | ||
package io.github.pkstdev.btamodlist.screen; | ||
|
||
import net.fabricmc.loader.api.FabricLoader; | ||
import net.fabricmc.loader.api.ModContainer; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.src.FontRenderer; | ||
import net.minecraft.src.GuiSlot; | ||
import net.minecraft.src.Tessellator; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
|
||
public class ScreenModListSlot extends GuiSlot { | ||
private final Collection<ModContainer> mods; | ||
private final ScreenModList parent; | ||
|
||
public ScreenModListSlot(ScreenModList modListScreen) { | ||
super(Minecraft.getMinecraft(), modListScreen.width, modListScreen.height, 32, modListScreen.height - 51, 36); | ||
this.mods = FabricLoader.getInstance().getAllMods(); | ||
this.parent = modListScreen; | ||
} | ||
|
||
@Override | ||
public int getSize() { | ||
return mods.size(); | ||
} | ||
|
||
@Override | ||
protected void elementClicked(int i, boolean b) { | ||
} | ||
|
||
@Override | ||
protected boolean isSelected(int i) { | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void drawBackground() { | ||
this.parent.drawDefaultBackground(); | ||
} | ||
|
||
@Override | ||
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); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
src/main/resources/modid.mixins.json → src/main/resources/btamodlist.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