interaction screen changes

This commit is contained in:
Cloudburst
2021-05-03 12:43:36 +02:00
parent 523e8ab544
commit 461f749a84
2 changed files with 97 additions and 61 deletions

View File

@@ -4,25 +4,18 @@ import java.awt.Point;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.function.Consumer;
import java.util.function.Function;
import cloudburst.rejects.modules.InteractionMenu;
import minegame159.meteorclient.MeteorClient;
import minegame159.meteorclient.systems.commands.commands.PeekCommand;
import minegame159.meteorclient.systems.modules.Modules;
import minegame159.meteorclient.utils.player.ChatUtils;
import minegame159.meteorclient.utils.player.InvUtils;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.options.KeyBinding;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.Saddleable;
import net.minecraft.entity.passive.HorseBaseEntity;
import net.minecraft.entity.passive.HorseEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.vehicle.ChestMinecartEntity;
import net.minecraft.entity.vehicle.StorageMinecartEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
@@ -34,9 +27,7 @@ import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.InputUtil;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
@@ -56,6 +47,7 @@ public class InteractionScreen extends Screen {
public InteractionScreen(Entity entity) {
super(new LiteralText("Menu Screen"));
this.entity = entity;
//MeteorClient.EVENT_BUS.subscribe(this);
functions = new HashMap<>();
functions.put("Stats", (Entity e) -> {
closeScreen();
@@ -67,25 +59,16 @@ public class InteractionScreen extends Screen {
closeScreen();
client.openScreen(new InventoryScreen((PlayerEntity) e));
});
functions.put("Message", (Entity e) -> {
this.cursorMode(GLFW.GLFW_CURSOR);
closeScreen();
client.openScreen(new ChatScreen(String.format("/msg %s ", ((PlayerEntity)e).getGameProfile().getName())));
});
}
else if (entity instanceof HorseBaseEntity) {
functions.put("Open Inventory", (Entity e) -> {
closeScreen();
if (client.player.isRiding()) {
client.player.networkHandler.sendPacket(new PlayerInputC2SPacket(0, 0, false, true));
}
client.player.networkHandler.sendPacket(new PlayerInteractEntityC2SPacket(entity, Hand.MAIN_HAND, false));
client.player.openRidingInventory();
client.player.networkHandler.sendPacket(new PlayerInputC2SPacket(0, 0, false, true));
});
functions.put("Ride", (Entity e) -> {
closeScreen();
client.player.networkHandler.sendPacket(new PlayerInteractEntityC2SPacket(entity, Hand.MAIN_HAND, false));
client.player.networkHandler.sendPacket(new PlayerInteractEntityC2SPacket(entity, Hand.MAIN_HAND, true));
client.player.setSneaking(false);
});
}
else if (entity instanceof StorageMinecartEntity) {
@@ -126,12 +109,33 @@ public class InteractionScreen extends Screen {
closeScreen();
});
}
if (entity.noClip) {
functions.put("Disable NoClip", (Entity e) -> {
entity.noClip = false;
closeScreen();
});
} else {
functions.put("NoClip", (Entity e) -> {
entity.noClip = true;
closeScreen();
});
}
msgs = Modules.get().get(InteractionMenu.class).messages;
msgs.keySet().forEach((key) -> {
functions.put(key, (Entity e) -> {
closeScreen();
client.openScreen(new ChatScreen(replacePlaceholders(msgs.get(key), e)));
});
if (msgs.get(key).contains("{username}")) {
if (entity instanceof PlayerEntity) {
functions.put(key, (Entity e) -> {
closeScreen();
client.openScreen(new ChatScreen(replacePlaceholders(msgs.get(key), e)));
});
}
} else {
functions.put(key, (Entity e) -> {
closeScreen();
client.openScreen(new ChatScreen(replacePlaceholders(msgs.get(key), e)));
});
}
});
functions.put("Cancel", (Entity e) -> {closeScreen();});
}
@@ -156,6 +160,7 @@ public class InteractionScreen extends Screen {
}
private void closeScreen() {
//MeteorClient.EVENT_BUS.unsubscribe(this);
client.openScreen((Screen) null);
//Modules.get().get(InteractionMenu.class).isOpen = false;
}

View File

@@ -1,7 +1,5 @@
package cloudburst.rejects.screens;
import cloudburst.rejects.modules.InteractionMenu;
import minegame159.meteorclient.systems.modules.Modules;
import net.minecraft.client.resource.language.TranslationStorage;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
@@ -10,53 +8,86 @@ import net.minecraft.entity.effect.StatusEffectUtil;
import net.minecraft.util.Language;
import net.minecraft.util.math.Box;
import meteordevelopment.orbit.EventHandler;
import minegame159.meteorclient.MeteorClient;
import minegame159.meteorclient.events.world.TickEvent;
import minegame159.meteorclient.gui.GuiTheme;
import minegame159.meteorclient.gui.GuiThemes;
import minegame159.meteorclient.gui.WindowScreen;
import minegame159.meteorclient.gui.widgets.containers.WSection;
import java.util.Collection;
public class StatsScreen extends WindowScreen {
public final Entity entity;
private boolean effectListExpanded = true;
private boolean attribListExpanded = true;
private boolean dimensionExpanded = false;
public StatsScreen(Entity e) {
super(GuiThemes.get(),e.getName().getString());
this.entity = e;
GuiTheme theme = GuiThemes.get();
add(theme.label(String.format("Age: %d", entity.age)));
if (entity instanceof LivingEntity) {
LivingEntity liv = (LivingEntity) entity;
add(theme.label(String.format("Health: %.2f/%.2f", liv.getHealth(), liv.getMaxHealth())));
Collection<StatusEffectInstance> statusEff = liv.getStatusEffects();
if (!statusEff.isEmpty()) {
WSection effectList = add(theme.section("Status Effects", true)).expandCellX().widget();
Language lang = TranslationStorage.getInstance();
statusEff.forEach((effect) -> {
String status = lang.get(effect.getTranslationKey());
if (effect.getAmplifier() != 0) {
status += (String.format(" %d (%s)", effect.getAmplifier()+1, StatusEffectUtil.durationToString(effect, 1)));
} else {
status += (String.format(" (%s)", StatusEffectUtil.durationToString(effect, 1)));
}
effectList.add(theme.label(status)).expandCellX();
});
}
}
WSection dimension = add(theme.section("Dimensions", false)).expandCellX().widget();
dimension.add(theme.label(String.format("Position: %.2f, %.2f, %.2f", entity.getX(), entity.getY(), entity.getZ()))).expandCellX();
dimension.add(theme.label(String.format("Yaw: %.2f, Pitch: %.2f", entity.yaw, entity.pitch))).expandCellX();
Box box = entity.getBoundingBox();
dimension.add(theme.label(String.format("Bounding Box: [%.2f, %.2f, %.2f] -> [%.2f, %.2f, %.2f]",
box.minX, box.minY, box.minZ,
box.maxX, box.maxY, box.maxZ
))).expandCellX();
updateData();
MeteorClient.EVENT_BUS.subscribe(this);
}
@Override
protected void onClosed() {
MeteorClient.EVENT_BUS.unsubscribe(this);
super.onClosed();
//Modules.get().get(InteractionMenu.class).isOpen = false;
}
private void updateData() {
clear();
GuiTheme theme = GuiThemes.get();
Language lang = TranslationStorage.getInstance();
add(theme.label(String.format("Type: %s", lang.get(entity.getType().getTranslationKey()))));
add(theme.label(String.format("Age: %d", entity.age)));
add(theme.label(String.format("UUID: %s", entity.getUuidAsString())));
if (entity instanceof LivingEntity) {
LivingEntity liv = (LivingEntity) entity;
add(theme.label(String.format("Health: %.2f/%.2f", liv.getHealth(), liv.getMaxHealth())));
add(theme.label(String.format("Armor: %d/20", liv.getArmor())));
WSection effectList = add(theme.section("Status Effects", effectListExpanded)).expandX().widget();
effectList.action = () -> {
effectListExpanded = effectList.isExpanded();
};
liv.getActiveStatusEffects().forEach((effect, instance) -> {
String status = lang.get(effect.getTranslationKey());
if (instance.getAmplifier() != 0) {
status += (String.format(" %d (%s)", instance.getAmplifier()+1, StatusEffectUtil.durationToString(instance, 1)));
} else {
status += (String.format(" (%s)", StatusEffectUtil.durationToString(instance, 1)));
}
effectList.add(theme.label(status)).expandX();
});
if (liv.getActiveStatusEffects().isEmpty()) {
effectList.add(theme.label("No effects")).expandX();
}
WSection attribList = add(theme.section("Attributes", attribListExpanded)).expandX().widget();
attribList.action = () -> {
attribListExpanded = attribList.isExpanded();
};
liv.getAttributes().getTracked().forEach((attrib) -> {
attribList.add(theme.label(String.format("%s: %.2f",
lang.get(attrib.getAttribute().getTranslationKey()),
attrib.getValue()
))).expandX();
});
}
WSection dimension = add(theme.section("Dimensions", dimensionExpanded)).expandX().widget();
dimension.action = () -> {
dimensionExpanded = dimension.isExpanded();
};
dimension.add(theme.label(String.format("Position: %.2f, %.2f, %.2f", entity.getX(), entity.getY(), entity.getZ()))).expandX();
dimension.add(theme.label(String.format("Yaw: %.2f, Pitch: %.2f", entity.yaw, entity.pitch))).expandX();
Box box = entity.getBoundingBox();
dimension.add(theme.label(String.format("Bounding Box: %.2f, %.2f, %.2f",
box.maxX-box.minX, box.maxY-box.minY, box.maxZ-box.minZ
))).expandX();
}
@EventHandler
private void onTick(TickEvent.Post event) {
updateData();
}
}