Reformat Code

This commit is contained in:
Kam committed 2026-02-18 05:13:51 -05:00
1 parent 21e920426e
commit 1de1c4e710
169 files changed
+3967 -1556

No files matched your search

@@ -74,10 +74,10 @@ public class GuiNpcMobSpawnerFullscreen extends GuiDirectory implements IGuiData
this.posZ = posZ;
// Configure GuiDirectory layout percentages
leftPanelPercent = 0.15f;
leftPanelPercent = 0.15f;
rightPanelPercent = 0.08f;
minLeftPanelW = 120;
minRightPanelW = 62;
minLeftPanelW = 120;
minRightPanelW = 62;
PacketClient.sendClient(new CloneAllTagsPacket());
if (GuiNpcMobSpawner.showingClones == 2) {
@@ -1,9 +1,6 @@
package noppes.npcs.client.gui;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.dialog.DialogSavePacket;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
@@ -1,7 +1,7 @@
package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityAction;
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
@@ -33,7 +33,14 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumScrollData;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.Vector;
/**
* GUI for managing NPC abilities.
@@ -42,30 +49,30 @@ import java.util.*;
public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, ICustomScrollListener, IGuiData, ITextfieldListener, ISubGuiListener, IAbilityConfigCallback, IChainedAbilityConfigCallback {
// ── Button IDs ────────────────────────────────────────────────────────────
private static final int BTN_SCROLL_TYPE = 50;
private static final int BTN_ADD_ABILITY = 70;
private static final int BTN_REMOVE = 71;
private static final int BTN_EDIT = 72;
private static final int BTN_MOVE_UP = 73;
private static final int BTN_MOVE_DOWN = 74;
private static final int BTN_LOAD = 75;
private static final int BTN_SAVE_PRESET = 76;
private static final int BTN_TOGGLE_SLOT = 77;
private static final int BTN_ADD_CHAIN = 78;
private static final int BTN_ENABLED = 100;
private static final int BTN_SCROLL_TYPE = 50;
private static final int BTN_ADD_ABILITY = 70;
private static final int BTN_REMOVE = 71;
private static final int BTN_EDIT = 72;
private static final int BTN_MOVE_UP = 73;
private static final int BTN_MOVE_DOWN = 74;
private static final int BTN_LOAD = 75;
private static final int BTN_SAVE_PRESET = 76;
private static final int BTN_TOGGLE_SLOT = 77;
private static final int BTN_ADD_CHAIN = 78;
private static final int BTN_ENABLED = 100;
// ── Scroll IDs ────────────────────────────────────────────────────────────
private static final int SCROLL_TYPES = 0;
private static final int SCROLL_NPC = 1;
private static final int SCROLL_TYPES = 0;
private static final int SCROLL_NPC = 1;
// ── TextField / Label IDs ─────────────────────────────────────────────────
private static final int TF_MIN_COOLDOWN = 101;
private static final int TF_MAX_COOLDOWN = 102;
private static final int TF_SEARCH = 4;
private static final int LBL_TYPES = 1;
private static final int LBL_NPC = 2;
private static final int LBL_MIN_COOLDOWN = 101;
private static final int LBL_MAX_COOLDOWN = 102;
private static final int TF_MIN_COOLDOWN = 101;
private static final int TF_MAX_COOLDOWN = 102;
private static final int TF_SEARCH = 4;
private static final int LBL_TYPES = 1;
private static final int LBL_NPC = 2;
private static final int LBL_MIN_COOLDOWN = 101;
private static final int LBL_MAX_COOLDOWN = 102;
// ── Scroll lists ──────────────────────────────────────────────────────────
private GuiCustomScroll availableTypesScroll;
@@ -127,7 +134,8 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
@Override
public String toString() {
switch (this) {
case CNPC: return "CustomNPCs";
case CNPC:
return "CustomNPCs";
case MODDED:
if (Register.isEmpty("ability"))
return "modded";
@@ -135,8 +143,10 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
String namespace = Register.REGISTERED_NAMESPACES.get("ability").get(modIndex);
String displayName = Register.NAMESPACE_DISPLAY_NAMES.get(namespace);
return displayName != null ? displayName : namespace;
case ALL: return "filter.all";
default: return name();
case ALL:
return "filter.all";
default:
return name();
}
}
}
@@ -855,13 +865,37 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (subgui instanceof SubGuiAbilityVariantSelect) { handleVariantSelectClosed((SubGuiAbilityVariantSelect) subgui); initGui(); return; }
if (subgui instanceof SubGuiChainedAbilityConfig) { handleChainConfigClosed(); initGui(); return; }
if (subgui instanceof SubGuiAbilityEditMode) { handleEditModeClosed((SubGuiAbilityEditMode) subgui); return; }
if (subgui instanceof SubGuiAbilitySaveConfirm) { handleSaveConfirmClosed((SubGuiAbilitySaveConfirm) subgui); initGui(); return; }
if (subgui instanceof SubGuiLoadTypeChoice) { handleLoadTypeChoiceClosed((SubGuiLoadTypeChoice) subgui); return; }
if (subgui instanceof SubGuiChainSelect) { handleChainSelectClosed((SubGuiChainSelect) subgui); return; }
if (subgui instanceof SubGuiAbilityConfig) { handleAbilityConfigClosed(); return; }
if (subgui instanceof SubGuiAbilityVariantSelect) {
handleVariantSelectClosed((SubGuiAbilityVariantSelect) subgui);
initGui();
return;
}
if (subgui instanceof SubGuiChainedAbilityConfig) {
handleChainConfigClosed();
initGui();
return;
}
if (subgui instanceof SubGuiAbilityEditMode) {
handleEditModeClosed((SubGuiAbilityEditMode) subgui);
return;
}
if (subgui instanceof SubGuiAbilitySaveConfirm) {
handleSaveConfirmClosed((SubGuiAbilitySaveConfirm) subgui);
initGui();
return;
}
if (subgui instanceof SubGuiLoadTypeChoice) {
handleLoadTypeChoiceClosed((SubGuiLoadTypeChoice) subgui);
return;
}
if (subgui instanceof SubGuiChainSelect) {
handleChainSelectClosed((SubGuiChainSelect) subgui);
return;
}
if (subgui instanceof SubGuiAbilityConfig) {
handleAbilityConfigClosed();
return;
}
}
private void handleVariantSelectClosed(SubGuiAbilityVariantSelect gui) {
@@ -3,10 +3,10 @@ package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.Condition;
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldBuilder;
import noppes.npcs.client.gui.builder.FieldDef;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.builder.FieldDef;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -75,11 +75,11 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
for (FieldDef def : fieldDefs) {
String tab = def.getTab();
if (tab != null
&& !TAB_NAME_GENERAL.equals(tab)
&& !TAB_NAME_TYPE.equals(tab)
&& !TAB_NAME_TARGET.equals(tab)
&& !TAB_NAME_EFFECTS.equals(tab)
&& !customTabNames.contains(tab)) {
&& !TAB_NAME_GENERAL.equals(tab)
&& !TAB_NAME_TYPE.equals(tab)
&& !TAB_NAME_TARGET.equals(tab)
&& !TAB_NAME_EFFECTS.equals(tab)
&& !customTabNames.contains(tab)) {
customTabNames.add(tab);
}
}
@@ -187,11 +187,21 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
}
} else {
switch (tabIndex) {
case TAB_GENERAL: tabName = TAB_NAME_GENERAL; break;
case TAB_TYPE: tabName = TAB_NAME_TYPE; break;
case TAB_TARGET: tabName = TAB_NAME_TARGET; break;
case TAB_EFFECTS: tabName = TAB_NAME_EFFECTS; break;
default: tabName = TAB_NAME_TYPE; break;
case TAB_GENERAL:
tabName = TAB_NAME_GENERAL;
break;
case TAB_TYPE:
tabName = TAB_NAME_TYPE;
break;
case TAB_TARGET:
tabName = TAB_NAME_TARGET;
break;
case TAB_EFFECTS:
tabName = TAB_NAME_EFFECTS;
break;
default:
tabName = TAB_NAME_TYPE;
break;
}
}
@@ -264,17 +274,36 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
int id = guibutton.id;
// Tab switching — fixed tabs
if (id == 90) { activeTab = TAB_GENERAL; initGui(); return; }
if (id == 91) { activeTab = TAB_TYPE; initGui(); return; }
if (id == 92) { activeTab = TAB_TARGET; initGui(); return; }
if (id == 93) { activeTab = TAB_EFFECTS; initGui(); return; }
if (id == 90) {
activeTab = TAB_GENERAL;
initGui();
return;
}
if (id == 91) {
activeTab = TAB_TYPE;
initGui();
return;
}
if (id == 92) {
activeTab = TAB_TARGET;
initGui();
return;
}
if (id == 93) {
activeTab = TAB_EFFECTS;
initGui();
return;
}
// Custom tabs (94+)
if (id >= 94 && id < 94 + customTabNames.size()) {
activeTab = 4 + (id - 94);
initGui();
return;
}
if (id == -1000) { close(); return; }
if (id == -1000) {
close();
return;
}
// Condition buttons (50-80)
if (handleConditionButton(id)) return;
@@ -1,7 +1,7 @@
package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.CustomAbilitiesGetPacket;
import kamkeel.npcs.network.packets.request.ability.CustomAbilityGetPacket;
@@ -43,37 +43,37 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
private static final int LABEL_ID_START = 3000;
// ── Tab constants (core tabs) ────────────────────────────────────────────
private static final int TAB_GENERAL = 0;
private static final int TAB_ENTRIES = 1;
private static final int TAB_GENERAL = 0;
private static final int TAB_ENTRIES = 1;
private static final int TAB_CONDITIONS = 2;
private static final int CORE_TAB_COUNT = 3;
// ── Tab button IDs ────────────────────────────────────────────────────────
private static final int BTN_TAB_GENERAL = 90;
private static final int BTN_TAB_ENTRIES = 91;
private static final int BTN_TAB_GENERAL = 90;
private static final int BTN_TAB_ENTRIES = 91;
private static final int BTN_TAB_CONDITIONS = 92;
private static final int BTN_TAB_EXTRA_BASE = 93;
private static final int BTN_CLOSE = -1000;
private static final int BTN_CLOSE = -1000;
// ── Entries tab: per-entry ID encoding ─────────────────────────────────────
// Actual ID = ENTRY_BASE + i * ENTRY_STRIDE + offset
// offset 0 = name/select button, 1 = delay text field, 2 = up, 3 = down, 4 = delete
private static final int ENTRY_BASE = 100;
private static final int ENTRY_END = 200;
private static final int ENTRY_STRIDE = 10;
private static final int ENTRY_BASE = 100;
private static final int ENTRY_END = 200;
private static final int ENTRY_STRIDE = 10;
private static final int BTN_ADD_ENTRY = 200;
// ── Conditions tab: per-condition ID encoding ─────────────────────────────
// Actual ID = COND_BASE + i * COND_STRIDE + offset
// offset 0 = name/click, 1 = edit, 2 = delete
private static final int COND_BASE = 50;
private static final int COND_END = 80;
private static final int COND_STRIDE = 10;
private static final int BTN_ADD_COND = 80;
private static final int COND_BASE = 50;
private static final int COND_END = 80;
private static final int COND_STRIDE = 10;
private static final int BTN_ADD_COND = 80;
// ── Layout constants ──────────────────────────────────────────────────────
private static final int L_LABEL_X = 5;
private static final int ROW_H = 24;
private static final int L_LABEL_X = 5;
private static final int ROW_H = 24;
private static final int MAX_ENTRIES = 10;
private final ChainedAbility chain;
@@ -109,7 +109,7 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
}
public SubGuiChainedAbilityConfig(ChainedAbility chain, IChainedAbilityConfigCallback callback,
boolean npcContext, List<AbilityAction> npcSlots) {
boolean npcContext, List<AbilityAction> npcSlots) {
this.chain = chain;
this.callback = callback;
this.npcContext = npcContext;
@@ -417,10 +417,26 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
int id = guibutton.id;
// Tab switching — core tabs
if (id == BTN_TAB_GENERAL) { activeTab = TAB_GENERAL; initGui(); return; }
if (id == BTN_TAB_ENTRIES) { activeTab = TAB_ENTRIES; initGui(); return; }
if (id == BTN_TAB_CONDITIONS) { activeTab = TAB_CONDITIONS; initGui(); return; }
if (id == BTN_CLOSE) { saveOnClose = true; close(); return; }
if (id == BTN_TAB_GENERAL) {
activeTab = TAB_GENERAL;
initGui();
return;
}
if (id == BTN_TAB_ENTRIES) {
activeTab = TAB_ENTRIES;
initGui();
return;
}
if (id == BTN_TAB_CONDITIONS) {
activeTab = TAB_CONDITIONS;
initGui();
return;
}
if (id == BTN_CLOSE) {
saveOnClose = true;
close();
return;
}
// Tab switching — extra tabs
if (id >= BTN_TAB_EXTRA_BASE && id < BTN_TAB_EXTRA_BASE + extraTabs.size()) {
@@ -575,12 +591,35 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
}
}
if (subgui instanceof SubGuiAbilitySelect) { handleAbilitySelectClosed((SubGuiAbilitySelect) subgui); initGui(); return; }
if (subgui instanceof SubGuiChainedEntrySource) { handleEntrySourceClosed((SubGuiChainedEntrySource) subgui); return; }
if (subgui instanceof SubGuiNpcSlotPicker) { handleSlotPickerClosed((SubGuiNpcSlotPicker) subgui); initGui(); return; }
if (subgui instanceof SubGuiAbilityTypeSelect) { handleTypeSelectClosed((SubGuiAbilityTypeSelect) subgui); if (!hasSubGui()) initGui(); return; }
if (subgui instanceof SubGuiAbilityConfig) { editingEntryIndex = -1; initGui(); return; }
if (subgui instanceof SubGuiConditionEdit) { handleConditionEditClosed((SubGuiConditionEdit) subgui); initGui(); return; }
if (subgui instanceof SubGuiAbilitySelect) {
handleAbilitySelectClosed((SubGuiAbilitySelect) subgui);
initGui();
return;
}
if (subgui instanceof SubGuiChainedEntrySource) {
handleEntrySourceClosed((SubGuiChainedEntrySource) subgui);
return;
}
if (subgui instanceof SubGuiNpcSlotPicker) {
handleSlotPickerClosed((SubGuiNpcSlotPicker) subgui);
initGui();
return;
}
if (subgui instanceof SubGuiAbilityTypeSelect) {
handleTypeSelectClosed((SubGuiAbilityTypeSelect) subgui);
if (!hasSubGui()) initGui();
return;
}
if (subgui instanceof SubGuiAbilityConfig) {
editingEntryIndex = -1;
initGui();
return;
}
if (subgui instanceof SubGuiConditionEdit) {
handleConditionEditClosed((SubGuiConditionEdit) subgui);
initGui();
return;
}
}
private void handleAbilitySelectClosed(SubGuiAbilitySelect gui) {
@@ -2,12 +2,12 @@ package noppes.npcs.client.gui.builder;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.select.GuiAnimationSelection;
import noppes.npcs.client.gui.select.GuiSoundSelection;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.data.Animation;
import java.util.List;
import java.util.function.BooleanSupplier;
@@ -175,8 +175,8 @@ public class FieldDef {
}
public static FieldDef animSubGui(String label,
Supplier<Integer> idGetter, Consumer<Integer> idSetter,
Supplier<String> nameGetter, Consumer<String> nameSetter) {
Supplier<Integer> idGetter, Consumer<Integer> idSetter,
Supplier<String> nameGetter, Consumer<String> nameSetter) {
return subGuiField(label,
() -> new GuiAnimationSelection(idGetter.get(), nameGetter.get()),
gui -> {
@@ -202,7 +202,10 @@ public class FieldDef {
}
return "gui.none";
})
.clearable(() -> { idSetter.accept(-1); nameSetter.accept(""); });
.clearable(() -> {
idSetter.accept(-1);
nameSetter.accept("");
});
}
// ═══════════════════════════════════════════════════════════════════
@@ -264,21 +267,65 @@ public class FieldDef {
// GETTERS
// ═══════════════════════════════════════════════════════════════════
public String getLabel() { return label; }
public FieldType getType() { return type; }
public String getTab() { return tab; }
public boolean isVisible() { return visibleWhen.getAsBoolean(); }
public boolean isEnabled() { return enabledWhen.getAsBoolean(); }
public String getHoverText() { return hoverText; }
public float getMin() { return min; }
public float getMax() { return max; }
public boolean hasRange() { return min != Float.NEGATIVE_INFINITY || max != Float.POSITIVE_INFINITY; }
public Class<? extends Enum<?>> getEnumClass() { return enumClass; }
public String[] getStringEnumValues() { return stringEnumValues; }
public Supplier<SubGuiInterface> getSubGuiFactory() { return subGuiFactory; }
public Consumer<SubGuiInterface> getSubGuiResultHandler() { return subGuiResultHandler; }
public boolean hasClearAction() { return clearAction != null; }
public Runnable getClearAction() { return clearAction; }
public String getLabel() {
return label;
}
public FieldType getType() {
return type;
}
public String getTab() {
return tab;
}
public boolean isVisible() {
return visibleWhen.getAsBoolean();
}
public boolean isEnabled() {
return enabledWhen.getAsBoolean();
}
public String getHoverText() {
return hoverText;
}
public float getMin() {
return min;
}
public float getMax() {
return max;
}
public boolean hasRange() {
return min != Float.NEGATIVE_INFINITY || max != Float.POSITIVE_INFINITY;
}
public Class<? extends Enum<?>> getEnumClass() {
return enumClass;
}
public String[] getStringEnumValues() {
return stringEnumValues;
}
public Supplier<SubGuiInterface> getSubGuiFactory() {
return subGuiFactory;
}
public Consumer<SubGuiInterface> getSubGuiResultHandler() {
return subGuiResultHandler;
}
public boolean hasClearAction() {
return clearAction != null;
}
public Runnable getClearAction() {
return clearAction;
}
public Object getValue() {
return getter != null ? getter.get() : null;
@@ -305,8 +352,13 @@ public class FieldDef {
return buttonTextColorSupplier != null ? buttonTextColorSupplier.get() : null;
}
public FieldDef getLeftChild() { return leftChild; }
public FieldDef getRightChild() { return rightChild; }
public FieldDef getLeftChild() {
return leftChild;
}
public FieldDef getRightChild() {
return rightChild;
}
// ═══════════════════════════════════════════════════════════════════
// LIST MANIPULATION (for mod injection)
@@ -356,7 +408,7 @@ public class FieldDef {
*
* @param fields The field list to modify
* @param targetLabel The label of the field to modify
* @param condition The condition to replace
* @param condition The condition to replace
* @return true if the target was found and the condition was modified
*/
public static boolean modifyVisibility(List<FieldDef> fields, String targetLabel, BooleanSupplier condition) {
@@ -69,13 +69,32 @@ public class GuiFieldBuilder {
// CONFIG CHAINING
// ═══════════════════════════════════════════════════════════════════
public GuiFieldBuilder scrollWindowId(int id) { this.scrollWindowId = id; return this; }
public GuiFieldBuilder contentRight(int v) { this.contentRight = v; return this; }
public GuiFieldBuilder startIds(int widget, int clear, int label) {
this.widgetId = widget; this.clearId = clear; this.labelId = label; return this;
public GuiFieldBuilder scrollWindowId(int id) {
this.scrollWindowId = id;
return this;
}
public GuiFieldBuilder contentRight(int v) {
this.contentRight = v;
return this;
}
public GuiFieldBuilder startIds(int widget, int clear, int label) {
this.widgetId = widget;
this.clearId = clear;
this.labelId = label;
return this;
}
public GuiFieldBuilder startY(int y) {
this.startY = y;
return this;
}
public GuiFieldBuilder rowHeight(int h) {
this.rowHeight = h;
return this;
}
public GuiFieldBuilder startY(int y) { this.startY = y; return this; }
public GuiFieldBuilder rowHeight(int h) { this.rowHeight = h; return this; }
// ═══════════════════════════════════════════════════════════════════
// BUILD
@@ -98,6 +117,7 @@ public class GuiFieldBuilder {
/**
* Processes all fields and adds widgets to the scroll window.
*
* @return the final Y position after all fields
*/
protected int build(List<FieldDef> fields) {
@@ -173,8 +193,14 @@ public class GuiFieldBuilder {
}
private int lastHandledIndex = -1;
protected void setLastHandledIndex(int index) { this.lastHandledIndex = index; }
protected int getLastHandledIndex() { return lastHandledIndex; }
protected void setLastHandledIndex(int index) {
this.lastHandledIndex = index;
}
protected int getLastHandledIndex() {
return lastHandledIndex;
}
// ═══════════════════════════════════════════════════════════════════
// FIELD RENDERING
@@ -268,7 +294,10 @@ public class GuiFieldBuilder {
String curVal = def.getStringEnumValue();
int selected = 0;
for (int i = 0; i < values.length; i++) {
if (values[i].equals(curVal)) { selected = i; break; }
if (values[i].equals(curVal)) {
selected = i;
break;
}
}
GuiNpcButton btn = new GuiNpcButton(widgetId, fieldX, y, fieldW, 20, values, selected);
if (!def.isEnabled()) btn.setEnabled(false);
@@ -321,14 +350,21 @@ public class GuiFieldBuilder {
protected int getFullFieldWidth(FieldDef def) {
switch (def.getType()) {
case FLOAT:
case INT: return 60;
case STRING: return 200;
case BOOLEAN: return 50;
case LABEL: return 60;
case INT:
return 60;
case STRING:
return 200;
case BOOLEAN:
return 50;
case LABEL:
return 60;
case ENUM:
case STRING_ENUM: return 120;
case SUB_GUI: return def.hasClearAction() ? 175 : 200;
default: return 80;
case STRING_ENUM:
return 120;
case SUB_GUI:
return def.hasClearAction() ? 175 : 200;
default:
return 80;
}
}
@@ -410,7 +446,8 @@ public class GuiFieldBuilder {
def.setValue(newVal);
return true;
}
} catch (NumberFormatException ignored) {}
} catch (NumberFormatException ignored) {
}
return false;
case INT:
try {
@@ -421,7 +458,8 @@ public class GuiFieldBuilder {
def.setValue(newVal);
return true;
}
} catch (NumberFormatException ignored) {}
} catch (NumberFormatException ignored) {
}
return false;
case STRING:
String newVal = field.getText();
@@ -453,10 +491,27 @@ public class GuiFieldBuilder {
// GETTERS
// ═══════════════════════════════════════════════════════════════════
public Map<Integer, FieldDef> getButtonFieldMap() { return buttonFieldMap; }
public Map<Integer, FieldDef> getTextFieldMap() { return textFieldMap; }
public Map<Integer, FieldDef> getClearFieldMap() { return clearFieldMap; }
public GuiScrollWindow getScrollWindow() { return sw; }
public int getLastBuildY() { return lastBuildY; }
public int getNextLabelId() { return labelId; }
public Map<Integer, FieldDef> getButtonFieldMap() {
return buttonFieldMap;
}
public Map<Integer, FieldDef> getTextFieldMap() {
return textFieldMap;
}
public Map<Integer, FieldDef> getClearFieldMap() {
return clearFieldMap;
}
public GuiScrollWindow getScrollWindow() {
return sw;
}
public int getLastBuildY() {
return lastBuildY;
}
public int getNextLabelId() {
return labelId;
}
}
@@ -1,7 +1,8 @@
package noppes.npcs.client.gui.global;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.BuiltInAbilityGetPacket;
@@ -19,7 +20,6 @@ import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.NoppesUtil;
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
import noppes.npcs.client.gui.advanced.SubGuiAbilityTypeSelect;
import noppes.npcs.client.gui.advanced.SubGuiAbilityVariantSelect;
import noppes.npcs.client.gui.advanced.SubGuiChainedAbilityConfig;
@@ -50,7 +50,7 @@ import java.util.Vector;
/**
* Global GUI for managing saved ability presets with 3D preview.
*
* <p>
* Features:
* - Left side: 3D preview of NPC with ability effects
* - Right side: Ability list with search
@@ -58,29 +58,29 @@ import java.util.Vector;
* - Toggle between Custom and Built-in ability views
*/
public class GuiNpcManageAbilities extends GuiAbilityInterface
implements ICustomScrollListener, ISubGuiListener, IAbilityConfigCallback,
IChainedAbilityConfigCallback, ITextfieldListener, GuiYesNoCallback,
IScrollData, IGuiData {
implements ICustomScrollListener, ISubGuiListener, IAbilityConfigCallback,
IChainedAbilityConfigCallback, ITextfieldListener, GuiYesNoCallback,
IScrollData, IGuiData {
// ── Button IDs ────────────────────────────────────────────────────────────
private static final int BTN_REMOVE = 1;
private static final int BTN_ADD = 2;
private static final int BTN_TOGGLE_VIEW = 10;
private static final int BTN_EDIT = 100;
private static final int BTN_PREVIEW_PLAY = 91;
private static final int BTN_PREVIEW_PAUSE = 92;
private static final int BTN_PREVIEW_STOP = 93;
private static final int BTN_REMOVE = 1;
private static final int BTN_ADD = 2;
private static final int BTN_TOGGLE_VIEW = 10;
private static final int BTN_EDIT = 100;
private static final int BTN_PREVIEW_PLAY = 91;
private static final int BTN_PREVIEW_PAUSE = 92;
private static final int BTN_PREVIEW_STOP = 93;
// ── TextField / Label IDs ─────────────────────────────────────────────────
private static final int TF_SEARCH = 55;
private static final int TF_SEARCH = 55;
private static final int LBL_PREVIEW_STATUS = 90;
// ── Scroll IDs ────────────────────────────────────────────────────────────
private static final int SCROLL_MAIN = 0;
private static final int SCROLL_MAIN = 0;
// ── Confirm dialog IDs ────────────────────────────────────────────────────
private static final int CONFIRM_REMOVE_ABILITY = 1;
private static final int CONFIRM_REMOVE_CHAIN = 2;
private static final int CONFIRM_REMOVE_CHAIN = 2;
// ==================== DATA ====================
private GuiCustomScroll scroll;
@@ -474,11 +474,20 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (subgui instanceof SubGuiChainedAbilityConfig) { handleChainConfigClosed(); initGui(); return; }
if (subgui instanceof SubGuiAbilityVariantSelect) { if (handleVariantSelectClosed((SubGuiAbilityVariantSelect) subgui)) return; }
else if (subgui instanceof SubGuiAbilityTypeSelect) { if (handleTypeSelectClosed((SubGuiAbilityTypeSelect) subgui)) return; }
else if (subgui instanceof SubGuiDuplicateNameConfirm) { if (handleDuplicateNameClosed((SubGuiDuplicateNameConfirm) subgui)) return; }
else if (pendingSaveAbility != null) { if (handlePendingSave()) return; }
if (subgui instanceof SubGuiChainedAbilityConfig) {
handleChainConfigClosed();
initGui();
return;
}
if (subgui instanceof SubGuiAbilityVariantSelect) {
if (handleVariantSelectClosed((SubGuiAbilityVariantSelect) subgui)) return;
} else if (subgui instanceof SubGuiAbilityTypeSelect) {
if (handleTypeSelectClosed((SubGuiAbilityTypeSelect) subgui)) return;
} else if (subgui instanceof SubGuiDuplicateNameConfirm) {
if (handleDuplicateNameClosed((SubGuiDuplicateNameConfirm) subgui)) return;
} else if (pendingSaveAbility != null) {
if (handlePendingSave()) return;
}
initGui();
}
@@ -491,7 +500,9 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
}
}
/** @return true if a SubGui was opened (caller should return early, skipping initGui) */
/**
* @return true if a SubGui was opened (caller should return early, skipping initGui)
*/
private boolean handleVariantSelectClosed(SubGuiAbilityVariantSelect gui) {
int idx = gui.getSelectedIndex();
if (idx >= 0 && pendingTypeId != null) {
@@ -514,7 +525,9 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
return false;
}
/** @return true if a SubGui was opened (caller should return early, skipping initGui) */
/**
* @return true if a SubGui was opened (caller should return early, skipping initGui)
*/
private boolean handleTypeSelectClosed(SubGuiAbilityTypeSelect gui) {
String typeId = gui.getSelectedTypeId();
if (typeId != null) {
@@ -542,7 +555,9 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
return false;
}
/** @return true if a SubGui was opened (caller should return early, skipping initGui) */
/**
* @return true if a SubGui was opened (caller should return early, skipping initGui)
*/
private boolean handleDuplicateNameClosed(SubGuiDuplicateNameConfirm gui) {
if (gui.isConfirmed() && pendingSaveAbility != null) {
if (pendingNewCreation) {
@@ -569,7 +584,9 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
return false;
}
/** @return true if a SubGui was opened (caller should return early, skipping initGui) */
/**
* @return true if a SubGui was opened (caller should return early, skipping initGui)
*/
private boolean handlePendingSave() {
if (hasDuplicateName(pendingSaveAbility)) {
pendingNewCreation = false;
@@ -12,20 +12,20 @@ import net.minecraft.util.StatCollector;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import noppes.npcs.client.AuctionClientConfig;
import noppes.npcs.constants.EnumClaimType;
import noppes.npcs.util.AuctionFormatUtil;
import noppes.npcs.containers.ContainerAuctionListing;
import noppes.npcs.containers.ContainerAuctionSell;
import noppes.npcs.containers.ContainerAuctionTrades;
import noppes.npcs.containers.SlotAuctionDisplay;
import noppes.npcs.controllers.data.AuctionClaim;
import noppes.npcs.controllers.data.AuctionListing;
import noppes.npcs.util.AuctionFormatUtil;
import java.util.List;
/**
* Handles adding auction information to item tooltips when viewing auction GUIs.
* Called from ItemTooltipEvent in ClientEventHandler.
*
* <p>
* Uses slot-based lookup (slot index) instead of ItemStack comparison to correctly
* handle duplicate items with different auction data (e.g., two porkchops at different prices).
*/
@@ -82,7 +82,9 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
return -1;
}
/** Update button visibility based on listing state */
/**
* Update button visibility based on listing state
*/
private void updateButtonState() {
if (listing == null) {
if (btnBid != null) btnBid.setVisible(false);
@@ -185,7 +187,9 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
drawAuctionInfo();
}
/** Draw auction listing information on the right side */
/**
* Draw auction listing information on the right side
*/
private void drawAuctionInfo() {
int x = guiLeft + infoX;
int y = guiTop + infoY;
@@ -226,7 +230,7 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
label = AuctionFormatUtil.formatCurrency(listing.startingPrice);
length = fontRendererObj.getStringWidth(label);
fontRendererObj.drawString(EnumChatFormatting.GOLD + label, xRight - length, y, 0xFFFFFF);
fontRendererObj.drawString(EnumChatFormatting.GOLD + label, xRight - length, y, 0xFFFFFF);
y += lineHeight + 4;
}
@@ -237,7 +241,7 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
label = AuctionFormatUtil.formatCurrency(listing.buyoutPrice);
length = fontRendererObj.getStringWidth(label);
fontRendererObj.drawString(EnumChatFormatting.GREEN + label, xRight - length, y, 0xFFFFFF);
fontRendererObj.drawString(EnumChatFormatting.GREEN + label, xRight - length, y, 0xFFFFFF);
y += lineHeight + 4;
}
@@ -306,5 +310,7 @@ public class GuiAuctionBidding extends GuiAuctionInterface implements ISubGuiLis
// Block all slot interactions - view only
}
public AuctionListing getListing() { return listing; }
public AuctionListing getListing() {
return listing;
}
}
@@ -69,7 +69,9 @@ public abstract class GuiAuctionInterface extends GuiContainerNPCInterface {
initNavigationButtons();
}
/** Initialize navigation buttons */
/**
* Initialize navigation buttons
*/
protected void initNavigationButtons() {
int page = getCurrentPage();
@@ -89,7 +91,9 @@ public abstract class GuiAuctionInterface extends GuiContainerNPCInterface {
addButton(btnClaims);
}
/** Returns current page constant - implement in subclass */
/**
* Returns current page constant - implement in subclass
*/
protected abstract int getCurrentPage();
@Override
@@ -136,7 +140,9 @@ public abstract class GuiAuctionInterface extends GuiContainerNPCInterface {
}
}
/** Draw navigation button tooltips */
/**
* Draw navigation button tooltips
*/
protected void drawNavButtonTooltips(int mouseX, int mouseY) {
List<String> tooltip = null;
if (btnListings != null && btnListings.isHovered()) tooltip = btnListings.getTooltipLines();
@@ -154,14 +160,18 @@ public abstract class GuiAuctionInterface extends GuiContainerNPCInterface {
// ========== Slot Drawing Utilities ==========
/** Draw auction slot background (18x18) */
/**
* Draw auction slot background (18x18)
*/
protected void drawAuctionSlot(int x, int y) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(AUCTION_SLOT);
Gui.func_146110_a(x, y, 0, 0, 18, 18, 18, 18);
}
/** Draw colored overlay on slot (ARGB format) */
/**
* Draw colored overlay on slot (ARGB format)
*/
protected void drawColoredOverlay(int x, int y, int color) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_DEPTH_TEST);
@@ -173,12 +183,16 @@ public abstract class GuiAuctionInterface extends GuiContainerNPCInterface {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
/** Draw dark overlay for unavailable slots */
/**
* Draw dark overlay for unavailable slots
*/
protected void drawDarkenedOverlay(int x, int y) {
drawColoredOverlay(x, y, OVERLAY_DARK);
}
/** Draw icon texture on slot (16x16) */
/**
* Draw icon texture on slot (16x16)
*/
protected void drawIconOverlay(int x, int y, ResourceLocation icon) {
GL11.glPushMatrix();
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
@@ -192,7 +206,9 @@ public abstract class GuiAuctionInterface extends GuiContainerNPCInterface {
GL11.glPopMatrix();
}
/** Subclasses implement this to draw specific content */
/**
* Subclasses implement this to draw specific content
*/
protected abstract void drawAuctionContent(float partialTicks, int mouseX, int mouseY);
@Override
@@ -98,12 +98,16 @@ public class GuiAuctionListing extends GuiAuctionInterface implements ISubGuiLis
return PAGE_LISTINGS;
}
/** Request listings from server */
/**
* Request listings from server
*/
private void requestListings() {
AuctionActionPacket.requestListings(filter, currentPage);
}
/** Update pagination button visibility based on current page state */
/**
* Update pagination button visibility based on current page state
*/
private void updatePaginationVisibility() {
if (btnPageUp != null) {
btnPageUp.setVisible(currentPage > 0);
@@ -193,7 +197,8 @@ public class GuiAuctionListing extends GuiAuctionInterface implements ISubGuiLis
}
@Override
public void subGuiClosed(SubGuiInterface subgui) {}
public void subGuiClosed(SubGuiInterface subgui) {
}
// ========== Data Handling ==========
@@ -294,6 +299,11 @@ public class GuiAuctionListing extends GuiAuctionInterface implements ISubGuiLis
// Block other slot interactions
}
public AuctionFilter getFilter() { return filter; }
public ContainerAuctionListing getListingContainer() { return listingContainer; }
public AuctionFilter getFilter() {
return filter;
}
public ContainerAuctionListing getListingContainer() {
return listingContainer;
}
}
@@ -7,16 +7,16 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.AuctionClientConfig;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiAuctionNavButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.AuctionClientConfig;
import noppes.npcs.containers.ContainerAuctionSell;
import noppes.npcs.util.AuctionFormatUtil;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.util.AuctionFormatUtil;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
@@ -105,7 +105,9 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
return PAGE_SELL;
}
/** Update visibility of buyout price field based on toggle state */
/**
* Update visibility of buyout price field based on toggle state
*/
private void updateBuyoutVisibility() {
if (lblBuyout != null) {
lblBuyout.enabled = allowBuyout;
@@ -119,7 +121,9 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
}
}
/** Update the buyout toggle button tooltip */
/**
* Update the buyout toggle button tooltip
*/
private void updateBuyoutTooltip() {
if (btnAllowBuyout == null) return;
@@ -252,7 +256,9 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
drawSellSlotIndicator(slotX, slotY);
}
/** Draw indicator showing staged vs available items */
/**
* Draw indicator showing staged vs available items
*/
private void drawSellSlotIndicator(int slotX, int slotY) {
ItemStack sellItem = sellContainer.getItemToSell();
if (sellItem != null) {
@@ -310,7 +316,9 @@ public class GuiAuctionSell extends GuiAuctionInterface implements ITextfieldLis
drawSellPageTooltips(mouseX, mouseY);
}
/** Draw tooltips for sell page buttons */
/**
* Draw tooltips for sell page buttons
*/
private void drawSellPageTooltips(int mouseX, int mouseY) {
List<String> tooltip = null;
@@ -50,7 +50,7 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
private int pendingSlot = -1;
private PendingOp pendingOp = PendingOp.NONE;
private enum PendingOp { NONE, CANCEL, CLAIM }
private enum PendingOp {NONE, CANCEL, CLAIM}
public GuiAuctionTrades(EntityNPCInterface npc, ContainerAuctionTrades container) {
super(npc, container);
@@ -117,7 +117,9 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
}
}
/** Handle click on pending operation slot */
/**
* Handle click on pending operation slot
*/
private void handlePendingClick(int mouseButton) {
if (pendingOp == PendingOp.CANCEL && mouseButton == 1) {
// Right-click confirms cancel
@@ -159,14 +161,18 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
}
}
/** Set pending operation and hide slot item */
/**
* Set pending operation and hide slot item
*/
private void setPending(int slot, PendingOp op) {
pendingSlot = slot;
pendingOp = op;
tradesContainer.setHiddenSlot(slot);
}
/** Clear pending operation and restore slot */
/**
* Clear pending operation and restore slot
*/
private void clearPending() {
if (pendingSlot >= 0) {
tradesContainer.clearHiddenSlot();
@@ -175,13 +181,17 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
pendingOp = PendingOp.NONE;
}
/** Play confirmation sound */
/**
* Play confirmation sound
*/
private void playConfirmSound() {
mc.getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(
new ResourceLocation("random.orb"), 1.0F));
}
/** Get slot index at mouse position */
/**
* Get slot index at mouse position
*/
private int getSlotAt(int mouseX, int mouseY) {
int relX = mouseX - guiLeft - GRID_X;
int relY = mouseY - guiTop - GRID_Y;
@@ -239,7 +249,9 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
}
}
/** Get tint color for slot based on contents */
/**
* Get tint color for slot based on contents
*/
private int getSlotTint(int slot) {
AuctionListing listing = tradesContainer.getListingAt(slot);
AuctionClaim claim = tradesContainer.getClaimAt(slot);
@@ -281,7 +293,9 @@ public class GuiAuctionTrades extends GuiAuctionInterface implements IGuiData {
}
}
/** Draw tooltip for a trade slot */
/**
* Draw tooltip for a trade slot
*/
private void drawTradeTooltip(int slot, int x, int y) {
List<String> tooltip = new ArrayList<>();
@@ -5,7 +5,6 @@ import kamkeel.npcs.network.packets.request.animation.AnimationsGetPacket;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IScrollData;
@@ -19,10 +19,10 @@ import java.util.List;
/**
* Client-side executor for previewing abilities in the GUI.
*
* <p>
* Uses unified execution: calls the REAL ability methods (onWindUpTick, onExecute, onActiveTick)
* with previewMode=true. Abilities skip damage/effects/sounds when isPreview() returns true.
*
* <p>
* Lifecycle:
* 1. WINDUP phase - real onWindUpTick() called, telegraph shown, entities may spawn
* 2. ACTIVE phase - real onExecute() then onActiveTick() called, physics simulated
@@ -36,8 +36,11 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
private Ability previewAbility;
private EntityNPCInterface previewNpc;
/** Executor's own phase tracking (separate from ability.getPhase()) */
private enum ExecutorPhase { IDLE, WINDUP, ACTIVE, EXTENDED }
/**
* Executor's own phase tracking (separate from ability.getPhase())
*/
private enum ExecutorPhase {IDLE, WINDUP, ACTIVE, EXTENDED}
private ExecutorPhase executorPhase = ExecutorPhase.IDLE;
private int currentTick = 0;
@@ -424,21 +427,48 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
// ==================== GETTERS ====================
public boolean isPlaying() { return playing; }
public boolean isPaused() { return paused; }
public boolean isActive() { return playing || paused; }
public boolean isPlaying() {
return playing;
}
public boolean isPaused() {
return paused;
}
public boolean isActive() {
return playing || paused;
}
public AbilityPhase getPhase() {
switch (executorPhase) {
case WINDUP: return AbilityPhase.WINDUP;
case ACTIVE: return AbilityPhase.ACTIVE;
default: return AbilityPhase.IDLE;
case WINDUP:
return AbilityPhase.WINDUP;
case ACTIVE:
return AbilityPhase.ACTIVE;
default:
return AbilityPhase.IDLE;
}
}
public int getCurrentTick() { return currentTick; }
public TelegraphInstance getTelegraph() { return previewTelegraph; }
public List<Entity> getPreviewEntities() { return previewEntities; }
public Ability getPreviewAbility() { return previewAbility; }
public EntityNPCInterface getPreviewNpc() { return previewNpc; }
public int getCurrentTick() {
return currentTick;
}
public TelegraphInstance getTelegraph() {
return previewTelegraph;
}
public List<Entity> getPreviewEntities() {
return previewEntities;
}
public Ability getPreviewAbility() {
return previewAbility;
}
public EntityNPCInterface getPreviewNpc() {
return previewNpc;
}
public String getStatusString() {
if (!playing && !paused) {
@@ -21,7 +21,7 @@ import java.util.List;
/**
* Base GUI class for ability preview with fixed camera.
*
* <p>
* Key concepts:
* - NPC positioned on left side of preview area
* - NPC faces a fixed direction (NPC_FACING_YAW)
@@ -33,15 +33,23 @@ import java.util.List;
public class GuiAbilityInterface extends GuiNPCInterface2 {
// ==================== FIXED CAMERA SETTINGS ====================
/** Fixed camera zoom level (higher = more zoomed in) */
/**
* Fixed camera zoom level (higher = more zoomed in)
*/
protected static float CAMERA_ZOOM = 45.0f;
/** NPC facing direction - affects anchor points and visual facing */
/**
* NPC facing direction - affects anchor points and visual facing
*/
protected static float NPC_FACING_YAW = 160.0f;
/** Camera pitch (slight downward angle) */
/**
* Camera pitch (slight downward angle)
*/
protected static float CAMERA_PITCH = 10.0f;
// ==================== VIEWING ROTATION ====================
/** Viewing direction rotation (rotates entire 3D space) */
/**
* Viewing direction rotation (rotates entire 3D space)
*/
protected static float viewRotation = 0.0f;
private GuiNpcButton btnLeft, btnRight;
@@ -49,21 +57,33 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
// ==================== NPC STATE ====================
public EntityNPCInterface npc;
/** NPC starting position (saved when preview starts, used to track movement) */
/**
* NPC starting position (saved when preview starts, used to track movement)
*/
protected double npcStartX, npcStartY, npcStartZ;
/** Whether we're tracking NPC movement */
/**
* Whether we're tracking NPC movement
*/
protected boolean trackingNpcMovement = false;
/** Entities to render in preview space */
/**
* Entities to render in preview space
*/
protected List<Entity> previewEntities = new ArrayList<>();
/** Current telegraph to render in preview */
/**
* Current telegraph to render in preview
*/
protected TelegraphInstance previewTelegraph;
// ==================== LAYOUT ====================
/** Preview area bounds */
/**
* Preview area bounds
*/
protected int previewX, previewY, previewWidth, previewHeight;
/** NPC render position on screen */
/**
* NPC render position on screen
*/
protected int npcScreenX, npcScreenY;
public int xOffset = 0;
@@ -74,7 +94,7 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
}
/**
* @param npc The NPC for preview rendering
* @param npc The NPC for preview rendering
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
* Use false when opened from the global menu without a real NPC.
*/
@@ -99,8 +119,8 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
previewHeight = 180;
// NPC position: left side of preview, slightly below center
npcScreenX = previewX + (int)(previewWidth * 0.33f) + xOffset;
npcScreenY = previewY + (int)(previewHeight * 0.85f) + yOffset;
npcScreenX = previewX + (int) (previewWidth * 0.33f) + xOffset;
npcScreenY = previewY + (int) (previewHeight * 0.85f) + yOffset;
// Viewing rotation buttons (below preview area)
int btnY = guiTop + 192;
@@ -351,7 +371,7 @@ public class GuiAbilityInterface extends GuiNPCInterface2 {
super.drawBackground();
drawGradientRect(previewX, previewY, previewX + previewWidth, previewY + previewHeight,
0xc0101010, 0xd0101010);
0xc0101010, 0xd0101010);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
@@ -64,14 +64,14 @@ public class GuiAuctionNavButton extends GuiNpcButton {
/**
* Create a fully customizable button.
*
* @param id Button ID
* @param x X position
* @param y Y position
* @param buttonSize Size of the button background texture (e.g., 18 for 18x18, 10 for 10x10)
* @param iconSize Size of the icon texture (e.g., 16 for 16x16, 8 for 8x8)
* @param tooltipKey Lang key for tooltip
* @param iconTexture Icon texture to draw inside the button
* @param textureNormal Background texture for normal state
* @param id Button ID
* @param x X position
* @param y Y position
* @param buttonSize Size of the button background texture (e.g., 18 for 18x18, 10 for 10x10)
* @param iconSize Size of the icon texture (e.g., 16 for 16x16, 8 for 8x8)
* @param tooltipKey Lang key for tooltip
* @param iconTexture Icon texture to draw inside the button
* @param textureNormal Background texture for normal state
* @param texturePressed Background texture for pressed/hover state
*/
public GuiAuctionNavButton(int id, int x, int y, int buttonSize, int iconSize, String tooltipKey,
@@ -4,29 +4,29 @@ package noppes.npcs.client.gui.util;
* Abstract base class for fullscreen directory-browsing GUIs.
* Provides a configurable three-panel layout (left nav, center content, right actions)
* with percentage-based sizing, panel backgrounds/borders, and an optional resizable divider.
*
* <p>
* Subclasses override abstract hooks to populate each panel region.
* Designed for reuse across Cloner, Quest Manager, Dialog Manager, etc.
*/
public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScrollListener, ISubGuiListener {
// ===== LAYOUT CONFIG (subclasses may override in constructor) =====
protected float leftPanelPercent = 0.20f;
protected float leftPanelPercent = 0.20f;
protected float rightPanelPercent = 0.10f;
protected int minLeftPanelW = 80;
protected int minLeftPanelW = 80;
protected int minRightPanelW = 40;
protected int minCenterW = 100;
protected int minCenterW = 100;
// ===== LAYOUT CONSTANTS =====
protected int pad = 10;
protected int pad = 10;
protected int topBarH = 24;
protected int gap = 4;
protected int btnH = 20;
protected int gap = 4;
protected int btnH = 20;
// ===== PANEL COLORS =====
protected int panelBg = 0xC0101010;
protected int panelBg = 0xC0101010;
protected int panelBorder = 0xFF333333;
protected int topBarBg = 0xC0181818;
protected int topBarBg = 0xC0181818;
// ===== COMPUTED LAYOUT (populated by computeLayout) =====
protected int originX, originY, usableW, usableH;
@@ -35,10 +35,10 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
protected int rightX;
// ===== OPTIONAL RESIZABLE DIVIDER (between left and center) =====
protected boolean enableDivider = false;
protected int dividerWidth = 5;
protected int dividerLineHeight = 20;
protected int minDividerPanelW = 50;
protected boolean enableDivider = false;
protected int dividerWidth = 5;
protected int dividerLineHeight = 20;
protected int minDividerPanelW = 50;
private int dividerOffset;
private boolean isDragging = false;
private int dragStartX;
@@ -57,8 +57,8 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
usableW = width - 2 * pad;
usableH = height - 2 * pad;
leftPanelW = Math.max(minLeftPanelW, (int)(usableW * leftPanelPercent));
rightPanelW = Math.max(minRightPanelW, (int)(usableW * rightPanelPercent));
leftPanelW = Math.max(minLeftPanelW, (int) (usableW * leftPanelPercent));
rightPanelW = Math.max(minRightPanelW, (int) (usableW * rightPanelPercent));
if (rightPanelPercent <= 0) {
rightPanelW = 0;
@@ -73,7 +73,7 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
contentX = originX + leftPanelW + gap;
contentY = originY + topBarH + gap;
contentH = usableH - topBarH - gap;
rightX = contentX + contentW + gap;
rightX = contentX + contentW + gap;
if (enableDivider && dividerOffset == 0) {
dividerOffset = leftPanelW;
@@ -128,7 +128,9 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
drawRect(divX + 1, handleTop, divX + dividerWidth - 1, handleTop + dividerLineHeight, 0xFF707070);
}
/** Override for extra drawing after super.drawScreen (e.g. status text) */
/**
* Override for extra drawing after super.drawScreen (e.g. status text)
*/
protected void drawOverlay(int mouseX, int mouseY, float partialTicks) {
}
@@ -177,7 +179,9 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
super.mouseMovedOrUp(mouseX, mouseY, state);
}
/** Called when divider is dragged. Override to update scroll sizes. */
/**
* Called when divider is dragged. Override to update scroll sizes.
*/
protected void onDividerMoved(int newOffset) {
}
@@ -192,15 +196,23 @@ public abstract class GuiDirectory extends GuiNPCInterface implements ICustomScr
// ===== ABSTRACT HOOKS (subclass must implement) =====
/** Populate top bar buttons. topBtnY is the y-coordinate for the button row. */
/**
* Populate top bar buttons. topBtnY is the y-coordinate for the button row.
*/
protected abstract void initTopBar(int topBtnY);
/** Populate the left navigation panel (scrolls, search fields, buttons). */
/**
* Populate the left navigation panel (scrolls, search fields, buttons).
*/
protected abstract void initLeftPanel();
/** Populate the center content panel (main scroll list). */
/**
* Populate the center content panel (main scroll list).
*/
protected abstract void initCenterPanel();
/** Populate the right action panel. startY is the first button y-coordinate. */
/**
* Populate the right action panel. startY is the first button y-coordinate.
*/
protected abstract void initRightPanel(int startY);
}
@@ -34,7 +34,7 @@ public class GuiModelInterface2 extends GuiNPCInterface2 {
}
/**
* @param npc The NPC for preview rendering
* @param npc The NPC for preview rendering
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
* Use false when opened from the global menu without a real NPC.
*/
@@ -60,12 +60,13 @@ public class GuiNpcLabel extends Gui {
/**
* Draws hover tooltip if the mouse is over this label.
* @param localMouseX Mouse X in scroll-local coordinates (for hit testing)
* @param localMouseY Mouse Y in scroll-local coordinates (for hit testing)
*
* @param localMouseX Mouse X in scroll-local coordinates (for hit testing)
* @param localMouseY Mouse Y in scroll-local coordinates (for hit testing)
* @param screenMouseX Mouse X in screen coordinates (for tooltip positioning)
* @param screenMouseY Mouse Y in screen coordinates (for tooltip positioning)
* @param hasSubGui Whether a sub-gui is open
* @param fr FontRenderer for measuring label width
* @param hasSubGui Whether a sub-gui is open
* @param fr FontRenderer for measuring label width
*/
public void drawHover(int localMouseX, int localMouseY, int screenMouseX, int screenMouseY, boolean hasSubGui, FontRenderer fr) {
if (hasSubGui || hoverableText.isEmpty()) return;
@@ -1,17 +1,17 @@
package noppes.npcs.client.gui.util;
import kamkeel.npcs.util.TextSplitter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.util.StatCollector;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.util.StatCollector;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import net.minecraft.client.renderer.RenderHelper;
import kamkeel.npcs.util.TextSplitter;
import java.util.List;
import java.util.Iterator;
public class GuiNpcTextField extends GuiTextField {
public boolean enabled = true;
@@ -224,7 +224,7 @@ public class GuiNpcTextField extends GuiTextField {
public boolean isMouseOver(int mouseX, int mouseY) {
return mouseX >= xPosition && mouseX < xPosition + width &&
mouseY >= yPosition && mouseY < yPosition + height;
mouseY >= yPosition && mouseY < yPosition + height;
}
public void drawHover(int mouseX, int mouseY, boolean hasSubGui) {
@@ -334,14 +334,14 @@ public class GuiNpcTextField extends GuiTextField {
}
protected void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor, int zLevel) {
float f = (float)(startColor >> 24 & 255) / 255.0F;
float f1 = (float)(startColor >> 16 & 255) / 255.0F;
float f2 = (float)(startColor >> 8 & 255) / 255.0F;
float f3 = (float)(startColor & 255) / 255.0F;
float f4 = (float)(endColor >> 24 & 255) / 255.0F;
float f5 = (float)(endColor >> 16 & 255) / 255.0F;
float f6 = (float)(endColor >> 8 & 255) / 255.0F;
float f7 = (float)(endColor & 255) / 255.0F;
float f = (float) (startColor >> 24 & 255) / 255.0F;
float f1 = (float) (startColor >> 16 & 255) / 255.0F;
float f2 = (float) (startColor >> 8 & 255) / 255.0F;
float f3 = (float) (startColor & 255) / 255.0F;
float f4 = (float) (endColor >> 24 & 255) / 255.0F;
float f5 = (float) (endColor >> 16 & 255) / 255.0F;
float f6 = (float) (endColor >> 8 & 255) / 255.0F;
float f7 = (float) (endColor & 255) / 255.0F;
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
@@ -350,11 +350,11 @@ public class GuiNpcTextField extends GuiTextField {
net.minecraft.client.renderer.Tessellator tessellator = net.minecraft.client.renderer.Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.setColorRGBA_F(f1, f2, f3, f);
tessellator.addVertex((double)right, (double)top, (double)zLevel);
tessellator.addVertex((double)left, (double)top, (double)zLevel);
tessellator.addVertex((double) right, (double) top, (double) zLevel);
tessellator.addVertex((double) left, (double) top, (double) zLevel);
tessellator.setColorRGBA_F(f5, f6, f7, f4);
tessellator.addVertex((double)left, (double)bottom, (double)zLevel);
tessellator.addVertex((double)right, (double)bottom, (double)zLevel);
tessellator.addVertex((double) left, (double) bottom, (double) zLevel);
tessellator.addVertex((double) right, (double) bottom, (double) zLevel);
tessellator.draw();
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glDisable(GL11.GL_BLEND);
@@ -8,6 +8,8 @@ import java.util.UUID;
public interface IClonerGui {
int getShowingClones();
HashMap<UUID, Tag> getTags();
TagMap getTagMap();
}