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

Commit

Permalink
Initial commit ugh
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamarine committed Jul 15, 2022
1 parent 92622d4 commit 78fec7b
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 69 deletions.
23 changes: 3 additions & 20 deletions README.md
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"/>
Binary file added epicpic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ loader_version=0.14.6-babric.1

# Mod
mod_version=1.0.0
mod_group=com.example
mod_name=BTAExampleMod-babric
mod_group=io.github.pkstdev
mod_name=BTAModList
14 changes: 0 additions & 14 deletions src/main/java/com/example/examplemod/ExampleMod.java

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/java/com/example/examplemod/mixin/ExampleMixin.java

This file was deleted.

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));
}
}
}
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);
}
}
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.example.examplemod.mixin",
"package": "io.github.pkstdev.btamodlist.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
"ExampleMixin"
"GuiMainMenuMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
21 changes: 6 additions & 15 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
{
"schemaVersion": 1,
"id": "modid",
"id": "btamodlist",
"version": "${version}",

"name": "Example Mod",
"description": "This is an example description! Tell everyone what your mod is about!",
"name": "BTA Mod List",
"description": "Simple Babric mod list for BTA",
"authors": [
"Me!"
"pkstDev"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
},

"license": "CC0-1.0",

"environment": "*",
"entrypoints": {
"main": [
"com.example.examplemod.ExampleMod"
]
},
"environment": "client",
"mixins": [
"modid.mixins.json"
"btamodlist.mixins.json"
],

"depends": {
Expand Down

0 comments on commit 78fec7b

Please sign in to comment.