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 @@ -24,6 +24,7 @@
import meteordevelopment.meteorclient.settings.*;
import meteordevelopment.meteorclient.systems.hud.elements.keyboard.KeyboardHud;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import net.minecraft.client.resources.language.I18n;
import org.apache.commons.lang3.Strings;
Expand Down Expand Up @@ -251,17 +252,17 @@ private void keybindW(WTable table, KeybindSetting setting) {
private void blockW(WTable table, BlockSetting setting) {
WHorizontalList list = table.add(theme.horizontalList()).expandX().widget();

WItem item = list.add(theme.item(setting.get().asItem().getDefaultInstance())).widget();
WItem item = list.add(theme.item(DisplayItemUtils.toStack(setting.get().asItem()))).widget();

WButton select = list.add(theme.button("Select")).widget();
select.action = () -> {
BlockSettingScreen screen = new BlockSettingScreen(theme, setting);
screen.onClosed(() -> item.set(setting.get().asItem().getDefaultInstance()));
screen.onClosed(() -> item.set(DisplayItemUtils.toStack(setting.get().asItem())));

mc.setScreen(screen);
};

reset(table, setting, () -> item.set(setting.get().asItem().getDefaultInstance()));
reset(table, setting, () -> item.set(DisplayItemUtils.toStack(setting.get().asItem())));
}

private void blockPosW(WTable table, BlockPosSetting setting) {
Expand All @@ -281,17 +282,17 @@ private void blockListW(WTable table, BlockListSetting setting) {
private void itemW(WTable table, ItemSetting setting) {
WHorizontalList list = table.add(theme.horizontalList()).expandX().widget();

WItem item = list.add(theme.item(setting.get().asItem().getDefaultInstance())).widget();
WItem item = list.add(theme.item(DisplayItemUtils.toStack(setting.get()))).widget();

WButton select = list.add(theme.button("Select")).widget();
select.action = () -> {
ItemSettingScreen screen = new ItemSettingScreen(theme, setting);
screen.onClosed(() -> item.set(setting.get().getDefaultInstance()));
screen.onClosed(() -> item.set(DisplayItemUtils.toStack(setting.get())));

mc.setScreen(screen);
};

reset(table, setting, () -> item.set(setting.get().getDefaultInstance()));
reset(table, setting, () -> item.set(DisplayItemUtils.toStack(setting.get())));
}

private void itemListW(WTable table, ItemListSetting setting) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import meteordevelopment.meteorclient.systems.modules.Module;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.utils.misc.NbtUtils;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.client.input.KeyEvent;
import net.minecraft.util.Tuple;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -123,7 +124,7 @@ protected WWindow createSearch(WContainer c) {
searchWindow = w;

if (theme.categoryIcons()) {
w.beforeHeaderInit = wContainer -> wContainer.add(theme.item(Items.COMPASS.getDefaultInstance())).pad(2);
w.beforeHeaderInit = wContainer -> wContainer.add(theme.item(DisplayItemUtils.toStack(Items.COMPASS))).pad(2);
}

c.add(w);
Expand Down Expand Up @@ -178,7 +179,7 @@ protected Cell<WWindow> createFavorites(WContainer c) {
w.spacing = 0;

if (theme.categoryIcons()) {
w.beforeHeaderInit = wContainer -> wContainer.add(theme.item(Items.NETHER_STAR.getDefaultInstance())).pad(2);
w.beforeHeaderInit = wContainer -> wContainer.add(theme.item(DisplayItemUtils.toStack(Items.NETHER_STAR))).pad(2);
}

Cell<WWindow> cell = c.add(w);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import meteordevelopment.meteorclient.settings.BlockDataSetting;
import meteordevelopment.meteorclient.settings.IBlockData;
import meteordevelopment.meteorclient.utils.misc.IChangeable;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import meteordevelopment.meteorclient.utils.misc.ICopyable;
import meteordevelopment.meteorclient.utils.misc.ISerializable;
import meteordevelopment.meteorclient.utils.misc.Names;
Expand Down Expand Up @@ -41,7 +42,7 @@ protected boolean includeValue(Block value) {

@Override
protected WWidget getValueWidget(Block block) {
return theme.itemWithLabel(block.asItem().getDefaultInstance(), Names.get(block));
return theme.itemWithLabel(DisplayItemUtils.toStack(block), Names.get(block));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import meteordevelopment.meteorclient.gui.widgets.WWidget;
import meteordevelopment.meteorclient.settings.BlockListSetting;
import meteordevelopment.meteorclient.utils.misc.Names;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.Identifier;
import net.minecraft.world.level.block.Block;
Expand All @@ -36,7 +37,7 @@ protected boolean includeValue(Block value) {

@Override
protected WWidget getValueWidget(Block value) {
return theme.itemWithLabel(value.asItem().getDefaultInstance(), Names.get(value));
return theme.itemWithLabel(DisplayItemUtils.toStack(value), Names.get(value));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import meteordevelopment.meteorclient.gui.widgets.pressable.WButton;
import meteordevelopment.meteorclient.settings.BlockSetting;
import meteordevelopment.meteorclient.utils.misc.Names;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
Expand Down Expand Up @@ -53,7 +54,7 @@ private void initTable() {
if (setting.filter != null && !setting.filter.test(block)) continue;
if (skipValue(block)) continue;

WItemWithLabel item = theme.itemWithLabel(block.asItem().getDefaultInstance(), Names.get(block));
WItemWithLabel item = theme.itemWithLabel(DisplayItemUtils.toStack(block), Names.get(block));
if (!filterText.isEmpty() && !Strings.CI.contains(item.getLabelText(), filterText)) continue;
table.add(item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import meteordevelopment.meteorclient.settings.EntityTypeListSetting;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.misc.Names;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.util.Tuple;
Expand Down Expand Up @@ -238,7 +239,7 @@ private void addEntityType(WTable table, WCheckbox tableCheckbox, EntityType<?>

//noinspection DataFlowIssue
if (component.type() == entityType) {
stack = item.getDefaultInstance();
stack = DisplayItemUtils.toStack(item);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import meteordevelopment.meteorclient.gui.widgets.WWidget;
import meteordevelopment.meteorclient.settings.ItemListSetting;
import meteordevelopment.meteorclient.utils.misc.Names;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
Expand All @@ -31,7 +32,7 @@ protected boolean includeValue(Item value) {

@Override
protected WWidget getValueWidget(Item value) {
return theme.itemWithLabel(value.getDefaultInstance());
return theme.itemWithLabel(DisplayItemUtils.toStack(value));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import meteordevelopment.meteorclient.gui.widgets.pressable.WButton;
import meteordevelopment.meteorclient.settings.ItemSetting;
import meteordevelopment.meteorclient.utils.misc.Names;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -52,7 +53,7 @@ public void initTable() {
if (setting.filter != null && !setting.filter.test(item)) continue;
if (item == Items.AIR) continue;

WItemWithLabel itemLabel = theme.itemWithLabel(item.getDefaultInstance(), Names.get(item));
WItemWithLabel itemLabel = theme.itemWithLabel(DisplayItemUtils.toStack(item), Names.get(item));
if (!filterText.isEmpty() && !Strings.CI.contains(itemLabel.getLabelText(), filterText)) continue;
table.add(itemLabel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import meteordevelopment.meteorclient.gui.widgets.input.WTextBox;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.utils.misc.Names;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -76,14 +77,14 @@ private void initTable() {
}

private ItemStack getPotionStack(MobEffect effect) {
ItemStack potion = Items.POTION.getDefaultInstance();
ItemStack potion = DisplayItemUtils.toStack(Items.POTION);

potion.set(
DataComponents.POTION_CONTENTS,
new PotionContents(
potion.get(DataComponents.POTION_CONTENTS).potion(),
Optional.empty(),
Optional.of(effect.getColor()),
potion.get(DataComponents.POTION_CONTENTS).customEffects(),
List.of(),
Optional.empty()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import meteordevelopment.meteorclient.gui.widgets.WWidget;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.utils.misc.Names;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.core.component.DataComponents;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.effect.MobEffect;
Expand Down Expand Up @@ -39,14 +40,14 @@ protected String[] getValueNames(MobEffect value) {
}

private ItemStack getPotionStack(MobEffect effect) {
ItemStack potion = Items.POTION.getDefaultInstance();
ItemStack potion = DisplayItemUtils.toStack(Items.POTION);

potion.set(
DataComponents.POTION_CONTENTS,
new PotionContents(
potion.get(DataComponents.POTION_CONTENTS).potion(),
Optional.empty(),
Optional.of(effect.getColor()),
potion.get(DataComponents.POTION_CONTENTS).customEffects(),
List.of(),
Optional.empty()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import meteordevelopment.meteorclient.gui.widgets.WWidget;
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.settings.StorageBlockListSetting;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -50,7 +51,7 @@ public StorageBlockListSettingScreen(GuiTheme theme, Setting<List<BlockEntityTyp
@Override
protected WWidget getValueWidget(BlockEntityType<?> value) {
BlockEntityTypeInfo info = BLOCK_ENTITY_TYPE_INFO_MAP.getOrDefault(value, UNKNOWN);
return theme.itemWithLabel(info.item().getDefaultInstance(), info.name());
return theme.itemWithLabel(DisplayItemUtils.toStack(info.item()), info.name());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.minecraft.world.effect.MobEffectUtil;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.alchemy.PotionContents;

import java.util.Iterator;

Expand Down Expand Up @@ -39,7 +40,10 @@ private String getStringToAppend() {
String str = "";

if (itemStack.getItem() == Items.POTION) {
Iterator<MobEffectInstance> effects = itemStack.getItem().components().get(DataComponents.POTION_CONTENTS).getAllEffects().iterator();
PotionContents potionContents = itemStack.get(DataComponents.POTION_CONTENTS);
if (potionContents == null) return str;

Iterator<MobEffectInstance> effects = potionContents.getAllEffects().iterator();
if (!effects.hasNext()) return str;

str += " ";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.events.render.Render2DEvent;
import meteordevelopment.meteorclient.gui.WidgetScreen;
import meteordevelopment.meteorclient.systems.hud.screens.HudEditorScreen;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.render.MeteorMcGuiRenderer;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -63,7 +64,7 @@ public abstract class GuiRendererMixin {
var fogRenderer = ((GameRendererAccessor) mc.gameRenderer).meteor$fogRenderer();
var delta = mc.getDeltaTracker().getGameTimeDeltaTicks();

if (Utils.canUpdate()) {
if (Utils.canUpdate() || HudEditorScreen.isOpen()) {
Profiler.get().push(MeteorClient.MOD_ID + "_render_2d");

Utils.unscaledProjection();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private void onTick(TickEvent.Post event) {
private void onRender(Render2DEvent event) {
if (Utils.isLoading()) return;

if (!active || shouldHideHud()) return;
if (!(active || HudEditorScreen.isOpen()) || shouldHideHud()) return;
if ((mc.options.hideGui || mc.debugEntries.isOverlayVisible()) && !HudEditorScreen.isOpen()) return;

HudRenderer.INSTANCE.begin(event.graphics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import meteordevelopment.meteorclient.systems.hud.HudElement;
import meteordevelopment.meteorclient.systems.hud.HudElementInfo;
import meteordevelopment.meteorclient.systems.hud.HudRenderer;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -191,15 +192,15 @@ public void render(HudRenderer renderer) {
private ItemStack getItem(EquipmentSlot slot) {
if (isInEditor()) {
return switch (slot.getIndex()) {
case 3 -> Items.NETHERITE_HELMET.getDefaultInstance();
case 2 -> Items.NETHERITE_CHESTPLATE.getDefaultInstance();
case 1 -> Items.NETHERITE_LEGGINGS.getDefaultInstance();
default -> Items.NETHERITE_BOOTS.getDefaultInstance();
case 3 -> DisplayItemUtils.toStack(Items.NETHERITE_HELMET);
case 2 -> DisplayItemUtils.toStack(Items.NETHERITE_CHESTPLATE);
case 1 -> DisplayItemUtils.toStack(Items.NETHERITE_LEGGINGS);
default -> DisplayItemUtils.toStack(Items.NETHERITE_BOOTS);
};
}

ItemStack stack = mc.player.getItemBySlot(slot);
return stack.isEmpty() && showEmpty.get() ? Items.BARRIER.getDefaultInstance() : stack;
return stack.isEmpty() && showEmpty.get() ? DisplayItemUtils.toStack(Items.BARRIER) : stack;
}

private float getScale() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import meteordevelopment.meteorclient.utils.entity.SortPriority;
import meteordevelopment.meteorclient.utils.entity.TargetUtils;
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import net.minecraft.core.Holder;
Expand Down Expand Up @@ -455,12 +456,12 @@ public void render(HudRenderer renderer) {
private ItemStack getItem(int i) {
if (isInEditor()) {
return switch (i) {
case 0 -> Items.NETHERITE_BOOTS.getDefaultInstance();
case 1 -> Items.NETHERITE_LEGGINGS.getDefaultInstance();
case 2 -> Items.NETHERITE_CHESTPLATE.getDefaultInstance();
case 3 -> Items.NETHERITE_HELMET.getDefaultInstance();
case 4 -> Items.TOTEM_OF_UNDYING.getDefaultInstance();
case 5 -> Items.END_CRYSTAL.getDefaultInstance();
case 0 -> DisplayItemUtils.toStack(Items.NETHERITE_BOOTS);
case 1 -> DisplayItemUtils.toStack(Items.NETHERITE_LEGGINGS);
case 2 -> DisplayItemUtils.toStack(Items.NETHERITE_CHESTPLATE);
case 3 -> DisplayItemUtils.toStack(Items.NETHERITE_HELMET);
case 4 -> DisplayItemUtils.toStack(Items.TOTEM_OF_UNDYING);
case 5 -> DisplayItemUtils.toStack(Items.END_CRYSTAL);
default -> ItemStack.EMPTY;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import meteordevelopment.meteorclient.systems.hud.HudElement;
import meteordevelopment.meteorclient.systems.hud.HudElementInfo;
import meteordevelopment.meteorclient.systems.hud.HudRenderer;
import meteordevelopment.meteorclient.utils.render.DisplayItemUtils;
import meteordevelopment.meteorclient.utils.render.color.Color;
import meteordevelopment.meteorclient.utils.render.color.SettingColor;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -112,7 +113,7 @@ private void drawBlock(HudRenderer renderer, Direction dir, double x, double y)
Block block = dir == Direction.DOWN ? Blocks.OBSIDIAN : mc.level.getBlockState(mc.player.blockPosition().relative(dir)).getBlock();
if (!safe.get().contains(block)) return;

renderer.item(block.asItem().getDefaultInstance(), (int) x, (int) y, getScale(), false);
renderer.item(DisplayItemUtils.toStack(block.asItem()), (int) x, (int) y, getScale(), false);

if (dir == Direction.DOWN) return;

Expand Down
Loading