Skip to content

Commit

Permalink
Make MC based, mod authors & contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamarine committed Nov 7, 2022
1 parent 90eaf60 commit 62c96a7
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 26 deletions.
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,41 @@ A picture's worth 2 words
4. Click on your new Prism Launcher instance and click "edit instance" on the right. Click "loader mods" then "add", and navigate to the mod you just downloaded, and press OK.

### Developers:
- You can obtain the latest build via [JitPack](https://jitpack.io/).
- You can obtain the latest build via [JitPack](https://jitpack.io/). Add following to your project's `build.gradle`:
```groovy
repositories {
// ...
maven {
name = 'JitPack'
url = 'https://jitpack.io/'
}
}
dependencies {
// ...
modImplementation "com.github.Turnip-Labs:ModMenu:<VERSION>"
}
```
Replace the version with the latest version, which you can find above.
- The icon comes from the icon specified in your fabric.mod.json (as per the spec)
- Clientside-only and API badges are defined as custom objects in your fabric.mod.json as such:
- Clientside-only and API badges are defined as custom objects in your `fabric.mod.json` as such:
```json
"custom": {
"modmenu:api": true,
"modmenu:clientsideOnly": true
}
```
- Mod parenting is used to display a mod as a child of another one. This is meant to be used for mods divided into different modules. The following element in a fabric.mod.json will define the mod as a child of the mod 'flamingo':
- Mod parenting is used to display a mod as a child of another one. This is meant to be used for mods divided into different modules. The following element in a `fabric.mod.json` will define the mod as a child of the mod 'flamingo':
```json
"custom": {
"modmenu:parent": "flamingo"
}
```
- ModMenuAPI
- To use the API, implement the ModMenuApi interface on a class and add that as an entry point of type "modmenu" in your fabric.mod.json as such:
- To use the API, implement the `ModMenuApi` interface on a class and add that as an entry point of type `modmenu` in your `fabric.mod.json` as such:
```json
"entrypoints": {
"modmenu": [ "com.example.mod.ExampleModMenuApiImpl" ]
"modmenu": [ "com.example.mod.ExampleModMenuApiImpl" ]
}
```
- Features
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx1G
# Also makes builds more reliable and less likely to randomly fail.
org.gradle.daemon=false

mod_version=1.8.5-bta.3
mod_version=1.8.6-bta.1
mod_group=io.github.prospector
mod_name=modmenu

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.function.Function;
import java.util.function.Supplier;
import net.minecraft.src.GuiScreen;
import org.jetbrains.annotations.ApiStatus;

public interface ModMenuApi {
/**
Expand All @@ -31,9 +32,10 @@ static void addConfigOverride(String modid, Runnable action) {
* now allows ModMenu to open the screen for you, rather than depending
* on you to open it, and gets rid of the messy Optional->Supplier wrapping.
*
* @deprecated Will be removed in 1.15 snapshots.
* @deprecated For internal use only.
*/
@Deprecated
@ApiStatus.Internal
default Optional<Supplier<GuiScreen>> getConfigScreen(GuiScreen screen) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.fabricmc.loader.api.ModContainer;

import java.util.Comparator;

public class ModMenuConfig {
private boolean showLibraries = false;
private Sorting sorting = Sorting.ASCENDING;
Expand All @@ -26,12 +27,12 @@ public Sorting getSorting() {
return sorting;
}

public static enum Sorting {
public enum Sorting {
ASCENDING(Comparator.comparing(modContainer -> HardcodedUtil.formatFabricModuleName(modContainer.getMetadata().getName())), "A-Z"),
DECENDING(ASCENDING.getComparator().reversed(), "Z-A");

Comparator<ModContainer> comparator;
String name;
final Comparator<ModContainer> comparator;
final String name;

Sorting(Comparator<ModContainer> comparator, String name) {
this.comparator = comparator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import io.github.prospector.modmenu.util.HardcodedUtil;
import io.github.prospector.modmenu.util.RenderUtils;
import net.fabricmc.loader.api.metadata.Person;
import net.minecraft.client.Minecraft;
import net.minecraft.src.FontRenderer;

public class DescriptionListWidget extends EntryListWidget<DescriptionListWidget.DescriptionEntry> {
import java.util.Collection;
import java.util.List;

public class DescriptionListWidget extends EntryListWidget<DescriptionListWidget.DescriptionEntry> {
private final ModListScreen parent;
private final FontRenderer textRenderer;
private ModListEntry lastSelected = null;
Expand Down Expand Up @@ -41,6 +44,9 @@ public void render(int mouseX, int mouseY, float delta) {
setScrollAmount(-Double.MAX_VALUE);
String description = lastSelected.getMetadata().getDescription();
String id = lastSelected.getMetadata().getId();
Collection<Person> authors = lastSelected.getMetadata().getAuthors();
Collection<Person> contributors = lastSelected.getMetadata().getContributors();
Collection<String> licenses = lastSelected.getMetadata().getLicense();
if (description.isEmpty() && HardcodedUtil.getHardcodedDescriptions().containsKey(id)) {
description = HardcodedUtil.getHardcodedDescription(id);
}
Expand All @@ -49,6 +55,27 @@ public void render(int mouseX, int mouseY, float delta) {
children().add(new DescriptionEntry(line));
}
}
if (!authors.isEmpty()) {
if (!children().isEmpty()) children().add(new DescriptionEntry(""));
children().add(new DescriptionEntry("Authors:"));
for (Person person : authors) {
children().add(new DescriptionEntry(" " + person.getName()));
}
}
if (!contributors.isEmpty()) {
if (!children().isEmpty()) children().add(new DescriptionEntry(""));
children().add(new DescriptionEntry("Contributors:"));
for (Person person : contributors) {
children().add(new DescriptionEntry(" " + person.getName()));
}
}
if (!licenses.isEmpty()) {
if (!children().isEmpty()) children().add(new DescriptionEntry(""));
children().add(new DescriptionEntry("Licenses:"));
for (String license : licenses) {
children().add(new DescriptionEntry(" " + license));
}
}
}
super.render(mouseX, mouseY, delta);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;

@SuppressWarnings({"unchecked", "unused"})
@Environment(EnvType.CLIENT)
public abstract class EntryListWidget<E extends EntryListWidget.Entry<E>> extends GuiScreen {
protected static final int DRAG_OUTSIDE = -2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import net.minecraft.src.GuiButton;

public class GuiButtonAccessor {

public static GuiButton createButton(int buttonId, int x, int y, int width, int height, String text) {
GuiButton button = new GuiButton(buttonId, x, y, text);
//noinspection ConstantConditions
MixinGuiButton accessor = (MixinGuiButton) button;
accessor.setWidth(width);
accessor.setHeight(height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

@Mixin(value = GuiButton.class, remap = false)
public interface MixinGuiButton {

@Accessor
int getWidth();

Expand All @@ -15,5 +14,4 @@ public interface MixinGuiButton {

@Accessor
void setHeight(int height);

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = GuiIngameMenu.class, remap = false)
public class MixinGameMenuScreen extends GuiScreen {
public class MixinGuiIngameMenu extends GuiScreen {

@SuppressWarnings("unchecked")
@Inject(at = @At("RETURN"), method = "initGui")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = GuiMainMenu.class, remap = false)
public class MixinTitleScreen extends GuiScreen {
public class MixinGuiMainMenu extends GuiScreen {
@Inject(at = @At("RETURN"), method = "initGui")
public void drawMenuButton(CallbackInfo info) {
GuiButton texturePackButton = this.controlList.get(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@

@Mixin(value = {TexturePackBase.class, TexturePackCustom.class}, remap = false)
public class MixinTexturePacks {

@Inject(method = "getResourceAsStream", at = @At(value = "INVOKE", target = "Ljava/lang/Class;getResourceAsStream(Ljava/lang/String;)Ljava/io/InputStream;", remap = false), cancellable = true)
private void onGetResource(String resource, CallbackInfoReturnable<InputStream> ci) {
InputStream in = ModMenu.class.getClassLoader().getResourceAsStream(resource);
if (in != null)
ci.setReturnValue(in);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static void initializeHardcodings() {
HARDCODED_DESCRIPTIONS.put("fabric-resource-loader-v0", "Asset and data resource loading.");
HARDCODED_DESCRIPTIONS.put("fabric-tag-extensions-v0", "Hooks for tags.");
HARDCODED_DESCRIPTIONS.put("fabric-textures-v0", "Hooks for texture loading and registration.");
HARDCODED_DESCRIPTIONS.put("minecraft", "The base game.");
HARDCODED_DESCRIPTIONS.put("minecraft", "The based game.");
}

public static void hardcodeModuleMetadata(ModContainer mod, ModMetadata metadata, String id) {
Expand Down
9 changes: 5 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
]
},
"contact": {
"homepage": "https://minecraft.curseforge.com/projects/modmenu",
"sources": "https://github.com/Prospector/ModMenu",
"issues": "https://github.com/Prospector/ModMenu/issues"
"homepage": "https://github.com/Turnip-Labs/",
"sources": "https://github.com/Turnip-Labs/ModMenu",
"issues": "https://github.com/Turnip-Labs/ModMenu/issues"
},
"depends": {
"fabricloader": "*"
Expand Down Expand Up @@ -45,7 +45,8 @@
"LeonXu98",
"magneticflux",
"Earthcomputer",
"Ambos"
"Ambos",
"pkstDev"
],
"description": "Adds a mod menu to view the list of mods you have installed.",
"mixins": [
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/mixins.modmenu.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"package": "io.github.prospector.modmenu.mixin",
"compatibilityLevel": "JAVA_8",
"client": [
"MixinGameMenuScreen",
"MixinTitleScreen",
"MixinGuiIngameMenu",
"MixinGuiMainMenu",
"MixinTexturePacks",
"MixinGuiButton",
"MinecraftAccessor"
Expand Down

0 comments on commit 62c96a7

Please sign in to comment.