mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 06:07:27 +00:00
Better GUI handling for Ability Making System
This commit is contained in:
1 parent
38d305ab99
commit
2c6ec0ce34
31 files changed
+792
-464
No files matched your search
@@ -29,7 +29,6 @@ import noppes.npcs.scripted.NpcAPI;
|
||||
import noppes.npcs.scripted.event.AbilityEvent;
|
||||
import noppes.npcs.scripted.event.player.PlayerAbilityEvent;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -362,20 +361,25 @@ public abstract class Ability implements IAbility {
|
||||
// General tab
|
||||
defs.add(FieldDef.stringField("gui.name", this::getName, this::setName)
|
||||
.tab("General"));
|
||||
defs.add(FieldDef.intField("ability.weight", this::getWeight, this::setWeight)
|
||||
.tab("General").range(1, 1000).column(ColumnHint.LEFT));
|
||||
defs.add(FieldDef.boolField("gui.enabled", this::isEnabled, this::setEnabled)
|
||||
.tab("General").column(ColumnHint.RIGHT));
|
||||
defs.add(FieldDef.row(
|
||||
FieldDef.intField("ability.weight", this::getWeight, this::setWeight).range(1, 1000),
|
||||
FieldDef.boolField("gui.enabled", this::isEnabled, this::setEnabled)
|
||||
).tab("General"));
|
||||
defs.add(FieldDef.section("ability.section.timing").tab("General"));
|
||||
// WindUp: 3 mutually exclusive entries based on animation/sync state
|
||||
defs.add(FieldDef.intField("ability.windUpTicks", this::getRawWindUpTicks, this::setWindUpTicks)
|
||||
.tab("General").range(0, 1000).column(ColumnHint.LEFT)
|
||||
.visibleWhen(() -> !hasWindUpAnimation() || !isSyncWindupWithAnimation()));
|
||||
defs.add(FieldDef.labelField("ability.windUpTicks", () -> getWindUpTicks() + "t")
|
||||
.tab("General").column(ColumnHint.LEFT)
|
||||
.visibleWhen(() -> hasWindUpAnimation() && isSyncWindupWithAnimation()));
|
||||
defs.add(FieldDef.boolField("ability.syncWindup", this::isSyncWindupWithAnimation, this::setSyncWindupWithAnimation)
|
||||
.tab("General").hover("ability.hover.sync").column(ColumnHint.RIGHT)
|
||||
.visibleWhen(this::hasWindUpAnimation));
|
||||
.tab("General").range(0, 1000)
|
||||
.visibleWhen(() -> !hasWindUpAnimation()));
|
||||
defs.add(FieldDef.row(
|
||||
FieldDef.intField("ability.windUpTicks", this::getRawWindUpTicks, this::setWindUpTicks).range(0, 1000),
|
||||
FieldDef.boolField("ability.syncWindup", this::isSyncWindupWithAnimation, this::setSyncWindupWithAnimation)
|
||||
.hover("ability.hover.sync")
|
||||
).tab("General").visibleWhen(() -> hasWindUpAnimation() && !isSyncWindupWithAnimation()));
|
||||
defs.add(FieldDef.row(
|
||||
FieldDef.labelField("ability.windUpTicks", () -> getWindUpTicks() + "t"),
|
||||
FieldDef.boolField("ability.syncWindup", this::isSyncWindupWithAnimation, this::setSyncWindupWithAnimation)
|
||||
.hover("ability.hover.sync")
|
||||
).tab("General").visibleWhen(() -> hasWindUpAnimation() && isSyncWindupWithAnimation()));
|
||||
defs.add(FieldDef.intField("ability.cooldownTicks", this::getCooldownTicks, this::setCooldownTicks)
|
||||
.tab("General").range(0, 10000));
|
||||
defs.add(FieldDef.section("ability.section.movement").tab("General"));
|
||||
@@ -388,17 +392,18 @@ public abstract class Ability implements IAbility {
|
||||
}
|
||||
})
|
||||
.tab("General").hover("ability.hover.lockMove"));
|
||||
defs.add(FieldDef.boolField("ability.interruptible", this::isInterruptible, this::setInterruptible)
|
||||
.tab("General").hover("ability.hover.interruptible").column(ColumnHint.LEFT));
|
||||
defs.add(FieldDef.intField("ability.dazedTicks", this::getDazedTicks, this::setDazedTicks)
|
||||
.tab("General").range(0, 1000)
|
||||
.visibleWhen(this::isInterruptible).column(ColumnHint.RIGHT));
|
||||
defs.add(FieldDef.row(
|
||||
FieldDef.boolField("ability.interruptible", this::isInterruptible, this::setInterruptible)
|
||||
.hover("ability.hover.interruptible"),
|
||||
FieldDef.intField("ability.dazedTicks", this::getDazedTicks, this::setDazedTicks)
|
||||
.range(0, 1000).visibleWhen(this::isInterruptible)
|
||||
).tab("General"));
|
||||
|
||||
// Target tab
|
||||
defs.add(FieldDef.intField("ability.minRange", () -> (int) getMinRange(), v -> setMinRange(v))
|
||||
.tab("Target").range(0, 100).column(ColumnHint.LEFT));
|
||||
defs.add(FieldDef.intField("ability.maxRange", () -> (int) getMaxRange(), v -> setMaxRange(v))
|
||||
.tab("Target").range(1, 100).column(ColumnHint.RIGHT));
|
||||
defs.add(FieldDef.row(
|
||||
FieldDef.intField("ability.minRange", () -> (int) getMinRange(), v -> setMinRange(v)).range(0, 100),
|
||||
FieldDef.intField("ability.maxRange", () -> (int) getMaxRange(), v -> setMaxRange(v)).range(1, 100)
|
||||
).tab("Target"));
|
||||
if (!isTargetingModeLocked()) {
|
||||
defs.add(FieldDef.enumField("ability.targetingMode", TargetingMode.class,
|
||||
this::getTargetingMode, this::setTargetingMode)
|
||||
@@ -426,7 +431,7 @@ public abstract class Ability implements IAbility {
|
||||
TelegraphType tType = getTelegraphType();
|
||||
if (tType != null && tType != TelegraphType.NONE) {
|
||||
defs.add(FieldDef.section("ability.section.telegraph").tab("Effects")
|
||||
.tooltip("telegraph." + tType.name().toLowerCase()));
|
||||
.hover("telegraph." + tType.name().toLowerCase()));
|
||||
defs.add(FieldDef.boolField("ability.showTelegraph", this::isShowTelegraph, this::setShowTelegraph)
|
||||
.tab("Effects").hover("ability.hover.showTelegraph"));
|
||||
defs.add(FieldDef.colorSubGui("ability.windUpColor", this::getWindUpColor, this::setWindUpColor)
|
||||
|
||||
@@ -4,6 +4,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.builder.FieldType;
|
||||
import noppes.npcs.client.gui.builder.GuiFieldBuilder;
|
||||
@@ -111,5 +112,69 @@ public class AbilityFieldBuilder extends GuiFieldBuilder {
|
||||
return y;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// EVENT HANDLING OVERRIDES
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean handleButtonEvent(int buttonId, GuiButton button) {
|
||||
// Check effects list buttons via metadata
|
||||
int[] meta = effectWidgetMeta.get(buttonId);
|
||||
if (meta != null) {
|
||||
FieldDef def = buttonFieldMap.get(buttonId);
|
||||
if (def == null) def = clearFieldMap.get(buttonId);
|
||||
if (def != null && def.getType() == FieldType.EFFECTS_LIST) {
|
||||
List<AbilityEffect> effects = (List<AbilityEffect>) def.getValue();
|
||||
if (effects == null) return false;
|
||||
int effectIdx = meta[0];
|
||||
int action = meta[1];
|
||||
|
||||
switch (action) {
|
||||
case 0: // Type changed
|
||||
if (effectIdx < effects.size()) {
|
||||
effects.get(effectIdx).setType(AbilityEffect.EffectType.fromOrdinal(((GuiNpcButton) button).getValue()));
|
||||
}
|
||||
return true;
|
||||
case 2: // Amp changed
|
||||
if (effectIdx < effects.size()) {
|
||||
effects.get(effectIdx).setAmplifier(((GuiNpcButton) button).getValue());
|
||||
}
|
||||
return true;
|
||||
case 3: // Delete
|
||||
if (effectIdx < effects.size()) {
|
||||
effects.remove(effectIdx);
|
||||
}
|
||||
return true;
|
||||
case 4: // Add
|
||||
if (effects.size() < 5) {
|
||||
effects.add(new AbilityEffect(AbilityEffect.EffectType.SLOWNESS, 60, 0));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return super.handleButtonEvent(buttonId, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean handleTextFieldEvent(int textFieldId, GuiNpcTextField field) {
|
||||
int[] meta = effectWidgetMeta.get(textFieldId);
|
||||
if (meta != null && meta[1] == 1) { // duration field
|
||||
FieldDef def = textFieldMap.get(textFieldId);
|
||||
if (def != null && def.getType() == FieldType.EFFECTS_LIST) {
|
||||
List<AbilityEffect> effects = (List<AbilityEffect>) def.getValue();
|
||||
if (effects != null && meta[0] < effects.size()) {
|
||||
effects.get(meta[0]).setDurationTicks(field.getInteger());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return super.handleTextFieldEvent(textFieldId, field);
|
||||
}
|
||||
|
||||
public Map<Integer, int[]> getEffectWidgetMeta() { return effectWidgetMeta; }
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import kamkeel.npcs.controllers.data.ability.AnchorPoint;
|
||||
import kamkeel.npcs.controllers.data.ability.LockMovementType;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.data.*;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
@@ -381,14 +380,20 @@ public class AbilityBeamDual extends Ability {
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
// Type tab
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed)
|
||||
),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
FieldDef.section("ability.section.beam"),
|
||||
FieldDef.floatField("ability.beamWidth", this::getBeamWidth, this::setBeamWidth).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.headSize", this::getHeadSize, this::setHeadSize).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.beamWidth", this::getBeamWidth, this::setBeamWidth),
|
||||
FieldDef.floatField("ability.headSize", this::getHeadSize, this::setHeadSize)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime)
|
||||
),
|
||||
FieldDef.section("ability.section.dual"),
|
||||
FieldDef.boolField("ability.dualFire", this::isDualFire, this::setDualFire),
|
||||
FieldDef.intField("ability.dualFireDelay", this::getDualFireDelay, this::setDualFireDelay)
|
||||
@@ -396,10 +401,12 @@ public class AbilityBeamDual extends Ability {
|
||||
FieldDef.section("ability.section.homing"),
|
||||
FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming)
|
||||
.hover("ability.hover.homing"),
|
||||
FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength)
|
||||
.visibleWhen(this::isHoming).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.range", this::getHomingRange, this::setHomingRange)
|
||||
.visibleWhen(this::isHoming).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength)
|
||||
.visibleWhen(this::isHoming),
|
||||
FieldDef.floatField("gui.range", this::getHomingRange, this::setHomingRange)
|
||||
.visibleWhen(this::isHoming)
|
||||
),
|
||||
FieldDef.section("ability.section.explosive"),
|
||||
FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive)
|
||||
.hover("ability.hover.explosive"),
|
||||
@@ -420,24 +427,28 @@ public class AbilityBeamDual extends Ability {
|
||||
FieldDef.colorSubGui("ability.outerColor",
|
||||
() -> getOuterColor(0), v -> setOuterColor(0, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)),
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v))
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(() -> isOuterColorEnabled(0)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v))
|
||||
.visibleWhen(() -> isOuterColorEnabled(0)),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v))
|
||||
.range(0, 1).visibleWhen(() -> isOuterColorEnabled(0))
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed",
|
||||
() -> getRotationSpeed(0), v -> setRotationSpeed(0, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning",
|
||||
() -> hasLightningEffect(0), v -> setLightningEffect(0, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(0), v -> setLightningDensity(0, v))
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(0), v -> setLightningRadius(0, v))
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(0), v -> setLightningDensity(0, v))
|
||||
.range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(0), v -> setLightningRadius(0, v))
|
||||
.range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0))
|
||||
).tab("ability.tab.visual"),
|
||||
// Visual tab - Beam 2
|
||||
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
|
||||
() -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v))
|
||||
@@ -452,24 +463,28 @@ public class AbilityBeamDual extends Ability {
|
||||
FieldDef.colorSubGui("ability.outerColor",
|
||||
() -> getOuterColor(1), v -> setOuterColor(1, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)),
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v))
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(() -> isOuterColorEnabled(1)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v))
|
||||
.visibleWhen(() -> isOuterColorEnabled(1)),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v))
|
||||
.range(0, 1).visibleWhen(() -> isOuterColorEnabled(1))
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed",
|
||||
() -> getRotationSpeed(1), v -> setRotationSpeed(1, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning",
|
||||
() -> hasLightningEffect(1), v -> setLightningEffect(1, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(1), v -> setLightningDensity(1, v))
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(1), v -> setLightningRadius(1, v))
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1)).column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(1), v -> setLightningDensity(1, v))
|
||||
.range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(1), v -> setLightningRadius(1, v))
|
||||
.range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1))
|
||||
).tab("ability.tab.visual")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import noppes.npcs.api.ability.type.IAbilityCharge;
|
||||
@@ -400,10 +399,14 @@ public class AbilityCharge extends Ability implements IAbilityCharge {
|
||||
@Override
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.chargeSpeed", this::getChargeSpeed, this::setChargeSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.hitWidth", this::getHitWidth, this::setHitWidth).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("ability.chargeSpeed", this::getChargeSpeed, this::setChargeSpeed)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
FieldDef.floatField("ability.hitWidth", this::getHitWidth, this::setHitWidth)
|
||||
),
|
||||
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.api.ability.type.IAbilityCutter;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
|
||||
@@ -319,14 +318,18 @@ public class AbilityCutter extends Ability implements IAbilityCutter {
|
||||
@Override
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.range", this::getRange, this::setRange).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("gui.range", this::getRange, this::setRange)
|
||||
),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
FieldDef.section("ability.section.sweep"),
|
||||
FieldDef.enumField("ability.sweepMode", SweepMode.class, this::getSweepModeEnum, this::setSweepModeEnum)
|
||||
.hover("ability.hover.sweepMode"),
|
||||
FieldDef.floatField("ability.arcAngle", this::getArcAngle, this::setArcAngle).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.innerRadius", this::getInnerRadius, this::setInnerRadius).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.arcAngle", this::getArcAngle, this::setArcAngle),
|
||||
FieldDef.floatField("ability.innerRadius", this::getInnerRadius, this::setInnerRadius)
|
||||
),
|
||||
FieldDef.floatField("ability.sweepSpeed", this::getSweepSpeed, this::setSweepSpeed),
|
||||
FieldDef.intField("ability.spinDuration", this::getSpinDurationTicks, this::setSpinDurationTicks)
|
||||
.range(1, 1000)
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.api.ability.type.IAbilityDash;
|
||||
|
||||
@@ -356,8 +355,10 @@ public class AbilityDash extends Ability implements IAbilityDash {
|
||||
return Arrays.asList(
|
||||
FieldDef.enumField("ability.dashMode", DashMode.class, this::getDashModeEnum, this::setDashModeEnum)
|
||||
.hover("ability.hover.dashMode"),
|
||||
FieldDef.floatField("ability.dashDistance", this::getDashDistance, this::setDashDistance).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.dashSpeed", this::getDashSpeed, this::setDashSpeed).column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.dashDistance", this::getDashDistance, this::setDashDistance),
|
||||
FieldDef.floatField("ability.dashSpeed", this::getDashSpeed, this::setDashSpeed)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import noppes.npcs.api.ability.type.IAbilityDisc;
|
||||
@@ -277,14 +276,20 @@ public class AbilityDisc extends Ability implements IAbilityDisc {
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
// Type tab
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed)
|
||||
),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
FieldDef.section("ability.section.disc"),
|
||||
FieldDef.floatField("gui.radius", this::getDiscRadius, this::setDiscRadius).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.thickness", this::getDiscThickness, this::setDiscThickness).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.radius", this::getDiscRadius, this::setDiscRadius),
|
||||
FieldDef.floatField("gui.thickness", this::getDiscThickness, this::setDiscThickness)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime)
|
||||
),
|
||||
FieldDef.section("ability.section.homing"),
|
||||
FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming)
|
||||
.hover("ability.hover.homing"),
|
||||
@@ -311,19 +316,23 @@ public class AbilityDisc extends Ability implements IAbilityDisc {
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor)
|
||||
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled),
|
||||
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
|
||||
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(this::isOuterColorEnabled).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
|
||||
.visibleWhen(this::isOuterColorEnabled),
|
||||
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
|
||||
.range(0, 1).visibleWhen(this::isOuterColorEnabled)
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.section("ability.section.effects").tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed", this::getRotationSpeed, this::setRotationSpeed)
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect)
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect).column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
|
||||
.range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect),
|
||||
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
|
||||
.range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect)
|
||||
).tab("ability.tab.visual")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import kamkeel.npcs.controllers.data.ability.AnchorPoint;
|
||||
import kamkeel.npcs.controllers.data.ability.LockMovementType;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.data.*;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
@@ -390,14 +389,20 @@ public class AbilityDiscDual extends Ability {
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
// Type tab
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed)
|
||||
),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
FieldDef.section("ability.section.disc"),
|
||||
FieldDef.floatField("gui.radius", this::getDiscRadius, this::setDiscRadius).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.thickness", this::getDiscThickness, this::setDiscThickness).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.radius", this::getDiscRadius, this::setDiscRadius),
|
||||
FieldDef.floatField("gui.thickness", this::getDiscThickness, this::setDiscThickness)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime)
|
||||
),
|
||||
FieldDef.section("ability.section.dual"),
|
||||
FieldDef.boolField("ability.dualFire", this::isDualFire, this::setDualFire),
|
||||
FieldDef.intField("ability.dualFireDelay", this::getDualFireDelay, this::setDualFireDelay)
|
||||
@@ -432,24 +437,28 @@ public class AbilityDiscDual extends Ability {
|
||||
FieldDef.colorSubGui("ability.outerColor",
|
||||
() -> getOuterColor(0), v -> setOuterColor(0, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)),
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v))
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(() -> isOuterColorEnabled(0)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v))
|
||||
.visibleWhen(() -> isOuterColorEnabled(0)),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v))
|
||||
.range(0, 1).visibleWhen(() -> isOuterColorEnabled(0))
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed",
|
||||
() -> getRotationSpeed(0), v -> setRotationSpeed(0, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning",
|
||||
() -> hasLightningEffect(0), v -> setLightningEffect(0, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(0), v -> setLightningDensity(0, v))
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(0), v -> setLightningRadius(0, v))
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(0), v -> setLightningDensity(0, v))
|
||||
.range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(0), v -> setLightningRadius(0, v))
|
||||
.range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0))
|
||||
).tab("ability.tab.visual"),
|
||||
// Visual tab - Disc 2
|
||||
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
|
||||
() -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v))
|
||||
@@ -464,24 +473,28 @@ public class AbilityDiscDual extends Ability {
|
||||
FieldDef.colorSubGui("ability.outerColor",
|
||||
() -> getOuterColor(1), v -> setOuterColor(1, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)),
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v))
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(() -> isOuterColorEnabled(1)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v))
|
||||
.visibleWhen(() -> isOuterColorEnabled(1)),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v))
|
||||
.range(0, 1).visibleWhen(() -> isOuterColorEnabled(1))
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed",
|
||||
() -> getRotationSpeed(1), v -> setRotationSpeed(1, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning",
|
||||
() -> hasLightningEffect(1), v -> setLightningEffect(1, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(1), v -> setLightningDensity(1, v))
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(1), v -> setLightningRadius(1, v))
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1)).column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(1), v -> setLightningDensity(1, v))
|
||||
.range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(1), v -> setLightningRadius(1, v))
|
||||
.range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1))
|
||||
).tab("ability.tab.visual")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import noppes.npcs.api.ability.type.IAbilityEnergyBeam;
|
||||
@@ -280,21 +279,29 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam {
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
// Type tab
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed)
|
||||
),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
FieldDef.section("ability.section.beam"),
|
||||
FieldDef.floatField("ability.beamWidth", this::getBeamWidth, this::setBeamWidth).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.headSize", this::getHeadSize, this::setHeadSize).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.beamWidth", this::getBeamWidth, this::setBeamWidth),
|
||||
FieldDef.floatField("ability.headSize", this::getHeadSize, this::setHeadSize)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime)
|
||||
),
|
||||
FieldDef.section("ability.section.homing"),
|
||||
FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming)
|
||||
.hover("ability.hover.homing"),
|
||||
FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength)
|
||||
.visibleWhen(this::isHoming).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.range", this::getHomingRange, this::setHomingRange)
|
||||
.visibleWhen(this::isHoming).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength)
|
||||
.visibleWhen(this::isHoming),
|
||||
FieldDef.floatField("gui.range", this::getHomingRange, this::setHomingRange)
|
||||
.visibleWhen(this::isHoming)
|
||||
),
|
||||
FieldDef.section("ability.section.explosive"),
|
||||
FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive)
|
||||
.hover("ability.hover.explosive"),
|
||||
@@ -311,19 +318,23 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam {
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor)
|
||||
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled),
|
||||
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
|
||||
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(this::isOuterColorEnabled).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
|
||||
.visibleWhen(this::isOuterColorEnabled),
|
||||
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
|
||||
.range(0, 1).visibleWhen(this::isOuterColorEnabled)
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.section("ability.section.effects").tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed", this::getRotationSpeed, this::setRotationSpeed)
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect)
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect).column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
|
||||
.range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect),
|
||||
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
|
||||
.range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect)
|
||||
).tab("ability.tab.visual")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.api.ability.type.IAbilityGuard;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
|
||||
@@ -306,10 +305,12 @@ public class AbilityGuard extends Ability implements IAbilityGuard {
|
||||
FieldDef.boolField("gui.enabled", this::isCanCounter, this::setCanCounter).hover("ability.hover.canCounter"),
|
||||
FieldDef.enumField("gui.type", CounterType.class, this::getCounterTypeEnum, this::setCounterTypeEnum)
|
||||
.hover("ability.hover.counterType").visibleWhen(this::isCanCounter),
|
||||
FieldDef.floatField("gui.value", this::getCounterValue, this::setCounterValue)
|
||||
.visibleWhen(this::isCanCounter).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.chance", this::getCounterChance, this::setCounterChance)
|
||||
.visibleWhen(this::isCanCounter).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.value", this::getCounterValue, this::setCounterValue)
|
||||
.visibleWhen(this::isCanCounter),
|
||||
FieldDef.floatField("gui.chance", this::getCounterChance, this::setCounterChance)
|
||||
.visibleWhen(this::isCanCounter)
|
||||
),
|
||||
FieldDef.stringField("gui.sound", this::getCounterSound, this::setCounterSound)
|
||||
.visibleWhen(this::isCanCounter),
|
||||
FieldDef.intField("gui.animation", this::getCounterAnimationId, this::setCounterAnimationId)
|
||||
|
||||
@@ -16,7 +16,6 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.api.ability.type.IAbilityHazard;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
|
||||
@@ -639,14 +638,20 @@ public class AbilityHazard extends Ability implements IAbilityHazard {
|
||||
FieldDef.enumField("ability.placement", PlacementMode.class, this::getPlacementEnum, this::setPlacementEnum)
|
||||
.hover("ability.hover.placement"),
|
||||
FieldDef.section("ability.section.area"),
|
||||
FieldDef.floatField("gui.radius", this::getRadius, this::setRadius).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.innerRadius", this::getInnerRadius, this::setInnerRadius).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.radius", this::getRadius, this::setRadius),
|
||||
FieldDef.floatField("ability.innerRadius", this::getInnerRadius, this::setInnerRadius)
|
||||
),
|
||||
FieldDef.section("ability.section.damage"),
|
||||
FieldDef.floatField("ability.damagePerSecond", this::getDamagePerSecond, this::setDamagePerSecond).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.damageInterval", this::getDamageInterval, this::setDamageInterval).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.damagePerSecond", this::getDamagePerSecond, this::setDamagePerSecond),
|
||||
FieldDef.intField("ability.damageInterval", this::getDamageInterval, this::setDamageInterval)
|
||||
),
|
||||
FieldDef.section("ability.section.debuffs"),
|
||||
FieldDef.intField("ability.slownessLevel", this::getSlownessLevel, this::setSlownessLevel).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.debuffDuration", this::getDebuffDuration, this::setDebuffDuration).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.intField("ability.slownessLevel", this::getSlownessLevel, this::setSlownessLevel),
|
||||
FieldDef.intField("ability.debuffDuration", this::getDebuffDuration, this::setDebuffDuration)
|
||||
),
|
||||
FieldDef.intField("ability.poisonLevel", this::getPoisonLevel, this::setPoisonLevel),
|
||||
FieldDef.boolField("ability.affectsCaster", this::isAffectsCaster, this::setAffectsCaster)
|
||||
.hover("ability.hover.affectsCaster"),
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.api.ability.type.IAbilityHeal;
|
||||
|
||||
@@ -289,13 +288,17 @@ public class AbilityHeal extends Ability implements IAbilityHeal {
|
||||
FieldDef.intField("ability.duration", this::getDurationTicks, this::setDurationTicks)
|
||||
.range(1, 1000).visibleWhen(() -> !this.isInstantHeal()),
|
||||
FieldDef.section("ability.section.healing"),
|
||||
FieldDef.floatField("ability.healAmount", this::getHealAmount, this::setHealAmount).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.healPercent", this::getHealPercent, this::setHealPercent).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.healAmount", this::getHealAmount, this::setHealAmount),
|
||||
FieldDef.floatField("ability.healPercent", this::getHealPercent, this::setHealPercent)
|
||||
),
|
||||
FieldDef.floatField("ability.healRadius", this::getHealRadius, this::setHealRadius),
|
||||
FieldDef.boolField("ability.healSelf", this::isHealSelf, this::setHealSelf)
|
||||
.hover("ability.hover.healSelf").column(ColumnHint.LEFT),
|
||||
FieldDef.boolField("ability.healAllies", this::isHealAllies, this::setHealAllies)
|
||||
.hover("ability.hover.healAllies").column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.boolField("ability.healSelf", this::isHealSelf, this::setHealSelf)
|
||||
.hover("ability.hover.healSelf"),
|
||||
FieldDef.boolField("ability.healAllies", this::isHealAllies, this::setHealAllies)
|
||||
.hover("ability.hover.healAllies")
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import noppes.npcs.api.ability.type.IAbilityHeavyHit;
|
||||
@@ -110,8 +109,10 @@ public class AbilityHeavyHit extends Ability implements IAbilityHeavyHit {
|
||||
@Override
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback)
|
||||
),
|
||||
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import kamkeel.npcs.controllers.data.ability.AnchorPoint;
|
||||
import kamkeel.npcs.controllers.data.ability.LockMovementType;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.data.*;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
@@ -252,34 +251,45 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot {
|
||||
return Arrays.asList(
|
||||
// Type tab
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.knockbackUp", this::getKnockbackUp, this::setKnockbackUp).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
FieldDef.floatField("ability.knockbackUp", this::getKnockbackUp, this::setKnockbackUp)
|
||||
),
|
||||
FieldDef.section("ability.section.beam"),
|
||||
FieldDef.floatField("ability.laserWidth", this::getLaserWidth, this::setLaserWidth).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.expansionSpeed", this::getExpansionSpeed, this::setExpansionSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.intField("ability.lingerTicks", this::getLingerTicks, this::setLingerTicks).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.laserWidth", this::getLaserWidth, this::setLaserWidth),
|
||||
FieldDef.floatField("ability.expansionSpeed", this::getExpansionSpeed, this::setExpansionSpeed)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.intField("ability.lingerTicks", this::getLingerTicks, this::setLingerTicks),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime)
|
||||
),
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance),
|
||||
FieldDef.section("ability.section.explosive"),
|
||||
FieldDef.boolField("gui.enabled", this::isExplosive, this::setExplosive).hover("ability.hover.explosive"),
|
||||
FieldDef.floatField("gui.radius", this::getExplosionRadius, this::setExplosionRadius).visibleWhen(this::isExplosive),
|
||||
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects),
|
||||
|
||||
// Visual tab
|
||||
FieldDef.section("ability.section.colors").tab("ability.tab.visual"),
|
||||
FieldDef.colorSubGui("ability.innerColor", this::getInnerColor, this::setInnerColor).tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled).tab("ability.tab.visual"),
|
||||
FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor)
|
||||
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled),
|
||||
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
|
||||
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(this::isOuterColorEnabled).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
|
||||
.visibleWhen(this::isOuterColorEnabled),
|
||||
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
|
||||
.range(0, 1).visibleWhen(this::isOuterColorEnabled)
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.section("ability.section.effects").tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect).tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect).column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
|
||||
.range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect),
|
||||
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
|
||||
.range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect)
|
||||
).tab("ability.tab.visual")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import noppes.npcs.api.ability.type.IAbilityOrb;
|
||||
@@ -416,12 +415,18 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
// Type tab
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("stats.speed", this::getOrbSpeed, this::setOrbSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("stats.size", this::getOrbSize, this::setOrbSize).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("stats.speed", this::getOrbSpeed, this::setOrbSpeed)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("stats.size", this::getOrbSize, this::setOrbSize),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime)
|
||||
),
|
||||
FieldDef.section("ability.section.homing"),
|
||||
FieldDef.boolField("gui.enabled", this::isHoming, this::setHoming).hover("ability.hover.homing"),
|
||||
FieldDef.floatField("gui.strength", this::getHomingStrength, this::setHomingStrength).visibleWhen(this::isHoming),
|
||||
@@ -439,17 +444,21 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
|
||||
FieldDef.boolField("ability.outerEnabled", this::isOuterColorEnabled, this::setOuterColorEnabled).tab("ability.tab.visual"),
|
||||
FieldDef.colorSubGui("ability.outerColor", this::getOuterColor, this::setOuterColor)
|
||||
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled),
|
||||
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
|
||||
.tab("ability.tab.visual").visibleWhen(this::isOuterColorEnabled).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(this::isOuterColorEnabled).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth", this::getOuterColorWidth, this::setOuterColorWidth)
|
||||
.visibleWhen(this::isOuterColorEnabled),
|
||||
FieldDef.floatField("ability.outerAlpha", this::getOuterColorAlpha, this::setOuterColorAlpha)
|
||||
.range(0, 1).visibleWhen(this::isOuterColorEnabled)
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.section("ability.section.effects").tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed", this::getRotationSpeed, this::setRotationSpeed).tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning", this::hasLightningEffect, this::setLightningEffect).tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect).column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density", this::getLightningDensity, this::setLightningDensity)
|
||||
.range(0.01f, 5.0f).visibleWhen(this::hasLightningEffect),
|
||||
FieldDef.floatField("gui.radius", this::getLightningRadius, this::setLightningRadius)
|
||||
.range(0.1f, 10.0f).visibleWhen(this::hasLightningEffect)
|
||||
).tab("ability.tab.visual")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@ import kamkeel.npcs.controllers.data.ability.AnchorPoint;
|
||||
import kamkeel.npcs.controllers.data.ability.LockMovementType;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.data.*;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
@@ -461,12 +460,18 @@ public class AbilityOrbDual extends Ability {
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
// Type tab
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("stats.speed", this::getOrbSpeed, this::setOrbSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("stats.size", this::getOrbSize, this::setOrbSize).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("stats.speed", this::getOrbSpeed, this::setOrbSpeed)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("stats.size", this::getOrbSize, this::setOrbSize),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.maxDistance", this::getMaxDistance, this::setMaxDistance),
|
||||
FieldDef.intField("ability.lifetime", this::getMaxLifetime, this::setMaxLifetime)
|
||||
),
|
||||
FieldDef.section("ability.section.dual"),
|
||||
FieldDef.boolField("ability.dualFire", this::isDualFire, this::setDualFire),
|
||||
FieldDef.intField("ability.dualFireDelay", this::getDualFireDelay, this::setDualFireDelay)
|
||||
@@ -492,24 +497,28 @@ public class AbilityOrbDual extends Ability {
|
||||
FieldDef.colorSubGui("ability.outerColor",
|
||||
() -> getOuterColor(0), v -> setOuterColor(0, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)),
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(0)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v))
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(() -> isOuterColorEnabled(0)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(0), v -> setOuterColorWidth(0, v))
|
||||
.visibleWhen(() -> isOuterColorEnabled(0)),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(0), v -> setOuterColorAlpha(0, v))
|
||||
.range(0, 1).visibleWhen(() -> isOuterColorEnabled(0))
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed",
|
||||
() -> getRotationSpeed(0), v -> setRotationSpeed(0, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning",
|
||||
() -> hasLightningEffect(0), v -> setLightningEffect(0, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(0), v -> setLightningDensity(0, v))
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(0), v -> setLightningRadius(0, v))
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(0), v -> setLightningDensity(0, v))
|
||||
.range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(0)),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(0), v -> setLightningRadius(0, v))
|
||||
.range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(0))
|
||||
).tab("ability.tab.visual"),
|
||||
// Visual tab - Orb 2
|
||||
FieldDef.enumField("ability.anchorPoint", AnchorPoint.class,
|
||||
() -> getAnchorPointEnum(1), v -> setAnchorPointEnum(1, v))
|
||||
@@ -524,24 +533,28 @@ public class AbilityOrbDual extends Ability {
|
||||
FieldDef.colorSubGui("ability.outerColor",
|
||||
() -> getOuterColor(1), v -> setOuterColor(1, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)),
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v))
|
||||
.tab("ability.tab.visual").visibleWhen(() -> isOuterColorEnabled(1)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v))
|
||||
.tab("ability.tab.visual").range(0, 1).visibleWhen(() -> isOuterColorEnabled(1)).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.outerWidth",
|
||||
() -> getOuterColorWidth(1), v -> setOuterColorWidth(1, v))
|
||||
.visibleWhen(() -> isOuterColorEnabled(1)),
|
||||
FieldDef.floatField("ability.outerAlpha",
|
||||
() -> getOuterColorAlpha(1), v -> setOuterColorAlpha(1, v))
|
||||
.range(0, 1).visibleWhen(() -> isOuterColorEnabled(1))
|
||||
).tab("ability.tab.visual"),
|
||||
FieldDef.floatField("ability.rotationSpeed",
|
||||
() -> getRotationSpeed(1), v -> setRotationSpeed(1, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.boolField("ability.lightning",
|
||||
() -> hasLightningEffect(1), v -> setLightningEffect(1, v))
|
||||
.tab("ability.tab.visual"),
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(1), v -> setLightningDensity(1, v))
|
||||
.tab("ability.tab.visual").range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(1), v -> setLightningRadius(1, v))
|
||||
.tab("ability.tab.visual").range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1)).column(ColumnHint.RIGHT)
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.density",
|
||||
() -> getLightningDensity(1), v -> setLightningDensity(1, v))
|
||||
.range(0.01f, 5.0f).visibleWhen(() -> hasLightningEffect(1)),
|
||||
FieldDef.floatField("gui.radius",
|
||||
() -> getLightningRadius(1), v -> setLightningRadius(1, v))
|
||||
.range(0.1f, 10.0f).visibleWhen(() -> hasLightningEffect(1))
|
||||
).tab("ability.tab.visual")
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.api.ability.type.IAbilityProjectile;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
|
||||
@@ -254,8 +253,10 @@ public class AbilityProjectile extends Ability implements IAbilityProjectile {
|
||||
@Override
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("stats.speed", this::getSpeed, this::setSpeed)
|
||||
),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
FieldDef.stringEnumField("ability.projectileType", new String[]{"fireball", "arrow", "magic"}, this::getProjectileType, this::setProjectileType),
|
||||
FieldDef.section("ability.section.homing"),
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import noppes.npcs.api.ability.type.IAbilityShockwave;
|
||||
@@ -171,8 +170,10 @@ public class AbilityShockwave extends Ability implements IAbilityShockwave {
|
||||
return Arrays.asList(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.section("ability.section.push"),
|
||||
FieldDef.floatField("gui.radius", this::getPushRadius, this::setPushRadius).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.strength", this::getPushStrength, this::setPushStrength).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.radius", this::getPushRadius, this::setPushRadius),
|
||||
FieldDef.floatField("gui.strength", this::getPushStrength, this::setPushStrength)
|
||||
),
|
||||
FieldDef.intField("ability.maxTargets", this::getMaxTargets, this::setMaxTargets),
|
||||
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects)
|
||||
);
|
||||
|
||||
@@ -18,7 +18,6 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.api.ability.type.IAbilitySlam;
|
||||
import somehussar.gui.annotationHandling.GuiEditable;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import java.util.Arrays;
|
||||
@@ -578,11 +577,15 @@ public class AbilitySlam extends Ability implements IAbilitySlam {
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("gui.radius", this::getRadius, this::setRadius).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockbackStrength, this::setKnockbackStrength).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.radius", this::getRadius, this::setRadius),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockbackStrength, this::setKnockbackStrength)
|
||||
),
|
||||
FieldDef.section("ability.section.leap"),
|
||||
FieldDef.floatField("gui.speed", this::getLeapSpeed, this::setLeapSpeed).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.height", this::getLeapHeight, this::setLeapHeight).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.speed", this::getLeapSpeed, this::setLeapSpeed),
|
||||
FieldDef.floatField("gui.height", this::getLeapHeight, this::setLeapHeight)
|
||||
),
|
||||
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.LockMovementType;
|
||||
import kamkeel.npcs.controllers.data.ability.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.data.EnergyColorData;
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
@@ -203,18 +202,26 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.damageInterval", this::getDamageInterval, this::setDamageInterval).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.intField("ability.damageInterval", this::getDamageInterval, this::setDamageInterval)
|
||||
),
|
||||
FieldDef.section("ability.section.beam"),
|
||||
FieldDef.floatField("gui.length", this::getBeamLength, this::setBeamLength).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.width", this::getBeamWidth, this::setBeamWidth).column(ColumnHint.RIGHT),
|
||||
FieldDef.floatField("gui.height", this::getBeamHeight, this::setBeamHeight).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.sweepSpeed", this::getSweepSpeed, this::setSweepSpeed).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.length", this::getBeamLength, this::setBeamLength),
|
||||
FieldDef.floatField("gui.width", this::getBeamWidth, this::setBeamWidth)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.height", this::getBeamHeight, this::setBeamHeight),
|
||||
FieldDef.floatField("ability.sweepSpeed", this::getSweepSpeed, this::setSweepSpeed)
|
||||
),
|
||||
FieldDef.intField("ability.rotations", this::getNumberOfRotations, this::setNumberOfRotations),
|
||||
FieldDef.boolField("ability.piercing", this::isPiercing, this::setPiercing)
|
||||
.hover("ability.hover.piercing").column(ColumnHint.LEFT),
|
||||
FieldDef.boolField("ability.lockTarget", this::isLockOnTarget, this::setLockOnTarget)
|
||||
.hover("ability.hover.lockTarget").column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.boolField("ability.piercing", this::isPiercing, this::setPiercing)
|
||||
.hover("ability.hover.piercing"),
|
||||
FieldDef.boolField("ability.lockTarget", this::isLockOnTarget, this::setLockOnTarget)
|
||||
.hover("ability.hover.lockTarget")
|
||||
),
|
||||
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects),
|
||||
|
||||
// Visual tab
|
||||
|
||||
@@ -16,7 +16,6 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.api.ability.type.IAbilityTeleport;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
|
||||
@@ -564,22 +563,28 @@ public class AbilityTeleport extends Ability implements IAbilityTeleport {
|
||||
FieldDef.enumField("ability.mode", TeleportMode.class, this::getModeEnum, this::setModeEnum),
|
||||
FieldDef.floatField("ability.blinkRadius", this::getBlinkRadius, this::setBlinkRadius)
|
||||
.visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK || this.getModeEnum() == TeleportMode.SINGLE),
|
||||
FieldDef.intField("ability.blinkCount", this::getBlinkCount, this::setBlinkCount)
|
||||
.visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.blinkDelay", this::getBlinkDelayTicks, this::setBlinkDelayTicks)
|
||||
.visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.intField("ability.blinkCount", this::getBlinkCount, this::setBlinkCount)
|
||||
.visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK),
|
||||
FieldDef.intField("ability.blinkDelay", this::getBlinkDelayTicks, this::setBlinkDelayTicks)
|
||||
.visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK)
|
||||
),
|
||||
FieldDef.floatField("ability.behindDistance", this::getBehindDistance, this::setBehindDistance)
|
||||
.visibleWhen(() -> this.getModeEnum() == TeleportMode.BEHIND),
|
||||
FieldDef.boolField("ability.lineOfSight", this::isRequireLineOfSight, this::setRequireLineOfSight)
|
||||
.hover("ability.hover.lineOfSight")
|
||||
.visibleWhen(() -> this.getModeEnum() == TeleportMode.BLINK || this.getModeEnum() == TeleportMode.SINGLE),
|
||||
FieldDef.section("ability.section.damage"),
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius", this::getDamageRadius, this::setDamageRadius).column(ColumnHint.RIGHT),
|
||||
FieldDef.boolField("ability.damageAtStart", this::isDamageAtStart, this::setDamageAtStart)
|
||||
.hover("ability.hover.dmgAtStart").column(ColumnHint.LEFT),
|
||||
FieldDef.boolField("ability.damageAtEnd", this::isDamageAtEnd, this::setDamageAtEnd)
|
||||
.hover("ability.hover.dmgAtEnd").column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("gui.radius", this::getDamageRadius, this::setDamageRadius)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.boolField("ability.damageAtStart", this::isDamageAtStart, this::setDamageAtStart)
|
||||
.hover("ability.hover.dmgAtStart"),
|
||||
FieldDef.boolField("ability.damageAtEnd", this::isDamageAtEnd, this::setDamageAtEnd)
|
||||
.hover("ability.hover.dmgAtEnd")
|
||||
),
|
||||
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.api.ability.type.IAbilityTrap;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
|
||||
@@ -476,13 +475,19 @@ public class AbilityTrap extends Ability implements IAbilityTrap {
|
||||
FieldDef.enumField("ability.placement", TrapPlacement.class, this::getPlacementEnum, this::setPlacementEnum)
|
||||
.hover("ability.hover.placement"),
|
||||
FieldDef.section("ability.section.trigger"),
|
||||
FieldDef.floatField("gui.radius", this::getTriggerRadius, this::setTriggerRadius).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.armTime", this::getArmTime, this::setArmTime).column(ColumnHint.RIGHT),
|
||||
FieldDef.intField("ability.maxTriggers", this::getMaxTriggers, this::setMaxTriggers).column(ColumnHint.LEFT),
|
||||
FieldDef.intField("ability.triggerCooldown", this::getTriggerCooldown, this::setTriggerCooldown).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("gui.radius", this::getTriggerRadius, this::setTriggerRadius),
|
||||
FieldDef.intField("ability.armTime", this::getArmTime, this::setArmTime)
|
||||
),
|
||||
FieldDef.row(
|
||||
FieldDef.intField("ability.maxTriggers", this::getMaxTriggers, this::setMaxTriggers),
|
||||
FieldDef.intField("ability.triggerCooldown", this::getTriggerCooldown, this::setTriggerCooldown)
|
||||
),
|
||||
FieldDef.section("ability.section.damage"),
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("gui.radius", this::getDamageRadius, this::setDamageRadius).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("gui.radius", this::getDamageRadius, this::setDamageRadius)
|
||||
),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback),
|
||||
AbilityFieldDefs.effectsListField("ability.effects", this::getEffects, this::setEffects)
|
||||
);
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import noppes.npcs.client.gui.builder.ColumnHint;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import noppes.npcs.api.ability.type.IAbilityVortex;
|
||||
@@ -304,11 +303,15 @@ public class AbilityVortex extends Ability implements IAbilityVortex {
|
||||
@Override
|
||||
public List<FieldDef> getFieldDefinitions() {
|
||||
return Arrays.asList(
|
||||
FieldDef.floatField("ability.pullRadius", this::getPullRadius, this::setPullRadius).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.pullStrength", this::getPullStrength, this::setPullStrength).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("ability.pullRadius", this::getPullRadius, this::setPullRadius),
|
||||
FieldDef.floatField("ability.pullStrength", this::getPullStrength, this::setPullStrength)
|
||||
),
|
||||
FieldDef.section("ability.section.damage"),
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage).column(ColumnHint.LEFT),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback).column(ColumnHint.RIGHT),
|
||||
FieldDef.row(
|
||||
FieldDef.floatField("enchantment.damage", this::getDamage, this::setDamage),
|
||||
FieldDef.floatField("ability.knockback", this::getKnockback, this::setKnockback)
|
||||
),
|
||||
FieldDef.section("ability.section.aoe"),
|
||||
FieldDef.boolField("gui.enabled", this::isAoe, this::setAoe)
|
||||
.hover("ability.hover.aoe"),
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package noppes.npcs.client.gui.advanced;
|
||||
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.AbilityEffect;
|
||||
import kamkeel.npcs.controllers.data.ability.Condition;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldBuilder;
|
||||
import noppes.npcs.client.gui.builder.FieldDef;
|
||||
import noppes.npcs.client.gui.builder.FieldType;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.StatCollector;
|
||||
@@ -55,7 +53,6 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
private int editingConditionIndex = -1;
|
||||
|
||||
private AbilityFieldBuilder builder;
|
||||
private FieldDef activeSubGuiField = null;
|
||||
|
||||
// Scroll position preservation per tab
|
||||
private float[] tabScrollY;
|
||||
@@ -263,7 +260,6 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public void buttonEvent(GuiButton guibutton) {
|
||||
int id = guibutton.id;
|
||||
|
||||
@@ -281,6 +277,22 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
if (id == -1000) { close(); return; }
|
||||
|
||||
// Condition buttons (50-80)
|
||||
if (handleConditionButton(id)) return;
|
||||
|
||||
// Declarative field handling (effects list, booleans, enums, sub-guis, clear buttons)
|
||||
if (builder.handleButtonEvent(id, guibutton)) {
|
||||
// SUB_GUI needs special handling: open the sub-gui
|
||||
FieldDef subGuiDef = builder.getActiveSubGuiField();
|
||||
if (subGuiDef != null && subGuiDef.getSubGuiFactory() != null) {
|
||||
setSubGui(subGuiDef.getSubGuiFactory().get());
|
||||
} else {
|
||||
initGui();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleConditionButton(int id) {
|
||||
if (id >= 50 && id < 80) {
|
||||
int condIndex = (id - 50) / 10;
|
||||
int action = (id - 50) % 10;
|
||||
@@ -295,109 +307,16 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
if (id == 80) {
|
||||
if (conditions.size() < 3) {
|
||||
editingConditionIndex = conditions.size();
|
||||
setSubGui(new SubGuiConditionEdit(null));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear buttons (effects delete or SUB_GUI clear)
|
||||
if (id >= CLEAR_ID_START) {
|
||||
// Check effects list delete first
|
||||
int[] meta = builder.getEffectWidgetMeta().get(id);
|
||||
if (meta != null && meta[1] == 3) {
|
||||
FieldDef def = builder.getClearFieldMap().get(id);
|
||||
if (def != null && def.getType() == FieldType.EFFECTS_LIST) {
|
||||
handleEffectButton(def, meta, guibutton);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// SUB_GUI clear
|
||||
FieldDef def = builder.getClearFieldMap().get(id);
|
||||
if (def != null && def.hasClearAction()) {
|
||||
def.getClearAction().run();
|
||||
initGui();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Declarative field buttons
|
||||
if (id >= DECLARATIVE_ID_START) {
|
||||
FieldDef def = builder.getButtonFieldMap().get(id);
|
||||
if (def == null) return;
|
||||
|
||||
// Effects list buttons (type, amp, add)
|
||||
int[] meta = builder.getEffectWidgetMeta().get(id);
|
||||
if (meta != null && def.getType() == FieldType.EFFECTS_LIST) {
|
||||
handleEffectButton(def, meta, guibutton);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (def.getType()) {
|
||||
case BOOLEAN:
|
||||
def.setValue(((GuiNpcButton) guibutton).getValue() == 1);
|
||||
initGui();
|
||||
break;
|
||||
case ENUM: {
|
||||
int idx = ((GuiNpcButton) guibutton).getValue();
|
||||
Class<? extends Enum<?>> ec = def.getEnumClass();
|
||||
if (ec != null) {
|
||||
Enum<?>[] constants = ec.getEnumConstants();
|
||||
if (idx >= 0 && idx < constants.length) def.setValue(constants[idx]);
|
||||
}
|
||||
initGui();
|
||||
break;
|
||||
}
|
||||
case STRING_ENUM: {
|
||||
int idx = ((GuiNpcButton) guibutton).getValue();
|
||||
String[] values = def.getStringEnumValues();
|
||||
if (values != null && idx >= 0 && idx < values.length) def.setStringEnumValue(values[idx]);
|
||||
initGui();
|
||||
break;
|
||||
}
|
||||
case SUB_GUI:
|
||||
activeSubGuiField = def;
|
||||
if (def.getSubGuiFactory() != null) setSubGui(def.getSubGuiFactory().get());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void handleEffectButton(FieldDef def, int[] meta, GuiButton btn) {
|
||||
List<AbilityEffect> effects = (List<AbilityEffect>) def.getValue();
|
||||
if (effects == null) return;
|
||||
int effectIdx = meta[0];
|
||||
int action = meta[1];
|
||||
|
||||
switch (action) {
|
||||
case 0: // Type changed
|
||||
if (effectIdx < effects.size()) {
|
||||
effects.get(effectIdx).setType(AbilityEffect.EffectType.fromOrdinal(((GuiNpcButton) btn).getValue()));
|
||||
}
|
||||
break;
|
||||
case 2: // Amp changed
|
||||
if (effectIdx < effects.size()) {
|
||||
effects.get(effectIdx).setAmplifier(((GuiNpcButton) btn).getValue());
|
||||
}
|
||||
break;
|
||||
case 3: // Delete
|
||||
if (effectIdx < effects.size()) {
|
||||
effects.remove(effectIdx);
|
||||
initGui();
|
||||
}
|
||||
break;
|
||||
case 4: // Add
|
||||
if (effects.size() < 5) {
|
||||
effects.add(new AbilityEffect(AbilityEffect.EffectType.SLOWNESS, 60, 0));
|
||||
initGui();
|
||||
}
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
@@ -405,38 +324,9 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void unFocused(GuiNpcTextField textField) {
|
||||
int id = textField.id;
|
||||
if (id < DECLARATIVE_ID_START) return;
|
||||
|
||||
// Check effects list duration fields
|
||||
int[] meta = builder.getEffectWidgetMeta().get(id);
|
||||
if (meta != null && meta[1] == 1) {
|
||||
FieldDef def = builder.getTextFieldMap().get(id);
|
||||
if (def != null && def.getType() == FieldType.EFFECTS_LIST) {
|
||||
List<AbilityEffect> effects = (List<AbilityEffect>) def.getValue();
|
||||
if (effects != null && meta[0] < effects.size()) {
|
||||
effects.get(meta[0]).setDurationTicks(textField.getInteger());
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
FieldDef def = builder.getTextFieldMap().get(id);
|
||||
if (def == null) return;
|
||||
|
||||
switch (def.getType()) {
|
||||
case FLOAT:
|
||||
try { def.setValue(Float.parseFloat(textField.getText())); } catch (NumberFormatException ignored) {}
|
||||
break;
|
||||
case INT:
|
||||
try { def.setValue(Integer.parseInt(textField.getText())); } catch (NumberFormatException ignored) {}
|
||||
break;
|
||||
case STRING:
|
||||
def.setValue(textField.getText());
|
||||
break;
|
||||
}
|
||||
if (textField.id < DECLARATIVE_ID_START) return;
|
||||
builder.handleTextFieldEvent(textField.id, textField);
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
@@ -445,12 +335,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
|
||||
|
||||
@Override
|
||||
public void subGuiClosed(SubGuiInterface subgui) {
|
||||
if (activeSubGuiField != null) {
|
||||
FieldDef def = activeSubGuiField;
|
||||
activeSubGuiField = null;
|
||||
if (def.getSubGuiResultHandler() != null) {
|
||||
def.getSubGuiResultHandler().accept(subgui);
|
||||
}
|
||||
if (builder.handleSubGuiClosed(subgui)) {
|
||||
initGui();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
package noppes.npcs.client.gui.builder;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum ColumnHint {
|
||||
FULL,
|
||||
LEFT,
|
||||
RIGHT
|
||||
}
|
||||
@@ -24,12 +24,10 @@ public class FieldDef {
|
||||
private final String label;
|
||||
private final FieldType type;
|
||||
private String tab = null;
|
||||
private ColumnHint column = ColumnHint.FULL;
|
||||
private Supplier<Object> getter;
|
||||
private Consumer<Object> setter;
|
||||
private BooleanSupplier visibleWhen = () -> true;
|
||||
private BooleanSupplier enabledWhen = () -> true;
|
||||
private String tooltip = null;
|
||||
private String hoverText = null;
|
||||
|
||||
// Numeric range
|
||||
@@ -51,6 +49,10 @@ public class FieldDef {
|
||||
private Supplier<Integer> buttonTextColorSupplier;
|
||||
private Runnable clearAction;
|
||||
|
||||
// Row pairing (ROW type only)
|
||||
private FieldDef leftChild;
|
||||
private FieldDef rightChild;
|
||||
|
||||
private FieldDef(String label, FieldType type) {
|
||||
this.label = label;
|
||||
this.type = type;
|
||||
@@ -134,6 +136,17 @@ public class FieldDef {
|
||||
return def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a two-column row pairing two fields side by side.
|
||||
* If one child is hidden (via visibleWhen), the other renders full-width.
|
||||
*/
|
||||
public static FieldDef row(FieldDef left, FieldDef right) {
|
||||
FieldDef def = new FieldDef("", FieldType.ROW);
|
||||
def.leftChild = left;
|
||||
def.rightChild = right;
|
||||
return def;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// CONVENIENCE FACTORIES (SUB_GUI wrappers)
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
@@ -206,11 +219,6 @@ public class FieldDef {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FieldDef column(ColumnHint column) {
|
||||
this.column = column;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FieldDef visibleWhen(BooleanSupplier condition) {
|
||||
this.visibleWhen = condition;
|
||||
return this;
|
||||
@@ -221,11 +229,6 @@ public class FieldDef {
|
||||
return this;
|
||||
}
|
||||
|
||||
public FieldDef tooltip(String tooltip) {
|
||||
this.tooltip = tooltip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public FieldDef hover(String hoverText) {
|
||||
this.hoverText = hoverText;
|
||||
return this;
|
||||
@@ -253,10 +256,8 @@ public class FieldDef {
|
||||
public String getLabel() { return label; }
|
||||
public FieldType getType() { return type; }
|
||||
public String getTab() { return tab; }
|
||||
public ColumnHint getColumn() { return column; }
|
||||
public boolean isVisible() { return visibleWhen.getAsBoolean(); }
|
||||
public boolean isEnabled() { return enabledWhen.getAsBoolean(); }
|
||||
public String getTooltip() { return tooltip; }
|
||||
public String getHoverText() { return hoverText; }
|
||||
public float getMin() { return min; }
|
||||
public float getMax() { return max; }
|
||||
@@ -293,4 +294,7 @@ public class FieldDef {
|
||||
return buttonTextColorSupplier != null ? buttonTextColorSupplier.get() : null;
|
||||
}
|
||||
|
||||
public FieldDef getLeftChild() { return leftChild; }
|
||||
public FieldDef getRightChild() { return rightChild; }
|
||||
|
||||
}
|
||||
@@ -14,5 +14,6 @@ public enum FieldType {
|
||||
STRING,
|
||||
SECTION_HEADER,
|
||||
LABEL,
|
||||
EFFECTS_LIST
|
||||
EFFECTS_LIST,
|
||||
ROW
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package noppes.npcs.client.gui.builder;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.gui.util.GuiNPCInterface;
|
||||
import noppes.npcs.client.gui.util.GuiNpcButton;
|
||||
@@ -10,6 +11,7 @@ import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
|
||||
import noppes.npcs.client.gui.util.GuiNpcLabel;
|
||||
import noppes.npcs.client.gui.util.GuiNpcTextField;
|
||||
import noppes.npcs.client.gui.util.GuiScrollWindow;
|
||||
import noppes.npcs.client.gui.util.SubGuiInterface;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -19,8 +21,8 @@ import java.util.Map;
|
||||
* General-purpose builder that converts a list of {@link FieldDef} into positioned
|
||||
* GUI widgets inside a {@link GuiScrollWindow}.
|
||||
* <p>
|
||||
* Supports 1-column and 2-column layouts. Subclasses can override {@link #buildField}
|
||||
* to handle custom field types.
|
||||
* Uses {@link FieldDef#row(FieldDef, FieldDef)} for two-column layouts.
|
||||
* Subclasses can override {@link #buildField} to handle custom field types.
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiFieldBuilder {
|
||||
@@ -36,9 +38,6 @@ public class GuiFieldBuilder {
|
||||
protected int rowHeight = 24;
|
||||
protected int labelPadding = 8;
|
||||
|
||||
// Column mode
|
||||
protected int columnCount = 2;
|
||||
|
||||
// Dependencies
|
||||
protected final GuiNPCInterface parent;
|
||||
protected GuiScrollWindow sw;
|
||||
@@ -71,7 +70,6 @@ public class GuiFieldBuilder {
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
public GuiFieldBuilder scrollWindowId(int id) { this.scrollWindowId = id; return this; }
|
||||
public GuiFieldBuilder columns(int count) { this.columnCount = Math.max(1, Math.min(2, count)); 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;
|
||||
@@ -125,38 +123,37 @@ public class GuiFieldBuilder {
|
||||
// Section header
|
||||
if (def.getType() == FieldType.SECTION_HEADER) {
|
||||
y += 3;
|
||||
String sectionText = StatCollector.translateToLocal(def.getLabel());
|
||||
if (def.getTooltip() != null && !def.getTooltip().isEmpty()) {
|
||||
sectionText += " (" + StatCollector.translateToLocal(def.getTooltip()) + ")";
|
||||
GuiNpcLabel sectionLabel = new GuiNpcLabel(labelId++, def.getLabel(), colLLabel, y + 2, 0xFFFF55);
|
||||
if (def.getHoverText() != null && !def.getHoverText().isEmpty()) {
|
||||
sectionLabel.setHoverText(def.getHoverText());
|
||||
}
|
||||
sw.addLabel(new GuiNpcLabel(labelId++, sectionText, colLLabel, y + 2, 0xFFFF55));
|
||||
sw.addLabel(sectionLabel);
|
||||
y += 15;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Two-column pair: LEFT followed by RIGHT (only in 2-column mode)
|
||||
if (columnCount == 2
|
||||
&& def.getColumn() == ColumnHint.LEFT
|
||||
&& i + 1 < fields.size()
|
||||
&& fields.get(i + 1).getColumn() == ColumnHint.RIGHT
|
||||
&& fields.get(i + 1).getType() != FieldType.SECTION_HEADER) {
|
||||
renderFieldAt(def, colLLabel, colLField, colLWidth, y);
|
||||
// ROW: explicit two-column pair
|
||||
if (def.getType() == FieldType.ROW) {
|
||||
FieldDef left = def.getLeftChild();
|
||||
FieldDef right = def.getRightChild();
|
||||
boolean leftVis = left != null && left.isVisible();
|
||||
boolean rightVis = right != null && right.isVisible();
|
||||
|
||||
i++;
|
||||
FieldDef rightDef = fields.get(i);
|
||||
renderFieldAt(rightDef, colRLabel, colRField, colRWidth, y);
|
||||
|
||||
y += rowHeight;
|
||||
} else {
|
||||
// Full-width: compute fieldX from label pixel width
|
||||
int fieldW = getFullFieldWidth(def);
|
||||
String translated = StatCollector.translateToLocal(def.getLabel());
|
||||
int labelW = fontRenderer.getStringWidth(translated);
|
||||
int fieldX = colLLabel + labelW + labelPadding;
|
||||
|
||||
renderFieldAt(def, colLLabel, fieldX, fieldW, y);
|
||||
y += rowHeight;
|
||||
if (leftVis && rightVis) {
|
||||
renderFieldAt(left, colLLabel, colLField, colLWidth, y);
|
||||
renderFieldAt(right, colRLabel, colRField, colRWidth, y);
|
||||
} else if (leftVis) {
|
||||
renderFullWidth(left, y);
|
||||
} else if (rightVis) {
|
||||
renderFullWidth(right, y);
|
||||
}
|
||||
if (leftVis || rightVis) y += rowHeight;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Full-width field
|
||||
renderFullWidth(def, y);
|
||||
y += rowHeight;
|
||||
}
|
||||
|
||||
lastBuildY = y;
|
||||
@@ -182,9 +179,12 @@ public class GuiFieldBuilder {
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
protected void renderFieldAt(FieldDef def, int labelX, int fieldX, int fieldW, int y) {
|
||||
sw.addLabel(new GuiNpcLabel(labelId++, def.getLabel(), labelX, y + 5, 0xFFFFFF));
|
||||
|
||||
String hover = def.getHoverText() != null ? def.getHoverText() : def.getTooltip();
|
||||
GuiNpcLabel fieldLabel = new GuiNpcLabel(labelId++, def.getLabel(), labelX, y + 5, 0xFFFFFF);
|
||||
String hover = def.getHoverText();
|
||||
if (hover != null && !hover.isEmpty()) {
|
||||
fieldLabel.setHoverText(hover);
|
||||
}
|
||||
sw.addLabel(fieldLabel);
|
||||
|
||||
switch (def.getType()) {
|
||||
case FLOAT: {
|
||||
@@ -307,6 +307,14 @@ public class GuiFieldBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderFullWidth(FieldDef def, int y) {
|
||||
int fieldW = getFullFieldWidth(def);
|
||||
String translated = StatCollector.translateToLocal(def.getLabel());
|
||||
int labelW = fontRenderer.getStringWidth(translated);
|
||||
int fieldX = colLLabel + labelW + labelPadding;
|
||||
renderFieldAt(def, colLLabel, fieldX, fieldW, y);
|
||||
}
|
||||
|
||||
protected int getFullFieldWidth(FieldDef def) {
|
||||
switch (def.getType()) {
|
||||
case FLOAT:
|
||||
@@ -321,6 +329,109 @@ public class GuiFieldBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// EVENT HANDLING
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
private FieldDef activeSubGuiField;
|
||||
|
||||
/**
|
||||
* Handles button events for declarative fields.
|
||||
* Call from parent GUI's buttonEvent(). Returns true if the event was handled.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public boolean handleButtonEvent(int buttonId, GuiButton button) {
|
||||
// Check clear buttons first
|
||||
if (clearFieldMap.containsKey(buttonId)) {
|
||||
FieldDef def = clearFieldMap.get(buttonId);
|
||||
if (def != null && def.hasClearAction()) {
|
||||
def.getClearAction().run();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check field buttons
|
||||
FieldDef def = buttonFieldMap.get(buttonId);
|
||||
if (def == null) return false;
|
||||
|
||||
switch (def.getType()) {
|
||||
case BOOLEAN:
|
||||
def.setValue(((GuiNpcButton) button).getValue() == 1);
|
||||
return true;
|
||||
case ENUM: {
|
||||
int idx = ((GuiNpcButton) button).getValue();
|
||||
Class<? extends Enum<?>> ec = def.getEnumClass();
|
||||
if (ec != null) {
|
||||
Enum<?>[] constants = ec.getEnumConstants();
|
||||
if (idx >= 0 && idx < constants.length) def.setValue(constants[idx]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case STRING_ENUM: {
|
||||
int idx = ((GuiNpcButton) button).getValue();
|
||||
String[] values = def.getStringEnumValues();
|
||||
if (values != null && idx >= 0 && idx < values.length) def.setStringEnumValue(values[idx]);
|
||||
return true;
|
||||
}
|
||||
case SUB_GUI:
|
||||
activeSubGuiField = def;
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles text field unfocus events for declarative fields.
|
||||
* Call from parent GUI's unFocused(). Returns true if the event was handled.
|
||||
*/
|
||||
public boolean handleTextFieldEvent(int textFieldId, GuiNpcTextField field) {
|
||||
FieldDef def = textFieldMap.get(textFieldId);
|
||||
if (def == null) return false;
|
||||
|
||||
switch (def.getType()) {
|
||||
case FLOAT:
|
||||
try { def.setValue(Float.parseFloat(field.getText())); } catch (NumberFormatException ignored) {}
|
||||
return true;
|
||||
case INT:
|
||||
try { def.setValue(Integer.parseInt(field.getText())); } catch (NumberFormatException ignored) {}
|
||||
return true;
|
||||
case STRING:
|
||||
def.setValue(field.getText());
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles sub-gui close events. Call from parent GUI's subGuiClosed().
|
||||
* Returns true if the event was handled (activeSubGuiField was set).
|
||||
*/
|
||||
public boolean handleSubGuiClosed(SubGuiInterface subgui) {
|
||||
if (activeSubGuiField != null) {
|
||||
FieldDef def = activeSubGuiField;
|
||||
activeSubGuiField = null;
|
||||
if (def.getSubGuiResultHandler() != null) {
|
||||
def.getSubGuiResultHandler().accept(subgui);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the FieldDef for the currently active sub-gui, or null.
|
||||
* After handleButtonEvent returns true for a SUB_GUI field, the parent
|
||||
* should check this and call setSubGui(def.getSubGuiFactory().get()).
|
||||
*/
|
||||
public FieldDef getActiveSubGuiField() { return activeSubGuiField; }
|
||||
|
||||
/**
|
||||
* Clears the active sub-gui field tracking.
|
||||
*/
|
||||
public void clearActiveSubGuiField() { activeSubGuiField = null; }
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
// GETTERS
|
||||
// ═══════════════════════════════════════════════════════════════════
|
||||
|
||||
@@ -1,18 +1,32 @@
|
||||
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.Gui;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import noppes.npcs.client.CustomNpcResourceListener;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
public class GuiNpcLabel {
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiNpcLabel extends Gui {
|
||||
public String label;
|
||||
public int x, y, color;
|
||||
public boolean enabled = true;
|
||||
public int id;
|
||||
public boolean drawShadow = false;
|
||||
|
||||
// Hover text support
|
||||
public String hoverableText = "";
|
||||
private boolean wasHovered = false;
|
||||
private int hoverCount = 0;
|
||||
|
||||
public GuiNpcLabel(int id, Object label, int x, int y, int color) {
|
||||
this.id = id;
|
||||
this.label = StatCollector.translateToLocal(label.toString());
|
||||
@@ -25,6 +39,10 @@ public class GuiNpcLabel {
|
||||
this(id, label, x, y, CustomNpcResourceListener.DefaultTextColor);
|
||||
}
|
||||
|
||||
public void setHoverText(String text) {
|
||||
this.hoverableText = text;
|
||||
}
|
||||
|
||||
public void drawLabel(GuiScreen gui, FontRenderer fontRenderer) {
|
||||
if (enabled)
|
||||
fontRenderer.drawString(label, x, y, color, drawShadow);
|
||||
@@ -34,4 +52,119 @@ public class GuiNpcLabel {
|
||||
int size = Minecraft.getMinecraft().fontRenderer.getStringWidth(label);
|
||||
x += (width - size) / 2;
|
||||
}
|
||||
|
||||
public boolean isMouseOver(int mouseX, int mouseY, FontRenderer fr) {
|
||||
int width = fr.getStringWidth(label);
|
||||
return mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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
|
||||
*/
|
||||
public void drawHover(int localMouseX, int localMouseY, int screenMouseX, int screenMouseY, boolean hasSubGui, FontRenderer fr) {
|
||||
if (hasSubGui || hoverableText.isEmpty()) return;
|
||||
|
||||
boolean hovered = isMouseOver(localMouseX, localMouseY, fr);
|
||||
if (!hovered) {
|
||||
wasHovered = false;
|
||||
hoverCount = 0;
|
||||
return;
|
||||
}
|
||||
if (!wasHovered) {
|
||||
wasHovered = true;
|
||||
hoverCount = 0;
|
||||
}
|
||||
if (hoverCount < 65) hoverCount++;
|
||||
|
||||
if (hoverCount > 60) {
|
||||
GL11.glPushMatrix();
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
String displayString = StatCollector.translateToLocal(hoverableText);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
List<String> lines = TextSplitter.splitText(displayString, 30);
|
||||
drawHoveringText(lines, screenMouseX, screenMouseY, mc);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
protected void drawHoveringText(List textLines, int x, int y, Minecraft mc) {
|
||||
if (mc.fontRenderer == null || textLines.isEmpty())
|
||||
return;
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
|
||||
int maxWidth = 0;
|
||||
Iterator iterator = textLines.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String s = (String) iterator.next();
|
||||
int lineWidth = mc.fontRenderer.getStringWidth(s);
|
||||
if (lineWidth > maxWidth) {
|
||||
maxWidth = lineWidth;
|
||||
}
|
||||
}
|
||||
|
||||
int j2 = x + 12;
|
||||
int k2 = y - 12;
|
||||
int maxHeight = 8;
|
||||
|
||||
if (textLines.size() > 1) {
|
||||
maxHeight += 2 + (textLines.size() - 1) * 10;
|
||||
}
|
||||
|
||||
ScaledResolution scaledRes = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
|
||||
int screenWidth = scaledRes.getScaledWidth();
|
||||
int screenHeight = scaledRes.getScaledHeight();
|
||||
|
||||
if (j2 + maxWidth + 6 > screenWidth) {
|
||||
j2 = x - maxWidth - 16;
|
||||
}
|
||||
if (j2 < 4) {
|
||||
j2 = 4;
|
||||
}
|
||||
if (k2 + maxHeight + 6 > screenHeight) {
|
||||
k2 = screenHeight - maxHeight - 6;
|
||||
}
|
||||
if (k2 < 4) {
|
||||
k2 = 4;
|
||||
}
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
int j1 = -267386864;
|
||||
this.drawGradientRect(j2 - 3, k2 - 4, j2 + maxWidth + 3, k2 - 3, j1, j1);
|
||||
this.drawGradientRect(j2 - 3, k2 + maxHeight + 3, j2 + maxWidth + 3, k2 + maxHeight + 4, j1, j1);
|
||||
this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 + maxHeight + 3, j1, j1);
|
||||
this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + maxHeight + 3, j1, j1);
|
||||
this.drawGradientRect(j2 + maxWidth + 3, k2 - 3, j2 + maxWidth + 4, k2 + maxHeight + 3, j1, j1);
|
||||
int k1 = 1347420415;
|
||||
int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
|
||||
this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + maxHeight + 3 - 1, k1, l1);
|
||||
this.drawGradientRect(j2 + maxWidth + 2, k2 - 3 + 1, j2 + maxWidth + 3, k2 + maxHeight + 3 - 1, k1, l1);
|
||||
this.drawGradientRect(j2 - 3, k2 - 3, j2 + maxWidth + 3, k2 - 3 + 1, k1, k1);
|
||||
this.drawGradientRect(j2 - 3, k2 + maxHeight + 2, j2 + maxWidth + 3, k2 + maxHeight + 3, l1, l1);
|
||||
|
||||
for (int i2 = 0; i2 < textLines.size(); ++i2) {
|
||||
String s1 = (String) textLines.get(i2);
|
||||
mc.fontRenderer.drawStringWithShadow(s1, j2, k2, -1);
|
||||
if (i2 == 0) {
|
||||
k2 += 2;
|
||||
}
|
||||
k2 += 10;
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
RenderHelper.enableStandardItemLighting();
|
||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
||||
}
|
||||
}
|
||||
@@ -300,6 +300,14 @@ public class GuiScrollWindow extends GuiScreen implements ITextfieldListener, IC
|
||||
button.drawHover(mouseX, mouseY, subGui);
|
||||
}
|
||||
}
|
||||
// Label hover: convert screen mouse to scroll-local coords for hit testing
|
||||
int localMouseX = mouseX - xPos;
|
||||
int localMouseY = (int) (mouseY - yPos + scrollY);
|
||||
for (GuiNpcLabel label : labels.values()) {
|
||||
if (!label.hoverableText.isEmpty()) {
|
||||
label.drawHover(localMouseX, localMouseY, mouseX, mouseY, subGui, fontRendererObj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void elementClicked() {
|
||||
|
||||
Reference in new issue
Block a user