Skip to content

Commit

Permalink
Merge pull request #4 from umollu/master
Browse files Browse the repository at this point in the history
Included cloth config dependency; Hide TitleScreen button based on name instead of index;
  • Loading branch information
TomB-134 authored Oct 29, 2020
2 parents 1f54e25 + c2623d6 commit 7a4e5ea
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ dependencies {
modApi("me.shedaniel.cloth:config-2:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}

include("me.shedaniel.cloth:config-2:${project.cloth_config_version}") {
exclude(group: "net.fabricmc.fabric-api")
}
}

processResources {
Expand Down
19 changes: 5 additions & 14 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,15 @@ org.gradle.jvmargs = -Xmx1G

#Fabric properties
minecraft_version = 1.16.3
yarn_mappings = 1.16.3+build.11
loader_version = 0.9.3+build.207
yarn_mappings = 1.16.3+build.47
loader_version = 0.10.5+build.213

#Mod properties
mod_version = 1.16.3-0.0.4
mod_version = 1.16.3-0.0.5
maven_group = minimalmenu
archives_base_name = minimalmenu

#Dependencies
fabric_api_version = 0.21.0+build.407-1.16
fabric_api_version = 0.24.3+build.414-1.16
mod_menu_version = 1.14.6+build.31
cloth_config_version = 4.7.0-unstable

modmenu_1.16.2 = 1.14.6+build.31
cloth_config_1.16.2 = 4.8.1

modmenu_1.16.1 = 1.14.5+build.30
cloth_config_1.16.1 = 4.6.0

modmenu_1.16.3 = 1.14.6+build.31
cloth_config_1.16.3 = 4.8.1
cloth_config_version = 4.8.2
30 changes: 21 additions & 9 deletions src/main/java/minimalmenu/mixin/TitleScreenMixin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package minimalmenu.mixin;

import com.google.common.collect.Lists;
import minimalmenu.MinimalMenu;
import minimalmenu.config.ConfigHandler;
import net.minecraft.client.gui.CubeMapRenderer;
Expand All @@ -8,13 +9,16 @@
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.widget.AbstractButtonWidget;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.List;

@Mixin(TitleScreen.class)
public class TitleScreenMixin extends Screen {
@Shadow public static final CubeMapRenderer PANORAMA_CUBE_MAP = new CubeMapRenderer(new Identifier("textures/gui/title/background/panorama"));
Expand Down Expand Up @@ -50,36 +54,44 @@ protected void init(CallbackInfo info) {
copyrightTextX = 1000000000;
}

for (AbstractButtonWidget buttonWidget : this.buttons) {
List<String> buttonsTypes = Lists.newArrayList();
for (AbstractButtonWidget button : this.buttons) {
buttonsTypes.add(((TranslatableText) button.getMessage()).getKey());
}

for (int i = 0; i < this.buttons.size(); i++) {
AbstractButtonWidget buttonWidget = this.buttons.get(i);
String buttonType = buttonsTypes.get(i);

if (ConfigHandler.REMOVE_SINGLEPLAYER) {
if (buttons.indexOf(buttonWidget) == 0) {
if (buttonType.equals("menu.singleplayer")) {
buttonWidget.visible = false;
} else if (buttons.indexOf(buttonWidget) == 1 || buttons.indexOf(buttonWidget) == 2 || buttons.indexOf(buttonWidget) == 3 || buttons.indexOf(buttonWidget) == 4 || buttons.indexOf(buttonWidget) == 5 || buttons.indexOf(buttonWidget) == 6 || buttons.indexOf(buttonWidget) == 7) {
} else if (i > buttonsTypes.indexOf("menu.singleplayer")) {
buttonWidget.y -= 24;
}
}

if (ConfigHandler.REMOVE_MULTIPLAYER) {
if (buttons.indexOf(buttonWidget) == 1) {
if (buttonType.equals("menu.multiplayer")) {
buttonWidget.visible = false;
} else if (buttons.indexOf(buttonWidget) == 2 || buttons.indexOf(buttonWidget) == 3 || buttons.indexOf(buttonWidget) == 4 || buttons.indexOf(buttonWidget) == 5 || buttons.indexOf(buttonWidget) == 6 || buttons.indexOf(buttonWidget) == 7) {
} else if (i > buttonsTypes.indexOf("menu.multiplayer")) {
buttonWidget.y -= 24;
}
}

if (ConfigHandler.REMOVE_REALMS) {
if (buttons.indexOf(buttonWidget) == 2) {
if (buttonType.equals("menu.online")) {
buttonWidget.visible = false;
} else if (buttons.indexOf(buttonWidget) == 3 || buttons.indexOf(buttonWidget) == 4 || buttons.indexOf(buttonWidget) == 5 || buttons.indexOf(buttonWidget) == 6 || buttons.indexOf(buttonWidget) == 7) {
} else if (i > buttonsTypes.indexOf("menu.online")) {
buttonWidget.y -= 24;
}
}

if (ConfigHandler.REMOVE_LANGUAGE && buttons.indexOf(buttonWidget) == 4) {
if (ConfigHandler.REMOVE_LANGUAGE && buttonType.equals("narrator.button.language")) {
buttonWidget.visible = false;
}

if (ConfigHandler.REMOVE_ACCESSIBILITY && buttons.indexOf(buttonWidget) == 7) {
if (ConfigHandler.REMOVE_ACCESSIBILITY && buttonType.equals("narrator.button.accessibility")) {
buttonWidget.visible = false;
}

Expand Down

0 comments on commit 7a4e5ea

Please sign in to comment.