Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ public static void hookRender(Entity entity, PoseStack poseStack, MultiBufferSou
poseStack.popPose();
}

private static @NotNull MutableComponent getNameString(Entity entity, LivingEntity living, Minecraft mc) {
public static @NotNull MutableComponent getNameString(Entity entity, LivingEntity living, Minecraft mc) {
int lvl = Load.Unit(living).getLevel();
int playerlvl = Load.Unit(mc.player).getLevel();
int diffabove = lvl - playerlvl;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
package com.robertx22.mine_and_slash.event_hooks.player;

import java.util.List;
import java.util.Stack;

import com.robertx22.library_of_exile.main.Packets;
import com.robertx22.mine_and_slash.config.forge.ClientConfigs;
import com.robertx22.mine_and_slash.gui.screens.character_screen.MainHubScreen;
import com.robertx22.mine_and_slash.gui.screens.stat_gui.StatScreen;
import com.robertx22.mine_and_slash.mmorpg.registers.client.KeybindsRegister;
import com.robertx22.mine_and_slash.mmorpg.registers.client.SpellKeybind;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.ChatUtils;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.LookUtils;
import com.robertx22.mine_and_slash.vanilla_mc.packets.OpenEntityStatsRequestPacket;
import com.robertx22.mine_and_slash.vanilla_mc.packets.QuickUsePotionPacket;
import com.robertx22.mine_and_slash.vanilla_mc.packets.UnsummonPacket;
import com.robertx22.mine_and_slash.vanilla_mc.packets.spells.TellServerToCastSpellPacket;
import net.minecraft.client.Minecraft;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.client.settings.KeyModifier;

public class OnKeyPress {
Expand Down Expand Up @@ -54,7 +61,38 @@ public static void onEndTick(Minecraft mc) {
cooldown = 5;
} else if (KeybindsRegister.QUICK_DRINK_POTION.consumeClick()) {
Packets.sendToServer(new QuickUsePotionPacket());
} else if (KeybindsRegister.SHOW_ENTITY_STATS.isDown()) {
if (showEntityStats(mc)) {
cooldown = 10;
}
}
}

private static boolean showEntityStats(Minecraft mc) {
LivingEntity pickedEntity = pickEntity(mc);
if (pickedEntity == null) {
return false;
}
if (pickedEntity instanceof Player) {
// we already have stats for other players
mc.setScreen(new StatScreen(pickedEntity));
} else {
// mob stats need to be requested from the server
Packets.sendToServer(new OpenEntityStatsRequestPacket(pickedEntity));
}
return true;
}

private static LivingEntity pickEntity(Minecraft mc) {
Entity cameraEntity = mc.getCameraEntity();
if (cameraEntity == null) {
return null;
}
List<LivingEntity> results = LookUtils.getLivingEntityLookedAt(cameraEntity, 100.0, true);
if (results.isEmpty()) {
return null;
}
return results.get(0);
}

private static boolean checkToAddSpellKeyPress(SpellKeybind key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import com.robertx22.mine_and_slash.uncommon.enumclasses.Elements;
import com.robertx22.mine_and_slash.uncommon.localization.Gui;
import com.robertx22.mine_and_slash.uncommon.localization.Words;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.ClientOnly;
import com.robertx22.mine_and_slash.vanilla_mc.packets.AllocateStatPacket;
import com.robertx22.mine_and_slash.vanilla_mc.packets.proxies.OpenGuiWrapper;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -270,7 +271,7 @@ public void init() {
leftButtons.add(new NewWikiScreen());
leftButtons.add(new OpenInvGuiScreen(Words.Salvaging, "salvage", GuiInventoryGrids.ofSalvageConfig()));
leftButtons.add(new OpenInvGuiScreen(Words.Configs, "configs", GuiInventoryGrids.ofConfigs()));
leftButtons.add(new StatScreen());
leftButtons.add(new StatScreen(ClientOnly.getPlayer()));


publicAddButton(new FavorButton(guiLeft + sizeX / 2 - FavorButton.FAVOR_BUTTON_SIZE_X / 2, guiTop - FavorButton.FAVOR_BUTTON_SIZE_Y));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@
import com.robertx22.mine_and_slash.uncommon.datasaving.Load;
import com.robertx22.mine_and_slash.uncommon.enumclasses.Elements;
import com.robertx22.mine_and_slash.uncommon.interfaces.IAutoLocName;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.ClientOnly;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.LivingEntity;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -57,18 +56,18 @@ public enum StatGuiGroupSection implements IAutoLocName {

public String id;
public String name;
private Function<Player, List<Stat>> sup;
private Function<LivingEntity, List<Stat>> sup;

StatGuiGroupSection(String id, String name, Function<Player, List<Stat>> sup) {
StatGuiGroupSection(String id, String name, Function<LivingEntity, List<Stat>> sup) {
this.id = id;
this.name = name;
this.sup = sup;
}

public List<Stat> getStats(Player p) {
public List<Stat> getStats(LivingEntity p) {
if (this == OTHER) {
List<Stat> list = new ArrayList<>();
for (StatData stat : Load.Unit(ClientOnly.getPlayer()).getUnit().getStats().stats.values()) {
for (StatData stat : Load.Unit(p).getUnit().getStats().stats.values()) {
if (stat.GetStat().show_in_gui) {
list.add(stat.GetStat());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import com.robertx22.mine_and_slash.mmorpg.SlashRef;
import com.robertx22.mine_and_slash.saveclasses.unit.StatData;
import com.robertx22.mine_and_slash.uncommon.datasaving.Load;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.ClientOnly;
import com.robertx22.library_of_exile.utils.GuiUtils;
import com.robertx22.library_of_exile.utils.RenderUtils;
import com.robertx22.library_of_exile.utils.TextUTIL;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.LivingEntity;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -21,9 +21,8 @@ public class StatIconAndNumberButton extends ImageButton {
public static int xSize = 19;
public static int ySize = 19;


StatData stat;

private StatData stat;
private LivingEntity target;

public StatIconAndNumberButton(StatScreen screen, StatData stat, int xPos, int yPos) {
super(xPos, yPos, xSize, ySize, 0, 0, 0, SlashRef.guiId("stat_gui/stat_icon"), xSize, ySize, (button) -> {
Expand All @@ -32,6 +31,7 @@ public StatIconAndNumberButton(StatScreen screen, StatData stat, int xPos, int y
});

this.stat = stat;
this.target = screen.getTarget();
}

@Override
Expand All @@ -45,7 +45,7 @@ public void render(GuiGraphics gui, int x, int y, float ticks) {

if (this.isHoveredOrFocused()) {
List<Component> tooltip = new ArrayList<>();
var text = stat.GetStat().locName().append(": " + CharacterStatsButtons.getStatString(stat.GetStat(), Load.Unit(ClientOnly.getPlayer())));
var text = stat.GetStat().locName().append(": " + CharacterStatsButtons.getStatString(stat.GetStat(), Load.Unit(target)));
tooltip.add(text);

tooltip.addAll(stat.GetStat().getCutDescTooltip());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import com.robertx22.mine_and_slash.saveclasses.unit.StatData;
import com.robertx22.mine_and_slash.uncommon.datasaving.Load;
import com.robertx22.mine_and_slash.uncommon.localization.Words;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.ClientOnly;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.NumberUtils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
Expand All @@ -23,6 +22,7 @@
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -34,16 +34,18 @@ public class StatInfoButton extends ImageButton implements IStatInfoButton {
public static int ySize = 20;


StatData stat;
private StatData stat;
private StatInfoType type;
private LivingEntity target;

StatInfoType type;

public StatInfoButton(StatInfoType type, StatData stat, int xPos, int yPos) {
public StatInfoButton(StatScreen screen, StatInfoType type, StatData stat, int xPos, int yPos) {
super(xPos, yPos, xSize, ySize, 0, 0, 0, SlashRef.guiId("stat_gui/info_button"), xSize, ySize, (button) -> {

});

this.type = type;
this.stat = stat;
this.target = screen.getTarget();
}

@Override
Expand All @@ -69,7 +71,7 @@ public void render(GuiGraphics gui, int x, int y, float ticks) {
if (type.hasIcon) {
RenderUtils.render16Icon(gui, this.type.getIcon(), getX() + iconX - 3, getY() + iconY - 3);
}
var text = type.getRenderText(stat, Load.Unit(ClientOnly.getPlayer()));
var text = type.getRenderText(stat, Load.Unit(target));

if (text != null) {
GuiUtils.renderScaledText(gui, getX() + numX, getY() + numY, 0.8F, text.getString(), ChatFormatting.YELLOW);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.robertx22.mine_and_slash.saveclasses.unit.StatData;
import com.robertx22.mine_and_slash.uncommon.datasaving.Load;
import com.robertx22.mine_and_slash.uncommon.localization.Words;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.ClientOnly;
import com.robertx22.library_of_exile.utils.RenderUtils;
import com.robertx22.library_of_exile.utils.TextUTIL;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -33,7 +32,7 @@ public StatPanelButton(StatScreen screen, StatData stat, int xPos, int yPos) {
screen.setInfo(stat);
});

var data = Load.Unit(ClientOnly.getPlayer());
var data = Load.Unit(screen.getTarget());


if (stat.GetStat().gui_group.isValid()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.robertx22.mine_and_slash.gui.screens.stat_gui;

import com.robertx22.mine_and_slash.a_libraries.neat.HealthBarRenderer;
import com.robertx22.mine_and_slash.a_libraries.neat.NeatConfig;
import com.robertx22.mine_and_slash.database.data.stats.Stat;
import com.robertx22.mine_and_slash.database.data.stats.StatGuiGroup;
import com.robertx22.mine_and_slash.database.data.stats.types.defense.Armor;
Expand All @@ -16,11 +18,15 @@
import com.robertx22.mine_and_slash.uncommon.enumclasses.Elements;
import com.robertx22.mine_and_slash.uncommon.localization.Words;
import com.robertx22.mine_and_slash.uncommon.utilityclasses.ClientOnly;

import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -31,22 +37,42 @@
public class StatScreen extends BaseScreen implements INamedScreen {
static ResourceLocation BG = SlashRef.guiId("stat_gui/background");

public StatScreen() {
private LivingEntity target;

public StatScreen(LivingEntity target) {
super(199, 222);
this.target = target;
}


@Override
public void render(GuiGraphics gui, int x, int y, float ticks) {
gui.setColor(1.0F, 1.0F, 1.0F, 1.0F);

if (target != ClientOnly.getPlayer()) {
// Show entity being viewed
int paperDollX = this.guiLeft - 88;
int paperDollY = this.guiTop + sizeY / 2 + 30;
float mouseOffsetX = (float) (paperDollX - x);
float mouseOffsetY = (float) (paperDollY - 50 - y);

boolean neatDraw = NeatConfig.draw;
NeatConfig.draw = false; // don't draw health bar
InventoryScreen.renderEntityInInventoryFollowsMouse(gui, paperDollX, paperDollY, 30, mouseOffsetX, mouseOffsetY, target);
NeatConfig.draw = neatDraw;

Component nameText = HealthBarRenderer.getNameString(target, target, mc);
int nameTextX = paperDollX - mc.font.width(nameText) / 2;
int nameTextY = paperDollY + 5;
gui.drawString(mc.font, nameText, nameTextX, nameTextY, ChatFormatting.WHITE.getColor());
}

gui.blit(BG, mc.getWindow().getGuiScaledWidth() / 2 - sizeX / 2, mc.getWindow().getGuiScaledHeight() / 2 - sizeY / 2, 0, 0, sizeX, sizeY);
super.render(gui, x, y, ticks);


SEARCH.setX(this.guiLeft - (SEARCH_WIDTH / 2) + sizeX / 2);
SEARCH.setY(this.guiTop - SEARCH_HEIGHT - 5);
SEARCH.render(gui, 0, 0, 0);

}

private static int SEARCH_WIDTH = 100;
Expand Down Expand Up @@ -88,7 +114,7 @@ public void setupStatButtons() {
int spaceleft = 143;
int yNavigationDownOffset = spaceleft;

var data = Load.Unit(ClientOnly.getPlayer());
var data = Load.Unit(target);

int addedAmount = 0;
for (int i = currentElement; i < currentElement + 15; i++) {
Expand Down Expand Up @@ -152,7 +178,7 @@ public void setInfo(StatData stat) {

for (StatInfoButton.StatInfoType type : StatInfoButton.StatInfoType.values()) {
if (type.shouldShow(stat)) {
this.publicAddButton(new StatInfoButton(type, stat, x, y));
this.publicAddButton(new StatInfoButton(this, type, stat, x, y));
x += StatInfoButton.xSize + 12;
}
}
Expand Down Expand Up @@ -182,7 +208,7 @@ public List<Stat> getAllStats() {

if (true) {

var stats = Load.Unit(ClientOnly.getPlayer()).getUnit().getStats().stats.values().stream().filter(x -> x.GetStat().show_in_gui).map(x -> x.GetStat()).collect(Collectors.toList());
var stats = Load.Unit(target).getUnit().getStats().stats.values().stream().filter(x -> x.GetStat().show_in_gui).map(x -> x.GetStat()).collect(Collectors.toList());

var ungrouped = stats.stream().filter(x -> !x.gui_group.isValid()).collect(Collectors.toList());
List<Stat> grouped = new ArrayList<>();
Expand All @@ -202,6 +228,10 @@ public List<Stat> getAllStats() {
return Arrays.asList(new ElementalResist(Elements.Physical), DodgeRating.getInstance(), Armor.getInstance(), Health.getInstance(), Mana.getInstance());
}

public LivingEntity getTarget() {
return target;
}

@Override
protected void init() {
super.init();
Expand All @@ -219,7 +249,7 @@ protected void init() {
});


showStats(StatGuiGroupSection.CORE.getStats(mc.player), true);
showStats(StatGuiGroupSection.CORE.getStats(target), true);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.robertx22.mine_and_slash.gui.screens.stat_gui;

import com.robertx22.mine_and_slash.uncommon.utilityclasses.ClientOnly;
import com.robertx22.library_of_exile.utils.TextUTIL;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
Expand All @@ -21,7 +20,7 @@ public class StatSectionButton extends ImageButton {

public StatSectionButton(StatScreen screen, StatGuiGroupSection sec, int xPos, int yPos) {
super(xPos, yPos, xSize, ySize, 0, 0, 0, sec.getIcon(), xSize, ySize, (button) -> {
screen.showStats(sec.getStats(ClientOnly.getPlayer()), true);
screen.showStats(sec.getStats(screen.getTarget()), true);
});

this.sec = sec;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class KeybindsRegister {

public static KeyMapping QUICK_DRINK_POTION = new KeyMapping(prefix + "quick_drink_potion", KeyConflictContext.IN_GAME, InputConstants.Type.KEYSYM,GLFW.GLFW_KEY_P, CATEGORY);

public static KeyMapping SHOW_ENTITY_STATS = new KeyMapping(prefix + "show_entity_stats", KeyConflictContext.IN_GAME, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_EQUAL, CATEGORY);

public static SpellKeybind SPELL_HOTBAR_1 = new SpellKeybind(1, GLFW.GLFW_KEY_R, null, true);
public static SpellKeybind SPELL_HOTBAR_2 = new SpellKeybind(2, GLFW.GLFW_KEY_V, null, true);
public static SpellKeybind SPELL_HOTBAR_3 = new SpellKeybind(3, GLFW.GLFW_KEY_C, null, true);
Expand All @@ -40,6 +42,7 @@ public static void register(RegisterKeyMappingsEvent x) {
x.register(UNSUMMON);
x.register(HOTBAR_SWAP);
x.register(QUICK_DRINK_POTION);
x.register(SHOW_ENTITY_STATS);
for (SpellKeybind k : SpellKeybind.ALL) {
x.register(k.key);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static void register() {
Packets.registerServerToClient(MMORPG.NETWORK, new ExileInteractionResultPacket(), i++);
Packets.registerServerToClient(MMORPG.NETWORK, new TellClientResetCaches(), i++);
Packets.registerServerToClient(MMORPG.NETWORK, new MapCompletePacket(), i++);
Packets.registerServerToClient(MMORPG.NETWORK, new OpenEntityStatsReplyPacket(), i++);


}
Expand Down
Loading