generated from MrSphay/codex-agent-repository-kit
497 lines
24 KiB
Java
497 lines
24 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package com.vinlanx.explosionoverhaul.client;
|
|
|
|
import com.vinlanx.explosionoverhaul.BlockIndexManager;
|
|
import com.vinlanx.explosionoverhaul.ExplosionOverhaul;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.EnumMap;
|
|
import java.util.HashMap;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import java.util.Set;
|
|
import java.util.function.Consumer;
|
|
import java.util.function.Supplier;
|
|
import java.util.stream.Collectors;
|
|
import net.minecraft.client.Minecraft;
|
|
import net.minecraft.client.gui.GuiGraphics;
|
|
import net.minecraft.client.gui.components.Button;
|
|
import net.minecraft.client.gui.components.CycleButton;
|
|
import net.minecraft.client.gui.components.EditBox;
|
|
import net.minecraft.client.gui.components.ObjectSelectionList;
|
|
import net.minecraft.client.gui.components.Tooltip;
|
|
import net.minecraft.client.gui.components.events.GuiEventListener;
|
|
import net.minecraft.client.gui.screens.Screen;
|
|
import net.minecraft.network.chat.Component;
|
|
import net.minecraft.network.chat.FormattedText;
|
|
import net.minecraft.network.chat.MutableComponent;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.item.Items;
|
|
import net.minecraft.world.level.ItemLike;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.Blocks;
|
|
import net.minecraftforge.registries.ForgeRegistries;
|
|
|
|
public class BlacklistScreen
|
|
extends Screen {
|
|
private static final int NAV_WIDTH = 160;
|
|
private static final int PADDING = 12;
|
|
private static final int HEADER_HEIGHT = 48;
|
|
private static final int FOOTER_HEIGHT = 64;
|
|
private static final int SEARCH_WIDTH = 200;
|
|
private static final int INPUT_WIDTH = 240;
|
|
private static final int BUTTON_HEIGHT = 20;
|
|
private static final int SPACING = 4;
|
|
private final Screen parent;
|
|
private BlacklistList widget;
|
|
private EditBox inputField;
|
|
private Button addButton;
|
|
private EditBox searchField;
|
|
private Button backButton;
|
|
private Button resetButton;
|
|
private Button infoButton;
|
|
private CycleButton<Boolean> defaultToggle;
|
|
private final LinkedHashSet<String> persistedEntries = new LinkedHashSet();
|
|
private final Map<String, ExplosionOverhaul.ExplosionSourceMode> persistedSourceModes = new HashMap<String, ExplosionOverhaul.ExplosionSourceMode>();
|
|
private final Set<String> defaultEntries = new LinkedHashSet<String>();
|
|
private boolean showDefaults = false;
|
|
private final EnumMap<BlacklistCategory, Button> categoryButtons = new EnumMap(BlacklistCategory.class);
|
|
private BlacklistCategory currentCategory = BlacklistCategory.EXPLOSION;
|
|
private List<String> suggestions = Collections.emptyList();
|
|
private List<String> registryCache = new ArrayList<String>();
|
|
|
|
public BlacklistScreen(Screen parent) {
|
|
super((Component)Component.m_237115_((String)"title.explosionoverhaul.blacklist"));
|
|
this.parent = parent;
|
|
}
|
|
|
|
protected void m_7856_() {
|
|
this.categoryButtons.clear();
|
|
this.setupLayout();
|
|
this.addNavigation();
|
|
this.addTopControls();
|
|
this.addInputArea();
|
|
this.updateCache();
|
|
this.loadCurrentCategoryEntries();
|
|
}
|
|
|
|
private void setupLayout() {
|
|
int listTop = 48;
|
|
int listBottom = this.f_96544_ - 64;
|
|
int listWidth = this.f_96543_ - 160 - 24;
|
|
int listLeft = 172;
|
|
this.widget = new BlacklistList(this.f_96541_, listWidth, listBottom - listTop, listTop, listBottom, 24);
|
|
this.widget.m_93507_(listLeft);
|
|
this.m_142416_((GuiEventListener)this.widget);
|
|
}
|
|
|
|
private void addNavigation() {
|
|
int buttonY = 48;
|
|
for (BlacklistCategory category : BlacklistCategory.values()) {
|
|
Button button = Button.m_253074_((Component)this.formatCategoryLabel(category), b -> this.selectCategory(category)).m_252794_(12, buttonY).m_253046_(160, 20).m_257505_(Tooltip.m_257550_((Component)Component.m_237115_((String)category.getTooltipKey()))).m_253136_();
|
|
this.categoryButtons.put(category, button);
|
|
this.m_142416_((GuiEventListener)button);
|
|
buttonY += 24;
|
|
}
|
|
}
|
|
|
|
private void addTopControls() {
|
|
int listLeft = 172;
|
|
this.backButton = Button.m_253074_((Component)Component.m_237115_((String)"gui.back"), b -> this.m_7379_()).m_252794_(12, 12).m_253046_(80, 20).m_253136_();
|
|
this.m_142416_((GuiEventListener)this.backButton);
|
|
this.searchField = new EditBox(this.f_96547_, listLeft, 26, 200, 18, (Component)Component.m_237119_());
|
|
this.searchField.m_257771_((Component)Component.m_237115_((String)"option.explosionoverhaul.blacklist_search"));
|
|
this.searchField.m_94151_(s -> this.refreshList());
|
|
this.m_142416_((GuiEventListener)this.searchField);
|
|
this.resetButton = Button.m_253074_((Component)Component.m_237115_((String)"option.explosionoverhaul.reset_list"), this::onResetClicked).m_252794_(this.f_96543_ - 250, 12).m_253046_(60, 20).m_257505_(Tooltip.m_257550_((Component)Component.m_237115_((String)"tooltip.explosionoverhaul.reset_list"))).m_253136_();
|
|
this.m_142416_((GuiEventListener)this.resetButton);
|
|
this.defaultToggle = CycleButton.m_168916_((boolean)this.showDefaults).m_232498_(value -> Tooltip.m_257550_((Component)Component.m_237115_((String)"tooltip.explosionoverhaul.show_defaults"))).m_168936_(this.f_96543_ - 180, 12, 168, 20, (Component)Component.m_237115_((String)"option.explosionoverhaul.show_defaults"), (btn, value) -> {
|
|
this.showDefaults = value;
|
|
this.refreshList();
|
|
});
|
|
this.m_142416_((GuiEventListener)this.defaultToggle);
|
|
}
|
|
|
|
private void addInputArea() {
|
|
int y = this.f_96544_ - 28;
|
|
this.inputField = new EditBox(this.f_96547_, (this.f_96543_ - 240) / 2, y, 240, 18, (Component)Component.m_237119_());
|
|
this.inputField.m_94199_(128);
|
|
this.inputField.m_257771_((Component)Component.m_237115_((String)"option.explosionoverhaul.blacklist_input"));
|
|
this.inputField.m_94151_(this::updateSuggestions);
|
|
this.m_142416_((GuiEventListener)this.inputField);
|
|
this.addButton = Button.m_253074_((Component)Component.m_237115_((String)"option.explosionoverhaul.blacklist_add"), b -> this.addCurrentInput()).m_252794_(this.inputField.m_252754_() + 240 + 8, this.inputField.m_252907_() - 1).m_253046_(80, 20).m_253136_();
|
|
this.m_142416_((GuiEventListener)this.addButton);
|
|
this.infoButton = Button.m_253074_((Component)Component.m_237115_((String)"option.explosionoverhaul.blacklist_info"), b -> {}).m_252794_(this.addButton.m_252754_() + 80 + 4, this.addButton.m_252907_()).m_253046_(40, 20).m_257505_(Tooltip.m_257550_((Component)Component.m_237115_((String)"tooltip.explosionoverhaul.blacklist_info"))).m_253136_();
|
|
this.infoButton.f_93624_ = this.currentCategory == BlacklistCategory.SOURCES;
|
|
this.m_142416_((GuiEventListener)this.infoButton);
|
|
}
|
|
|
|
private void onResetClicked(Button b) {
|
|
if (BlacklistScreen.m_96638_()) {
|
|
List<String> defaults = this.currentCategory.loadDefaults();
|
|
this.currentCategory.saveEntries(defaults);
|
|
this.persistedEntries.clear();
|
|
this.persistedEntries.addAll(defaults);
|
|
if (this.currentCategory == BlacklistCategory.SOURCES) {
|
|
this.persistedSourceModes.clear();
|
|
this.save();
|
|
}
|
|
this.refreshList();
|
|
this.displayStatus((Component)Component.m_237115_((String)"message.explosionoverhaul.list_reset"));
|
|
}
|
|
}
|
|
|
|
private void updateCache() {
|
|
LinkedHashSet<String> uniqueRegistry = new LinkedHashSet<String>();
|
|
if (this.currentCategory == BlacklistCategory.SOURCES) {
|
|
uniqueRegistry.add("generic");
|
|
ForgeRegistries.ENTITY_TYPES.getKeys().stream().map(ResourceLocation::toString).forEach(uniqueRegistry::add);
|
|
ForgeRegistries.BLOCKS.getKeys().stream().map(ResourceLocation::toString).forEach(uniqueRegistry::add);
|
|
ForgeRegistries.ITEMS.getKeys().stream().map(ResourceLocation::toString).forEach(uniqueRegistry::add);
|
|
} else {
|
|
ForgeRegistries.BLOCKS.getKeys().stream().map(ResourceLocation::toString).forEach(uniqueRegistry::add);
|
|
}
|
|
this.registryCache = new ArrayList<String>(uniqueRegistry);
|
|
}
|
|
|
|
private void loadCurrentCategoryEntries() {
|
|
this.persistedEntries.clear();
|
|
this.persistedEntries.addAll(this.currentCategory.loadEntries());
|
|
if (this.currentCategory == BlacklistCategory.SOURCES) {
|
|
this.persistedSourceModes.clear();
|
|
this.persistedSourceModes.putAll(ExplosionOverhaul.getSourceModes());
|
|
}
|
|
this.defaultEntries.clear();
|
|
this.defaultEntries.addAll(this.currentCategory.loadDefaults());
|
|
this.refreshList();
|
|
}
|
|
|
|
private void selectCategory(BlacklistCategory category) {
|
|
if (this.currentCategory == category) {
|
|
return;
|
|
}
|
|
this.currentCategory = category;
|
|
this.updateCache();
|
|
this.loadCurrentCategoryEntries();
|
|
this.updateCategoryButtons();
|
|
if (this.infoButton != null) {
|
|
boolean bl = this.infoButton.f_93624_ = this.currentCategory == BlacklistCategory.SOURCES;
|
|
}
|
|
if (this.inputField != null) {
|
|
this.inputField.m_94144_("");
|
|
this.updateSuggestions("");
|
|
this.inputField.m_257771_((Component)Component.m_237115_((String)(this.currentCategory == BlacklistCategory.SOURCES ? "option.explosionoverhaul.blacklist_input_entities" : "option.explosionoverhaul.blacklist_input")));
|
|
}
|
|
}
|
|
|
|
private void updateCategoryButtons() {
|
|
this.categoryButtons.forEach((category, button) -> button.m_93666_(this.formatCategoryLabel((BlacklistCategory)((Object)category))));
|
|
}
|
|
|
|
private Component formatCategoryLabel(BlacklistCategory category) {
|
|
MutableComponent label = Component.m_237115_((String)category.getLabelKey());
|
|
if (category == this.currentCategory) {
|
|
return Component.m_237113_((String)"\u25b6 ").m_7220_((Component)label);
|
|
}
|
|
return label;
|
|
}
|
|
|
|
private void refreshList() {
|
|
String query = this.searchField == null ? "" : this.searchField.m_94155_().trim().toLowerCase(Locale.ROOT);
|
|
boolean hasQuery = !query.isEmpty();
|
|
ArrayList<BlacklistEntry> entries = new ArrayList<BlacklistEntry>();
|
|
for (String id : this.persistedEntries) {
|
|
boolean isDefault = this.defaultEntries.contains(id);
|
|
if (!hasQuery && !this.showDefaults && isDefault || hasQuery && !id.toLowerCase(Locale.ROOT).contains(query)) continue;
|
|
entries.add(new BlacklistEntry(id, isDefault));
|
|
}
|
|
this.widget.rebuild(entries);
|
|
}
|
|
|
|
private void addCurrentInput() {
|
|
String normalized;
|
|
String raw = this.inputField.m_94155_().trim().toLowerCase(Locale.ROOT);
|
|
if (raw.isEmpty()) {
|
|
return;
|
|
}
|
|
if (raw.equals("generic")) {
|
|
normalized = "generic";
|
|
} else {
|
|
ResourceLocation id = ResourceLocation.m_135820_((String)(raw.contains(":") ? raw : "minecraft:" + raw));
|
|
if (id == null) {
|
|
this.displayStatus((Component)Component.m_237115_((String)"message.explosionoverhaul.invalid_id"));
|
|
return;
|
|
}
|
|
normalized = id.toString();
|
|
}
|
|
if (!this.persistedEntries.add(normalized)) {
|
|
this.displayStatus((Component)Component.m_237115_((String)"message.explosionoverhaul.duplicate_entry"));
|
|
return;
|
|
}
|
|
if (this.currentCategory == BlacklistCategory.SOURCES) {
|
|
this.persistedSourceModes.put(normalized, ExplosionOverhaul.ExplosionSourceMode.DEFAULT);
|
|
}
|
|
this.save();
|
|
this.inputField.m_94144_("");
|
|
this.updateSuggestions("");
|
|
this.refreshList();
|
|
}
|
|
|
|
private void removeEntry(String id) {
|
|
if (this.persistedEntries.remove(id)) {
|
|
if (this.currentCategory == BlacklistCategory.SOURCES) {
|
|
this.persistedSourceModes.remove(id);
|
|
}
|
|
this.save();
|
|
this.refreshList();
|
|
}
|
|
}
|
|
|
|
private void save() {
|
|
if (this.currentCategory == BlacklistCategory.SOURCES) {
|
|
HashMap<String, ExplosionOverhaul.ExplosionSourceMode> toSave = new HashMap<String, ExplosionOverhaul.ExplosionSourceMode>();
|
|
for (String id : this.persistedEntries) {
|
|
toSave.put(id, this.persistedSourceModes.getOrDefault(id, ExplosionOverhaul.ExplosionSourceMode.DEFAULT));
|
|
}
|
|
ExplosionOverhaul.setSourceModes(toSave);
|
|
} else {
|
|
this.currentCategory.saveEntries(new ArrayList<String>(this.persistedEntries));
|
|
}
|
|
}
|
|
|
|
private void updateSuggestions(String current) {
|
|
String query = current.trim().toLowerCase(Locale.ROOT);
|
|
if (query.isEmpty()) {
|
|
this.suggestions = Collections.emptyList();
|
|
return;
|
|
}
|
|
this.suggestions = this.registryCache.stream().filter(name -> name.startsWith(query)).limit(12L).collect(Collectors.toList());
|
|
}
|
|
|
|
private void displayStatus(Component message) {
|
|
if (this.f_96541_ != null && this.f_96541_.f_91065_ != null) {
|
|
this.f_96541_.f_91065_.m_93063_(message, false);
|
|
}
|
|
}
|
|
|
|
public boolean m_7933_(int keyCode, int scanCode, int modifiers) {
|
|
if (this.inputField.m_93696_() && (keyCode == 257 || keyCode == 335)) {
|
|
this.addCurrentInput();
|
|
return true;
|
|
}
|
|
return super.m_7933_(keyCode, scanCode, modifiers);
|
|
}
|
|
|
|
public void m_88315_(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
|
|
this.m_280273_(graphics);
|
|
graphics.m_280614_(this.f_96547_, this.f_96539_, this.f_96543_ / 2 - this.f_96547_.m_92852_((FormattedText)this.f_96539_) / 2, 16, 0xFFFFFF, false);
|
|
this.widget.m_88315_(graphics, mouseX, mouseY, delta);
|
|
super.m_88315_(graphics, mouseX, mouseY, delta);
|
|
this.inputField.m_88315_(graphics, mouseX, mouseY, delta);
|
|
this.renderSuggestions(graphics, mouseX, mouseY);
|
|
}
|
|
|
|
private void renderSuggestions(GuiGraphics graphics, int mouseX, int mouseY) {
|
|
if (this.suggestions.isEmpty() || !this.inputField.m_93696_()) {
|
|
return;
|
|
}
|
|
int x = this.inputField.m_252754_();
|
|
int y = this.inputField.m_252907_() - this.suggestions.size() * 12 - 4;
|
|
int width = this.inputField.m_5711_();
|
|
int line = 0;
|
|
for (String s : this.suggestions) {
|
|
int yy = y + line * 12;
|
|
graphics.m_280509_(x, yy, x + width, yy + 12, -1442840576);
|
|
graphics.m_280056_(this.f_96547_, s, x + 4, yy + 2, 0xE0E0E0, false);
|
|
++line;
|
|
}
|
|
}
|
|
|
|
public boolean m_6375_(double mouseX, double mouseY, int button) {
|
|
if (this.inputField.m_93696_() && !this.suggestions.isEmpty()) {
|
|
int x = this.inputField.m_252754_();
|
|
int y = this.inputField.m_252907_() - this.suggestions.size() * 12 - 4;
|
|
int width = this.inputField.m_5711_();
|
|
for (int i = 0; i < this.suggestions.size(); ++i) {
|
|
int yy = y + i * 12;
|
|
if (!(mouseX >= (double)x) || !(mouseX <= (double)(x + width)) || !(mouseY >= (double)yy) || !(mouseY <= (double)(yy + 12))) continue;
|
|
this.inputField.m_94144_(this.suggestions.get(i));
|
|
this.inputField.m_94196_(this.inputField.m_94155_().length());
|
|
this.updateSuggestions(this.inputField.m_94155_());
|
|
return true;
|
|
}
|
|
}
|
|
return super.m_6375_(mouseX, mouseY, button);
|
|
}
|
|
|
|
public void m_7379_() {
|
|
this.save();
|
|
this.f_96541_.m_91152_(this.parent);
|
|
}
|
|
|
|
private static enum BlacklistCategory {
|
|
EXPLOSION("option.explosionoverhaul.blacklist_category_explosion", "tooltip.explosionoverhaul.blacklist_category_explosion", ExplosionOverhaul::getExplosionBlacklistList, ExplosionOverhaul::getDefaultExplosionBlacklist, ExplosionOverhaul::setExplosionBlacklistFromList),
|
|
GLASS("option.explosionoverhaul.blacklist_category_glass", "tooltip.explosionoverhaul.blacklist_category_glass", BlockIndexManager::getReinforcedGlassBlacklist, BlockIndexManager::getDefaultReinforcedGlassBlacklist, BlockIndexManager::setReinforcedGlassBlacklistFromList),
|
|
SOURCES("option.explosionoverhaul.blacklist_category_sources", "tooltip.explosionoverhaul.blacklist_category_sources", () -> new ArrayList<String>(ExplosionOverhaul.getSourceModes().keySet()), ArrayList::new, list -> {});
|
|
|
|
private final String labelKey;
|
|
private final String tooltipKey;
|
|
private final Supplier<List<String>> entriesSupplier;
|
|
private final Supplier<List<String>> defaultsSupplier;
|
|
private final Consumer<List<String>> saveAction;
|
|
|
|
private BlacklistCategory(String labelKey, String tooltipKey, Supplier<List<String>> entriesSupplier, Supplier<List<String>> defaultsSupplier, Consumer<List<String>> saveAction) {
|
|
this.labelKey = labelKey;
|
|
this.tooltipKey = tooltipKey;
|
|
this.entriesSupplier = entriesSupplier;
|
|
this.defaultsSupplier = defaultsSupplier;
|
|
this.saveAction = saveAction;
|
|
}
|
|
|
|
String getLabelKey() {
|
|
return this.labelKey;
|
|
}
|
|
|
|
String getTooltipKey() {
|
|
return this.tooltipKey;
|
|
}
|
|
|
|
List<String> loadEntries() {
|
|
return this.entriesSupplier.get();
|
|
}
|
|
|
|
List<String> loadDefaults() {
|
|
return this.defaultsSupplier.get();
|
|
}
|
|
|
|
void saveEntries(List<String> entries) {
|
|
this.saveAction.accept(entries);
|
|
}
|
|
}
|
|
|
|
private class BlacklistList
|
|
extends ObjectSelectionList<BlacklistEntry> {
|
|
public BlacklistList(Minecraft mc, int width, int height, int top, int bottom, int itemHeight) {
|
|
super(mc, width, height, top, bottom, itemHeight);
|
|
}
|
|
|
|
void rebuild(List<BlacklistEntry> entries) {
|
|
this.m_5988_(entries);
|
|
}
|
|
|
|
public int m_5759_() {
|
|
return this.f_93388_ - 12;
|
|
}
|
|
|
|
protected int m_5756_() {
|
|
return this.m_5747_() + this.m_5759_();
|
|
}
|
|
|
|
public boolean m_7979_(double mouseX, double mouseY, int button, double dragX, double dragY) {
|
|
return super.m_7979_(mouseX, mouseY, button, dragX, dragY);
|
|
}
|
|
}
|
|
|
|
private class BlacklistEntry
|
|
extends ObjectSelectionList.Entry<BlacklistEntry> {
|
|
private final String id;
|
|
private final boolean isDefault;
|
|
private final Button removeButton;
|
|
private CycleButton<ExplosionOverhaul.ExplosionSourceMode> modeButton;
|
|
private ItemStack icon;
|
|
private int lastX;
|
|
private int lastY;
|
|
private int lastRowWidth;
|
|
private int lastRowHeight;
|
|
|
|
BlacklistEntry(String id, boolean isDefault) {
|
|
this.id = id;
|
|
this.isDefault = isDefault;
|
|
if (BlacklistScreen.this.currentCategory == BlacklistCategory.SOURCES) {
|
|
if (id.equals("generic")) {
|
|
this.icon = new ItemStack((ItemLike)Items.f_41996_);
|
|
} else {
|
|
ResourceLocation rl = ResourceLocation.m_135820_((String)id);
|
|
ItemStack stack = ItemStack.f_41583_;
|
|
if (rl != null) {
|
|
Block b2;
|
|
stack = new ItemStack((ItemLike)ForgeRegistries.ITEMS.getValue(rl));
|
|
if (stack.m_41619_()) {
|
|
stack = new ItemStack((ItemLike)ForgeRegistries.ITEMS.getValue(new ResourceLocation(rl.m_135827_(), rl.m_135815_() + "_spawn_egg")));
|
|
}
|
|
if (stack.m_41619_() && (b2 = (Block)ForgeRegistries.BLOCKS.getValue(rl)) != Blocks.f_50016_) {
|
|
stack = new ItemStack((ItemLike)b2.m_5456_());
|
|
}
|
|
}
|
|
this.icon = stack.m_41619_() ? new ItemStack((ItemLike)Items.f_41996_) : stack;
|
|
}
|
|
ExplosionOverhaul.ExplosionSourceMode currentMode = BlacklistScreen.this.persistedSourceModes.getOrDefault(id, ExplosionOverhaul.ExplosionSourceMode.DEFAULT);
|
|
String entryId = id;
|
|
this.modeButton = CycleButton.m_168894_(m -> Component.m_237115_((String)("option.explosionoverhaul.sourcemode_" + m.name().toLowerCase(Locale.ROOT)))).m_168961_((Object[])ExplosionOverhaul.ExplosionSourceMode.values()).m_168948_((Object)currentMode).m_232498_(m -> Tooltip.m_257550_((Component)Component.m_237115_((String)("tooltip.explosionoverhaul.sourcemode_" + m.name().toLowerCase(Locale.ROOT))))).m_168936_(0, 0, 150, 20, (Component)Component.m_237119_(), (btn, value) -> {
|
|
BlacklistScreen.this.persistedSourceModes.put(entryId, (ExplosionOverhaul.ExplosionSourceMode)((Object)value));
|
|
BlacklistScreen.this.save();
|
|
});
|
|
} else {
|
|
ItemStack stack;
|
|
Block block = (Block)ForgeRegistries.BLOCKS.getValue(ResourceLocation.m_135820_((String)id));
|
|
ItemStack itemStack = stack = block == null || block == Blocks.f_50016_ ? ItemStack.f_41583_ : new ItemStack((ItemLike)block.m_5456_());
|
|
if (stack.m_41619_()) {
|
|
stack = new ItemStack((ItemLike)Items.f_42127_);
|
|
}
|
|
this.icon = stack;
|
|
}
|
|
this.removeButton = Button.m_253074_((Component)Component.m_237113_((String)"\u2715"), b -> BlacklistScreen.this.removeEntry(this.id)).m_252794_(0, 0).m_253046_(20, 20).m_253136_();
|
|
}
|
|
|
|
public Component m_142172_() {
|
|
return Component.m_237113_((String)this.id);
|
|
}
|
|
|
|
public boolean m_6375_(double mouseX, double mouseY, int button) {
|
|
if (this.modeButton != null && this.modeButton.m_6375_(mouseX, mouseY, button)) {
|
|
return true;
|
|
}
|
|
int btnX = this.lastX + this.lastRowWidth - 26;
|
|
int btnY = this.lastY + (this.lastRowHeight - 20) / 2;
|
|
if (mouseX >= (double)btnX && mouseX <= (double)(btnX + 20) && mouseY >= (double)btnY && mouseY <= (double)(btnY + 20)) {
|
|
BlacklistScreen.this.removeEntry(this.id);
|
|
return true;
|
|
}
|
|
return super.m_6375_(mouseX, mouseY, button);
|
|
}
|
|
|
|
public void m_6311_(GuiGraphics graphics, int index, int y, int x, int rowWidth, int rowHeight, int mouseX, int mouseY, boolean hovered, float delta) {
|
|
this.lastX = x;
|
|
this.lastY = y;
|
|
this.lastRowWidth = rowWidth;
|
|
this.lastRowHeight = rowHeight;
|
|
int iconX = x + 6;
|
|
int iconY = y + (rowHeight - 16) / 2;
|
|
try {
|
|
graphics.m_280480_(this.icon, iconX, iconY);
|
|
}
|
|
catch (Throwable t) {
|
|
this.icon = new ItemStack((ItemLike)Items.f_42127_);
|
|
graphics.m_280480_(this.icon, iconX, iconY);
|
|
}
|
|
int textX = iconX + 22;
|
|
int color = this.isDefault ? -5197648 : -1;
|
|
graphics.m_280056_(BlacklistScreen.this.f_96547_, this.id, textX, y + (rowHeight - 8) / 2, color, false);
|
|
if (this.modeButton != null) {
|
|
int modeX = x + rowWidth - 180;
|
|
this.modeButton.m_264152_(modeX, y + (rowHeight - 20) / 2);
|
|
this.modeButton.m_88315_(graphics, mouseX, mouseY, delta);
|
|
}
|
|
int btnX = x + rowWidth - 26;
|
|
this.removeButton.m_264152_(btnX, y + (rowHeight - 20) / 2);
|
|
this.removeButton.m_88315_(graphics, mouseX, mouseY, delta);
|
|
}
|
|
}
|
|
}
|
|
|