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 @@ -20,12 +20,13 @@
import net.minecraft.client.render.RenderLayer;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.screen.slot.Slot;
import net.minecraft.text.Text;
import net.minecraft.util.hit.BlockHitResult;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;

public class SlotGhostManager extends Feature {
private Action action;
Expand Down Expand Up @@ -84,10 +85,10 @@ public void render(DrawContext context, int mouseX, int mouseY, int x, int y, fl

@Nullable
public Argument getArgument(Slot slot) {
var args = new ArrayList<Argument>();
List<Argument> args = new ArrayList<>();

for (var group : action.icon.getArgGroups()) {
var pos = group.getPossibilities();
for (Icon.ArgumentGroup group : action.icon.getArgGroups()) {
List<Icon.ArgumentGroup.ArgumentPossibilities> pos = group.getPossibilities();
args.addAll(pos.get((int) (time / 30F) % pos.size()).arguments());
}

Expand All @@ -97,35 +98,29 @@ public Argument getArgument(Slot slot) {
}

public void drawSlot(DrawContext context, Slot slot) {
try {
if (!(CodeClient.MC.currentScreen instanceof GenericContainerScreen || CodeClient.MC.currentScreen instanceof CustomChestMenu)) {
action = null;
}
if (badAction() || slot.inventory instanceof PlayerInventory)
return;
if (slot.hasStack()) return;
var arg = getArgument(slot);
if (arg == null) return;
Icon.Type type = Icon.Type.valueOf(arg.type);
ItemStack itemStack = type.getIcon();
if (itemStack.isEmpty()) return;
// itemStack.setCount(slot.id);
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, arg.optional ? 0x50__90_90_ff : 0x30__ff_00_00);
context.drawItem(itemStack, slot.x, slot.y);
context.drawStackOverlay(CodeClient.MC.textRenderer, itemStack, slot.x, slot.y);
// context.drawText(CodeClient.MC.textRenderer, Text.literal(arg.type),slot.x,slot.y,0xFFFFFF00,true);
context.fill(RenderLayer.getGuiGhostRecipeOverlay(), slot.x, slot.y, slot.x + 16, slot.y + 16, 0x40ffffff);
} catch (Exception e) {
context.drawText(CodeClient.MC.textRenderer, Text.literal("Error."), slot.x, slot.y, 0xFF0000, true);
if (!(CodeClient.MC.currentScreen instanceof GenericContainerScreen || CodeClient.MC.currentScreen instanceof CustomChestMenu)) {
action = null;
}
if (badAction() || slot.inventory instanceof PlayerInventory)
return;
if (slot.hasStack()) return;
Argument arg = getArgument(slot);
if (arg == null) return;
ItemStack itemStack = arg.getItem();

if (itemStack.isEmpty()) return;
context.fill(slot.x, slot.y, slot.x + 16, slot.y + 16, arg.optional ? 0x50__90_90_ff : 0x30__ff_00_00);
context.drawItem(itemStack, slot.x, slot.y);
context.drawStackOverlay(CodeClient.MC.textRenderer, itemStack, slot.x, slot.y);
context.fill(RenderLayer.getGuiGhostRecipeOverlay(), slot.x, slot.y, slot.x + 16, slot.y + 16, 0x40ffffff);
}

@Override @Nullable
public ItemStack getHoverStack(Slot slot) {
if (badAction() || slot.inventory instanceof PlayerInventory)
return null;
if (slot.hasStack()) return null;
var arg = getArgument(slot);
Argument arg = getArgument(slot);
if (arg == null) return null;
return arg.getItem();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,10 @@ public List<Text> getOverlayText() {
text.append(item.getCount() + "x ");
text.append(item.getName());
} else {
JsonObject object = JsonParser.parseString(varItem).getAsJsonObject();
try {
JsonObject object = JsonParser.parseString(varItem).getAsJsonObject();
Type type = Type.valueOf(object.get("id").getAsString());
JsonObject data = object.get("data").getAsJsonObject();
// JsonArray lore = data.get("display").getAsJsonObject().get("Lore").getAsJsonArray();
text.append(Text.literal(type.name.toUpperCase()).fillStyle(Style.EMPTY.withColor(type.color)).append(" "));
if (type == Type.var) {
Scope scope = Scope.valueOf(data.get("scope").getAsString());
Expand Down Expand Up @@ -202,8 +201,11 @@ public List<Text> getOverlayText() {
text.append(Text.literal(data.get("option").getAsString()).formatted(Formatting.AQUA));
}
if (type == Type.hint) continue;
} catch (Exception ignored) {
continue;
} catch (IllegalArgumentException ignored) {
text.append(Text.literal(object.get("id").getAsString().toUpperCase())
.styled(style -> style.withColor(TextColor.fromRgb(0x808080)))
.append(" "));
text.append(item.getName());
}
}
texts.add(text);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package dev.dfonline.codeclient.hypercube.actiondump;

import com.ibm.icu.text.CaseMap;
import dev.dfonline.codeclient.Utility;
import dev.dfonline.codeclient.data.DFItem;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TextColor;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Objects;

public class Argument {
Expand All @@ -30,9 +34,10 @@ public Icon.Type getType() {
}

public ItemStack getItem() {
Icon.Type icon = getType();
if(icon == null) return ItemStack.EMPTY;
var item = icon.getIcon();
Icon.Type type = getType();
ItemStack item = type == null
? Items.GRAY_DYE.getDefaultStack()
: type.getIcon();

DFItem dfItem = DFItem.of(item);
// First line is item name, others are lore
Expand All @@ -50,10 +55,22 @@ public List<Text> getLore() {
int i = 0;
if (this.text != null) addToLore(lore, this.text);
if (this.description != null) for (String line : this.description) {
Icon.Type type = Icon.Type.valueOf(this.type);
MutableText text = Text.empty().formatted(Formatting.GRAY).styled(s -> s.withItalic(false));
MutableText typeText;

try {
Icon.Type type = Icon.Type.valueOf(this.type);
typeText = Text.literal(type.display).setStyle(Text.empty().getStyle().withColor(type.color).withItalic(false));
} catch (IllegalArgumentException e) {
// Show a grayed out version of the name.
String properCase = CaseMap.Title.toTitle().apply(Locale.ENGLISH, null, this.type.replaceAll("_", " "));
typeText = Text.literal(properCase).setStyle(Text.empty().getStyle()
.withColor(TextColor.fromRgb(0x808080))
.withItalic(false));
}

if (i == 0) {
MutableText text = Text.empty().formatted(Formatting.GRAY).styled(s -> s.withItalic(false));
MutableText typeText = Text.literal(type.display).setStyle(Text.empty().getStyle().withColor(type.color).withItalic(false));

if (this.plural) typeText.append("(s)");
text.append(typeText);
if (this.optional) {
Expand All @@ -80,10 +97,12 @@ public List<Text> getLore() {
public boolean isOr() {
return text != null && text.endsWith("OR");
}

public boolean isSplitter() {
return Objects.equals(text,"");
return Objects.equals(text, "");
}

private void addToLore(ArrayList<Text> lore, String text) {
lore.add(Utility.textFromString(text));
}}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dev.dfonline.codeclient.hypercube.actiondump;

import com.ibm.icu.text.CaseMap;
import dev.dfonline.codeclient.Utility;
import dev.dfonline.codeclient.data.DFItem;
import dev.dfonline.codeclient.data.ItemData;
Expand All @@ -19,10 +20,12 @@
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import org.apache.commons.lang3.text.WordUtils;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Locale;

public class Icon {
private static final TextColor GOLD = TextColor.fromFormatting(Formatting.GOLD);
Expand Down Expand Up @@ -78,33 +81,7 @@ public ItemStack getItem() {
addToLore(lore, "Chest Parameters:");
boolean hasOptional = false;
for (Argument arg : arguments) {
int i = 0;
if (arg.text != null) addToLore(lore, arg.text);
if (arg.description != null && description.length != 0) for (String line : arg.description) {
Type type = Type.valueOf(arg.type);
if (i == 0) {
MutableText text = Text.empty().formatted(Formatting.GRAY).styled(s -> s.withItalic(false));
MutableText typeText = Text.literal(type.display).setStyle(Text.empty().getStyle().withColor(type.color).withItalic(false));
if (arg.plural) typeText.append("(s)");
text.append(typeText);
if (arg.optional) {
text.append(Text.literal("*").formatted(Formatting.WHITE));
hasOptional = true;
}
text.append(Text.literal(" - ").formatted(Formatting.DARK_GRAY));
text.append(Utility.textFromString(line).formatted(Formatting.GRAY));
lore.add(text);
} else lore.add(Utility.textFromString(line).formatted(Formatting.GRAY));
i++;
}
if (arg.notes != null) for (String[] lines : arg.notes) {
i = 0;
if (lines != null) for (String line : lines) {
if (i == 0) addToLore(lore, "§9⏵ §7" + line);
else addToLore(lore, "§7" + line);
i++;
}
}
lore.addAll(arg.getLore());
}
if (tags != null && tags != 0) {
lore.add(Text.literal("# ").formatted(Formatting.DARK_AQUA).styled(s -> s.withItalic(false)).append(Text.literal(tags + " Tag" + (tags != 1 ? "s" : "")).formatted(Formatting.GRAY)));
Expand Down Expand Up @@ -149,17 +126,16 @@ public ItemStack getItem() {
if (cancelledAutomatically) addToLore(lore, "§4∅ §cCancelled automatically");
else addToLore(lore, "§4∅ §cCancellable");
}
if(requireTokens) {
addToLore(lore,"");
if (requireTokens) {
addToLore(lore, "");
lore.add(Text.literal("Unlock with Tokens").withColor(0xffd42a));
}
if(requiredRank != null) {
if(requireTokens) {
if (requiredRank != null) {
if (requireTokens) {
lore.add(Text.literal("OR").withColor(0xff55aa));
lore.add(Text.literal("Unlock with " + requiredRank.name).withColor(requiredRank.color.getRgb()));
}
else {
addToLore(lore,"");
} else {
addToLore(lore, "");
lore.add(Text.literal(requiredRank.name + " Exclusive").setStyle(Style.EMPTY.withColor(requiredRank.color.getRgb()).withItalic(false)));
}
}
Expand All @@ -185,8 +161,8 @@ private void addToLore(ArrayList<Text> lore, String text) {
public List<ArgumentGroup> getArgGroups() {
var groups = new ArrayList<ArgumentGroup>();
var group = new ArrayList<Argument>();
for(var arg: arguments) {
if(!arg.isSplitter()) group.add(arg);
for (var arg : arguments) {
if (!arg.isSplitter()) group.add(arg);
else {
groups.add(new ArgumentGroup(group));
group = new ArrayList<>();
Expand All @@ -200,6 +176,7 @@ public enum Type {
TEXT(TextColor.fromFormatting(Formatting.AQUA), "String", Items.STRING, dev.dfonline.codeclient.hypercube.item.Text::new),
COMPONENT(TextColor.fromRgb(0x7fd42a), "Styled Text", Items.BOOK, Component::new),
NUMBER(TextColor.fromFormatting(Formatting.RED), "Number", Items.SLIME_BALL, Number::new),
BYTE(TextColor.fromFormatting(Formatting.RED), "Byte", Items.SLIME_BALL, Number::new),
LOCATION(TextColor.fromFormatting(Formatting.GREEN), "Location", Items.PAPER, Location::new),
VECTOR(TextColor.fromRgb(0x2AFFAA), "Vector", Items.PRISMARINE_SHARD, Vector::new),
SOUND(TextColor.fromFormatting(Formatting.BLUE), "Sound", Items.NAUTILUS_SHELL, Sound::new),
Expand All @@ -216,18 +193,19 @@ public enum Type {
BLOCK_TAG(TextColor.fromFormatting(Formatting.AQUA), "Block Tag", Items.CHAIN_COMMAND_BLOCK, dev.dfonline.codeclient.hypercube.item.Text::new),
LIST(TextColor.fromFormatting(Formatting.DARK_GREEN), "List", Items.SKULL_BANNER_PATTERN), // Ender chest or empty banner pattern
DICT(TextColor.fromRgb(0x55AAFF), "Dictionary", Items.KNOWLEDGE_BOOK), // Knowledge book or chest minecart
NONE(TextColor.fromRgb(0x808080), "None", Items.AIR),
NONE(TextColor.fromRgb(0x808080), "None", Items.AIR)
;

public final TextColor color;
public final String display;
private final ItemStack icon;
@Nullable public final Icon.Type.getVarItem getVarItem;
@Nullable
public final Icon.Type.getVarItem getVarItem;

Type(TextColor color, String display, Item icon) {
this.color = color;
this.display = display;
var item = icon.getDefaultStack();
ItemStack item = icon.getDefaultStack();
this.icon = item;
getVarItem = null;
}
Expand All @@ -249,14 +227,15 @@ public ItemStack getIcon() {
}

public enum RequiredRank {
Noble("Noble",TextColor.fromRgb(0x7fff7f)),
Emperor("Emperor",TextColor.fromRgb(0x55aaff)),
Mythic("Mythic",TextColor.fromRgb(0xd42ad4)),
Overlord("Overlord",TextColor.fromFormatting(Formatting.RED)),
Dev("",TextColor.fromRgb(0));
Noble("Noble", TextColor.fromRgb(0x7fff7f)),
Emperor("Emperor", TextColor.fromRgb(0x55aaff)),
Mythic("Mythic", TextColor.fromRgb(0xd42ad4)),
Overlord("Overlord", TextColor.fromFormatting(Formatting.RED)),
Dev("", TextColor.fromRgb(0));

public final String name;
public final TextColor color;

RequiredRank(String name, TextColor color) {
this.name = name;
this.color = color;
Expand All @@ -267,8 +246,8 @@ public record ArgumentGroup(List<Argument> arguments) {
public List<ArgumentPossibilities> getPossibilities() {
var groups = new ArrayList<ArgumentPossibilities>();
var group = new ArrayList<Argument>();
for(var arg: arguments) {
if(!arg.isOr()) group.add(arg);
for (var arg : arguments) {
if (!arg.isOr()) group.add(arg);
else {
groups.add(new ArgumentPossibilities(group));
group = new ArrayList<>();
Expand Down