Skip to content
This repository has been archived by the owner on Oct 20, 2021. It is now read-only.

Commit

Permalink
- last bugfixes
Browse files Browse the repository at this point in the history
- slight code cleanup
- Update README.md
  • Loading branch information
UltraBlackLinux committed Jun 18, 2021
1 parent 5c7678f commit 54833af
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 45 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

<a href="https://www.curseforge.com/minecraft/mc-mods/fabric-api"> <img src="https://i.imgur.com/Ol1Tcf8.png" width="171.8" height="57,6"> </a>

# MineMenuFabric
**Minemenu, but for Fabric**
# MineMenu(for)Fabric

Note: This project doesn't have anything to do with Girafi's Minemenu, This is only a fabric port!
**Note: This project is completely seperate from Girafi's MineMenu mod - This is only a very customized port for the Fabric-modloader!**

MineMenuFabric is a customizable menu, that lets you manage commands and chat messages in a simple, yet powerful circular menu
MineMenuFabric assists you with sending and queueing chat messages, copying text, opening links and even pressing (un)bound keybinds in a simple, yet powerful circular and customizable menu with support for categories.

Supports enchanted/playerhead icons and copying text, opening links, saying a message in the chat and creating categories to keep your menu sorted!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import me.ultrablacklinux.minemenufabric.client.util.GsonUtil;
import me.ultrablacklinux.minemenufabric.client.util.RandomUtil;
import me.ultrablacklinux.minemenufabric.access.KeyBindingInterface;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
Expand Down Expand Up @@ -276,6 +277,7 @@ private void handleTypes(JsonObject value) {

switch (type) {
case "empty":
close();
RandomUtil.openConfigScreen(this);
break;

Expand All @@ -289,18 +291,19 @@ private void handleTypes(JsonObject value) {


case "print":
close();
client.player.sendChatMessage(value.get("data").getAsString());
this.client.openScreen(null);
break;

case "chatbox":
close();
client.openScreen(new ChatScreen(value.get("data").getAsString()));
break;

case "clipboard":
close();
this.client.keyboard.setClipboard(value.get("data").getAsString());
client.player.sendMessage(new TranslatableText("minemenu.select.copied"), true);
this.client.openScreen(null);
break;

/*case "keydetect":
Expand All @@ -327,8 +330,6 @@ private void handleTypes(JsonObject value) {
break;*/

case "keyselect":
if (client.currentScreen instanceof MineMenuSelectScreen) this.client.openScreen(null);

KeyBinding tmpBinding = keyBindings.stream()
.filter(keyBindingstream -> keyBindingstream.getTranslationKey().equals(value.get("data")
.getAsJsonObject().get("key").getAsString())).findFirst().get();
Expand All @@ -345,10 +346,12 @@ private void handleTypes(JsonObject value) {
if (delay != 25001) pressKey(false, tmpBinding);
});

close();
press.start();
break;

case "link":
close();
String link = value.get("data").getAsString();
try {
if (!link.startsWith("http")) link = "http://" + link;
Expand Down Expand Up @@ -376,6 +379,10 @@ public static void updateRepeatData(String type, JsonObject value) {
repeatDatapath = (ArrayList<String>) datapath.clone();
}
}
}

private static void close() {
MinecraftClient.getInstance().openScreen(null);
datapath = new ArrayList<>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import me.ultrablacklinux.minemenufabric.client.util.GsonUtil;
import me.ultrablacklinux.minemenufabric.client.util.RandomUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ScreenTexts;
import net.minecraft.client.gui.widget.ButtonWidget;
Expand Down Expand Up @@ -64,7 +63,7 @@ public class MineMenuSettingsScreen extends Screen {
private boolean enchanted = false;
private boolean firstRun = true;
private int customModelData = 0;
private int keyBindReleaseTime = 0;
private int keyBindReleaseTime = 10;

public MineMenuSettingsScreen(Screen parent, boolean repeat) {
super(new TranslatableText("minemenu.settings.title"));
Expand All @@ -79,10 +78,6 @@ public MineMenuSettingsScreen(Screen parent, boolean repeat) {
}

private void updateData() {
/*if (localDPath == null) {
client.openScreen(null);
return;
}*/
localData = minemenuData;
for (String s : localDPath) localData = localData.get(s).getAsJsonObject();
}
Expand Down Expand Up @@ -140,16 +135,7 @@ protected void init() {

this.keyBindButton = this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, 140, 200, 20,
InputUtil.UNKNOWN_KEY.getLocalizedText(), (buttonWidget) -> {
/*if (itemTypes == itemTypes.KEYDETECT) {
this.keyListenerActive = !this.keyListenerActive;
this.updateInput();
if (keyListenerActive) this.keyBindButton.setMessage((new LiteralText("> "))
.append(this.keyBindButton.getMessage().shallowCopy().formatted(Formatting.YELLOW))
.append(" <").formatted(Formatting.YELLOW)); //Definitely not stolen from minecraft's code
}
else */if (itemTypes == itemTypes.KEYSELECT) {
this.keyBindCycle(false);
}
if (itemTypes == itemTypes.KEYSELECT) this.keyBindCycle(false);
}));

this.itemType = this.addDrawableChild(new ButtonWidget(this.width / 2 - 100, 180, 200,
Expand All @@ -166,7 +152,7 @@ protected void init() {
}

this.keyBindreleaseSlider = this.addDrawableChild(new SliderWidget(this.width / 2 - 100, 160, 200,
20, LiteralText.EMPTY, this.keyBindReleaseTime / 25001D) {
20, LiteralText.EMPTY, (this.keyBindReleaseTime - 10) / (25001 - 10)) {
{ //hippedy, hoppedy, your code is now my property
this.updateMessage();
}
Expand All @@ -183,7 +169,7 @@ protected void updateMessage() {

protected void applyValue() {
MineMenuSettingsScreen.this.keyBindReleaseTime
= MathHelper.floor(MathHelper.clampedLerp(0, 25001, this.value));
= MathHelper.floor(MathHelper.clampedLerp(10, 25001, this.value));
}
});

Expand All @@ -200,7 +186,6 @@ protected void applyValue() {

private void keyBindCycle(boolean reverse) {
int index = keyBindings.indexOf(usedBinding);
//KeyBindingHelper.getBoundKeyOf()
if (this.usedBinding == null || (index == keyBindings.size() - 1 && !reverse)) {
this.usedBinding = keyBindings.get(0);
}
Expand Down Expand Up @@ -257,7 +242,7 @@ private void updateInput() {
break;
}

if (/*itemTypes == MenuTypes.KEYDETECT ||*/ itemTypes == MenuTypes.KEYSELECT) {
if (itemTypes == MenuTypes.KEYSELECT) {
this.keyBindButton.visible = true;
this.keyBindreleaseSlider.visible = true;
this.itemData.visible = false;
Expand All @@ -279,13 +264,6 @@ private void updateInput() {
this.itemData.setEditable(true);
break;

/*case KEYDETECT:
this.itemData.setEditable(false);
try {
this.keyBindButton.setMessage(this.usedKey.getLocalizedText());
} catch (Exception ingore) {}
break;*/

case KEYSELECT:
this.itemData.setEditable(false);
try {
Expand Down Expand Up @@ -490,11 +468,6 @@ private void applySettings() {
subDataOut = new JsonPrimitive(dataTextOut);
break;

/*case KEYDETECT:
subDataOut.getAsJsonObject().add("key", new JsonPrimitive(this.usedKey.getTranslationKey()));
subDataOut.getAsJsonObject().add("releaseDelay", new JsonPrimitive(keyBindReleaseTime));
break;*/

case KEYSELECT:
subDataOut.getAsJsonObject().add("key", new JsonPrimitive(this.usedBinding.getTranslationKey()));
subDataOut.getAsJsonObject().add("releaseDelay", new JsonPrimitive(keyBindReleaseTime));
Expand Down Expand Up @@ -538,11 +511,6 @@ private void readTypes(JsonObject data) {
this.itemData.setText(data.get("data").getAsString());
break;

/*case KEYDETECT:
this.usedKey = InputUtil.fromTranslationKey(data.get("data").getAsJsonObject().get("key").getAsString());
this.keyBindReleaseTime = data.get("data").getAsJsonObject().get("releaseDelay").getAsInt();
break;*/

case KEYSELECT:
try {
this.usedBinding = this.keyBindings.stream()
Expand Down

0 comments on commit 54833af

Please sign in to comment.