Skip to content

Commit

Permalink
Fix crash, add icons to spoofed potions screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Big-Iron-Cheems committed Oct 11, 2023
1 parent 3872a8e commit 159f690
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.utils.misc.Names;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
Expand All @@ -25,7 +27,6 @@ public class StatusEffectAmplifierMapSettingScreen extends WindowScreen {

private WTable table;

private WTextBox filter;
private String filterText = "";

public StatusEffectAmplifierMapSettingScreen(GuiTheme theme, Setting<Object2IntMap<StatusEffect>> setting) {
Expand All @@ -36,7 +37,7 @@ public StatusEffectAmplifierMapSettingScreen(GuiTheme theme, Setting<Object2IntM

@Override
public void initWidgets() {
filter = add(theme.textBox("")).minWidth(400).expandX().widget();
WTextBox filter = add(theme.textBox("")).minWidth(400).expandX().widget();
filter.setFocused(true);
filter.action = () -> {
filterText = filter.get().trim();
Expand All @@ -46,6 +47,7 @@ public void initWidgets() {
};

table = add(theme.table()).expandX().widget();

initTable();
}

Expand All @@ -57,7 +59,7 @@ private void initTable() {
String name = Names.get(statusEffect);
if (!StringUtils.containsIgnoreCase(name, filterText)) continue;

table.add(theme.label(name)).expandCellX();
table.add(theme.itemWithLabel(getPotionStack(statusEffect), name)).expandCellX();

WIntEdit level = theme.intEdit(setting.get().getInt(statusEffect), 0, Integer.MAX_VALUE, true);
level.action = () -> {
Expand All @@ -69,4 +71,10 @@ private void initTable() {
table.row();
}
}

private ItemStack getPotionStack(StatusEffect effect) {
ItemStack potion = Items.POTION.getDefaultStack();
potion.getOrCreateNbt().putInt("CustomPotionColor", effect.getColor());
return potion;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,8 @@
import meteordevelopment.meteorclient.settings.Setting;
import meteordevelopment.meteorclient.utils.misc.Names;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.entity.effect.StatusEffectInstance;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionUtil;
import net.minecraft.registry.Registries;

import java.util.List;
Expand All @@ -36,7 +33,7 @@ protected String getValueName(StatusEffect value) {

private ItemStack getPotionStack(StatusEffect effect) {
ItemStack potion = Items.POTION.getDefaultStack();
potion.getOrCreateNbt().putInt("CustomPotionColor", PotionUtil.getColor(new Potion(new StatusEffectInstance(effect))));
potion.getOrCreateNbt().putInt("CustomPotionColor", effect.getColor());
return potion;
}
}

0 comments on commit 159f690

Please sign in to comment.