InteractionMenu updates
This commit is contained in:
committed by
Cloudburst
parent
bb7c6f016f
commit
c4f4539a87
@@ -4,7 +4,6 @@ import anticope.rejects.MeteorRejectsAddon;
|
||||
import anticope.rejects.gui.screens.InteractionScreen;
|
||||
import it.unimi.dsi.fastutil.objects.Object2BooleanMap;
|
||||
import meteordevelopment.meteorclient.gui.GuiTheme;
|
||||
import meteordevelopment.meteorclient.gui.utils.CharFilter;
|
||||
import meteordevelopment.meteorclient.gui.utils.StarscriptTextBoxRenderer;
|
||||
import meteordevelopment.meteorclient.gui.widgets.WWidget;
|
||||
import meteordevelopment.meteorclient.gui.widgets.containers.WTable;
|
||||
@@ -19,7 +18,6 @@ import meteordevelopment.meteorclient.utils.misc.MeteorStarscript;
|
||||
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
|
||||
import meteordevelopment.starscript.value.Value;
|
||||
import meteordevelopment.starscript.value.ValueMap;
|
||||
|
||||
import net.minecraft.client.render.debug.DebugRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
@@ -27,7 +25,8 @@ import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtString;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Optional;
|
||||
|
||||
public class InteractionMenu extends Module {
|
||||
|
||||
@@ -47,6 +46,12 @@ public class InteractionMenu extends Module {
|
||||
.action(this::onKey)
|
||||
.build()
|
||||
);
|
||||
public final Setting<Boolean> useCrosshairTarget = sgGeneral.add(new BoolSetting.Builder()
|
||||
.name("use-crosshair-target")
|
||||
.description("Use crosshair target.")
|
||||
.defaultValue(false)
|
||||
.build()
|
||||
);
|
||||
|
||||
// Style
|
||||
public final Setting<SettingColor> selectedDotColor = sgStyle.add(new ColorSetting.Builder()
|
||||
@@ -89,15 +94,22 @@ public class InteractionMenu extends Module {
|
||||
}
|
||||
|
||||
public void onKey() {
|
||||
if (mc.currentScreen != null) return;
|
||||
if (mc.player == null || mc.currentScreen != null) return;
|
||||
Entity e = null;
|
||||
if (useCrosshairTarget.get()) {
|
||||
e = mc.targetedEntity;
|
||||
} else {
|
||||
Optional<Entity> lookingAt = DebugRenderer.getTargetedEntity(mc.player, 20);
|
||||
if (lookingAt.isPresent()) {
|
||||
Entity e = lookingAt.get();
|
||||
e = lookingAt.get();
|
||||
}
|
||||
}
|
||||
|
||||
if (e == null) return;
|
||||
if (entities.get().getBoolean(e.getType())) {
|
||||
mc.setScreen(new InteractionScreen(e, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public WWidget getWidget(GuiTheme theme) {
|
||||
@@ -119,18 +131,15 @@ public class InteractionMenu extends Module {
|
||||
table.row();
|
||||
});
|
||||
WTextBox textBoxK = table.add(theme.textBox(currMsgK)).minWidth(100).expandX().widget();
|
||||
textBoxK.action = () -> {
|
||||
currMsgK = textBoxK.get();
|
||||
};
|
||||
textBoxK.action = () -> currMsgK = textBoxK.get();
|
||||
WTextBox textBoxV = table.add(theme.textBox(currMsgV, (text1, c) -> true, StarscriptTextBoxRenderer.class)).minWidth(100).expandX().widget();
|
||||
textBoxV.action = () -> {
|
||||
currMsgV = textBoxV.get();
|
||||
};
|
||||
textBoxV.action = () -> currMsgV = textBoxV.get();
|
||||
WPlus add = table.add(theme.plus()).widget();
|
||||
add.action = () -> {
|
||||
if (currMsgK != "" && currMsgV != "") {
|
||||
if (!currMsgK.equals("") && !currMsgV.equals("")) {
|
||||
messages.put(currMsgK, currMsgV);
|
||||
currMsgK = ""; currMsgV = "";
|
||||
currMsgK = "";
|
||||
currMsgV = "";
|
||||
fillTable(theme, table);
|
||||
}
|
||||
};
|
||||
@@ -142,9 +151,7 @@ public class InteractionMenu extends Module {
|
||||
NbtCompound tag = super.toTag();
|
||||
|
||||
NbtCompound messTag = new NbtCompound();
|
||||
messages.keySet().forEach((key) -> {
|
||||
messTag.put(key, NbtString.of(messages.get(key)));
|
||||
});
|
||||
messages.keySet().forEach((key) -> messTag.put(key, NbtString.of(messages.get(key))));
|
||||
|
||||
tag.put("messages", messTag);
|
||||
return tag;
|
||||
@@ -156,9 +163,7 @@ public class InteractionMenu extends Module {
|
||||
messages.clear();
|
||||
if (tag.contains("messages")) {
|
||||
NbtCompound msgs = tag.getCompound("messages");
|
||||
msgs.getKeys().forEach((key) -> {
|
||||
messages.put(key, msgs.getString(key));
|
||||
});
|
||||
msgs.getKeys().forEach((key) -> messages.put(key, msgs.getString(key)));
|
||||
}
|
||||
|
||||
return super.fromTag(tag);
|
||||
|
||||
Reference in New Issue
Block a user