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