OMG janino-scripts-final merge

This commit is contained in:
bigguy345 committed 2026-01-23 19:01:56 +02:00
commit 96239118e7
200 files changed
+10048 -6771

No files matched your search

-3
View File
@@ -31,9 +31,6 @@ public class Market {
NBTTagCompound roleCompound = r.writeNBT(new NBTTagCompound());
roleCompound.setString("SaveName", name);
putMarketCache(name, roleCompound);
if (r.recordHistory)
return;
saveFile(roleCompound);
}
@@ -1,6 +1,5 @@
package kamkeel.npcs.controllers;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.data.profile.CNPCData;
import kamkeel.npcs.controllers.data.profile.EnumProfileOperation;
import kamkeel.npcs.controllers.data.profile.IProfileData;
@@ -2,9 +2,9 @@ package kamkeel.npcs.controllers;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.addon.DBCAddon;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import kamkeel.npcs.addon.DBCAddon;
import kamkeel.npcs.network.LargeAbstractPacket;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumSyncAction;
@@ -15,8 +15,8 @@ import noppes.npcs.DataAbilities;
import noppes.npcs.NpcDamageSource;
import noppes.npcs.api.INbt;
import noppes.npcs.api.ability.IAbility;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.AbilityEvent;
@@ -89,33 +89,46 @@ public abstract class Ability implements IAbility {
// ABSTRACT METHODS
// ═══════════════════════════════════════════════════════════════════
/** Called first tick of ACTIVE phase */
/**
* Called first tick of ACTIVE phase
*/
public abstract void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world);
/** Called every tick of ACTIVE phase */
/**
* Called every tick of ACTIVE phase
*/
public abstract void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick);
/** Write type-specific config to NBT */
/**
* Write type-specific config to NBT
*/
public abstract void writeTypeNBT(NBTTagCompound nbt);
/** Read type-specific config from NBT */
/**
* Read type-specific config from NBT
*/
public abstract void readTypeNBT(NBTTagCompound nbt);
// ═══════════════════════════════════════════════════════════════════
// OPTIONAL OVERRIDES
// ═══════════════════════════════════════════════════════════════════
public void onWindUpTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {}
public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {}
public void onComplete(EntityNPCInterface npc, EntityLivingBase target) {}
public void onWindUpTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
}
public void onInterrupt(EntityNPCInterface npc, DamageSource source, float damage) {
}
public void onComplete(EntityNPCInterface npc, EntityLivingBase target) {
}
/**
* Apply damage to an entity with ability hit event support.
* Fires the abilityHit script event, allowing scripts to modify or cancel the damage.
*
* @param npc The NPC executing the ability
* @param npc The NPC executing the ability
* @param hitEntity The entity being hit
* @param damage The damage amount
* @param damage The damage amount
* @param knockback The horizontal knockback
* @return true if damage was applied (not cancelled), false if cancelled
*/
@@ -160,17 +173,17 @@ public abstract class Ability implements IAbility {
* Apply damage to an entity with ability hit event support and custom knockback direction.
* Fires the abilityHit script event, allowing scripts to modify or cancel the damage.
*
* @param npc The NPC executing the ability
* @param hitEntity The entity being hit
* @param damage The damage amount
* @param knockback The horizontal knockback
* @param npc The NPC executing the ability
* @param hitEntity The entity being hit
* @param damage The damage amount
* @param knockback The horizontal knockback
* @param knockbackDirX The X component of knockback direction (normalized)
* @param knockbackDirZ The Z component of knockback direction (normalized)
* @return true if damage was applied (not cancelled), false if cancelled
*/
protected boolean applyAbilityDamageWithDirection(EntityNPCInterface npc, EntityLivingBase hitEntity,
float damage, float knockback,
double knockbackDirX, double knockbackDirZ) {
float damage, float knockback,
double knockbackDirX, double knockbackDirZ) {
DataAbilities dataAbilities = npc.abilities;
AbilityEvent.HitEvent event = dataAbilities.fireHitEvent(
this, currentTarget, hitEntity, damage, knockback, 0.0f);
@@ -206,53 +219,77 @@ public abstract class Ability implements IAbility {
hitEntity.addVelocity(x, 0.1D, z);
hitEntity.velocityChanged = true;
}
public float getTelegraphRadius() { return 5.0f; }
public float getTelegraphLength() { return 5.0f; }
public float getTelegraphWidth() { return 2.0f; }
public float getTelegraphAngle() { return 45.0f; }
public float getTelegraphRadius() {
return 5.0f;
}
public float getTelegraphLength() {
return 5.0f;
}
public float getTelegraphWidth() {
return 2.0f;
}
public float getTelegraphAngle() {
return 45.0f;
}
/**
* Returns true if this ability controls NPC movement during ACTIVE phase.
* When true, AI pathfinding will be blocked during ability execution.
* Override in abilities that move the NPC (Charge, Dash, Slam, etc.)
*/
public boolean hasAbilityMovement() { return false; }
public boolean hasAbilityMovement() {
return false;
}
/**
* Returns true if the targeting mode for this ability type is locked and cannot be changed.
* Most abilities have fixed targeting (e.g., Heal is always SELF, Charge is always AGGRO_TARGET).
* Override and return false for abilities with flexible targeting.
*/
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
/**
* Returns the allowed targeting modes for this ability, or null if all modes are allowed.
* Override in abilities that only support specific targeting modes.
*/
public TargetingMode[] getAllowedTargetingModes() { return null; }
public TargetingMode[] getAllowedTargetingModes() {
return null;
}
/**
* Returns true if the telegraph type for this ability is locked and cannot be changed.
* Telegraph type is inherent to how the ability works (e.g., Charge uses LINE, Slam uses CIRCLE).
*/
public boolean isTelegraphTypeLocked() { return true; }
public boolean isTelegraphTypeLocked() {
return true;
}
/**
* Returns true if this ability type has custom settings that need a Type-specific tab.
* Override to return true if the ability has settings beyond the base Ability fields.
*/
public boolean hasTypeSettings() { return false; }
public boolean hasTypeSettings() {
return false;
}
/**
* Get the number of rows needed for type-specific settings in the GUI.
* Each row is approximately 24 pixels. Used for GUI layout.
*/
public int getTypeSettingsRowCount() { return 0; }
public int getTypeSettingsRowCount() {
return 0;
}
/**
* Creates the GUI for configuring this ability.
* Override this method to provide a custom GUI subclass for type-specific settings.
*
* <p>
* Third-party mods can extend SubGuiAbilityConfig and override initTypeTab(),
* handleTypeButton(), and handleTypeTextField() to provide custom type settings.
*
@@ -268,7 +305,7 @@ public abstract class Ability implements IAbility {
* Create a telegraph instance for this ability.
* Override for custom telegraph shapes.
*
* @param npc The caster
* @param npc The caster
* @param target The target (for position calculation)
* @return The telegraph instance, or null if no telegraph
*/
@@ -283,9 +320,9 @@ public abstract class Ability implements IAbility {
// Determine position based on targeting mode
boolean positionAtNpc = targetingMode == TargetingMode.AOE_SELF ||
targetingMode == TargetingMode.SELF ||
telegraphType == TelegraphType.LINE ||
telegraphType == TelegraphType.CONE;
targetingMode == TargetingMode.SELF ||
telegraphType == TelegraphType.LINE ||
telegraphType == TelegraphType.CONE;
if (positionAtNpc) {
x = npc.posX;
@@ -347,10 +384,10 @@ public abstract class Ability implements IAbility {
* Find the ground level at a given position.
* Searches downward from the given Y to find a solid block.
*
* @param world The world
* @param x X coordinate
* @param world The world
* @param x X coordinate
* @param startY Starting Y coordinate (entity feet position)
* @param z Z coordinate
* @param z Z coordinate
* @return The Y coordinate of the ground surface
*/
protected double findGroundLevel(World world, double x, double startY, double z) {
@@ -391,7 +428,9 @@ public abstract class Ability implements IAbility {
// EXECUTION LOGIC (called by CombatHandler)
// ═══════════════════════════════════════════════════════════════════
/** Start executing this ability */
/**
* Start executing this ability
*/
public void start(EntityLivingBase target) {
this.phase = AbilityPhase.WINDUP;
this.currentTick = 0;
@@ -399,7 +438,9 @@ public abstract class Ability implements IAbility {
this.executionStartTime = System.currentTimeMillis();
}
/** Tick the ability. Returns true if phase changed. */
/**
* Tick the ability. Returns true if phase changed.
*/
public boolean tick() {
if (phase == AbilityPhase.IDLE) return false;
@@ -432,7 +473,9 @@ public abstract class Ability implements IAbility {
return false;
}
/** Interrupt this ability */
/**
* Interrupt this ability
*/
public void interrupt() {
phase = AbilityPhase.IDLE;
currentTick = 0;
@@ -440,17 +483,23 @@ public abstract class Ability implements IAbility {
telegraphInstance = null;
}
/** Start cooldown timer */
/**
* Start cooldown timer
*/
public void startCooldown() {
cooldownEndTime = System.currentTimeMillis() + (cooldownTicks * 50L);
}
/** Check if on cooldown */
/**
* Check if on cooldown
*/
public boolean isOnCooldown() {
return System.currentTimeMillis() < cooldownEndTime;
}
/** Check if executing */
/**
* Check if executing
*/
public boolean isExecuting() {
return phase != AbilityPhase.IDLE;
}
@@ -487,7 +536,9 @@ public abstract class Ability implements IAbility {
return true;
}
/** Reset all execution state (called on combat end) */
/**
* Reset all execution state (called on combat end)
*/
public void reset() {
phase = AbilityPhase.IDLE;
currentTick = 0;
@@ -507,7 +558,9 @@ public abstract class Ability implements IAbility {
return true;
}
/** Full eligibility check */
/**
* Full eligibility check
*/
public boolean canUse(EntityNPCInterface npc, EntityLivingBase target) {
if (!enabled) return false;
if (isOnCooldown()) return false;
@@ -634,110 +687,266 @@ public abstract class Ability implements IAbility {
// GETTERS & SETTERS
// ═══════════════════════════════════════════════════════════════════
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getId() {
return id;
}
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public void setId(String id) {
this.id = id;
}
public String getTypeId() { return typeId; }
public String getName() {
return name;
}
public int getWeight() { return weight; }
public void setWeight(int weight) { this.weight = weight; }
public void setName(String name) {
this.name = name;
}
public boolean isEnabled() { return enabled; }
public void setEnabled(boolean enabled) { this.enabled = enabled; }
public String getTypeId() {
return typeId;
}
public TargetingMode getTargetingMode() { return targetingMode; }
public void setTargetingMode(TargetingMode targetingMode) { this.targetingMode = targetingMode; }
public int getWeight() {
return weight;
}
public float getMinRange() { return minRange; }
public void setMinRange(float minRange) { this.minRange = minRange; }
public void setWeight(int weight) {
this.weight = weight;
}
public float getMaxRange() { return maxRange; }
public void setMaxRange(float maxRange) { this.maxRange = maxRange; }
public boolean isEnabled() {
return enabled;
}
public int getCooldownTicks() { return cooldownTicks; }
public void setCooldownTicks(int cooldownTicks) { this.cooldownTicks = cooldownTicks; }
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public int getWindUpTicks() { return windUpTicks; }
public void setWindUpTicks(int windUpTicks) { this.windUpTicks = windUpTicks; }
public TargetingMode getTargetingMode() {
return targetingMode;
}
public int getActiveTicks() { return activeTicks; }
public void setActiveTicks(int activeTicks) { this.activeTicks = activeTicks; }
public void setTargetingMode(TargetingMode targetingMode) {
this.targetingMode = targetingMode;
}
public int getRecoveryTicks() { return recoveryTicks; }
public void setRecoveryTicks(int recoveryTicks) { this.recoveryTicks = recoveryTicks; }
public float getMinRange() {
return minRange;
}
public boolean isInterruptible() { return interruptible; }
public void setInterruptible(boolean interruptible) { this.interruptible = interruptible; }
public void setMinRange(float minRange) {
this.minRange = minRange;
}
public boolean isLockMovement() { return lockMovement; }
public void setLockMovement(boolean lockMovement) { this.lockMovement = lockMovement; }
public float getMaxRange() {
return maxRange;
}
public int getWindUpColor() { return windUpColor; }
public void setWindUpColor(int windUpColor) { this.windUpColor = windUpColor; }
public void setMaxRange(float maxRange) {
this.maxRange = maxRange;
}
public int getActiveColor() { return activeColor; }
public void setActiveColor(int activeColor) { this.activeColor = activeColor; }
public int getCooldownTicks() {
return cooldownTicks;
}
/** @deprecated Use getWindUpColor() instead */
public void setCooldownTicks(int cooldownTicks) {
this.cooldownTicks = cooldownTicks;
}
public int getWindUpTicks() {
return windUpTicks;
}
public void setWindUpTicks(int windUpTicks) {
this.windUpTicks = windUpTicks;
}
public int getActiveTicks() {
return activeTicks;
}
public void setActiveTicks(int activeTicks) {
this.activeTicks = activeTicks;
}
public int getRecoveryTicks() {
return recoveryTicks;
}
public void setRecoveryTicks(int recoveryTicks) {
this.recoveryTicks = recoveryTicks;
}
public boolean isInterruptible() {
return interruptible;
}
public void setInterruptible(boolean interruptible) {
this.interruptible = interruptible;
}
public boolean isLockMovement() {
return lockMovement;
}
public void setLockMovement(boolean lockMovement) {
this.lockMovement = lockMovement;
}
public int getWindUpColor() {
return windUpColor;
}
public void setWindUpColor(int windUpColor) {
this.windUpColor = windUpColor;
}
public int getActiveColor() {
return activeColor;
}
public void setActiveColor(int activeColor) {
this.activeColor = activeColor;
}
/**
* @deprecated Use getWindUpColor() instead
*/
@Deprecated
public int getTelegraphColor() { return windUpColor; }
/** @deprecated Use setWindUpColor() instead */
public int getTelegraphColor() {
return windUpColor;
}
/**
* @deprecated Use setWindUpColor() instead
*/
@Deprecated
public void setTelegraphColor(int telegraphColor) { this.windUpColor = telegraphColor; }
public void setTelegraphColor(int telegraphColor) {
this.windUpColor = telegraphColor;
}
public String getWindUpSound() { return windUpSound; }
public void setWindUpSound(String windUpSound) { this.windUpSound = windUpSound; }
public String getWindUpSound() {
return windUpSound;
}
public String getActiveSound() { return activeSound; }
public void setActiveSound(String activeSound) { this.activeSound = activeSound; }
public void setWindUpSound(String windUpSound) {
this.windUpSound = windUpSound;
}
public int getWindUpAnimationId() { return windUpAnimationId; }
public void setWindUpAnimationId(int windUpAnimationId) { this.windUpAnimationId = windUpAnimationId; }
public String getActiveSound() {
return activeSound;
}
public int getActiveAnimationId() { return activeAnimationId; }
public void setActiveAnimationId(int activeAnimationId) { this.activeAnimationId = activeAnimationId; }
public void setActiveSound(String activeSound) {
this.activeSound = activeSound;
}
/** @deprecated Use getWindUpSound() instead */
public int getWindUpAnimationId() {
return windUpAnimationId;
}
public void setWindUpAnimationId(int windUpAnimationId) {
this.windUpAnimationId = windUpAnimationId;
}
public int getActiveAnimationId() {
return activeAnimationId;
}
public void setActiveAnimationId(int activeAnimationId) {
this.activeAnimationId = activeAnimationId;
}
/**
* @deprecated Use getWindUpSound() instead
*/
@Deprecated
public String getCastSound() { return windUpSound; }
/** @deprecated Use setWindUpSound() instead */
public String getCastSound() {
return windUpSound;
}
/**
* @deprecated Use setWindUpSound() instead
*/
@Deprecated
public void setCastSound(String castSound) { this.windUpSound = castSound; }
public void setCastSound(String castSound) {
this.windUpSound = castSound;
}
/** @deprecated Use getWindUpAnimationId() instead */
/**
* @deprecated Use getWindUpAnimationId() instead
*/
@Deprecated
public int getAnimationId() { return windUpAnimationId; }
/** @deprecated Use setWindUpAnimationId() instead */
public int getAnimationId() {
return windUpAnimationId;
}
/**
* @deprecated Use setWindUpAnimationId() instead
*/
@Deprecated
public void setAnimationId(int animationId) { this.windUpAnimationId = animationId; }
public void setAnimationId(int animationId) {
this.windUpAnimationId = animationId;
}
public boolean isShowTelegraph() { return showTelegraph; }
public void setShowTelegraph(boolean showTelegraph) { this.showTelegraph = showTelegraph; }
public boolean isShowTelegraph() {
return showTelegraph;
}
public TelegraphType getTelegraphType() { return telegraphType; }
public void setTelegraphType(TelegraphType telegraphType) { this.telegraphType = telegraphType; }
public void setShowTelegraph(boolean showTelegraph) {
this.showTelegraph = showTelegraph;
}
public float getTelegraphHeightOffset() { return telegraphHeightOffset; }
public void setTelegraphHeightOffset(float telegraphHeightOffset) { this.telegraphHeightOffset = telegraphHeightOffset; }
public TelegraphType getTelegraphType() {
return telegraphType;
}
public AbilityPhase getPhase() { return phase; }
public void setTelegraphType(TelegraphType telegraphType) {
this.telegraphType = telegraphType;
}
public float getTelegraphHeightOffset() {
return telegraphHeightOffset;
}
public void setTelegraphHeightOffset(float telegraphHeightOffset) {
this.telegraphHeightOffset = telegraphHeightOffset;
}
public AbilityPhase getPhase() {
return phase;
}
/**
* Get the current execution phase as int (0=IDLE, 1=WINDUP, 2=ACTIVE, 3=RECOVERY).
* Required for IAbility interface.
*/
@Override
public int getPhaseInt() { return phase.ordinal(); }
public int getPhaseInt() {
return phase.ordinal();
}
public int getCurrentTick() { return currentTick; }
public EntityLivingBase getCurrentTarget() { return currentTarget; }
public NBTTagCompound getCustomData() { return customData; }
public int getCurrentTick() {
return currentTick;
}
public List<Condition> getConditions() { return conditions; }
public void addCondition(Condition c) { conditions.add(c); }
public EntityLivingBase getCurrentTarget() {
return currentTarget;
}
public NBTTagCompound getCustomData() {
return customData;
}
public List<Condition> getConditions() {
return conditions;
}
public void addCondition(Condition c) {
conditions.add(c);
}
// ═══════════════════════════════════════════════════════════════════
// IAbility API METHODS
@@ -1,6 +1,20 @@
package kamkeel.npcs.controllers.data.ability;
import kamkeel.npcs.controllers.data.ability.type.*;
import kamkeel.npcs.controllers.data.ability.type.AbilityBeam;
import kamkeel.npcs.controllers.data.ability.type.AbilityCharge;
import kamkeel.npcs.controllers.data.ability.type.AbilityCutter;
import kamkeel.npcs.controllers.data.ability.type.AbilityDash;
import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
import kamkeel.npcs.controllers.data.ability.type.AbilityHazard;
import kamkeel.npcs.controllers.data.ability.type.AbilityHeal;
import kamkeel.npcs.controllers.data.ability.type.AbilityHeavyHit;
import kamkeel.npcs.controllers.data.ability.type.AbilityOrb;
import kamkeel.npcs.controllers.data.ability.type.AbilityProjectile;
import kamkeel.npcs.controllers.data.ability.type.AbilityShockwave;
import kamkeel.npcs.controllers.data.ability.type.AbilitySlam;
import kamkeel.npcs.controllers.data.ability.type.AbilityTeleport;
import kamkeel.npcs.controllers.data.ability.type.AbilityTrap;
import kamkeel.npcs.controllers.data.ability.type.AbilityVortex;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
@@ -8,13 +22,17 @@ import noppes.npcs.api.handler.IAbilityHandler;
import noppes.npcs.util.NBTJsonUtil;
import java.io.File;
import java.util.*;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
/**
* Controller for ability types. Allows external mods to register custom ability types.
* Initialize during FMLInitializationEvent.
*
* <p>
* Also manages saved ability presets that can be reused across NPCs.
*/
public class AbilityController implements IAbilityHandler {
@@ -211,7 +229,7 @@ public class AbilityController implements IAbilityHandler {
* Call during FMLInitializationEvent.
*
* @param factoryKey The factory key (e.g., "cnpc:slam", "mymod:custom_ability")
* @param factory Factory lambda that creates a new instance
* @param factory Factory lambda that creates a new instance
*/
public void registerType(String factoryKey, Supplier<Ability> factory) {
if (factories.containsKey(factoryKey)) {
@@ -252,6 +270,7 @@ public class AbilityController implements IAbilityHandler {
/**
* Create a new empty ability of the given type.
*
* @param factoryKey The factory key (e.g., "cnpc:slam") or the ability typeId (e.g., "ability.cnpc.slam")
*/
public Ability create(String factoryKey) {
@@ -13,7 +13,7 @@ public interface Condition {
/**
* Check if this condition is met.
*
* @param npc The NPC that would use the ability
* @param npc The NPC that would use the ability
* @param target The current target (may be null for self-targeting abilities)
* @return true if the condition is satisfied
*/
@@ -80,7 +80,8 @@ public interface Condition {
class ConditionHPAbove implements Condition {
private float threshold = 0.5f; // 50%
public ConditionHPAbove() {}
public ConditionHPAbove() {
}
public ConditionHPAbove(float threshold) {
this.threshold = threshold;
@@ -92,7 +93,9 @@ public interface Condition {
}
@Override
public String getTypeId() { return "hp_above"; }
public String getTypeId() {
return "hp_above";
}
@Override
public NBTTagCompound writeNBT() {
@@ -114,7 +117,8 @@ public interface Condition {
class ConditionHPBelow implements Condition {
private float threshold = 0.5f;
public ConditionHPBelow() {}
public ConditionHPBelow() {
}
public ConditionHPBelow(float threshold) {
this.threshold = threshold;
@@ -126,7 +130,9 @@ public interface Condition {
}
@Override
public String getTypeId() { return "hp_below"; }
public String getTypeId() {
return "hp_below";
}
@Override
public NBTTagCompound writeNBT() {
@@ -148,7 +154,8 @@ public interface Condition {
class ConditionTargetHPAbove implements Condition {
private float threshold = 0.5f;
public ConditionTargetHPAbove() {}
public ConditionTargetHPAbove() {
}
public ConditionTargetHPAbove(float threshold) {
this.threshold = threshold;
@@ -161,7 +168,9 @@ public interface Condition {
}
@Override
public String getTypeId() { return "target_hp_above"; }
public String getTypeId() {
return "target_hp_above";
}
@Override
public NBTTagCompound writeNBT() {
@@ -183,7 +192,8 @@ public interface Condition {
class ConditionTargetHPBelow implements Condition {
private float threshold = 0.5f;
public ConditionTargetHPBelow() {}
public ConditionTargetHPBelow() {
}
public ConditionTargetHPBelow(float threshold) {
this.threshold = threshold;
@@ -196,7 +206,9 @@ public interface Condition {
}
@Override
public String getTypeId() { return "target_hp_below"; }
public String getTypeId() {
return "target_hp_below";
}
@Override
public NBTTagCompound writeNBT() {
@@ -220,7 +232,8 @@ public interface Condition {
private int requiredHits = 3;
private int withinTicks = 60;
public ConditionHitCount() {}
public ConditionHitCount() {
}
public ConditionHitCount(int requiredHits, int withinTicks) {
this.requiredHits = requiredHits;
@@ -237,7 +250,9 @@ public interface Condition {
}
@Override
public String getTypeId() { return "hit_count"; }
public String getTypeId() {
return "hit_count";
}
@Override
public NBTTagCompound writeNBT() {
@@ -254,10 +269,20 @@ public interface Condition {
withinTicks = nbt.getInteger("withinTicks");
}
public int getRequiredHits() { return requiredHits; }
public void setRequiredHits(int hits) { this.requiredHits = hits; }
public int getRequiredHits() {
return requiredHits;
}
public int getWithinTicks() { return withinTicks; }
public void setWithinTicks(int ticks) { this.withinTicks = ticks; }
public void setRequiredHits(int hits) {
this.requiredHits = hits;
}
public int getWithinTicks() {
return withinTicks;
}
public void setWithinTicks(int ticks) {
this.withinTicks = ticks;
}
}
}
@@ -4,24 +4,38 @@ package kamkeel.npcs.controllers.data.ability;
* Defines how an ability selects its target(s).
*/
public enum TargetingMode {
/** Target the current aggro target */
/**
* Target the current aggro target
*/
AGGRO_TARGET,
/** Target self (for buffs, heals, guards) */
/**
* Target self (for buffs, heals, guards)
*/
SELF,
/** AOE centered on self */
/**
* AOE centered on self
*/
AOE_SELF,
/** AOE centered on target */
/**
* AOE centered on target
*/
AOE_TARGET,
/** Random nearby enemy */
/**
* Random nearby enemy
*/
RANDOM_ENEMY,
/** Lowest HP enemy in range */
/**
* Lowest HP enemy in range
*/
LOWEST_HP,
/** Highest threat enemy */
/**
* Highest threat enemy
*/
HIGHEST_THREAT
}
@@ -35,7 +35,8 @@ public class Telegraph {
private boolean followsCaster = false;
private float offsetForward = 0.0f;
public Telegraph() {}
public Telegraph() {
}
public Telegraph(String id, TelegraphType type) {
this.id = id;
@@ -149,54 +150,139 @@ public class Telegraph {
// GETTERS & SETTERS
// ═══════════════════════════════════════════════════════════════════
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getId() {
return id;
}
public TelegraphType getType() { return type; }
public void setType(TelegraphType type) { this.type = type; }
public void setId(String id) {
this.id = id;
}
public float getRadius() { return radius; }
public void setRadius(float radius) { this.radius = radius; }
public TelegraphType getType() {
return type;
}
public float getInnerRadius() { return innerRadius; }
public void setInnerRadius(float innerRadius) { this.innerRadius = innerRadius; }
public void setType(TelegraphType type) {
this.type = type;
}
public float getLength() { return length; }
public void setLength(float length) { this.length = length; }
public float getRadius() {
return radius;
}
public float getWidth() { return width; }
public void setWidth(float width) { this.width = width; }
public void setRadius(float radius) {
this.radius = radius;
}
public float getAngle() { return angle; }
public void setAngle(float angle) { this.angle = angle; }
public float getInnerRadius() {
return innerRadius;
}
public int getDurationTicks() { return durationTicks; }
public void setDurationTicks(int durationTicks) { this.durationTicks = durationTicks; }
public void setInnerRadius(float innerRadius) {
this.innerRadius = innerRadius;
}
public int getColor() { return color; }
public void setColor(int color) { this.color = color; }
public float getLength() {
return length;
}
public int getWarningColor() { return warningColor; }
public void setWarningColor(int warningColor) { this.warningColor = warningColor; }
public void setLength(float length) {
this.length = length;
}
public int getWarningStartTick() { return warningStartTick; }
public void setWarningStartTick(int warningStartTick) { this.warningStartTick = warningStartTick; }
public float getWidth() {
return width;
}
public boolean isAnimated() { return animated; }
public void setAnimated(boolean animated) { this.animated = animated; }
public void setWidth(float width) {
this.width = width;
}
public float getHeightOffset() { return heightOffset; }
public void setHeightOffset(float heightOffset) { this.heightOffset = heightOffset; }
public float getAngle() {
return angle;
}
public boolean isAtTarget() { return atTarget; }
public void setAtTarget(boolean atTarget) { this.atTarget = atTarget; }
public void setAngle(float angle) {
this.angle = angle;
}
public boolean isFollowsTarget() { return followsTarget; }
public void setFollowsTarget(boolean followsTarget) { this.followsTarget = followsTarget; }
public int getDurationTicks() {
return durationTicks;
}
public boolean isFollowsCaster() { return followsCaster; }
public void setFollowsCaster(boolean followsCaster) { this.followsCaster = followsCaster; }
public void setDurationTicks(int durationTicks) {
this.durationTicks = durationTicks;
}
public float getOffsetForward() { return offsetForward; }
public void setOffsetForward(float offsetForward) { this.offsetForward = offsetForward; }
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public int getWarningColor() {
return warningColor;
}
public void setWarningColor(int warningColor) {
this.warningColor = warningColor;
}
public int getWarningStartTick() {
return warningStartTick;
}
public void setWarningStartTick(int warningStartTick) {
this.warningStartTick = warningStartTick;
}
public boolean isAnimated() {
return animated;
}
public void setAnimated(boolean animated) {
this.animated = animated;
}
public float getHeightOffset() {
return heightOffset;
}
public void setHeightOffset(float heightOffset) {
this.heightOffset = heightOffset;
}
public boolean isAtTarget() {
return atTarget;
}
public void setAtTarget(boolean atTarget) {
this.atTarget = atTarget;
}
public boolean isFollowsTarget() {
return followsTarget;
}
public void setFollowsTarget(boolean followsTarget) {
this.followsTarget = followsTarget;
}
public boolean isFollowsCaster() {
return followsCaster;
}
public void setFollowsCaster(boolean followsCaster) {
this.followsCaster = followsCaster;
}
public float getOffsetForward() {
return offsetForward;
}
public void setOffsetForward(float offsetForward) {
this.offsetForward = offsetForward;
}
}
@@ -55,6 +55,7 @@ public class TelegraphInstance {
/**
* Called every tick to update telegraph state.
*
* @param world The world (for entity lookup)
* @return false if telegraph should be removed
*/
@@ -90,10 +91,10 @@ public class TelegraphInstance {
* Find the ground level at a given position.
* Searches downward from the given Y to find a solid block.
*
* @param world The world
* @param x X coordinate
* @param world The world
* @param x X coordinate
* @param startY Starting Y coordinate (entity feet position)
* @param z Z coordinate
* @param z Z coordinate
* @return The Y coordinate of the ground surface
*/
private double findGroundLevel(World world, double x, double startY, double z) {
@@ -207,42 +208,99 @@ public class TelegraphInstance {
// GETTERS & SETTERS
// ═══════════════════════════════════════════════════════════════════
public String getInstanceId() { return instanceId; }
public void setInstanceId(String instanceId) { this.instanceId = instanceId; }
public String getInstanceId() {
return instanceId;
}
public Telegraph getTelegraph() { return telegraph; }
public void setTelegraph(Telegraph telegraph) { this.telegraph = telegraph; }
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
public double getX() { return x; }
public void setX(double x) { this.x = x; }
public Telegraph getTelegraph() {
return telegraph;
}
public double getY() { return y; }
public void setY(double y) { this.y = y; }
public void setTelegraph(Telegraph telegraph) {
this.telegraph = telegraph;
}
public double getZ() { return z; }
public void setZ(double z) { this.z = z; }
public double getX() {
return x;
}
public float getYaw() { return yaw; }
public void setYaw(float yaw) { this.yaw = yaw; }
public void setX(double x) {
this.x = x;
}
public int getEntityIdToFollow() { return entityIdToFollow; }
public void setEntityIdToFollow(int entityIdToFollow) { this.entityIdToFollow = entityIdToFollow; }
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
public float getYaw() {
return yaw;
}
public void setYaw(float yaw) {
this.yaw = yaw;
}
public int getEntityIdToFollow() {
return entityIdToFollow;
}
public void setEntityIdToFollow(int entityIdToFollow) {
this.entityIdToFollow = entityIdToFollow;
}
/**
* Locks the telegraph at its current position.
* Stops following any entity - used when ability commits to action.
*/
public void lockPosition() { this.entityIdToFollow = -1; }
public void lockPosition() {
this.entityIdToFollow = -1;
}
public int getCasterEntityId() { return casterEntityId; }
public void setCasterEntityId(int casterEntityId) { this.casterEntityId = casterEntityId; }
public int getCasterEntityId() {
return casterEntityId;
}
public int getRemainingTicks() { return remainingTicks; }
public void setRemainingTicks(int remainingTicks) { this.remainingTicks = remainingTicks; }
public void setCasterEntityId(int casterEntityId) {
this.casterEntityId = casterEntityId;
}
public int getTotalTicks() { return totalTicks; }
public void setTotalTicks(int totalTicks) { this.totalTicks = totalTicks; }
public int getRemainingTicks() {
return remainingTicks;
}
public boolean isWarning() { return isWarning; }
public void setWarning(boolean warning) { isWarning = warning; }
public void setRemainingTicks(int remainingTicks) {
this.remainingTicks = remainingTicks;
}
public int getTotalTicks() {
return totalTicks;
}
public void setTotalTicks(int totalTicks) {
this.totalTicks = totalTicks;
}
public boolean isWarning() {
return isWarning;
}
public void setWarning(boolean warning) {
isWarning = warning;
}
}
@@ -12,12 +12,15 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class TelegraphManager {
/** Client-side instance for rendering */
/**
* Client-side instance for rendering
*/
public static TelegraphManager ClientInstance;
private final ConcurrentHashMap<String, TelegraphInstance> telegraphs = new ConcurrentHashMap<>();
public TelegraphManager() {}
public TelegraphManager() {
}
/**
* Initialize the client-side manager.
@@ -4,21 +4,33 @@ package kamkeel.npcs.controllers.data.ability.telegraph;
* Types of telegraph shapes for visual attack warnings.
*/
public enum TelegraphType {
/** Filled circle (uses radius) */
/**
* Filled circle (uses radius)
*/
CIRCLE,
/** Donut shape (uses radius and innerRadius) */
/**
* Donut shape (uses radius and innerRadius)
*/
RING,
/** Rectangle (uses length, width) */
/**
* Rectangle (uses length, width)
*/
LINE,
/** Fan/wedge shape (uses length, angle) */
/**
* Fan/wedge shape (uses length, angle)
*/
CONE,
/** Single point indicator */
/**
* Single point indicator
*/
POINT,
/** No telegraph */
/**
* No telegraph
*/
NONE
}
@@ -2,19 +2,17 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityBeam;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityBeam;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -61,21 +59,25 @@ public class AbilityBeam extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
IAbilityConfigCallback callback) {
IAbilityConfigCallback callback) {
return new SubGuiAbilityBeam(this, callback);
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -184,7 +186,7 @@ public class AbilityBeam extends Ability {
}
private boolean isInBeamPath(EntityLivingBase entity, double startX, double startY, double startZ,
double dirX, double dirZ) {
double dirX, double dirZ) {
// Project entity position onto beam line
double entityX = entity.posX - startX;
double entityZ = entity.posZ - startZ;
@@ -209,7 +211,7 @@ public class AbilityBeam extends Ability {
}
private void spawnBeamParticles(World world, double startX, double startY, double startZ,
double dirX, double dirZ) {
double dirX, double dirZ) {
// Spawn particles along beam line
for (int i = 0; i < beamLength; i++) {
double px = startX + dirX * i;
@@ -259,30 +261,75 @@ public class AbilityBeam extends Ability {
}
// Getters & Setters
public float getBeamLength() { return beamLength; }
public void setBeamLength(float beamLength) { this.beamLength = beamLength; }
public float getBeamLength() {
return beamLength;
}
public float getBeamWidth() { return beamWidth; }
public void setBeamWidth(float beamWidth) { this.beamWidth = beamWidth; }
public void setBeamLength(float beamLength) {
this.beamLength = beamLength;
}
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getBeamWidth() {
return beamWidth;
}
public int getDamageInterval() { return damageInterval; }
public void setDamageInterval(int damageInterval) { this.damageInterval = damageInterval; }
public void setBeamWidth(float beamWidth) {
this.beamWidth = beamWidth;
}
public boolean isPiercing() { return piercing; }
public void setPiercing(boolean piercing) { this.piercing = piercing; }
public float getDamage() {
return damage;
}
public float getSweepAngle() { return sweepAngle; }
public void setSweepAngle(float sweepAngle) { this.sweepAngle = sweepAngle; }
public void setDamage(float damage) {
this.damage = damage;
}
public float getSweepSpeed() { return sweepSpeed; }
public void setSweepSpeed(float sweepSpeed) { this.sweepSpeed = sweepSpeed; }
public int getDamageInterval() {
return damageInterval;
}
public boolean isSweepBackAndForth() { return sweepBackAndForth; }
public void setSweepBackAndForth(boolean sweepBackAndForth) { this.sweepBackAndForth = sweepBackAndForth; }
public void setDamageInterval(int damageInterval) {
this.damageInterval = damageInterval;
}
public boolean isLockOnTarget() { return lockOnTarget; }
public void setLockOnTarget(boolean lockOnTarget) { this.lockOnTarget = lockOnTarget; }
public boolean isPiercing() {
return piercing;
}
public void setPiercing(boolean piercing) {
this.piercing = piercing;
}
public float getSweepAngle() {
return sweepAngle;
}
public void setSweepAngle(float sweepAngle) {
this.sweepAngle = sweepAngle;
}
public float getSweepSpeed() {
return sweepSpeed;
}
public void setSweepSpeed(float sweepSpeed) {
this.sweepSpeed = sweepSpeed;
}
public boolean isSweepBackAndForth() {
return sweepBackAndForth;
}
public void setSweepBackAndForth(boolean sweepBackAndForth) {
this.sweepBackAndForth = sweepBackAndForth;
}
public boolean isLockOnTarget() {
return lockOnTarget;
}
public void setLockOnTarget(boolean lockOnTarget) {
this.lockOnTarget = lockOnTarget;
}
}
@@ -11,12 +11,11 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityCharge;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -59,7 +58,9 @@ public class AbilityCharge extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
@@ -68,11 +69,13 @@ public class AbilityCharge extends Ability {
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -150,7 +153,7 @@ public class AbilityCharge extends Ability {
// Calculate distance traveled
double distanceTraveled = Math.sqrt(
Math.pow(npc.posX - startX, 2) +
Math.pow(npc.posZ - startZ, 2)
Math.pow(npc.posZ - startZ, 2)
);
// Check if reached max distance
@@ -305,15 +308,35 @@ public class AbilityCharge extends Ability {
}
// Getters & Setters
public float getChargeSpeed() { return chargeSpeed; }
public void setChargeSpeed(float chargeSpeed) { this.chargeSpeed = chargeSpeed; }
public float getChargeSpeed() {
return chargeSpeed;
}
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public void setChargeSpeed(float chargeSpeed) {
this.chargeSpeed = chargeSpeed;
}
public float getKnockback() { return knockback; }
public void setKnockback(float knockback) { this.knockback = knockback; }
public float getDamage() {
return damage;
}
public float getHitWidth() { return hitWidth; }
public void setHitWidth(float hitWidth) { this.hitWidth = hitWidth; }
public void setDamage(float damage) {
this.damage = damage;
}
public float getKnockback() {
return knockback;
}
public void setKnockback(float knockback) {
this.knockback = knockback;
}
public float getHitWidth() {
return hitWidth;
}
public void setHitWidth(float hitWidth) {
this.hitWidth = hitWidth;
}
}
@@ -12,9 +12,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityCutter;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -67,7 +67,9 @@ public class AbilityCutter extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
@@ -76,21 +78,29 @@ public class AbilityCutter extends Ability {
}
@Override
public boolean isTargetingModeLocked() { return true; }
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AOE_SELF };
public boolean isTargetingModeLocked() {
return true;
}
@Override
public float getTelegraphRadius() { return range; }
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[]{TargetingMode.AOE_SELF};
}
@Override
public float getTelegraphLength() { return range; }
public float getTelegraphRadius() {
return range;
}
@Override
public float getTelegraphAngle() { return arcAngle; }
public float getTelegraphLength() {
return range;
}
@Override
public float getTelegraphAngle() {
return arcAngle;
}
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
@@ -145,7 +155,7 @@ public class AbilityCutter extends Ability {
hitEntities.add(entity.getEntityId());
float distFactor = 1.0f - ((float)dist / maxDist) * 0.3f;
float distFactor = 1.0f - ((float) dist / maxDist) * 0.3f;
float actualDamage = damage * distFactor;
// Apply damage with scripted event support
@@ -223,38 +233,95 @@ public class AbilityCutter extends Ability {
}
// Getters & Setters
public float getArcAngle() { return arcAngle; }
public void setArcAngle(float arcAngle) { this.arcAngle = arcAngle; }
public float getArcAngle() {
return arcAngle;
}
public float getRange() { return range; }
public void setRange(float range) { this.range = range; }
public void setArcAngle(float arcAngle) {
this.arcAngle = arcAngle;
}
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getRange() {
return range;
}
public float getKnockback() { return knockback; }
public void setKnockback(float knockback) { this.knockback = knockback; }
public void setRange(float range) {
this.range = range;
}
public SweepMode getSweepMode() { return sweepMode; }
public void setSweepMode(SweepMode sweepMode) { this.sweepMode = sweepMode; }
public float getDamage() {
return damage;
}
public float getSweepSpeed() { return sweepSpeed; }
public void setSweepSpeed(float sweepSpeed) { this.sweepSpeed = sweepSpeed; }
public void setDamage(float damage) {
this.damage = damage;
}
public int getStunDuration() { return stunDuration; }
public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
public float getKnockback() {
return knockback;
}
public int getPoisonDurationSeconds() { return poisonDurationSeconds; }
public void setPoisonDurationSeconds(int poisonDurationSeconds) { this.poisonDurationSeconds = poisonDurationSeconds; }
public void setKnockback(float knockback) {
this.knockback = knockback;
}
public int getPoisonLevel() { return poisonLevel; }
public void setPoisonLevel(int poisonLevel) { this.poisonLevel = poisonLevel; }
public SweepMode getSweepMode() {
return sweepMode;
}
public boolean isPiercing() { return piercing; }
public void setPiercing(boolean piercing) { this.piercing = piercing; }
public void setSweepMode(SweepMode sweepMode) {
this.sweepMode = sweepMode;
}
public float getInnerRadius() { return innerRadius; }
public void setInnerRadius(float innerRadius) { this.innerRadius = innerRadius; }
public float getSweepSpeed() {
return sweepSpeed;
}
public float getCurrentRotation() { return currentRotation; }
public void setSweepSpeed(float sweepSpeed) {
this.sweepSpeed = sweepSpeed;
}
public int getStunDuration() {
return stunDuration;
}
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getPoisonDurationSeconds() {
return poisonDurationSeconds;
}
public void setPoisonDurationSeconds(int poisonDurationSeconds) {
this.poisonDurationSeconds = poisonDurationSeconds;
}
public int getPoisonLevel() {
return poisonLevel;
}
public void setPoisonLevel(int poisonLevel) {
this.poisonLevel = poisonLevel;
}
public boolean isPiercing() {
return piercing;
}
public void setPiercing(boolean piercing) {
this.piercing = piercing;
}
public float getInnerRadius() {
return innerRadius;
}
public void setInnerRadius(float innerRadius) {
this.innerRadius = innerRadius;
}
public float getCurrentRotation() {
return currentRotation;
}
}
@@ -2,17 +2,16 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDash;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
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.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityDash;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.Random;
@@ -100,21 +99,25 @@ public class AbilityDash extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
IAbilityConfigCallback callback) {
IAbilityConfigCallback callback) {
return new SubGuiAbilityDash(this, callback);
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -163,7 +166,7 @@ public class AbilityDash extends Ability {
// Calculate distance traveled
double distanceTraveled = Math.sqrt(
Math.pow(npc.posX - startX, 2) +
Math.pow(npc.posZ - startZ, 2)
Math.pow(npc.posZ - startZ, 2)
);
// Check if reached max distance
@@ -246,14 +249,31 @@ public class AbilityDash extends Ability {
}
// Getters & Setters
public DashMode getDashMode() { return dashMode; }
public void setDashMode(DashMode dashMode) { this.dashMode = dashMode; }
public DashMode getDashMode() {
return dashMode;
}
public float getDashDistance() { return dashDistance; }
public void setDashDistance(float dashDistance) { this.dashDistance = dashDistance; }
public void setDashMode(DashMode dashMode) {
this.dashMode = dashMode;
}
public float getDashSpeed() { return dashSpeed; }
public void setDashSpeed(float dashSpeed) { this.dashSpeed = dashSpeed; }
public float getDashDistance() {
return dashDistance;
}
public DashDirection getChosenDirection() { return chosenDirection; }
public void setDashDistance(float dashDistance) {
this.dashDistance = dashDistance;
}
public float getDashSpeed() {
return dashSpeed;
}
public void setDashSpeed(float dashSpeed) {
this.dashSpeed = dashSpeed;
}
public DashDirection getChosenDirection() {
return chosenDirection;
}
}
@@ -2,17 +2,16 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityGuard;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityGuard;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.Random;
@@ -62,21 +61,25 @@ public class AbilityGuard extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
IAbilityConfigCallback callback) {
IAbilityConfigCallback callback) {
return new SubGuiAbilityGuard(this, callback);
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.SELF };
return new TargetingMode[]{TargetingMode.SELF};
}
@Override
@@ -99,7 +102,7 @@ public class AbilityGuard extends Ability {
* This should be called from the damage handling code.
*
* @param attacker The entity that attacked
* @param damage The damage amount (after reduction)
* @param damage The damage amount (after reduction)
*/
public void onDamageTaken(EntityNPCInterface npc, EntityLivingBase attacker, DamageSource source, float damage) {
if (!canCounter || attacker == null) return;
@@ -212,24 +215,59 @@ public class AbilityGuard extends Ability {
}
// Getters & Setters
public float getDamageReduction() { return damageReduction; }
public void setDamageReduction(float damageReduction) { this.damageReduction = damageReduction; }
public float getDamageReduction() {
return damageReduction;
}
public boolean isCanCounter() { return canCounter; }
public void setCanCounter(boolean canCounter) { this.canCounter = canCounter; }
public void setDamageReduction(float damageReduction) {
this.damageReduction = damageReduction;
}
public CounterType getCounterType() { return counterType; }
public void setCounterType(CounterType counterType) { this.counterType = counterType; }
public boolean isCanCounter() {
return canCounter;
}
public float getCounterValue() { return counterValue; }
public void setCounterValue(float counterValue) { this.counterValue = counterValue; }
public void setCanCounter(boolean canCounter) {
this.canCounter = canCounter;
}
public float getCounterChance() { return counterChance; }
public void setCounterChance(float counterChance) { this.counterChance = counterChance; }
public CounterType getCounterType() {
return counterType;
}
public String getCounterSound() { return counterSound; }
public void setCounterSound(String counterSound) { this.counterSound = counterSound; }
public void setCounterType(CounterType counterType) {
this.counterType = counterType;
}
public int getCounterAnimationId() { return counterAnimationId; }
public void setCounterAnimationId(int counterAnimationId) { this.counterAnimationId = counterAnimationId; }
public float getCounterValue() {
return counterValue;
}
public void setCounterValue(float counterValue) {
this.counterValue = counterValue;
}
public float getCounterChance() {
return counterChance;
}
public void setCounterChance(float counterChance) {
this.counterChance = counterChance;
}
public String getCounterSound() {
return counterSound;
}
public void setCounterSound(String counterSound) {
this.counterSound = counterSound;
}
public int getCounterAnimationId() {
return counterAnimationId;
}
public void setCounterAnimationId(int counterAnimationId) {
this.counterAnimationId = counterAnimationId;
}
}
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHazard;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
@@ -17,6 +13,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHazard;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -90,25 +89,31 @@ public class AbilityHazard extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
IAbilityConfigCallback callback) {
IAbilityConfigCallback callback) {
return new SubGuiAbilityHazard(this, callback);
}
@Override
public boolean isTargetingModeLocked() { return true; }
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
public boolean isTargetingModeLocked() {
return true;
}
@Override
public float getTelegraphRadius() { return radius; }
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
public float getTelegraphRadius() {
return radius;
}
@Override
public TelegraphInstance createTelegraph(EntityNPCInterface npc, EntityLivingBase target) {
@@ -414,68 +419,176 @@ public class AbilityHazard extends Ability {
}
// Getters & Setters
public float getRadius() { return radius; }
public void setRadius(float radius) { this.radius = radius; }
public float getRadius() {
return radius;
}
public float getInnerRadius() { return innerRadius; }
public void setInnerRadius(float innerRadius) { this.innerRadius = innerRadius; }
public void setRadius(float radius) {
this.radius = radius;
}
public float getConeAngle() { return coneAngle; }
public void setConeAngle(float coneAngle) { this.coneAngle = coneAngle; }
public float getInnerRadius() {
return innerRadius;
}
public HazardShape getShape() { return shape; }
public void setShape(HazardShape shape) { this.shape = shape; }
public void setInnerRadius(float innerRadius) {
this.innerRadius = innerRadius;
}
public PlacementMode getPlacement() { return placement; }
public void setPlacement(PlacementMode placement) { this.placement = placement; }
public float getConeAngle() {
return coneAngle;
}
public float getDamagePerTick() { return damagePerTick; }
public void setDamagePerTick(float damagePerTick) { this.damagePerTick = damagePerTick; }
public void setConeAngle(float coneAngle) {
this.coneAngle = coneAngle;
}
public int getDamageInterval() { return damageInterval; }
public void setDamageInterval(int damageInterval) { this.damageInterval = damageInterval; }
public HazardShape getShape() {
return shape;
}
public boolean isIgnoreInvulnFrames() { return ignoreInvulnFrames; }
public void setIgnoreInvulnFrames(boolean ignoreInvulnFrames) { this.ignoreInvulnFrames = ignoreInvulnFrames; }
public void setShape(HazardShape shape) {
this.shape = shape;
}
public int getSlownessLevel() { return slownessLevel; }
public void setSlownessLevel(int slownessLevel) { this.slownessLevel = slownessLevel; }
public PlacementMode getPlacement() {
return placement;
}
public int getWeaknessLevel() { return weaknessLevel; }
public void setWeaknessLevel(int weaknessLevel) { this.weaknessLevel = weaknessLevel; }
public void setPlacement(PlacementMode placement) {
this.placement = placement;
}
public int getPoisonLevel() { return poisonLevel; }
public void setPoisonLevel(int poisonLevel) { this.poisonLevel = poisonLevel; }
public float getDamagePerTick() {
return damagePerTick;
}
public int getWitherLevel() { return witherLevel; }
public void setWitherLevel(int witherLevel) { this.witherLevel = witherLevel; }
public void setDamagePerTick(float damagePerTick) {
this.damagePerTick = damagePerTick;
}
public int getBlindnessLevel() { return blindnessLevel; }
public void setBlindnessLevel(int blindnessLevel) { this.blindnessLevel = blindnessLevel; }
public int getDamageInterval() {
return damageInterval;
}
public int getDebuffDuration() { return debuffDuration; }
public void setDebuffDuration(int debuffDuration) { this.debuffDuration = debuffDuration; }
public void setDamageInterval(int damageInterval) {
this.damageInterval = damageInterval;
}
public boolean isAffectsCaster() { return affectsCaster; }
public void setAffectsCaster(boolean affectsCaster) { this.affectsCaster = affectsCaster; }
public boolean isIgnoreInvulnFrames() {
return ignoreInvulnFrames;
}
public float getHeightAbove() { return heightAbove; }
public void setHeightAbove(float heightAbove) { this.heightAbove = heightAbove; }
public void setIgnoreInvulnFrames(boolean ignoreInvulnFrames) {
this.ignoreInvulnFrames = ignoreInvulnFrames;
}
public float getHeightBelow() { return heightBelow; }
public void setHeightBelow(float heightBelow) { this.heightBelow = heightBelow; }
public int getSlownessLevel() {
return slownessLevel;
}
public float getMinOffset() { return minOffset; }
public void setMinOffset(float minOffset) { this.minOffset = minOffset; }
public void setSlownessLevel(int slownessLevel) {
this.slownessLevel = slownessLevel;
}
public float getMaxOffset() { return maxOffset; }
public void setMaxOffset(float maxOffset) { this.maxOffset = maxOffset; }
public int getWeaknessLevel() {
return weaknessLevel;
}
public boolean isRandomOffset() { return randomOffset; }
public void setRandomOffset(boolean randomOffset) { this.randomOffset = randomOffset; }
public void setWeaknessLevel(int weaknessLevel) {
this.weaknessLevel = weaknessLevel;
}
public int getPoisonLevel() {
return poisonLevel;
}
public void setPoisonLevel(int poisonLevel) {
this.poisonLevel = poisonLevel;
}
public int getWitherLevel() {
return witherLevel;
}
public void setWitherLevel(int witherLevel) {
this.witherLevel = witherLevel;
}
public int getBlindnessLevel() {
return blindnessLevel;
}
public void setBlindnessLevel(int blindnessLevel) {
this.blindnessLevel = blindnessLevel;
}
public int getDebuffDuration() {
return debuffDuration;
}
public void setDebuffDuration(int debuffDuration) {
this.debuffDuration = debuffDuration;
}
public boolean isAffectsCaster() {
return affectsCaster;
}
public void setAffectsCaster(boolean affectsCaster) {
this.affectsCaster = affectsCaster;
}
public float getHeightAbove() {
return heightAbove;
}
public void setHeightAbove(float heightAbove) {
this.heightAbove = heightAbove;
}
public float getHeightBelow() {
return heightBelow;
}
public void setHeightBelow(float heightBelow) {
this.heightBelow = heightBelow;
}
public float getMinOffset() {
return minOffset;
}
public void setMinOffset(float minOffset) {
this.minOffset = minOffset;
}
public float getMaxOffset() {
return maxOffset;
}
public void setMaxOffset(float maxOffset) {
this.maxOffset = maxOffset;
}
public boolean isRandomOffset() {
return randomOffset;
}
public void setRandomOffset(boolean randomOffset) {
this.randomOffset = randomOffset;
}
// Runtime getters
public double getZoneX() { return zoneX; }
public double getZoneY() { return zoneY; }
public double getZoneZ() { return zoneZ; }
public double getZoneX() {
return zoneX;
}
public double getZoneY() {
return zoneY;
}
public double getZoneZ() {
return zoneZ;
}
}
@@ -10,9 +10,9 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeal;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
@@ -50,7 +50,9 @@ public class AbilityHeal extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
@@ -59,11 +61,13 @@ public class AbilityHeal extends Ability {
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.SELF };
return new TargetingMode[]{TargetingMode.SELF};
}
@Override
@@ -197,21 +201,51 @@ public class AbilityHeal extends Ability {
}
// Getters & Setters
public float getHealAmount() { return healAmount; }
public void setHealAmount(float healAmount) { this.healAmount = healAmount; }
public float getHealAmount() {
return healAmount;
}
public float getHealPercent() { return healPercent; }
public void setHealPercent(float healPercent) { this.healPercent = healPercent; }
public void setHealAmount(float healAmount) {
this.healAmount = healAmount;
}
public boolean isHealSelf() { return healSelf; }
public void setHealSelf(boolean healSelf) { this.healSelf = healSelf; }
public float getHealPercent() {
return healPercent;
}
public boolean isHealAllies() { return healAllies; }
public void setHealAllies(boolean healAllies) { this.healAllies = healAllies; }
public void setHealPercent(float healPercent) {
this.healPercent = healPercent;
}
public float getHealRadius() { return healRadius; }
public void setHealRadius(float healRadius) { this.healRadius = healRadius; }
public boolean isHealSelf() {
return healSelf;
}
public boolean isInstantHeal() { return instantHeal; }
public void setInstantHeal(boolean instantHeal) { this.instantHeal = instantHeal; }
public void setHealSelf(boolean healSelf) {
this.healSelf = healSelf;
}
public boolean isHealAllies() {
return healAllies;
}
public void setHealAllies(boolean healAllies) {
this.healAllies = healAllies;
}
public float getHealRadius() {
return healRadius;
}
public void setHealRadius(float healRadius) {
this.healRadius = healRadius;
}
public boolean isInstantHeal() {
return instantHeal;
}
public void setInstantHeal(boolean instantHeal) {
this.instantHeal = instantHeal;
}
}
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeavyHit;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
@@ -14,6 +10,9 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityHeavyHit;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
/**
@@ -46,21 +45,25 @@ public class AbilityHeavyHit extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
IAbilityConfigCallback callback) {
IAbilityConfigCallback callback) {
return new SubGuiAbilityHeavyHit(this, callback);
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -105,18 +108,43 @@ public class AbilityHeavyHit extends Ability {
}
// Getters & Setters
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getDamage() {
return damage;
}
public float getKnockback() { return knockback; }
public void setKnockback(float knockback) { this.knockback = knockback; }
public void setDamage(float damage) {
this.damage = damage;
}
public int getSlownessLevel() { return slownessLevel; }
public void setSlownessLevel(int slownessLevel) { this.slownessLevel = slownessLevel; }
public float getKnockback() {
return knockback;
}
public int getWeaknessLevel() { return weaknessLevel; }
public void setWeaknessLevel(int weaknessLevel) { this.weaknessLevel = weaknessLevel; }
public void setKnockback(float knockback) {
this.knockback = knockback;
}
public int getPotionDurationSeconds() { return potionDurationSeconds; }
public void setPotionDurationSeconds(int potionDurationSeconds) { this.potionDurationSeconds = potionDurationSeconds; }
public int getSlownessLevel() {
return slownessLevel;
}
public void setSlownessLevel(int slownessLevel) {
this.slownessLevel = slownessLevel;
}
public int getWeaknessLevel() {
return weaknessLevel;
}
public void setWeaknessLevel(int weaknessLevel) {
this.weaknessLevel = weaknessLevel;
}
public int getPotionDurationSeconds() {
return potionDurationSeconds;
}
public void setPotionDurationSeconds(int potionDurationSeconds) {
this.potionDurationSeconds = potionDurationSeconds;
}
}
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityOrb;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
@@ -16,6 +12,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityOrb;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
@@ -67,21 +66,25 @@ public class AbilityOrb extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
IAbilityConfigCallback callback) {
IAbilityConfigCallback callback) {
return new SubGuiAbilityOrb(this, callback);
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -124,8 +127,8 @@ public class AbilityOrb extends Ability {
double distTraveled = Math.sqrt(
Math.pow(orbX - startX, 2) +
Math.pow(orbY - startY, 2) +
Math.pow(orbZ - startZ, 2)
Math.pow(orbY - startY, 2) +
Math.pow(orbZ - startZ, 2)
);
if (distTraveled >= maxDistance) {
hasHit = true;
@@ -139,8 +142,8 @@ public class AbilityOrb extends Ability {
double distToTarget = Math.sqrt(
Math.pow(targetX - orbX, 2) +
Math.pow(targetY - orbY, 2) +
Math.pow(targetZ - orbZ, 2)
Math.pow(targetY - orbY, 2) +
Math.pow(targetZ - orbZ, 2)
);
if (distToTarget <= homingRange) {
@@ -202,7 +205,7 @@ public class AbilityOrb extends Ability {
break;
}
if (!hasHit && world.getBlock((int)orbX, (int)orbY, (int)orbZ).getMaterial().isSolid()) {
if (!hasHit && world.getBlock((int) orbX, (int) orbY, (int) orbZ).getMaterial().isSolid()) {
hasHit = true;
if (explosive) {
doExplosion(npc, world);
@@ -224,12 +227,12 @@ public class AbilityOrb extends Ability {
double dist = Math.sqrt(
Math.pow(blastTarget.posX - orbX, 2) +
Math.pow(blastTarget.posY - orbY, 2) +
Math.pow(blastTarget.posZ - orbZ, 2)
Math.pow(blastTarget.posY - orbY, 2) +
Math.pow(blastTarget.posZ - orbZ, 2)
);
if (dist <= explosionRadius) {
float falloff = 1.0f - (float)(dist / explosionRadius) * explosionDamageFalloff;
float falloff = 1.0f - (float) (dist / explosionRadius) * explosionDamageFalloff;
// Apply damage with scripted event support
boolean wasHit = applyAbilityDamage(npc, blastTarget, damage * falloff, knockback * falloff);
if (wasHit) {
@@ -314,54 +317,140 @@ public class AbilityOrb extends Ability {
}
// Getters & Setters
public float getOrbSpeed() { return orbSpeed; }
public void setOrbSpeed(float orbSpeed) { this.orbSpeed = orbSpeed; }
public float getOrbSpeed() {
return orbSpeed;
}
public float getOrbSize() { return orbSize; }
public void setOrbSize(float orbSize) { this.orbSize = orbSize; }
public void setOrbSpeed(float orbSpeed) {
this.orbSpeed = orbSpeed;
}
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getOrbSize() {
return orbSize;
}
public float getKnockback() { return knockback; }
public void setKnockback(float knockback) { this.knockback = knockback; }
public void setOrbSize(float orbSize) {
this.orbSize = orbSize;
}
public float getMaxDistance() { return maxDistance; }
public void setMaxDistance(float maxDistance) { this.maxDistance = maxDistance; }
public float getDamage() {
return damage;
}
public int getMaxLifetime() { return maxLifetime; }
public void setMaxLifetime(int maxLifetime) { this.maxLifetime = maxLifetime; }
public void setDamage(float damage) {
this.damage = damage;
}
public boolean isHoming() { return homing; }
public void setHoming(boolean homing) { this.homing = homing; }
public float getKnockback() {
return knockback;
}
public float getHomingStrength() { return homingStrength; }
public void setHomingStrength(float homingStrength) { this.homingStrength = homingStrength; }
public void setKnockback(float knockback) {
this.knockback = knockback;
}
public float getHomingRange() { return homingRange; }
public void setHomingRange(float homingRange) { this.homingRange = homingRange; }
public float getMaxDistance() {
return maxDistance;
}
public boolean isExplosive() { return explosive; }
public void setExplosive(boolean explosive) { this.explosive = explosive; }
public void setMaxDistance(float maxDistance) {
this.maxDistance = maxDistance;
}
public float getExplosionRadius() { return explosionRadius; }
public void setExplosionRadius(float explosionRadius) { this.explosionRadius = explosionRadius; }
public int getMaxLifetime() {
return maxLifetime;
}
public float getExplosionDamageFalloff() { return explosionDamageFalloff; }
public void setExplosionDamageFalloff(float explosionDamageFalloff) { this.explosionDamageFalloff = explosionDamageFalloff; }
public void setMaxLifetime(int maxLifetime) {
this.maxLifetime = maxLifetime;
}
public int getStunDuration() { return stunDuration; }
public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
public boolean isHoming() {
return homing;
}
public int getSlowDuration() { return slowDuration; }
public void setSlowDuration(int slowDuration) { this.slowDuration = slowDuration; }
public void setHoming(boolean homing) {
this.homing = homing;
}
public int getSlowLevel() { return slowLevel; }
public void setSlowLevel(int slowLevel) { this.slowLevel = slowLevel; }
public float getHomingStrength() {
return homingStrength;
}
public void setHomingStrength(float homingStrength) {
this.homingStrength = homingStrength;
}
public float getHomingRange() {
return homingRange;
}
public void setHomingRange(float homingRange) {
this.homingRange = homingRange;
}
public boolean isExplosive() {
return explosive;
}
public void setExplosive(boolean explosive) {
this.explosive = explosive;
}
public float getExplosionRadius() {
return explosionRadius;
}
public void setExplosionRadius(float explosionRadius) {
this.explosionRadius = explosionRadius;
}
public float getExplosionDamageFalloff() {
return explosionDamageFalloff;
}
public void setExplosionDamageFalloff(float explosionDamageFalloff) {
this.explosionDamageFalloff = explosionDamageFalloff;
}
public int getStunDuration() {
return stunDuration;
}
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getSlowDuration() {
return slowDuration;
}
public void setSlowDuration(int slowDuration) {
this.slowDuration = slowDuration;
}
public int getSlowLevel() {
return slowLevel;
}
public void setSlowLevel(int slowLevel) {
this.slowLevel = slowLevel;
}
// Runtime getters for rendering
public double getOrbX() { return orbX; }
public double getOrbY() { return orbY; }
public double getOrbZ() { return orbZ; }
public boolean hasHit() { return hasHit; }
public double getOrbX() {
return orbX;
}
public double getOrbY() {
return orbY;
}
public double getOrbZ() {
return orbZ;
}
public boolean hasHit() {
return hasHit;
}
}
@@ -8,11 +8,10 @@ import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityProjectile;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
@@ -49,7 +48,9 @@ public class AbilityProjectile extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
@@ -58,11 +59,13 @@ public class AbilityProjectile extends Ability {
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -187,27 +190,67 @@ public class AbilityProjectile extends Ability {
}
// Getters & Setters
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getDamage() {
return damage;
}
public float getSpeed() { return speed; }
public void setSpeed(float speed) { this.speed = speed; }
public void setDamage(float damage) {
this.damage = damage;
}
public float getKnockback() { return knockback; }
public void setKnockback(float knockback) { this.knockback = knockback; }
public float getSpeed() {
return speed;
}
public String getProjectileType() { return projectileType; }
public void setProjectileType(String projectileType) { this.projectileType = projectileType; }
public void setSpeed(float speed) {
this.speed = speed;
}
public boolean isExplosive() { return explosive; }
public void setExplosive(boolean explosive) { this.explosive = explosive; }
public float getKnockback() {
return knockback;
}
public float getExplosionRadius() { return explosionRadius; }
public void setExplosionRadius(float explosionRadius) { this.explosionRadius = explosionRadius; }
public void setKnockback(float knockback) {
this.knockback = knockback;
}
public boolean isHoming() { return homing; }
public void setHoming(boolean homing) { this.homing = homing; }
public String getProjectileType() {
return projectileType;
}
public float getHomingStrength() { return homingStrength; }
public void setHomingStrength(float homingStrength) { this.homingStrength = homingStrength; }
public void setProjectileType(String projectileType) {
this.projectileType = projectileType;
}
public boolean isExplosive() {
return explosive;
}
public void setExplosive(boolean explosive) {
this.explosive = explosive;
}
public float getExplosionRadius() {
return explosionRadius;
}
public void setExplosionRadius(float explosionRadius) {
this.explosionRadius = explosionRadius;
}
public boolean isHoming() {
return homing;
}
public void setHoming(boolean homing) {
this.homing = homing;
}
public float getHomingStrength() {
return homingStrength;
}
public void setHomingStrength(float homingStrength) {
this.homingStrength = homingStrength;
}
}
@@ -12,9 +12,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityShockwave;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
@@ -50,7 +50,9 @@ public class AbilityShockwave extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
@@ -59,15 +61,19 @@ public class AbilityShockwave extends Ability {
}
@Override
public boolean isTargetingModeLocked() { return true; }
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AOE_SELF };
public boolean isTargetingModeLocked() {
return true;
}
@Override
public float getTelegraphRadius() { return pushRadius; }
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[]{TargetingMode.AOE_SELF};
}
@Override
public float getTelegraphRadius() {
return pushRadius;
}
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
@@ -111,7 +117,7 @@ public class AbilityShockwave extends Ability {
}
// Scale knockback by distance (closer = stronger)
float distFactor = 1.0f - (float)(dist / pushRadius) * 0.5f;
float distFactor = 1.0f - (float) (dist / pushRadius) * 0.5f;
float finalPush = pushStrength * distFactor;
// Apply damage with custom knockback direction
boolean wasHit = applyAbilityDamageWithDirection(npc, entity, damage * distFactor, finalPush, dx, dz);
@@ -153,19 +159,44 @@ public class AbilityShockwave extends Ability {
}
// Getters & Setters
public float getPushRadius() { return pushRadius; }
public void setPushRadius(float pushRadius) { this.pushRadius = pushRadius; }
public float getPushRadius() {
return pushRadius;
}
public float getPushStrength() { return pushStrength; }
public void setPushStrength(float pushStrength) { this.pushStrength = pushStrength; }
public void setPushRadius(float pushRadius) {
this.pushRadius = pushRadius;
}
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getPushStrength() {
return pushStrength;
}
public int getStunDuration() { return stunDuration; }
public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
public void setPushStrength(float pushStrength) {
this.pushStrength = pushStrength;
}
public int getMaxTargets() { return maxTargets; }
public void setMaxTargets(int maxTargets) { this.maxTargets = maxTargets; }
public float getDamage() {
return damage;
}
public void setDamage(float damage) {
this.damage = damage;
}
public int getStunDuration() {
return stunDuration;
}
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getMaxTargets() {
return maxTargets;
}
public void setMaxTargets(int maxTargets) {
this.maxTargets = maxTargets;
}
}
@@ -11,18 +11,17 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilitySlam;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
/**
* Slam ability: NPC leaps toward target in an arc and slams down, dealing AOE damage on landing.
*
* <p>
* Phases:
* - WINDUP: NPC prepares to leap, telegraph shows landing zone
* - ACTIVE: NPC is in the air, traveling in arc toward destination
@@ -62,7 +61,9 @@ public class AbilitySlam extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
@@ -80,7 +81,7 @@ public class AbilitySlam extends Ability {
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AOE_SELF, TargetingMode.AOE_TARGET };
return new TargetingMode[]{TargetingMode.AOE_SELF, TargetingMode.AOE_TARGET};
}
@Override
@@ -317,7 +318,7 @@ public class AbilitySlam extends Ability {
}
// Ground crack particles - check if block is valid
net.minecraft.block.Block groundBlock = world.getBlock((int)x, (int)y - 1, (int)z);
net.minecraft.block.Block groundBlock = world.getBlock((int) x, (int) y - 1, (int) z);
if (groundBlock != null && groundBlock.getMaterial().isSolid()) {
int blockId = net.minecraft.block.Block.getIdFromBlock(groundBlock);
if (blockId > 0) {
@@ -427,18 +428,43 @@ public class AbilitySlam extends Ability {
}
// Getters & Setters
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getDamage() {
return damage;
}
public float getRadius() { return radius; }
public void setRadius(float radius) { this.radius = radius; }
public void setDamage(float damage) {
this.damage = damage;
}
public float getKnockbackStrength() { return knockbackStrength; }
public void setKnockbackStrength(float knockbackStrength) { this.knockbackStrength = knockbackStrength; }
public float getRadius() {
return radius;
}
public float getLeapSpeed() { return leapSpeed; }
public void setLeapSpeed(float leapSpeed) { this.leapSpeed = leapSpeed; }
public void setRadius(float radius) {
this.radius = radius;
}
public float getLeapHeight() { return leapHeight; }
public void setLeapHeight(float leapHeight) { this.leapHeight = leapHeight; }
public float getKnockbackStrength() {
return knockbackStrength;
}
public void setKnockbackStrength(float knockbackStrength) {
this.knockbackStrength = knockbackStrength;
}
public float getLeapSpeed() {
return leapSpeed;
}
public void setLeapSpeed(float leapSpeed) {
this.leapSpeed = leapSpeed;
}
public float getLeapHeight() {
return leapHeight;
}
public void setLeapHeight(float leapHeight) {
this.leapHeight = leapHeight;
}
}
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityTeleport;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.block.Block;
@@ -14,10 +10,12 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityTeleport;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.List;
@@ -73,21 +71,25 @@ public class AbilityTeleport extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
IAbilityConfigCallback callback) {
IAbilityConfigCallback callback) {
return new SubGuiAbilityTeleport(this, callback);
}
@Override
public boolean isTargetingModeLocked() { return true; }
public boolean isTargetingModeLocked() {
return true;
}
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
@@ -202,7 +204,7 @@ public class AbilityTeleport extends Ability {
}
private Vec3 findSafeDestination(World world, double oldX, double oldY, double oldZ,
double destX, double destY, double destZ) {
double destX, double destY, double destZ) {
int oldBlockX = (int) Math.floor(oldX);
int oldBlockY = (int) Math.floor(oldY);
int oldBlockZ = (int) Math.floor(oldZ);
@@ -291,7 +293,7 @@ public class AbilityTeleport extends Ability {
double checkZ = z1 + dz * d;
if (hasLineOfSight(world, x1, y1 + npc.getEyeHeight(), z1,
checkX, checkY + npc.getEyeHeight(), checkZ)) {
checkX, checkY + npc.getEyeHeight(), checkZ)) {
int blockX = MathHelper.floor_double(checkX);
int blockY = MathHelper.floor_double(checkY);
int blockZ = MathHelper.floor_double(checkZ);
@@ -330,8 +332,8 @@ public class AbilityTeleport extends Ability {
Block headBlock = world.getBlock(x, y + 1, z);
return groundBlock.getMaterial().isSolid() &&
!feetBlock.getMaterial().isSolid() &&
!headBlock.getMaterial().isSolid();
!feetBlock.getMaterial().isSolid() &&
!headBlock.getMaterial().isSolid();
}
private void dealDamageAt(EntityNPCInterface npc, World world, double x, double y, double z) {
@@ -414,33 +416,83 @@ public class AbilityTeleport extends Ability {
}
// Getters & Setters
public TeleportMode getMode() { return mode; }
public void setMode(TeleportMode mode) { this.mode = mode; }
public TeleportMode getMode() {
return mode;
}
public int getBlinkCount() { return blinkCount; }
public void setBlinkCount(int blinkCount) { this.blinkCount = blinkCount; }
public void setMode(TeleportMode mode) {
this.mode = mode;
}
public int getBlinkDelayTicks() { return blinkDelayTicks; }
public void setBlinkDelayTicks(int blinkDelayTicks) { this.blinkDelayTicks = blinkDelayTicks; }
public int getBlinkCount() {
return blinkCount;
}
public float getBlinkRadius() { return blinkRadius; }
public void setBlinkRadius(float blinkRadius) { this.blinkRadius = blinkRadius; }
public void setBlinkCount(int blinkCount) {
this.blinkCount = blinkCount;
}
public float getBehindDistance() { return behindDistance; }
public void setBehindDistance(float behindDistance) { this.behindDistance = behindDistance; }
public int getBlinkDelayTicks() {
return blinkDelayTicks;
}
public boolean isRequireLineOfSight() { return requireLineOfSight; }
public void setRequireLineOfSight(boolean requireLineOfSight) { this.requireLineOfSight = requireLineOfSight; }
public void setBlinkDelayTicks(int blinkDelayTicks) {
this.blinkDelayTicks = blinkDelayTicks;
}
public boolean isDamageAtStart() { return damageAtStart; }
public void setDamageAtStart(boolean damageAtStart) { this.damageAtStart = damageAtStart; }
public float getBlinkRadius() {
return blinkRadius;
}
public boolean isDamageAtEnd() { return damageAtEnd; }
public void setDamageAtEnd(boolean damageAtEnd) { this.damageAtEnd = damageAtEnd; }
public void setBlinkRadius(float blinkRadius) {
this.blinkRadius = blinkRadius;
}
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getBehindDistance() {
return behindDistance;
}
public float getDamageRadius() { return damageRadius; }
public void setDamageRadius(float damageRadius) { this.damageRadius = damageRadius; }
public void setBehindDistance(float behindDistance) {
this.behindDistance = behindDistance;
}
public boolean isRequireLineOfSight() {
return requireLineOfSight;
}
public void setRequireLineOfSight(boolean requireLineOfSight) {
this.requireLineOfSight = requireLineOfSight;
}
public boolean isDamageAtStart() {
return damageAtStart;
}
public void setDamageAtStart(boolean damageAtStart) {
this.damageAtStart = damageAtStart;
}
public boolean isDamageAtEnd() {
return damageAtEnd;
}
public void setDamageAtEnd(boolean damageAtEnd) {
this.damageAtEnd = damageAtEnd;
}
public float getDamage() {
return damage;
}
public void setDamage(float damage) {
this.damage = damage;
}
public float getDamageRadius() {
return damageRadius;
}
public void setDamageRadius(float damageRadius) {
this.damageRadius = damageRadius;
}
}
@@ -13,9 +13,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityTrap;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -80,7 +80,9 @@ public class AbilityTrap extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
@@ -89,15 +91,19 @@ public class AbilityTrap extends Ability {
}
@Override
public boolean isTargetingModeLocked() { return true; }
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AGGRO_TARGET };
public boolean isTargetingModeLocked() {
return true;
}
@Override
public float getTelegraphRadius() { return triggerRadius; }
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[]{TargetingMode.AGGRO_TARGET};
}
@Override
public float getTelegraphRadius() {
return triggerRadius;
}
@Override
public TelegraphInstance createTelegraph(EntityNPCInterface npc, EntityLivingBase target) {
@@ -362,66 +368,172 @@ public class AbilityTrap extends Ability {
}
// Getters & Setters
public TrapPlacement getPlacement() { return placement; }
public void setPlacement(TrapPlacement placement) { this.placement = placement; }
public TrapPlacement getPlacement() {
return placement;
}
public float getPlacementDistance() { return placementDistance; }
public void setPlacementDistance(float placementDistance) { this.placementDistance = placementDistance; }
public void setPlacement(TrapPlacement placement) {
this.placement = placement;
}
public float getTriggerRadius() { return triggerRadius; }
public void setTriggerRadius(float triggerRadius) { this.triggerRadius = triggerRadius; }
public float getPlacementDistance() {
return placementDistance;
}
public int getArmTime() { return armTime; }
public void setArmTime(int armTime) { this.armTime = armTime; }
public void setPlacementDistance(float placementDistance) {
this.placementDistance = placementDistance;
}
public int getMaxTriggers() { return maxTriggers; }
public void setMaxTriggers(int maxTriggers) { this.maxTriggers = maxTriggers; }
public float getTriggerRadius() {
return triggerRadius;
}
public int getTriggerCooldown() { return triggerCooldown; }
public void setTriggerCooldown(int triggerCooldown) { this.triggerCooldown = triggerCooldown; }
public void setTriggerRadius(float triggerRadius) {
this.triggerRadius = triggerRadius;
}
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public int getArmTime() {
return armTime;
}
public float getDamageRadius() { return damageRadius; }
public void setDamageRadius(float damageRadius) { this.damageRadius = damageRadius; }
public void setArmTime(int armTime) {
this.armTime = armTime;
}
public float getKnockback() { return knockback; }
public void setKnockback(float knockback) { this.knockback = knockback; }
public int getMaxTriggers() {
return maxTriggers;
}
public int getStunDuration() { return stunDuration; }
public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
public void setMaxTriggers(int maxTriggers) {
this.maxTriggers = maxTriggers;
}
public int getRootDuration() { return rootDuration; }
public void setRootDuration(int rootDuration) { this.rootDuration = rootDuration; }
public int getTriggerCooldown() {
return triggerCooldown;
}
public int getSlowDuration() { return slowDuration; }
public void setSlowDuration(int slowDuration) { this.slowDuration = slowDuration; }
public void setTriggerCooldown(int triggerCooldown) {
this.triggerCooldown = triggerCooldown;
}
public int getSlowLevel() { return slowLevel; }
public void setSlowLevel(int slowLevel) { this.slowLevel = slowLevel; }
public float getDamage() {
return damage;
}
public int getPoisonDuration() { return poisonDuration; }
public void setPoisonDuration(int poisonDuration) { this.poisonDuration = poisonDuration; }
public void setDamage(float damage) {
this.damage = damage;
}
public int getPoisonLevel() { return poisonLevel; }
public void setPoisonLevel(int poisonLevel) { this.poisonLevel = poisonLevel; }
public float getDamageRadius() {
return damageRadius;
}
public boolean isVisible() { return visible; }
public void setVisible(boolean visible) { this.visible = visible; }
public void setDamageRadius(float damageRadius) {
this.damageRadius = damageRadius;
}
public float getMinOffset() { return minOffset; }
public void setMinOffset(float minOffset) { this.minOffset = minOffset; }
public float getKnockback() {
return knockback;
}
public float getMaxOffset() { return maxOffset; }
public void setMaxOffset(float maxOffset) { this.maxOffset = maxOffset; }
public void setKnockback(float knockback) {
this.knockback = knockback;
}
public boolean isRandomOffset() { return randomOffset; }
public void setRandomOffset(boolean randomOffset) { this.randomOffset = randomOffset; }
public int getStunDuration() {
return stunDuration;
}
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getRootDuration() {
return rootDuration;
}
public void setRootDuration(int rootDuration) {
this.rootDuration = rootDuration;
}
public int getSlowDuration() {
return slowDuration;
}
public void setSlowDuration(int slowDuration) {
this.slowDuration = slowDuration;
}
public int getSlowLevel() {
return slowLevel;
}
public void setSlowLevel(int slowLevel) {
this.slowLevel = slowLevel;
}
public int getPoisonDuration() {
return poisonDuration;
}
public void setPoisonDuration(int poisonDuration) {
this.poisonDuration = poisonDuration;
}
public int getPoisonLevel() {
return poisonLevel;
}
public void setPoisonLevel(int poisonLevel) {
this.poisonLevel = poisonLevel;
}
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public float getMinOffset() {
return minOffset;
}
public void setMinOffset(float minOffset) {
this.minOffset = minOffset;
}
public float getMaxOffset() {
return maxOffset;
}
public void setMaxOffset(float maxOffset) {
this.maxOffset = maxOffset;
}
public boolean isRandomOffset() {
return randomOffset;
}
public void setRandomOffset(boolean randomOffset) {
this.randomOffset = randomOffset;
}
// Runtime getters
public double getTrapX() { return trapX; }
public double getTrapY() { return trapY; }
public double getTrapZ() { return trapZ; }
public boolean isArmed() { return armed; }
public double getTrapX() {
return trapX;
}
public double getTrapY() {
return trapY;
}
public double getTrapZ() {
return trapZ;
}
public boolean isArmed() {
return armed;
}
}
@@ -2,11 +2,7 @@ package kamkeel.npcs.controllers.data.ability.type;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.data.ability.Ability;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityVortex;
import kamkeel.npcs.controllers.data.ability.TargetingMode;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphType;
import net.minecraft.entity.EntityLivingBase;
@@ -16,6 +12,9 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.ability.SubGuiAbilityVortex;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.HashSet;
@@ -61,25 +60,31 @@ public class AbilityVortex extends Ability {
}
@Override
public boolean hasTypeSettings() { return true; }
public boolean hasTypeSettings() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public SubGuiAbilityConfig createConfigGui(
IAbilityConfigCallback callback) {
IAbilityConfigCallback callback) {
return new SubGuiAbilityVortex(this, callback);
}
@Override
public boolean isTargetingModeLocked() { return true; }
@Override
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[] { TargetingMode.AOE_SELF };
public boolean isTargetingModeLocked() {
return true;
}
@Override
public float getTelegraphRadius() { return pullRadius; }
public TargetingMode[] getAllowedTargetingModes() {
return new TargetingMode[]{TargetingMode.AOE_SELF};
}
@Override
public float getTelegraphRadius() {
return pullRadius;
}
@Override
public void onExecute(EntityNPCInterface npc, EntityLivingBase target, World world) {
@@ -249,33 +254,83 @@ public class AbilityVortex extends Ability {
}
// Getters & Setters
public float getPullRadius() { return pullRadius; }
public void setPullRadius(float pullRadius) { this.pullRadius = pullRadius; }
public float getPullRadius() {
return pullRadius;
}
public float getPullStrength() { return pullStrength; }
public void setPullStrength(float pullStrength) { this.pullStrength = pullStrength; }
public void setPullRadius(float pullRadius) {
this.pullRadius = pullRadius;
}
public float getDamage() { return damage; }
public void setDamage(float damage) { this.damage = damage; }
public float getPullStrength() {
return pullStrength;
}
public float getKnockback() { return knockback; }
public void setKnockback(float knockback) { this.knockback = knockback; }
public void setPullStrength(float pullStrength) {
this.pullStrength = pullStrength;
}
public int getStunDuration() { return stunDuration; }
public void setStunDuration(int stunDuration) { this.stunDuration = stunDuration; }
public float getDamage() {
return damage;
}
public int getRootDuration() { return rootDuration; }
public void setRootDuration(int rootDuration) { this.rootDuration = rootDuration; }
public void setDamage(float damage) {
this.damage = damage;
}
public boolean isAoe() { return aoe; }
public void setAoe(boolean aoe) { this.aoe = aoe; }
public float getKnockback() {
return knockback;
}
public int getMaxTargets() { return maxTargets; }
public void setMaxTargets(int maxTargets) { this.maxTargets = maxTargets; }
public void setKnockback(float knockback) {
this.knockback = knockback;
}
public boolean isDamageOnPull() { return damageOnPull; }
public void setDamageOnPull(boolean damageOnPull) { this.damageOnPull = damageOnPull; }
public int getStunDuration() {
return stunDuration;
}
public float getPullDamage() { return pullDamage; }
public void setPullDamage(float pullDamage) { this.pullDamage = pullDamage; }
public void setStunDuration(int stunDuration) {
this.stunDuration = stunDuration;
}
public int getRootDuration() {
return rootDuration;
}
public void setRootDuration(int rootDuration) {
this.rootDuration = rootDuration;
}
public boolean isAoe() {
return aoe;
}
public void setAoe(boolean aoe) {
this.aoe = aoe;
}
public int getMaxTargets() {
return maxTargets;
}
public void setMaxTargets(int maxTargets) {
this.maxTargets = maxTargets;
}
public boolean isDamageOnPull() {
return damageOnPull;
}
public void setDamageOnPull(boolean damageOnPull) {
this.damageOnPull = damageOnPull;
}
public float getPullDamage() {
return pullDamage;
}
public void setPullDamage(float pullDamage) {
this.pullDamage = pullDamage;
}
}
@@ -26,6 +26,8 @@ import kamkeel.npcs.network.packets.data.SoundManagementPacket;
import kamkeel.npcs.network.packets.data.SwingPlayerArmPacket;
import kamkeel.npcs.network.packets.data.UpdateAnimationsPacket;
import kamkeel.npcs.network.packets.data.VillagerListPacket;
import kamkeel.npcs.network.packets.data.ability.TelegraphRemovePacket;
import kamkeel.npcs.network.packets.data.ability.TelegraphSpawnPacket;
import kamkeel.npcs.network.packets.data.gui.GuiClosePacket;
import kamkeel.npcs.network.packets.data.gui.GuiErrorPacket;
import kamkeel.npcs.network.packets.data.gui.GuiOpenBookPacket;
@@ -49,20 +51,20 @@ import kamkeel.npcs.network.packets.data.npc.WeaponNpcPacket;
import kamkeel.npcs.network.packets.data.script.ScriptOverlayClosePacket;
import kamkeel.npcs.network.packets.data.script.ScriptOverlayDataPacket;
import kamkeel.npcs.network.packets.data.script.ScriptedParticlePacket;
import kamkeel.npcs.network.packets.data.ability.TelegraphSpawnPacket;
import kamkeel.npcs.network.packets.data.ability.TelegraphRemovePacket;
import kamkeel.npcs.network.packets.player.BankActionPacket;
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
import kamkeel.npcs.network.packets.player.CompanionActionPacket;
import kamkeel.npcs.network.packets.player.DialogSelectPacket;
import kamkeel.npcs.network.packets.player.FollowerPacket;
import kamkeel.npcs.network.packets.player.GetNPCRole;
import kamkeel.npcs.network.packets.player.GetTraderData;
import kamkeel.npcs.network.packets.player.InputDevicePacket;
import kamkeel.npcs.network.packets.player.MailActionPacket;
import kamkeel.npcs.network.packets.player.SaveBookPacket;
import kamkeel.npcs.network.packets.player.SaveSignPacket;
import kamkeel.npcs.network.packets.player.ScreenSizePacket;
import kamkeel.npcs.network.packets.player.SpecialKeyStatePacket;
import kamkeel.npcs.network.packets.player.SyncRevisionInfoPacket;
import kamkeel.npcs.network.packets.player.TransportPacket;
import kamkeel.npcs.network.packets.player.customgui.CustomGuiButtonPacket;
import kamkeel.npcs.network.packets.player.customgui.CustomGuiClosePacket;
@@ -74,7 +76,6 @@ import kamkeel.npcs.network.packets.player.item.MagicCyclesPacket;
import kamkeel.npcs.network.packets.player.profile.ProfileChangePacket;
import kamkeel.npcs.network.packets.player.profile.ProfileCreatePacket;
import kamkeel.npcs.network.packets.player.profile.ProfileGetInfoPacket;
import kamkeel.npcs.network.packets.player.SyncRevisionInfoPacket;
import kamkeel.npcs.network.packets.player.profile.ProfileGetPacket;
import kamkeel.npcs.network.packets.player.profile.ProfileRemovePacket;
import kamkeel.npcs.network.packets.player.profile.ProfileRenamePacket;
@@ -87,6 +88,9 @@ import kamkeel.npcs.network.packets.request.MountPacket;
import kamkeel.npcs.network.packets.request.TileEntityGetPacket;
import kamkeel.npcs.network.packets.request.TileEntitySavePacket;
import kamkeel.npcs.network.packets.request.TraderMarketSavePacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesGetAllPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcGetPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcSavePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket;
import kamkeel.npcs.network.packets.request.animation.AnimationRemovePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket;
@@ -140,9 +144,6 @@ import kamkeel.npcs.network.packets.request.linked.LinkedItemSavePacket;
import kamkeel.npcs.network.packets.request.linked.LinkedNPCAddPacket;
import kamkeel.npcs.network.packets.request.linked.LinkedNPCRemovePacket;
import kamkeel.npcs.network.packets.request.linked.LinkedSetPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesGetAllPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcGetPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcSavePacket;
import kamkeel.npcs.network.packets.request.magic.MagicCycleRemovePacket;
import kamkeel.npcs.network.packets.request.magic.MagicCycleSavePacket;
import kamkeel.npcs.network.packets.request.magic.MagicGetAllPacket;
@@ -215,7 +216,16 @@ import kamkeel.npcs.network.packets.request.recipe.RecipesGetPacket;
import kamkeel.npcs.network.packets.request.role.RoleCompanionUpdatePacket;
import kamkeel.npcs.network.packets.request.role.RoleGetPacket;
import kamkeel.npcs.network.packets.request.role.RoleSavePacket;
import kamkeel.npcs.network.packets.request.script.*;
import kamkeel.npcs.network.packets.request.script.BlockScriptPacket;
import kamkeel.npcs.network.packets.request.script.EffectScriptPacket;
import kamkeel.npcs.network.packets.request.script.EventScriptPacket;
import kamkeel.npcs.network.packets.request.script.ForgeScriptPacket;
import kamkeel.npcs.network.packets.request.script.GlobalNPCScriptPacket;
import kamkeel.npcs.network.packets.request.script.NPCScriptPacket;
import kamkeel.npcs.network.packets.request.script.PlayerScriptPacket;
import kamkeel.npcs.network.packets.request.script.RecipeScriptPacket;
import kamkeel.npcs.network.packets.request.script.ScriptFilesPacket;
import kamkeel.npcs.network.packets.request.script.ScriptInfoPacket;
import kamkeel.npcs.network.packets.request.script.item.ItemScriptErrorPacket;
import kamkeel.npcs.network.packets.request.script.item.ItemScriptPacket;
import kamkeel.npcs.network.packets.request.script.item.LinkedItemScriptPacket;
@@ -579,6 +589,7 @@ public class PacketHandler {
PLAYER_PACKET.registerPacket(new CompanionActionPacket());
PLAYER_PACKET.registerPacket(new GetNPCRole());
PLAYER_PACKET.registerPacket(new GetTraderData());
PLAYER_PACKET.registerPacket(new InputDevicePacket());
@@ -13,6 +13,7 @@ public enum EnumPlayerPacket {
SaveBook,
CompanionAction,
GetRole,
GetTraderData,
InputDevice,
SpecialKeyState,
ScreenSize,
@@ -33,4 +34,7 @@ public enum EnumPlayerPacket {
ProfileGet,
ProfileGetInfo,
SyncRevisionInfo,
// Auction
AuctionAction,
}
@@ -3,7 +3,6 @@ package kamkeel.npcs.network.packets.data.ability;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.controllers.data.ability.telegraph.Telegraph;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import kamkeel.npcs.network.AbstractPacket;
@@ -0,0 +1,77 @@
package kamkeel.npcs.network.packets.player;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumPlayerPacket;
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.roles.RoleTrader;
import java.io.IOException;
/**
* Client requests trader-specific GUI data from server.
* Server responds with player balance, stock info, currency costs via GuiDataPacket.
*/
public class GetTraderData extends AbstractPacket {
public static final String packetName = "Player|GetTraderData";
@Override
public Enum getType() {
return EnumPlayerPacket.GetTraderData;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.PLAYER_PACKET;
}
@Override
public boolean needsNPC() {
return true;
}
@Override
public void sendData(ByteBuf out) throws IOException {
// No data needed for request
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!(npc.roleInterface instanceof RoleTrader))
return;
RoleTrader role = (RoleTrader) npc.roleInterface;
NBTTagCompound compound = new NBTTagCompound();
// Player balance
PlayerData data = PlayerData.get(player);
compound.setLong("Balance", data.currencyData.getBalance());
// Stock info
compound.setBoolean("StockEnabled", role.stock.enableStock);
compound.setLong("ResetTimeMillis", role.getResetTimeRemainingMillis());
// Available stock per slot (player-specific if perPlayer mode)
String playerName = player.getCommandSenderName();
int[] stock = new int[18];
for (int i = 0; i < 18; i++) {
stock[i] = role.getAvailableStock(i, playerName);
}
compound.setIntArray("Stock", stock);
// Currency cost per slot
for (int i = 0; i < 18; i++) {
compound.setLong("Cost" + i, role.getCurrencyCost(i));
}
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
}
@@ -84,6 +84,10 @@ public final class BlockScriptPacket extends AbstractPacket {
NBTTagCompound compound = ((TileScripted) tile).getNBT(new NBTTagCompound());
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
NBTTagCompound loadComplete = new NBTTagCompound();
loadComplete.setInteger("LoadComplete", 1);
GuiDataPacket.sendGuiData((EntityPlayerMP) player, loadComplete);
} else {
if (!player.capabilities.isCreativeMode) {
return;
@@ -3,7 +3,9 @@ package kamkeel.npcs.network.packets.request.script;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.*;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
@@ -75,6 +75,10 @@ public final class ItemScriptPacket extends AbstractPacket {
NBTTagCompound compound = iw.getMCNbt();
compound.setTag("Languages", ScriptController.Instance.nbtLanguages());
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
NBTTagCompound loadComplete = new NBTTagCompound();
loadComplete.setInteger("LoadComplete", 1);
GuiDataPacket.sendGuiData((EntityPlayerMP) player, loadComplete);
} else {
if (!player.capabilities.isCreativeMode) {
return;
@@ -95,6 +95,7 @@ public class BukkitUtil {
/**
* Checks if a specific Bukkit plugin is enabled.
*
* @param pluginName the plugin name to check
* @return true if the plugin is enabled
*/
@@ -112,6 +113,7 @@ public class BukkitUtil {
/**
* Gets a Bukkit OfflinePlayer by name.
*
* @param playerName the player name
* @return the OfflinePlayer object, or null if not available
*/
@@ -128,6 +130,7 @@ public class BukkitUtil {
/**
* Gets a Bukkit Player by name (online players only).
*
* @param playerName the player name
* @return the Player object, or null if not online or not available
*/
@@ -144,6 +147,7 @@ public class BukkitUtil {
/**
* Gets a service provider from Bukkit's ServicesManager.
*
* @param serviceClass the service class to get
* @return the service provider, or null if not available
*/
+35 -11
View File
@@ -174,6 +174,7 @@ public class VaultUtil {
/**
* Checks if a player has an account in the economy system.
*
* @param player the player to check
* @return true if the player has an account
*/
@@ -183,6 +184,7 @@ public class VaultUtil {
/**
* Checks if a player has an account in the economy system.
*
* @param playerName the player name to check
* @return true if the player has an account
*/
@@ -203,6 +205,7 @@ public class VaultUtil {
/**
* Gets the balance of a player.
*
* @param player the player
* @return the player's balance, or 0 if not available
*/
@@ -212,6 +215,7 @@ public class VaultUtil {
/**
* Gets the balance of a player by name.
*
* @param playerName the player name
* @return the player's balance, or 0 if not available
*/
@@ -232,6 +236,7 @@ public class VaultUtil {
/**
* Checks if a player has at least the specified amount.
*
* @param player the player
* @param amount the amount to check
* @return true if the player has at least the specified amount
@@ -242,8 +247,9 @@ public class VaultUtil {
/**
* Checks if a player has at least the specified amount.
*
* @param playerName the player name
* @param amount the amount to check
* @param amount the amount to check
* @return true if the player has at least the specified amount
*/
public static boolean has(String playerName, double amount) {
@@ -263,6 +269,7 @@ public class VaultUtil {
/**
* Withdraws money from a player's account.
*
* @param player the player
* @param amount the amount to withdraw
* @return true if the transaction was successful
@@ -273,8 +280,9 @@ public class VaultUtil {
/**
* Withdraws money from a player's account.
*
* @param playerName the player name
* @param amount the amount to withdraw
* @param amount the amount to withdraw
* @return true if the transaction was successful
*/
public static boolean withdrawMoney(String playerName, double amount) {
@@ -297,6 +305,7 @@ public class VaultUtil {
/**
* Adds money to a player's account (deposit).
*
* @param player the player
* @param amount the amount to add
* @return true if the transaction was successful
@@ -307,8 +316,9 @@ public class VaultUtil {
/**
* Adds money to a player's account (deposit).
*
* @param playerName the player name
* @param amount the amount to add
* @param amount the amount to add
* @return true if the transaction was successful
*/
public static boolean addMoney(String playerName, double amount) {
@@ -332,6 +342,7 @@ public class VaultUtil {
/**
* Sets a player's balance to the specified amount.
* This withdraws all money first, then deposits the new amount.
*
* @param player the player
* @param amount the new balance
* @return true if the transaction was successful
@@ -343,8 +354,9 @@ public class VaultUtil {
/**
* Sets a player's balance to the specified amount.
* This withdraws all money first, then deposits the new amount.
*
* @param playerName the player name
* @param amount the new balance
* @param amount the new balance
* @return true if the transaction was successful
*/
public static boolean setBalance(String playerName, double amount) {
@@ -364,6 +376,7 @@ public class VaultUtil {
/**
* Formats an amount according to the economy plugin's settings.
*
* @param amount the amount to format
* @return the formatted string, or the raw number as string if not available
*/
@@ -380,6 +393,7 @@ public class VaultUtil {
/**
* Gets the plural currency name (e.g., "Dollars").
*
* @return the plural currency name, or "coins" if not available
*/
public static String getCurrencyNamePlural() {
@@ -395,6 +409,7 @@ public class VaultUtil {
/**
* Gets the singular currency name (e.g., "Dollar").
*
* @return the singular currency name, or "coin" if not available
*/
public static String getCurrencyNameSingular() {
@@ -410,6 +425,7 @@ public class VaultUtil {
/**
* Creates an account for the player if one doesn't exist.
*
* @param player the player
* @return true if the account was created or already exists
*/
@@ -419,6 +435,7 @@ public class VaultUtil {
/**
* Creates an account for the player if one doesn't exist.
*
* @param playerName the player name
* @return true if the account was created or already exists
*/
@@ -455,6 +472,7 @@ public class VaultUtil {
/**
* Gets a list of all bank names.
*
* @return list of bank names, or empty list if not available
*/
@SuppressWarnings("unchecked")
@@ -471,6 +489,7 @@ public class VaultUtil {
/**
* Gets the balance of a bank.
*
* @param bankName the bank name
* @return the bank balance, or 0 if not available
*/
@@ -488,8 +507,9 @@ public class VaultUtil {
/**
* Checks if a bank has at least the specified amount.
*
* @param bankName the bank name
* @param amount the amount to check
* @param amount the amount to check
* @return true if the bank has at least the specified amount
*/
public static boolean bankHas(String bankName, double amount) {
@@ -506,8 +526,9 @@ public class VaultUtil {
/**
* Withdraws money from a bank.
*
* @param bankName the bank name
* @param amount the amount to withdraw
* @param amount the amount to withdraw
* @return true if the transaction was successful
*/
public static boolean bankWithdraw(String bankName, double amount) {
@@ -524,8 +545,9 @@ public class VaultUtil {
/**
* Deposits money into a bank.
*
* @param bankName the bank name
* @param amount the amount to deposit
* @param amount the amount to deposit
* @return true if the transaction was successful
*/
public static boolean bankDeposit(String bankName, double amount) {
@@ -542,8 +564,9 @@ public class VaultUtil {
/**
* Transfers money from one player to another.
* @param from the player to take money from
* @param to the player to give money to
*
* @param from the player to take money from
* @param to the player to give money to
* @param amount the amount to transfer
* @return true if the transfer was successful
*/
@@ -553,9 +576,10 @@ public class VaultUtil {
/**
* Transfers money from one player to another.
*
* @param fromPlayerName the player name to take money from
* @param toPlayerName the player name to give money to
* @param amount the amount to transfer
* @param toPlayerName the player name to give money to
* @param amount the amount to transfer
* @return true if the transfer was successful
*/
public static boolean transfer(String fromPlayerName, String toPlayerName, double amount) {
+8 -2
View File
@@ -4,7 +4,13 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
import cpw.mods.fml.common.event.FMLServerStartedEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLServerStoppedEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -18,6 +24,7 @@ import kamkeel.npcs.command.profile.CommandProfile;
import kamkeel.npcs.controllers.AttributeController;
import kamkeel.npcs.controllers.ProfileController;
import kamkeel.npcs.controllers.SyncController;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import kamkeel.npcs.controllers.data.profile.CNPCData;
import kamkeel.npcs.developer.Developer;
import kamkeel.npcs.network.PacketHandler;
@@ -68,7 +75,6 @@ import noppes.npcs.controllers.SpawnController;
import noppes.npcs.controllers.TagController;
import noppes.npcs.controllers.TransportController;
import noppes.npcs.enchants.EnchantInterface;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import noppes.npcs.entity.EntityChairMount;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityMagicProjectile;
+32 -15
View File
@@ -1,8 +1,8 @@
package noppes.npcs;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphInstance;
import kamkeel.npcs.network.packets.data.ability.TelegraphRemovePacket;
import kamkeel.npcs.network.packets.data.ability.TelegraphSpawnPacket;
@@ -35,32 +35,48 @@ public class DataAbilities {
// CONFIGURATION (saved to NBT)
// ═══════════════════════════════════════════════════════════════════
/** List of abilities this NPC can use */
/**
* List of abilities this NPC can use
*/
private List<Ability> abilities = new ArrayList<>();
/** Whether the ability system is enabled for this NPC */
/**
* Whether the ability system is enabled for this NPC
*/
public boolean enabled = false;
/** Minimum ticks between ability selections (global cooldown) */
/**
* Minimum ticks between ability selections (global cooldown)
*/
public int globalCooldown = 20;
// ═══════════════════════════════════════════════════════════════════
// RUNTIME STATE (not saved)
// ═══════════════════════════════════════════════════════════════════
/** Currently executing ability (null if none) */
/**
* Currently executing ability (null if none)
*/
private transient Ability currentAbility;
/** Per-ability cooldown timers (ability ID -> world time when cooldown ends) */
/**
* Per-ability cooldown timers (ability ID -> world time when cooldown ends)
*/
private transient Map<String, Long> cooldowns = new HashMap<>();
/** Ticks until next ability can be selected (global cooldown timer) */
/**
* Ticks until next ability can be selected (global cooldown timer)
*/
private transient int globalCooldownTimer = 0;
/** Last target used for ability execution */
/**
* Last target used for ability execution
*/
private transient EntityLivingBase lastTarget;
/** Recent hit timestamps for hit count condition */
/**
* Recent hit timestamps for hit count condition
*/
private transient List<Long> recentHitTimes = new ArrayList<>();
// ═══════════════════════════════════════════════════════════════════
@@ -532,11 +548,11 @@ public class DataAbilities {
* Fire an ability hit event. Called by abilities when they hit an entity.
* Returns null if the event was cancelled, otherwise returns the (possibly modified) event.
*
* @param ability The ability doing the hit
* @param target The original target of the ability
* @param hitEntity The entity being hit
* @param damage The damage amount
* @param knockback The horizontal knockback
* @param ability The ability doing the hit
* @param target The original target of the ability
* @param hitEntity The entity being hit
* @param damage The damage amount
* @param knockback The horizontal knockback
* @param knockbackUp The vertical knockback (deprecated, ignored)
* @return The event (with possibly modified values), or null if cancelled
*/
@@ -636,7 +652,7 @@ public class DataAbilities {
/**
* Check if ability is controlling NPC movement (AI pathfinding should be blocked).
* Called by AI tasks to determine if they should try to path.
*
* <p>
* Rules:
* - WINDUP phase: Block AI if lockMovement is true
* - ACTIVE phase: Block AI if lockMovement OR hasAbilityMovement is true
@@ -672,6 +688,7 @@ public class DataAbilities {
/**
* Check if NPC movement should be blocked due to ability execution.
*
* @deprecated Use isAbilityControllingMovement() instead
*/
@Deprecated
+19 -20
View File
@@ -38,7 +38,6 @@ import noppes.npcs.controllers.CustomGuiController;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.Dialog;
import noppes.npcs.controllers.data.EffectScript;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.IScriptBlockHandler;
import noppes.npcs.controllers.data.IScriptHandler;
@@ -265,7 +264,7 @@ public class EventHooks {
noppes.npcs.scripted.event.NpcEvent.InitEvent event = new noppes.npcs.scripted.event.NpcEvent.InitEvent(npc.wrappedNPC);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INIT, event);
npc.script.callScript(EnumScriptType.INIT, event);
NpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
npc.advanced.soulStoneInit = false;
}
@@ -276,7 +275,7 @@ public class EventHooks {
noppes.npcs.scripted.event.NpcEvent.UpdateEvent event = new noppes.npcs.scripted.event.NpcEvent.UpdateEvent(npc.wrappedNPC);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TICK, event);
npc.script.callScript(EnumScriptType.TICK, event);
NpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCDialog(EntityNPCInterface npc, EntityPlayer player, int dialogId, int optionId, Dialog dialog) {
@@ -297,7 +296,7 @@ public class EventHooks {
NpcEvent.DialogClosedEvent event = new NpcEvent.DialogClosedEvent(npc.wrappedNPC, player, dialogId, optionId, dialog);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DIALOG_CLOSE, event);
npc.script.callScript(EnumScriptType.DIALOG_CLOSE, event, "player", event.getPlayer(), "dialog", event.getDialogId(), "option", event.getOptionId(), "dialogObj", event.getDialog());
NpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCInteract(EntityNPCInterface npc, EntityPlayer player) {
@@ -307,7 +306,7 @@ public class EventHooks {
NpcEvent.InteractEvent event = new NpcEvent.InteractEvent(npc.wrappedNPC, player);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.INTERACT, event);
boolean result = npc.script.callScript(EnumScriptType.INTERACT, event, "player", player);
NpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
return result;
}
@@ -318,7 +317,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_MELEE, event);
npc.script.callScript(EnumScriptType.ATTACK_MELEE, event, "target", event.target);
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
return NpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCMeleeSwing(EntityNPCInterface npc, NpcEvent.SwingEvent event) {
@@ -327,7 +326,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.ATTACK_SWING, event);
npc.script.callScript(EnumScriptType.ATTACK_SWING, event);
return NpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCRangedAttack(EntityNPCInterface npc, NpcEvent.RangedLaunchedEvent event) {
@@ -337,7 +336,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.RANGED_LAUNCHED, event);
npc.script.callScript(EnumScriptType.RANGED_LAUNCHED, event, "target", event.target);
npc.script.callScript(EnumScriptType.ATTACK, event, "target", event.target);
return NpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCKilledEntity(EntityNPCInterface npc, EntityLivingBase entity) {
@@ -347,7 +346,7 @@ public class EventHooks {
NpcEvent.KilledEntityEvent event = new NpcEvent.KilledEntityEvent(npc.wrappedNPC, entity);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLS, event);
npc.script.callScript(EnumScriptType.KILLS, event, "target", entity);
NpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCTarget(EntityNPCInterface npc, NpcEvent.TargetEvent event) {
@@ -356,7 +355,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET, event);
npc.script.callScript(EnumScriptType.TARGET, event);
return NpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCTargetLost(EntityNPCInterface npc, EntityLivingBase prevtarget, EntityLivingBase newTarget) {
@@ -366,7 +365,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TARGET_LOST, event);
npc.script.callScript(EnumScriptType.TARGET_LOST, event);
return NpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCCollide(EntityNPCInterface npc, Entity entity) {
@@ -376,7 +375,7 @@ public class EventHooks {
NpcEvent.CollideEvent event = new NpcEvent.CollideEvent(npc.wrappedNPC, entity);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.COLLIDE, event);
npc.script.callScript(EnumScriptType.COLLIDE, event, "entity", entity);
NpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCDamaged(EntityNPCInterface npc, NpcEvent.DamagedEvent event) {
@@ -385,7 +384,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.DAMAGED, event);
npc.script.callScript(EnumScriptType.DAMAGED, event);
return NpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onNPCKilled(EntityNPCInterface npc, NpcEvent.DiedEvent event) {
@@ -394,7 +393,7 @@ public class EventHooks {
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.KILLED, event);
npc.script.callScript(EnumScriptType.KILLED, event);
return NpcAPI.EVENT_BUS.post(event);
return NpcAPI.EVENT_BUS.post(event);
}
public static void onNPCTimer(EntityNPCInterface npc, int id) {
@@ -404,7 +403,7 @@ public class EventHooks {
NpcEvent.TimerEvent event = new NpcEvent.TimerEvent(npc.wrappedNPC, id);
ScriptController.Instance.globalNpcScripts.callScript(EnumScriptType.TIMER, event);
npc.script.callScript(EnumScriptType.TIMER, event);
NpcAPI.EVENT_BUS.post(event);
NpcAPI.EVENT_BUS.post(event);
}
public static void onProjectileTick(EntityProjectile projectile) {
@@ -422,7 +421,7 @@ public class EventHooks {
EntityNPCInterface npc = (EntityNPCInterface) thrower;
npc.script.callScript(EnumScriptType.PROJECTILE_TICK, event);
}
}
}
NpcAPI.EVENT_BUS.post(event);
@@ -442,7 +441,7 @@ public class EventHooks {
EntityNPCInterface npc = (EntityNPCInterface) thrower;
npc.script.callScript(EnumScriptType.PROJECTILE_IMPACT, event);
}
}
}
NpcAPI.EVENT_BUS.post(event);
@@ -491,21 +490,21 @@ public class EventHooks {
public static boolean onEffectAdded(IPlayer player, IPlayerEffect effect) {
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
PlayerEvent.EffectEvent.Added event = new PlayerEvent.EffectEvent.Added(player, effect);
handler.callScript(EffectScript.ScriptType.OnEffectAdd.function, event);
handler.callScript(EnumScriptType.ON_EFFECT_ADD.function, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onEffectTick(IPlayer player, IPlayerEffect effect) {
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
PlayerEvent.EffectEvent.Ticked event = new PlayerEvent.EffectEvent.Ticked(player, effect);
handler.callScript(EffectScript.ScriptType.OnEffectTick.function, event);
handler.callScript(EnumScriptType.ON_EFFECT_TICK.function, event);
return NpcAPI.EVENT_BUS.post(event);
}
public static boolean onEffectRemove(IPlayer player, IPlayerEffect effect, EffectEvent.ExpirationType type) {
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts(player);
PlayerEvent.EffectEvent.Removed event = new PlayerEvent.EffectEvent.Removed(player, effect, type);
handler.callScript(EffectScript.ScriptType.OnEffectRemove.function, event);
handler.callScript(EnumScriptType.ON_EFFECT_REMOVE.function, event);
return NpcAPI.EVENT_BUS.post(event);
}
-1
View File
@@ -6,7 +6,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.data.IScriptHandler;
import noppes.npcs.controllers.data.IScriptUnit;
@@ -4,7 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.StatCollector;
import noppes.npcs.entity.EntityNPCInterface;
import java.awt.*;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.DataFlavor;
@@ -384,6 +384,7 @@ public class NoppesUtilServer {
if (gui == EnumGuiType.PlayerFollower || gui == EnumGuiType.PlayerFollowerHire || gui == EnumGuiType.PlayerTrader || gui == EnumGuiType.PlayerTransporter) {
sendRoleData(player, npc);
}
// Note: Trader-specific data (balance, stock, costs) is requested by client via GetTraderData packet
}
private static ArrayList<String> getScrollData(EntityPlayer player, EnumGuiType gui, EntityNPCInterface npc) {
@@ -36,6 +36,10 @@ public class ScriptForgeEventHandler {
@SubscribeEvent
public void forgeEntity(Event event) {
if (CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
return;
}
if (event instanceof TickEvent && !(((TickEvent) event).side == Side.SERVER && ((TickEvent) event).phase == TickEvent.Phase.START)) {
return;
}
@@ -62,7 +62,6 @@ import noppes.npcs.items.ItemNpcTool;
import noppes.npcs.quests.QuestItem;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.item.ScriptCustomizableItem;
import noppes.npcs.scripted.item.ScriptItemStack;
import static noppes.npcs.config.ConfigMain.TrackedQuestUpdateFrequency;
@@ -549,7 +548,7 @@ public class ScriptPlayerEventHandler {
if (event.source.getEntity() instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) event.source.getEntity();
if(playerMP.getHeldItem() != null) {
if (playerMP.getHeldItem() != null) {
IItemStack itemStack = NpcAPI.Instance().getIItemStack(playerMP.getHeldItem());
if (itemStack instanceof ScriptCustomizableItem) {
ScriptCustomizableItem sci = (ScriptCustomizableItem) itemStack;
@@ -51,7 +51,6 @@ import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.Line;
import noppes.npcs.controllers.data.LinkedItem;
import noppes.npcs.controllers.data.MarkData;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.PlayerData;
@@ -60,7 +59,6 @@ import noppes.npcs.controllers.data.Quest;
import noppes.npcs.controllers.data.QuestData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.items.ItemExcalibur;
import noppes.npcs.items.ItemLinked;
import noppes.npcs.items.ItemShield;
import noppes.npcs.items.ItemSoulstoneEmpty;
import noppes.npcs.quests.QuestKill;
@@ -10,8 +10,8 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.world.WorldServer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.controllers.data.action.ActionManager;
import noppes.npcs.entity.EntityNPCInterface;
public class ServerTickHandler {
@@ -3,6 +3,7 @@ package noppes.npcs.blocks.tiles;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.network.packets.request.script.BlockScriptPacket;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.ITickable;
import net.minecraft.item.Item;
@@ -25,8 +26,10 @@ import noppes.npcs.api.IBlock;
import noppes.npcs.api.block.ITextPlane;
import noppes.npcs.client.renderer.blocks.BlockScriptedRenderer;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.IScriptBlockHandler;
import noppes.npcs.controllers.data.IScriptHandlerPacket;
import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.entity.data.DataTimers;
import noppes.npcs.scripted.BlockScriptedWrapper;
@@ -36,10 +39,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;
public class TileScripted extends TileEntity implements IScriptBlockHandler {
public class TileScripted extends TileEntity implements IScriptBlockHandler, IScriptHandlerPacket {
public List<IScriptUnit> scripts = new ArrayList<>();
public Map<String, Object> tempData = new HashMap<>();
@@ -161,6 +162,36 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
text6.setNBT(compound.getCompoundTag("Text6"));
}
@Override
public ScriptContext getContext() {
return ScriptContext.BLOCK;
}
@Override
public void requestData() {
BlockScriptPacket.Get(this.xCoord, this.yCoord, this.zCoord);
}
@Override
public void sendSavePacket(int index, int totalCount, NBTTagCompound nbt) {
BlockScriptPacket.Save(this.xCoord, this.yCoord, this.zCoord, nbt);
}
@Override
public GuiDataResult setGuiData(NBTTagCompound compound) {
if (compound.hasKey("LoadComplete")) {
return new GuiDataResult(GuiDataKind.LOAD_COMPLETE, -1);
}
setNBT(compound);
return new GuiDataResult(GuiDataKind.METADATA, -1);
}
@Override
public void sync() {
sendSavePacket(-1, getScripts().size(), getNBT(new NBTTagCompound()));
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
@@ -417,25 +448,6 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler {
return scripts;
}
@Override
public Map<Long, String> getConsoleText() {
Map<Long, String> map = new TreeMap<>();
int tab = 0;
for (IScriptUnit script : getScripts()) {
tab++;
for (Entry<Long, String> entry : script.getConsole().entrySet()) {
map.put(entry.getKey(), " tab " + tab + ":\n" + entry.getValue());
}
}
return map;
}
@Override
public void clearConsole() {
for (IScriptUnit script : getScripts()) {
script.clearConsole();
}
}
@SideOnly(Side.CLIENT)
@Override
@@ -1,5 +1,6 @@
package noppes.npcs.client;
import kamkeel.npcs.network.enums.EnumSyncType;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.controllers.MusicController;
@@ -15,7 +16,6 @@ import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.controllers.data.Party;
import noppes.npcs.controllers.data.PlayerData;
import noppes.npcs.controllers.data.SkinOverlay;
import kamkeel.npcs.network.enums.EnumSyncType;
import noppes.npcs.util.CacheHashMap;
import java.util.EnumMap;
@@ -6,6 +6,8 @@ import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import kamkeel.npcs.addon.client.DBCClient;
import kamkeel.npcs.client.renderer.TelegraphRenderer;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.model.ModelBiped;
@@ -21,7 +23,9 @@ import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.Achievement;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ReportedException;
import net.minecraft.util.ResourceLocation;
@@ -120,9 +124,8 @@ import noppes.npcs.client.gui.roles.GuiNpcFollowerSetup;
import noppes.npcs.client.gui.roles.GuiNpcItemGiver;
import noppes.npcs.client.gui.roles.GuiNpcTraderSetup;
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
import noppes.npcs.client.gui.script.GuiScriptBlock;
import noppes.npcs.client.gui.script.GuiScriptGlobal;
import noppes.npcs.client.gui.script.GuiScriptItem;
import noppes.npcs.client.gui.script.GuiScriptInterface;
import noppes.npcs.client.gui.util.script.PackageFinder;
import noppes.npcs.client.gui.util.script.interpreter.type.ClassIndex;
import noppes.npcs.client.model.ModelNPCGolem;
@@ -138,8 +141,6 @@ import noppes.npcs.client.renderer.RenderNpcCrystal;
import noppes.npcs.client.renderer.RenderNpcDragon;
import noppes.npcs.client.renderer.RenderNpcSlime;
import noppes.npcs.client.renderer.RenderProjectile;
import kamkeel.npcs.client.renderer.TelegraphRenderer;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import noppes.npcs.client.renderer.blocks.BlockBannerRenderer;
import noppes.npcs.client.renderer.blocks.BlockBarrelRenderer;
import noppes.npcs.client.renderer.blocks.BlockBeamRenderer;
@@ -213,6 +214,7 @@ import noppes.npcs.entity.data.ModelPartData;
import noppes.npcs.items.ItemLinked;
import noppes.npcs.items.ItemNpcTool;
import noppes.npcs.items.ItemScripted;
import noppes.npcs.scripted.item.ScriptCustomItem;
import org.lwjgl.input.Keyboard;
import tconstruct.client.tabs.InventoryTabCustomNpc;
import tconstruct.client.tabs.InventoryTabVanilla;
@@ -493,7 +495,7 @@ public class ClientProxy extends CommonProxy {
return new GuiScript(npc);
else if (gui == EnumGuiType.ScriptItem)
return new GuiScriptItem();
return GuiScriptInterface.create(null, new ScriptCustomItem(new ItemStack(CustomItems.scripted_item)));
else if (gui == EnumGuiType.PlayerCarpentryBench)
return new GuiNpcCarpentryBench((ContainerCarpentryBench) container);
@@ -568,7 +570,7 @@ public class ClientProxy extends CommonProxy {
return new GuiCustom((ContainerCustomGui) container);
else if (gui == EnumGuiType.ScriptBlock)
return new GuiScriptBlock(x, y, z);
return getScriptBlockGui(x, y, z);
else if (gui == EnumGuiType.Paintbrush)
return new GuiNpcPaintbrush();
@@ -620,9 +622,22 @@ public class ClientProxy extends CommonProxy {
if (guiscreen != null) {
minecraft.displayGuiScreen((GuiScreen) guiscreen);
}
}
private GuiScreen getScriptBlockGui(int x, int y, int z) {
World world = Minecraft.getMinecraft().theWorld;
if (world == null)
return null;
TileEntity tile = world.getTileEntity(x, y, z);
if (!(tile instanceof TileScripted))
return null;
return GuiScriptInterface.create(null, (TileScripted) tile);
}
@Override
public void spawnParticle(EntityLivingBase player, String string, Object... ob) {
if (string.equals("Spell")) {
@@ -5,11 +5,12 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.CheckPlayerValue;
import kamkeel.npcs.network.packets.player.InputDevicePacket;
import kamkeel.npcs.network.packets.player.SpecialKeyStatePacket;
import kamkeel.npcs.network.packets.player.ScreenSizePacket;
import kamkeel.npcs.network.packets.player.SpecialKeyStatePacket;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@@ -18,7 +19,6 @@ import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.client.controllers.MusicController;
import noppes.npcs.client.controllers.ScriptSoundController;
import kamkeel.npcs.controllers.data.ability.telegraph.TelegraphManager;
import noppes.npcs.client.gui.hud.ClientHudManager;
import noppes.npcs.client.gui.hud.CompassHudComponent;
import noppes.npcs.client.gui.hud.EnumHudComponent;
@@ -11,7 +11,7 @@ import noppes.npcs.CustomNpcs;
import noppes.npcs.LogWriter;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.InputStream;
@@ -199,6 +199,7 @@ public class MusicController {
/**
* Stops a specific sound by its resource key.
* This is used to stop dialog sounds without affecting Bard music.
*
* @param soundKey The sound resource key to stop
*/
public void stopSound(String soundKey) {
@@ -5,35 +5,41 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.script.GuiNPCEventScripts;
import noppes.npcs.client.gui.script.GuiScriptInterface;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextArea;
import noppes.npcs.client.gui.util.GuiScriptTextArea;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.DataScript;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* NPC Script GUI - extends GuiScriptInterface but with unique behavior:
* - Uses scroll-based tab selection instead of top buttons
* - Shows settings/script toggle
* - Shows settings/script toggle
* - Uses DataScript with getNPCScript(index) access pattern
* - Has console filtering by hook type
*/
public class GuiScript extends GuiScriptInterface {
public boolean showScript = false;
public DataScript script;
private static int activeConsole = 0;
public GuiScript(EntityNPCInterface npc) {
super();
this.npc = npc;
@@ -41,7 +47,7 @@ public class GuiScript extends GuiScriptInterface {
this.handler = script;
this.useScrollTabs = true;
this.useSettingsToggle = true;
// Initialize hook list for NPC scripts
hookList.add("script.init");
hookList.add("script.update");
@@ -58,20 +64,20 @@ public class GuiScript extends GuiScriptInterface {
hookList.add("script.targetLost");
hookList.add("script.projectileTick");
hookList.add("script.projectileImpact");
NPCScriptPacket.Get();
}
@Override
protected ScriptContext getScriptContext() {
return ScriptContext.NPC;
}
@Override
protected int getActiveScriptIndex() {
return this.activeTab;
}
@Override
protected ScriptContainer getCurrentContainer() {
return script.getNPCScript(activeTab);
@@ -81,16 +87,18 @@ public class GuiScript extends GuiScriptInterface {
public void initGui() {
super.initGui();
this.guiTop += 10;
// ==================== TOP BUTTONS ====================
GuiMenuTopButton top;
addTopButton(top = new GuiMenuTopButton(13, guiLeft + 4, guiTop - 17, "script.scripts"));
addTopButton(new GuiMenuTopButton(16, guiLeft + (xSize - 102), guiTop - 17, "eventscript.eventScripts"));
addTopButton(new GuiMenuTopButton(17, guiLeft + (xSize - 22), guiTop - 17, "X"));
top.active = showScript;
addTopButton(top = new GuiMenuTopButton(14, top, "gui.settings"));
top.active = !showScript;
addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
// ==================== TOP BUTTONS (hidden in fullscreen) ====================
if (!isFullscreen) {
GuiMenuTopButton top;
addTopButton(top = new GuiMenuTopButton(13, guiLeft + 4, guiTop - 17, "script.scripts"));
addTopButton(new GuiMenuTopButton(16, guiLeft + (xSize - 102), guiTop - 17, "eventscript.eventScripts"));
addTopButton(new GuiMenuTopButton(17, guiLeft + (xSize - 22), guiTop - 17, "X"));
top.active = showScript;
addTopButton(top = new GuiMenuTopButton(14, top, "gui.settings"));
top.active = !showScript;
addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
}
if (showScript) {
initScriptView();
@@ -98,13 +106,13 @@ public class GuiScript extends GuiScriptInterface {
initSettingsView();
}
}
private void initScriptView() {
ScriptContainer container = getCurrentContainer();
// ==================== CALCULATE VIEWPORT BOUNDS ====================
int editorX, editorY, editorWidth, editorHeight;
if (isFullscreen) {
// Fullscreen: viewport fills screen with configured padding
FullscreenConfig.paddingTop = 30;
@@ -122,11 +130,11 @@ public class GuiScript extends GuiScriptInterface {
editorWidth = 239;
editorHeight = 208;
}
// ==================== HOOKS SCROLL (hidden in fullscreen) ====================
if (!isFullscreen) {
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
hooks.setSize(68, 198);
hooks.guiLeft = guiLeft + 4;
@@ -141,36 +149,34 @@ public class GuiScript extends GuiScriptInterface {
GuiScriptTextArea activeArea = getActiveScriptArea();
if (activeArea == null) {
activeArea = new GuiScriptTextArea(this, 2, editorX, editorY, editorWidth, editorHeight,
container == null ? "" : container.script);
container == null ? "" : container.script);
activeArea.setListener(this);
this.closeOnEsc(activeArea::closeOnEsc);
textAreas.put(idx, activeArea);
} else {
activeArea.init(editorX, editorY, editorWidth, editorHeight,
container == null ? "" : container.script);
activeArea.init(editorX, editorY, editorWidth, editorHeight,
container == null ? "" : container.script);
}
activeArea.setLanguage(script.getLanguage());
activeArea.setScriptContext(getScriptContext());
// Setup fullscreen key binding
GuiScriptTextArea.KEYS.FULLSCREEN.setTask(e -> {
if (e.isPress()) {
toggleFullscreen();
}
});
activeArea.enableCodeHighlighting();
addTextField(activeArea);
// Initialize fullscreen button
int scrollbarOffset = activeArea.hasVerticalScrollbar() ? -8 : -2;
fullscreenButton.initGui(editorX + editorWidth, editorY, scrollbarOffset);
// Set language and script context for proper syntax highlighting and autocomplete
activeArea.setLanguage(script.getLanguage());
activeArea.setScriptContext(ScriptContext.NPC);
// ==================== RIGHT PANEL (hidden in fullscreen) ====================
if (!isFullscreen) {
addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear"));
addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste"));
addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy"));
@@ -184,33 +190,36 @@ public class GuiScript extends GuiScriptInterface {
scroll.setList(container.scripts);
addScroll(scroll);
}
}
private void initSettingsView() {
addLabel(new GuiNpcLabel(0, "script.console", guiLeft + 4, guiTop + 16));
getTopButton(14).active = true;
if (getTopButton(14) != null)
getTopButton(14).active = true;
GuiNpcTextArea consoleArea = new GuiNpcTextArea(2, this, guiLeft + 4, guiTop + 26, 226, 186, getConsoleText());
consoleArea.canEdit = false;
addTextField(consoleArea);
addButton(new GuiNpcButton(100, guiLeft + 232, guiTop + 170, 56, 20, "gui.copy"));
addButton(new GuiNpcButton(102, guiLeft + 232, guiTop + 192, 56, 20, "gui.clear"));
List<String> consoleOptions = new ArrayList<>();
consoleOptions.add("All");
consoleOptions.addAll(hookList);
addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20,
consoleOptions.toArray(new String[0]), activeConsole));
addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20,
consoleOptions.toArray(new String[0]), activeConsole));
addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30));
addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20,
languages.keySet().toArray(new String[0]), getScriptIndex()));
getButton(103).enabled = languages.size() > 0;
List<String> languageOptions = getLanguageOptions();
addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20,
languageOptions.toArray(new String[0]), getLanguageIndex(languageOptions)));
getButton(103).enabled = languageOptions.size() > 0;
addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53));
addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20,
new String[]{"gui.no", "gui.yes"}, script.enabled ? 1 : 0));
addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20,
new String[]{"gui.no", "gui.yes"}, script.enabled ? 1 : 0));
if (MinecraftServer.getServer() != null)
addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder"));
@@ -269,7 +278,7 @@ public class GuiScript extends GuiScriptInterface {
}
if (guibutton.id == 16) {
close();
mc.displayGuiScreen(new GuiNPCEventScripts(npc));
GuiScriptInterface.open(this, this.script);
}
if (guibutton.id == 17) {
close();
@@ -278,12 +287,12 @@ public class GuiScript extends GuiScriptInterface {
NoppesStringUtils.setClipboardContents(getTextField(2).getText());
}
if (guibutton.id == 101) {
displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.paste"),
StatCollector.translateToLocal("gui.sure"), 101));
displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.paste"),
StatCollector.translateToLocal("gui.sure"), 101));
}
if (guibutton.id == 102) {
displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.clear"),
StatCollector.translateToLocal("gui.sure"), 102));
displayGuiScreen(new GuiYesNo(this, StatCollector.translateToLocal("gui.clear"),
StatCollector.translateToLocal("gui.sure"), 102));
}
if (guibutton.id == 103) {
script.scriptLanguage = ((GuiNpcButton) guibutton).displayString;
@@ -342,5 +351,24 @@ public class GuiScript extends GuiScriptInterface {
initGui();
}
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
// Draw fullscreen button when in script view (GuiScript uses 0-based activeTab)
if (showScript) {
fullscreenButton.draw(mouseX, mouseY);
}
}
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
// Check fullscreen button first when in script view
if (showScript && fullscreenButton.mouseClicked(mouseX, mouseY, mouseButton)) {
return;
}
super.mouseClicked(mouseX, mouseY, mouseButton);
}
}
@@ -20,7 +20,7 @@ public class GuiScriptList extends SubGuiInterface {
public GuiScriptList(List<String> scripts, ScriptContainer container) {
this(scripts, (IScriptUnit) container);
}
public GuiScriptList(List<String> scripts, IScriptUnit scriptUnit) {
this.scriptUnit = scriptUnit;
setBackground("menubg.png");
@@ -7,7 +7,7 @@ import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.gui.global.GuiNPCManageEffects;
import noppes.npcs.client.gui.script.GuiScriptEffect;
import noppes.npcs.client.gui.script.GuiScriptInterface;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -17,6 +17,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.controllers.data.CustomEffect;
import noppes.npcs.controllers.data.EffectScript;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
@@ -202,10 +203,7 @@ public class SubGuiEffectGeneral extends SubGuiInterface implements ITextfieldLi
}
if (id == -2) {
PacketClient.sendClient(new EffectSavePacket(effect.writeToNBT(false), originalName));
GuiScriptEffect scriptGUI = new GuiScriptEffect(parent, effect);
scriptGUI.setWorldAndResolution(mc, width, height);
scriptGUI.initGui();
mc.currentScreen = scriptGUI;
GuiScriptInterface.open(parent, new EffectScript(effect.id));
}
if (id == 10) {
GuiNpcButtonYesNo button = (GuiNpcButtonYesNo) guibutton;
@@ -36,7 +36,7 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Fields
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
// Current tab (10=Quest, 11=Dialog, 12=Transport, 13=Bank, 14=Faction, 15=Magic)
private int currentTab = 10;
@@ -99,7 +99,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Constructor
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
public SubGuiPlayerData(String playerName) {
this.playerName = playerName;
xSize = 420;
@@ -112,7 +113,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Layout Helpers
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
private int getPaddedLeft() {
return guiLeft + leftPadding;
}
@@ -135,7 +137,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Component Setup Helpers
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
private void setupTopButtons() {
// Show General Display Information
GuiMenuTopButton playerTab = new GuiMenuTopButton(-10, guiLeft + 4, guiTop - 10, playerName);
@@ -192,7 +195,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// initGui() & Tab Initialization
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
@Override
public void initGui() {
super.initGui();
@@ -489,7 +493,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Drawing Helpers
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
@@ -525,7 +530,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Mouse & Resizing Handlers
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
@Override
public void mouseClicked(int mouseX, int mouseY, int mouseButton) {
int hitMargin = 3;
@@ -672,7 +678,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Key & Search Field Handling
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
@Override
public void keyTyped(char c, int i) {
super.keyTyped(c, i);
@@ -894,7 +901,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Action Handling
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
@Override
public void actionPerformed(GuiButton button) {
if (button.id == -5) {
@@ -1043,7 +1051,8 @@ public class SubGuiPlayerData extends SubGuiInterface implements IPlayerDataInfo
////////////////////////////////////////////////////////////////////////////////
// Data Setting Methods (IPlayerDataInfo)
////////////////////////////////////////////////////////////////////////////////
/// /////////////////////////////////////////////////////////////////////////////
@Override
public void setQuestData(Map<String, Integer> questCategories, Map<String, Integer> questActive, Map<String, Integer> questFinished) {
this.questCatData = new HashMap<>(questCategories);
@@ -10,7 +10,18 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.resources.I18n;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.IScrollData;
import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumScrollData;
import noppes.npcs.entity.EntityNPCInterface;
@@ -10,7 +10,14 @@ import net.minecraft.util.StatCollector;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.select.GuiAnimationSelection;
import noppes.npcs.client.gui.select.GuiSoundSelection;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.ArrayList;
import java.util.List;
@@ -18,13 +25,13 @@ import java.util.List;
/**
* Base SubGui for editing ability configuration with tabbed interface.
* Uses GuiMenuTopButton for navigation tabs.
*
* <p>
* Tabs:
* - General: Name, Weight, Lock Movement, Interruptible, Timing
* - Type: Type-specific settings per Ability (override in subclasses)
* - Target: Min/Max Range, Targeting Mode, Conditions (up to 3)
* - Effects: Sounds, Animations, Telegraph settings, Colors
*
* <p>
* Subclasses should override initTypeTab() and handleTypeButton()/handleTypeTextField()
* to provide type-specific settings UI.
*/
@@ -144,20 +151,20 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// ═══════════════════════════════════════════════════════════════════════
// TOP TABS using GuiMenuTopButton
// ═══════════════════════════════════════════════════════════════════════
GuiMenuTopButton generalTab = new GuiMenuTopButton(90, guiLeft + 4, guiTop - 17, "ability.tab.general");
GuiMenuTopButton generalTab = new GuiMenuTopButton(90, guiLeft + 4, guiTop - 17, "menu.general");
generalTab.active = (activeTab == TAB_GENERAL);
addTopButton(generalTab);
GuiMenuTopButton lastTab = generalTab;
if (hasTypeSettings) {
GuiMenuTopButton typeTab = new GuiMenuTopButton(91, lastTab, "ability.tab.type");
GuiMenuTopButton typeTab = new GuiMenuTopButton(91, lastTab, "gui.type");
typeTab.active = (activeTab == TAB_TYPE);
addTopButton(typeTab);
lastTab = typeTab;
}
GuiMenuTopButton targetTab = new GuiMenuTopButton(92, lastTab, "ability.tab.target");
GuiMenuTopButton targetTab = new GuiMenuTopButton(92, lastTab, "script.target");
targetTab.active = (activeTab == TAB_TARGET);
addTopButton(targetTab);
lastTab = targetTab;
@@ -376,13 +383,13 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
String typeId = cond.getTypeId();
switch (typeId) {
case "hp_above":
return StatCollector.translateToLocal("condition.hp_above") + " " + (int)(getConditionThreshold(cond) * 100) + "%";
return StatCollector.translateToLocal("condition.hp_above") + " " + (int) (getConditionThreshold(cond) * 100) + "%";
case "hp_below":
return StatCollector.translateToLocal("condition.hp_below") + " " + (int)(getConditionThreshold(cond) * 100) + "%";
return StatCollector.translateToLocal("condition.hp_below") + " " + (int) (getConditionThreshold(cond) * 100) + "%";
case "target_hp_above":
return StatCollector.translateToLocal("condition.target_hp_above") + " " + (int)(getConditionThreshold(cond) * 100) + "%";
return StatCollector.translateToLocal("condition.target_hp_above") + " " + (int) (getConditionThreshold(cond) * 100) + "%";
case "target_hp_below":
return StatCollector.translateToLocal("condition.target_hp_below") + " " + (int)(getConditionThreshold(cond) * 100) + "%";
return StatCollector.translateToLocal("condition.target_hp_below") + " " + (int) (getConditionThreshold(cond) * 100) + "%";
case "hit_count":
Condition.ConditionHitCount hitCount = (Condition.ConditionHitCount) cond;
return StatCollector.translateToLocal("condition.hit_count") + ": " + hitCount.getRequiredHits() + "/" + hitCount.getWithinTicks() + "t";
@@ -435,7 +442,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// ─────────────────────────────────────────────────────────────────────
// SOUNDS SECTION
// ─────────────────────────────────────────────────────────────────────
addLabel(new GuiNpcLabel(30, "ability.sounds", col1LabelX, y));
addLabel(new GuiNpcLabel(30, "advanced.sounds", col1LabelX, y));
y += 14;
// Wind Up Sound
@@ -455,7 +462,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// ─────────────────────────────────────────────────────────────────────
// ANIMATIONS SECTION
// ─────────────────────────────────────────────────────────────────────
addLabel(new GuiNpcLabel(33, "ability.animations", col1LabelX, y));
addLabel(new GuiNpcLabel(33, "menu.animations", col1LabelX, y));
y += 14;
// Wind Up Animation
@@ -486,7 +493,8 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// Telegraph Type (separate column)
String typeKey = ability.getTelegraphType().name().toLowerCase();
addLabel(new GuiNpcLabel(42, "ability.telegraphType", guiLeft + 200, y + 5));
addLabel(new GuiNpcLabel(43, "ability.telegraph." + typeKey, guiLeft + 280, y + 5));
String telegraphLangKey = typeKey.equals("none") ? "gui.none" : "telegraph." + typeKey;
addLabel(new GuiNpcLabel(43, telegraphLangKey, guiLeft + 280, y + 5));
y += 24;
@@ -565,8 +573,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
// General tab buttons
else if (id == 14) {
interruptible = ((GuiNpcButton) guibutton).getValue() == 1;
}
else if (id == 16) {
} else if (id == 16) {
lockMovement = ((GuiNpcButton) guibutton).getValue() == 1;
}
@@ -618,12 +625,10 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
else if (id == 20) {
showTelegraph = ((GuiNpcButton) guibutton).getValue() == 1;
initGui();
}
else if (id == 22) {
} else if (id == 22) {
editingColorId = 22;
setSubGui(new SubGuiColorSelector(windUpColor));
}
else if (id == 24) {
} else if (id == 24) {
editingColorId = 24;
setSubGui(new SubGuiColorSelector(activeColor));
}
@@ -632,8 +637,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
else if (id == 30) {
editingSoundId = 30;
setSubGui(new GuiSoundSelection(windUpSound));
}
else if (id == 31) {
} else if (id == 31) {
editingSoundId = 31;
setSubGui(new GuiSoundSelection(activeSound));
}
@@ -641,8 +645,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
else if (id == 35) {
windUpSound = "";
initGui();
}
else if (id == 36) {
} else if (id == 36) {
activeSound = "";
initGui();
}
@@ -650,8 +653,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
else if (id == 32) {
editingAnimationId = 32;
setSubGui(new GuiAnimationSelection(windUpAnimationId));
}
else if (id == 33) {
} else if (id == 33) {
editingAnimationId = 33;
setSubGui(new GuiAnimationSelection(activeAnimationId));
}
@@ -660,8 +662,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
windUpAnimationId = -1;
windUpAnimationName = null;
initGui();
}
else if (id == 38) {
} else if (id == 38) {
activeAnimationId = -1;
activeAnimationName = null;
initGui();
@@ -3,7 +3,11 @@ package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import java.util.ArrayList;
import java.util.List;
@@ -2,7 +2,11 @@ package noppes.npcs.client.gui.advanced;
import kamkeel.npcs.controllers.data.ability.Condition;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
/**
* SubGui for editing a single ability condition.
@@ -106,7 +110,7 @@ public class SubGuiConditionEdit extends SubGuiInterface implements ITextfieldLi
} else {
// HP threshold field (as percentage)
addLabel(new GuiNpcLabel(2, "condition.percent", labelX, y + 5));
int percent = (int)(threshold * 100);
int percent = (int) (threshold * 100);
GuiNpcTextField thresholdField = new GuiNpcTextField(4, this, fontRendererObj, fieldX, y, 40, 20, String.valueOf(percent));
thresholdField.setIntegersOnly();
thresholdField.setMinMaxDefault(1, 99, 50);
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityBeam;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Beam ability type-specific settings.
@@ -28,7 +28,7 @@ public class SubGuiAbilityBeam extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Damage Interval
addLabel(new GuiNpcLabel(100, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, beam.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.dmgInterval", col2LabelX, y + 5));
@@ -72,21 +72,39 @@ public class SubGuiAbilityBeam extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
case 106: beam.setPiercing(value == 1); break;
case 107: beam.setLockOnTarget(value == 1); break;
case 108: beam.setSweepBackAndForth(value == 1); break;
case 106:
beam.setPiercing(value == 1);
break;
case 107:
beam.setLockOnTarget(value == 1);
break;
case 108:
beam.setSweepBackAndForth(value == 1);
break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: beam.setDamage(parseFloat(field, beam.getDamage())); break;
case 101: beam.setDamageInterval(field.getInteger()); break;
case 102: beam.setBeamLength(parseFloat(field, beam.getBeamLength())); break;
case 103: beam.setBeamWidth(parseFloat(field, beam.getBeamWidth())); break;
case 104: beam.setSweepAngle(parseFloat(field, beam.getSweepAngle())); break;
case 105: beam.setSweepSpeed(parseFloat(field, beam.getSweepSpeed())); break;
case 100:
beam.setDamage(parseFloat(field, beam.getDamage()));
break;
case 101:
beam.setDamageInterval(field.getInteger());
break;
case 102:
beam.setBeamLength(parseFloat(field, beam.getBeamLength()));
break;
case 103:
beam.setBeamWidth(parseFloat(field, beam.getBeamWidth()));
break;
case 104:
beam.setSweepAngle(parseFloat(field, beam.getSweepAngle()));
break;
case 105:
beam.setSweepSpeed(parseFloat(field, beam.getSweepSpeed()));
break;
}
}
}
@@ -1,10 +1,10 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityCharge;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Charge ability type-specific settings.
@@ -27,10 +27,10 @@ public class SubGuiAbilityCharge extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Speed
addLabel(new GuiNpcLabel(100, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, charge.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.speed", col2LabelX, y + 5));
addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5));
addTextField(createFloatField(101, col2FieldX, y, 50, charge.getChargeSpeed()));
y += 24;
@@ -50,10 +50,18 @@ public class SubGuiAbilityCharge extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: charge.setDamage(parseFloat(field, charge.getDamage())); break;
case 101: charge.setChargeSpeed(parseFloat(field, charge.getChargeSpeed())); break;
case 102: charge.setKnockback(parseFloat(field, charge.getKnockback())); break;
case 104: charge.setHitWidth(parseFloat(field, charge.getHitWidth())); break;
case 100:
charge.setDamage(parseFloat(field, charge.getDamage()));
break;
case 101:
charge.setChargeSpeed(parseFloat(field, charge.getChargeSpeed()));
break;
case 102:
charge.setKnockback(parseFloat(field, charge.getKnockback()));
break;
case 104:
charge.setHitWidth(parseFloat(field, charge.getHitWidth()));
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityCutter;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Cutter ability type-specific settings.
@@ -28,10 +28,10 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Range
addLabel(new GuiNpcLabel(100, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, cutter.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.range", col2LabelX, y + 5));
addLabel(new GuiNpcLabel(101, "gui.range", col2LabelX, y + 5));
addTextField(createFloatField(101, col2FieldX, y, 50, cutter.getRange()));
y += 24;
@@ -82,23 +82,45 @@ public class SubGuiAbilityCutter extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
case 106: cutter.setSweepMode(AbilityCutter.SweepMode.values()[value]); break;
case 107: cutter.setPiercing(value == 1); break;
case 106:
cutter.setSweepMode(AbilityCutter.SweepMode.values()[value]);
break;
case 107:
cutter.setPiercing(value == 1);
break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: cutter.setDamage(parseFloat(field, cutter.getDamage())); break;
case 101: cutter.setRange(parseFloat(field, cutter.getRange())); break;
case 102: cutter.setArcAngle(parseFloat(field, cutter.getArcAngle())); break;
case 103: cutter.setInnerRadius(parseFloat(field, cutter.getInnerRadius())); break;
case 104: cutter.setKnockback(parseFloat(field, cutter.getKnockback())); break;
case 105: cutter.setSweepSpeed(parseFloat(field, cutter.getSweepSpeed())); break;
case 108: cutter.setStunDuration(field.getInteger()); break;
case 109: cutter.setPoisonDurationSeconds(field.getInteger()); break;
case 110: cutter.setPoisonLevel(field.getInteger()); break;
case 100:
cutter.setDamage(parseFloat(field, cutter.getDamage()));
break;
case 101:
cutter.setRange(parseFloat(field, cutter.getRange()));
break;
case 102:
cutter.setArcAngle(parseFloat(field, cutter.getArcAngle()));
break;
case 103:
cutter.setInnerRadius(parseFloat(field, cutter.getInnerRadius()));
break;
case 104:
cutter.setKnockback(parseFloat(field, cutter.getKnockback()));
break;
case 105:
cutter.setSweepSpeed(parseFloat(field, cutter.getSweepSpeed()));
break;
case 108:
cutter.setStunDuration(field.getInteger());
break;
case 109:
cutter.setPoisonDurationSeconds(field.getInteger());
break;
case 110:
cutter.setPoisonLevel(field.getInteger());
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityDash;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Dash ability type-specific settings.
@@ -28,7 +28,7 @@ public class SubGuiAbilityDash extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Dash Mode
addLabel(new GuiNpcLabel(100, "ability.dashMode", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "ability.mode", labelX, y + 5));
String[] dashModes = {"Aggressive", "Defensive"};
addButton(new GuiNpcButton(100, fieldX, y, 80, 20, dashModes, dash.getDashMode().ordinal()));
@@ -52,8 +52,12 @@ public class SubGuiAbilityDash extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 101: dash.setDashDistance(parseFloat(field, dash.getDashDistance())); break;
case 102: dash.setDashSpeed(parseFloat(field, dash.getDashSpeed())); break;
case 101:
dash.setDashDistance(parseFloat(field, dash.getDashDistance()));
break;
case 102:
dash.setDashSpeed(parseFloat(field, dash.getDashSpeed()));
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Guard ability type-specific settings.
@@ -86,11 +86,21 @@ public class SubGuiAbilityGuard extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: guard.setDamageReduction(parseFloat(field, guard.getDamageReduction())); break;
case 103: guard.setCounterValue(parseFloat(field, guard.getCounterValue())); break;
case 104: guard.setCounterChance(parseFloat(field, guard.getCounterChance())); break;
case 105: guard.setCounterSound(field.getText()); break;
case 106: guard.setCounterAnimationId(field.getInteger()); break;
case 100:
guard.setDamageReduction(parseFloat(field, guard.getDamageReduction()));
break;
case 103:
guard.setCounterValue(parseFloat(field, guard.getCounterValue()));
break;
case 104:
guard.setCounterChance(parseFloat(field, guard.getCounterChance()));
break;
case 105:
guard.setCounterSound(field.getText());
break;
case 106:
guard.setCounterAnimationId(field.getInteger());
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityHazard;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Hazard ability type-specific settings.
@@ -77,22 +77,42 @@ public class SubGuiAbilityHazard extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
case 100: hazard.setShape(AbilityHazard.HazardShape.values()[value]); break;
case 101: hazard.setPlacement(AbilityHazard.PlacementMode.values()[value]); break;
case 109: hazard.setAffectsCaster(value == 1); break;
case 100:
hazard.setShape(AbilityHazard.HazardShape.values()[value]);
break;
case 101:
hazard.setPlacement(AbilityHazard.PlacementMode.values()[value]);
break;
case 109:
hazard.setAffectsCaster(value == 1);
break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 102: hazard.setRadius(parseFloat(field, hazard.getRadius())); break;
case 103: hazard.setInnerRadius(parseFloat(field, hazard.getInnerRadius())); break;
case 104: hazard.setDamagePerTick(parseFloat(field, hazard.getDamagePerTick())); break;
case 105: hazard.setDamageInterval(field.getInteger()); break;
case 106: hazard.setSlownessLevel(field.getInteger()); break;
case 107: hazard.setDebuffDuration(field.getInteger()); break;
case 108: hazard.setPoisonLevel(field.getInteger()); break;
case 102:
hazard.setRadius(parseFloat(field, hazard.getRadius()));
break;
case 103:
hazard.setInnerRadius(parseFloat(field, hazard.getInnerRadius()));
break;
case 104:
hazard.setDamagePerTick(parseFloat(field, hazard.getDamagePerTick()));
break;
case 105:
hazard.setDamageInterval(field.getInteger());
break;
case 106:
hazard.setSlownessLevel(field.getInteger());
break;
case 107:
hazard.setDebuffDuration(field.getInteger());
break;
case 108:
hazard.setPoisonLevel(field.getInteger());
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityHeal;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Heal ability type-specific settings.
@@ -40,7 +40,7 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
addLabel(new GuiNpcLabel(102, "ability.healRadius", labelX, y + 5));
addTextField(createFloatField(102, fieldX, y, 50, heal.getHealRadius()));
addLabel(new GuiNpcLabel(103, "ability.instant", col2LabelX, y + 5));
addLabel(new GuiNpcLabel(103, "dialog.instant", col2LabelX, y + 5));
addButton(new GuiNpcButton(103, col2FieldX, y, 50, 20, new String[]{"gui.no", "gui.yes"}, heal.isInstantHeal() ? 1 : 0));
y += 24;
@@ -57,18 +57,30 @@ public class SubGuiAbilityHeal extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
case 103: heal.setInstantHeal(value == 1); break;
case 104: heal.setHealSelf(value == 1); break;
case 105: heal.setHealAllies(value == 1); break;
case 103:
heal.setInstantHeal(value == 1);
break;
case 104:
heal.setHealSelf(value == 1);
break;
case 105:
heal.setHealAllies(value == 1);
break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: heal.setHealAmount(parseFloat(field, heal.getHealAmount())); break;
case 101: heal.setHealPercent(parseFloat(field, heal.getHealPercent())); break;
case 102: heal.setHealRadius(parseFloat(field, heal.getHealRadius())); break;
case 100:
heal.setHealAmount(parseFloat(field, heal.getHealAmount()));
break;
case 101:
heal.setHealPercent(parseFloat(field, heal.getHealPercent()));
break;
case 102:
heal.setHealRadius(parseFloat(field, heal.getHealRadius()));
break;
}
}
}
@@ -1,10 +1,10 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityHeavyHit;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Heavy Hit ability type-specific settings.
@@ -27,7 +27,7 @@ public class SubGuiAbilityHeavyHit extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Potion Time
addLabel(new GuiNpcLabel(100, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, heavyHit.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.potionTime", col2LabelX, y + 5));
@@ -52,11 +52,21 @@ public class SubGuiAbilityHeavyHit extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: heavyHit.setDamage(parseFloat(field, heavyHit.getDamage())); break;
case 101: heavyHit.setPotionDurationSeconds(field.getInteger()); break;
case 102: heavyHit.setKnockback(parseFloat(field, heavyHit.getKnockback())); break;
case 103: heavyHit.setSlownessLevel(field.getInteger()); break;
case 104: heavyHit.setWeaknessLevel(field.getInteger()); break;
case 100:
heavyHit.setDamage(parseFloat(field, heavyHit.getDamage()));
break;
case 101:
heavyHit.setPotionDurationSeconds(field.getInteger());
break;
case 102:
heavyHit.setKnockback(parseFloat(field, heavyHit.getKnockback()));
break;
case 103:
heavyHit.setSlownessLevel(field.getInteger());
break;
case 104:
heavyHit.setWeaknessLevel(field.getInteger());
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityOrb;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Orb ability type-specific settings.
@@ -28,16 +28,16 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Speed
addLabel(new GuiNpcLabel(100, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, orb.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.speed", col2LabelX, y + 5));
addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5));
addTextField(createFloatField(101, col2FieldX, y, 50, orb.getOrbSpeed()));
y += 24;
// Row 2: Orb Size + Max Distance
addLabel(new GuiNpcLabel(102, "ability.orbSize", labelX, y + 5));
addLabel(new GuiNpcLabel(102, "stats.size", labelX, y + 5));
addTextField(createFloatField(102, fieldX, y, 50, orb.getOrbSize()));
addLabel(new GuiNpcLabel(103, "ability.maxDist", col2LabelX, y + 5));
@@ -75,22 +75,42 @@ public class SubGuiAbilityOrb extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
case 104: orb.setHoming(value == 1); break;
case 106: orb.setExplosive(value == 1); break;
case 104:
orb.setHoming(value == 1);
break;
case 106:
orb.setExplosive(value == 1);
break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: orb.setDamage(parseFloat(field, orb.getDamage())); break;
case 101: orb.setOrbSpeed(parseFloat(field, orb.getOrbSpeed())); break;
case 102: orb.setOrbSize(parseFloat(field, orb.getOrbSize())); break;
case 103: orb.setMaxDistance(parseFloat(field, orb.getMaxDistance())); break;
case 105: orb.setHomingStrength(parseFloat(field, orb.getHomingStrength())); break;
case 107: orb.setExplosionRadius(parseFloat(field, orb.getExplosionRadius())); break;
case 108: orb.setKnockback(parseFloat(field, orb.getKnockback())); break;
case 109: orb.setMaxLifetime(field.getInteger()); break;
case 100:
orb.setDamage(parseFloat(field, orb.getDamage()));
break;
case 101:
orb.setOrbSpeed(parseFloat(field, orb.getOrbSpeed()));
break;
case 102:
orb.setOrbSize(parseFloat(field, orb.getOrbSize()));
break;
case 103:
orb.setMaxDistance(parseFloat(field, orb.getMaxDistance()));
break;
case 105:
orb.setHomingStrength(parseFloat(field, orb.getHomingStrength()));
break;
case 107:
orb.setExplosionRadius(parseFloat(field, orb.getExplosionRadius()));
break;
case 108:
orb.setKnockback(parseFloat(field, orb.getKnockback()));
break;
case 109:
orb.setMaxLifetime(field.getInteger());
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityProjectile;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Projectile ability type-specific settings.
@@ -28,10 +28,10 @@ public class SubGuiAbilityProjectile extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Speed
addLabel(new GuiNpcLabel(100, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, projectile.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.speed", col2LabelX, y + 5));
addLabel(new GuiNpcLabel(101, "stats.speed", col2LabelX, y + 5));
addTextField(createFloatField(101, col2FieldX, y, 50, projectile.getSpeed()));
y += 24;
@@ -79,19 +79,33 @@ public class SubGuiAbilityProjectile extends SubGuiAbilityConfig {
String[] projTypes = {"fireball", "arrow", "magic"};
projectile.setProjectileType(projTypes[value]);
break;
case 104: projectile.setExplosive(value == 1); break;
case 106: projectile.setHoming(value == 1); break;
case 104:
projectile.setExplosive(value == 1);
break;
case 106:
projectile.setHoming(value == 1);
break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: projectile.setDamage(parseFloat(field, projectile.getDamage())); break;
case 101: projectile.setSpeed(parseFloat(field, projectile.getSpeed())); break;
case 102: projectile.setKnockback(parseFloat(field, projectile.getKnockback())); break;
case 105: projectile.setExplosionRadius(parseFloat(field, projectile.getExplosionRadius())); break;
case 107: projectile.setHomingStrength(parseFloat(field, projectile.getHomingStrength())); break;
case 100:
projectile.setDamage(parseFloat(field, projectile.getDamage()));
break;
case 101:
projectile.setSpeed(parseFloat(field, projectile.getSpeed()));
break;
case 102:
projectile.setKnockback(parseFloat(field, projectile.getKnockback()));
break;
case 105:
projectile.setExplosionRadius(parseFloat(field, projectile.getExplosionRadius()));
break;
case 107:
projectile.setHomingStrength(parseFloat(field, projectile.getHomingStrength()));
break;
}
}
}
@@ -1,10 +1,10 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityShockwave;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Shockwave ability type-specific settings.
@@ -27,7 +27,7 @@ public class SubGuiAbilityShockwave extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Push Radius
addLabel(new GuiNpcLabel(100, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, shockwave.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.pushRadius", col2LabelX, y + 5));
@@ -55,11 +55,21 @@ public class SubGuiAbilityShockwave extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: shockwave.setDamage(parseFloat(field, shockwave.getDamage())); break;
case 101: shockwave.setPushRadius(parseFloat(field, shockwave.getPushRadius())); break;
case 102: shockwave.setPushStrength(parseFloat(field, shockwave.getPushStrength())); break;
case 103: shockwave.setStunDuration(field.getInteger()); break;
case 104: shockwave.setMaxTargets(field.getInteger()); break;
case 100:
shockwave.setDamage(parseFloat(field, shockwave.getDamage()));
break;
case 101:
shockwave.setPushRadius(parseFloat(field, shockwave.getPushRadius()));
break;
case 102:
shockwave.setPushStrength(parseFloat(field, shockwave.getPushStrength()));
break;
case 103:
shockwave.setStunDuration(field.getInteger());
break;
case 104:
shockwave.setMaxTargets(field.getInteger());
break;
}
}
}
@@ -1,10 +1,10 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilitySlam;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Slam ability type-specific settings.
@@ -27,7 +27,7 @@ public class SubGuiAbilitySlam extends SubGuiAbilityConfig {
int col2FieldX = guiLeft + 205;
// Row 1: Damage + Radius
addLabel(new GuiNpcLabel(100, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(100, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(100, fieldX, y, 50, slam.getDamage()));
addLabel(new GuiNpcLabel(101, "ability.radius", col2LabelX, y + 5));
@@ -52,11 +52,21 @@ public class SubGuiAbilitySlam extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: slam.setDamage(parseFloat(field, slam.getDamage())); break;
case 101: slam.setRadius(parseFloat(field, slam.getRadius())); break;
case 102: slam.setKnockbackStrength(parseFloat(field, slam.getKnockbackStrength())); break;
case 103: slam.setLeapSpeed(parseFloat(field, slam.getLeapSpeed())); break;
case 104: slam.setLeapHeight(parseFloat(field, slam.getLeapHeight())); break;
case 100:
slam.setDamage(parseFloat(field, slam.getDamage()));
break;
case 101:
slam.setRadius(parseFloat(field, slam.getRadius()));
break;
case 102:
slam.setKnockbackStrength(parseFloat(field, slam.getKnockbackStrength()));
break;
case 103:
slam.setLeapSpeed(parseFloat(field, slam.getLeapSpeed()));
break;
case 104:
slam.setLeapHeight(parseFloat(field, slam.getLeapHeight()));
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityTeleport;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Teleport ability type-specific settings.
@@ -71,7 +71,7 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig {
}
// Damage + Damage Radius
addLabel(new GuiNpcLabel(106, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(106, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(106, fieldX, y, 50, teleport.getDamage()));
addLabel(new GuiNpcLabel(107, "ability.dmgRadius", col2LabelX, y + 5));
@@ -95,21 +95,39 @@ public class SubGuiAbilityTeleport extends SubGuiAbilityConfig {
teleport.setMode(AbilityTeleport.TeleportMode.values()[value]);
initGui();
break;
case 105: teleport.setRequireLineOfSight(value == 1); break;
case 108: teleport.setDamageAtStart(value == 1); break;
case 109: teleport.setDamageAtEnd(value == 1); break;
case 105:
teleport.setRequireLineOfSight(value == 1);
break;
case 108:
teleport.setDamageAtStart(value == 1);
break;
case 109:
teleport.setDamageAtEnd(value == 1);
break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 101: teleport.setBlinkRadius(parseFloat(field, teleport.getBlinkRadius())); break;
case 102: teleport.setBlinkCount(field.getInteger()); break;
case 103: teleport.setBlinkDelayTicks(field.getInteger()); break;
case 104: teleport.setBehindDistance(parseFloat(field, teleport.getBehindDistance())); break;
case 106: teleport.setDamage(parseFloat(field, teleport.getDamage())); break;
case 107: teleport.setDamageRadius(parseFloat(field, teleport.getDamageRadius())); break;
case 101:
teleport.setBlinkRadius(parseFloat(field, teleport.getBlinkRadius()));
break;
case 102:
teleport.setBlinkCount(field.getInteger());
break;
case 103:
teleport.setBlinkDelayTicks(field.getInteger());
break;
case 104:
teleport.setBehindDistance(parseFloat(field, teleport.getBehindDistance()));
break;
case 106:
teleport.setDamage(parseFloat(field, teleport.getDamage()));
break;
case 107:
teleport.setDamageRadius(parseFloat(field, teleport.getDamageRadius()));
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityTrap;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Trap ability type-specific settings.
@@ -38,7 +38,7 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig {
y += 24;
// Row 2: Damage + Damage Radius
addLabel(new GuiNpcLabel(102, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(102, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(102, fieldX, y, 50, trap.getDamage()));
addLabel(new GuiNpcLabel(103, "ability.dmgRadius", col2LabelX, y + 5));
@@ -79,14 +79,30 @@ public class SubGuiAbilityTrap extends SubGuiAbilityConfig {
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 101: trap.setTriggerRadius(parseFloat(field, trap.getTriggerRadius())); break;
case 102: trap.setDamage(parseFloat(field, trap.getDamage())); break;
case 103: trap.setDamageRadius(parseFloat(field, trap.getDamageRadius())); break;
case 104: trap.setArmTime(field.getInteger()); break;
case 105: trap.setMaxTriggers(field.getInteger()); break;
case 106: trap.setRootDuration(field.getInteger()); break;
case 107: trap.setStunDuration(field.getInteger()); break;
case 108: trap.setKnockback(parseFloat(field, trap.getKnockback())); break;
case 101:
trap.setTriggerRadius(parseFloat(field, trap.getTriggerRadius()));
break;
case 102:
trap.setDamage(parseFloat(field, trap.getDamage()));
break;
case 103:
trap.setDamageRadius(parseFloat(field, trap.getDamageRadius()));
break;
case 104:
trap.setArmTime(field.getInteger());
break;
case 105:
trap.setMaxTriggers(field.getInteger());
break;
case 106:
trap.setRootDuration(field.getInteger());
break;
case 107:
trap.setStunDuration(field.getInteger());
break;
case 108:
trap.setKnockback(parseFloat(field, trap.getKnockback()));
break;
}
}
}
@@ -1,11 +1,11 @@
package noppes.npcs.client.gui.advanced.ability;
import kamkeel.npcs.controllers.data.ability.type.AbilityVortex;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
/**
* GUI for configuring Vortex ability type-specific settings.
@@ -37,7 +37,7 @@ public class SubGuiAbilityVortex extends SubGuiAbilityConfig {
y += 24;
// Row 2: Damage + Knockback
addLabel(new GuiNpcLabel(102, "ability.damage", labelX, y + 5));
addLabel(new GuiNpcLabel(102, "enchantment.damage", labelX, y + 5));
addTextField(createFloatField(102, fieldX, y, 50, vortex.getDamage()));
addLabel(new GuiNpcLabel(103, "ability.knockback", col2LabelX, y + 5));
@@ -75,22 +75,42 @@ public class SubGuiAbilityVortex extends SubGuiAbilityConfig {
protected void handleTypeButton(int id, GuiNpcButton button) {
int value = button.getValue();
switch (id) {
case 104: vortex.setAoe(value == 1); break;
case 108: vortex.setDamageOnPull(value == 1); break;
case 104:
vortex.setAoe(value == 1);
break;
case 108:
vortex.setDamageOnPull(value == 1);
break;
}
}
@Override
protected void handleTypeTextField(int id, GuiNpcTextField field) {
switch (id) {
case 100: vortex.setPullRadius(parseFloat(field, vortex.getPullRadius())); break;
case 101: vortex.setPullStrength(parseFloat(field, vortex.getPullStrength())); break;
case 102: vortex.setDamage(parseFloat(field, vortex.getDamage())); break;
case 103: vortex.setKnockback(parseFloat(field, vortex.getKnockback())); break;
case 105: vortex.setMaxTargets(field.getInteger()); break;
case 106: vortex.setStunDuration(field.getInteger()); break;
case 107: vortex.setRootDuration(field.getInteger()); break;
case 109: vortex.setPullDamage(parseFloat(field, vortex.getPullDamage())); break;
case 100:
vortex.setPullRadius(parseFloat(field, vortex.getPullRadius()));
break;
case 101:
vortex.setPullStrength(parseFloat(field, vortex.getPullStrength()));
break;
case 102:
vortex.setDamage(parseFloat(field, vortex.getDamage()));
break;
case 103:
vortex.setKnockback(parseFloat(field, vortex.getKnockback()));
break;
case 105:
vortex.setMaxTargets(field.getInteger());
break;
case 106:
vortex.setStunDuration(field.getInteger());
break;
case 107:
vortex.setRootDuration(field.getInteger());
break;
case 109:
vortex.setPullDamage(parseFloat(field, vortex.getPullDamage()));
break;
}
}
}
@@ -3,13 +3,21 @@ package noppes.npcs.client.gui.global;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityController;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.advanced.SubGuiAbilityConfig;
import noppes.npcs.client.gui.advanced.SubGuiAbilityDeleteConfirm;
import noppes.npcs.client.gui.advanced.SubGuiAbilityLoad;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.IAbilityConfigCallback;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* Global GUI for managing saved ability presets.
@@ -12,7 +12,7 @@ import net.minecraft.util.StatCollector;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.SubGuiNpcAvailability;
import noppes.npcs.client.gui.script.GuiScriptRecipe;
import noppes.npcs.client.gui.script.GuiScriptInterface;
import noppes.npcs.client.gui.util.GuiButtonBiDirectional;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
import noppes.npcs.client.gui.util.GuiCustomScroll;
@@ -31,6 +31,7 @@ import noppes.npcs.constants.EnumScrollData;
import noppes.npcs.containers.ContainerManageRecipes;
import noppes.npcs.controllers.data.RecipeAnvil;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.data.RecipeScript;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.opengl.GL11;
@@ -222,15 +223,9 @@ public class GuiNpcManageRecipes extends GuiContainerNPCInterface2 implements IS
if (button.id == 16) {
save();
if (container.width == 1) {
GuiScriptRecipe gui = new GuiScriptRecipe(this, container.recipeAnvil);
gui.setWorldAndResolution(mc, width, height);
gui.initGui();
mc.currentScreen = gui;
GuiScriptInterface.open(this, new RecipeScript(container.recipeAnvil.id, true));
} else if (!container.recipe.isGlobal) {
GuiScriptRecipe gui = new GuiScriptRecipe(this, container.recipe);
gui.setWorldAndResolution(mc, width, height);
gui.initGui();
mc.currentScreen = gui;
GuiScriptInterface.open(this, new RecipeScript(container.recipe.id, false));
}
}
}
@@ -12,7 +12,7 @@ import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.SubGuiColorSelector;
import noppes.npcs.client.gui.global.GuiNPCManageLinked;
import noppes.npcs.client.gui.script.GuiScriptLinkedItem;
import noppes.npcs.client.gui.script.GuiScriptInterface;
import noppes.npcs.client.gui.util.GuiButtonBiDirectional;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
@@ -25,6 +25,7 @@ import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.client.renderer.ImageData;
import noppes.npcs.controllers.data.LinkedItem;
import noppes.npcs.controllers.data.LinkedItemScript;
import org.lwjgl.opengl.GL11;
public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListener, GuiYesNoCallback, ISubGuiListener {
@@ -119,8 +120,8 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe
GuiNpcTextField digSpeedField = new GuiNpcTextField(12, this, x + 110, y, 50, 20, "" + linkedItem.digSpeed);
digSpeedField.setIntegersOnly().setMinMaxDefault(0, 20, 1);
addTextField(digSpeedField);
GuiNpcTextField attackSpeedField = new GuiNpcTextField(14, this, x +165, y, 50, 20, "" +linkedItem.attackSpeed);
attackSpeedField.setIntegersOnly().setMinMaxDefault(0,999999999,20);
GuiNpcTextField attackSpeedField = new GuiNpcTextField(14, this, x + 165, y, 50, 20, "" + linkedItem.attackSpeed);
attackSpeedField.setIntegersOnly().setMinMaxDefault(0, 999999999, 20);
addTextField(attackSpeedField);
y += spacing;
@@ -307,10 +308,7 @@ public class SubGuiLinkedItem extends SubGuiInterface implements ITextfieldListe
return;
} else if (id == -3) {
PacketClient.sendClient(new LinkedItemSavePacket(linkedItem.writeToNBT(false), originalName));
GuiScriptLinkedItem scriptGUI = new GuiScriptLinkedItem((GuiNPCManageLinked) this.parent, linkedItem);
scriptGUI.setWorldAndResolution(mc, width, height);
scriptGUI.initGui();
mc.currentScreen = scriptGUI;
GuiScriptInterface.open(this.parent, new LinkedItemScript(linkedItem.id));
return;
} else if (id == 20) {
// Open confirmation for version bump.
@@ -9,11 +9,11 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.advanced.GuiNPCAbilities;
import noppes.npcs.client.gui.advanced.GuiNPCAdvancedLinkedNpc;
import noppes.npcs.client.gui.advanced.GuiNPCDialogNpcOptions;
import noppes.npcs.client.gui.advanced.GuiNPCFactionSetup;
import noppes.npcs.client.gui.advanced.GuiNPCLinesMenu;
import noppes.npcs.client.gui.advanced.GuiNPCAbilities;
import noppes.npcs.client.gui.advanced.GuiNPCMagic;
import noppes.npcs.client.gui.advanced.GuiNPCMarks;
import noppes.npcs.client.gui.advanced.GuiNPCNightSetup;
@@ -25,8 +25,8 @@ import noppes.npcs.client.gui.roles.GuiNpcConversation;
import noppes.npcs.client.gui.roles.GuiNpcFollowerJob;
import noppes.npcs.client.gui.roles.GuiNpcGuard;
import noppes.npcs.client.gui.roles.GuiNpcHealer;
import noppes.npcs.client.gui.roles.GuiNpcSpawner;
import noppes.npcs.client.gui.roles.GuiNpcMount;
import noppes.npcs.client.gui.roles.GuiNpcSpawner;
import noppes.npcs.client.gui.roles.GuiNpcTransporter;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
@@ -49,7 +49,7 @@ public class GuiNpcAdvanced extends GuiNPCInterface2 implements IGuiData {
super.initGui();
int y = guiTop + 10;
this.addButton(new GuiNpcButton(3, guiLeft + 85 + 160, y, 52, 20, "selectServer.edit"));
this.addButton(new GuiNpcButton(8, guiLeft + 85, y, 155, 20, new String[]{"role.none", "role.trader", "role.follower", "role.bank", "role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)"), "role.mount"}, npc.advanced.role.ordinal()));
this.addButton(new GuiNpcButton(8, guiLeft + 85, y, 155, 20, new String[]{"role.none", "role.trader", "role.follower", "role.bank", "role.transporter", "role.mailman", NoppesStringUtils.translate("role.companion", "(WIP)"), "role.mount", "role.auctioneer"}, npc.advanced.role.ordinal()));
getButton(3).setEnabled(npc.advanced.role != EnumRoleType.None && npc.advanced.role != EnumRoleType.Postman);
this.addButton(new GuiNpcButton(4, guiLeft + 85 + 160, y += 22, 52, 20, "selectServer.edit"));
@@ -1,136 +1,335 @@
package noppes.npcs.client.gui.player;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.player.GetTraderData;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.containers.ContainerNPCTrader;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.roles.RoleTrader;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
public class GuiNPCTrader extends GuiContainerNPCInterface {
private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/trader.png");
public class GuiNPCTrader extends GuiContainerNPCInterface implements IGuiData {
private final ResourceLocation resource = new ResourceLocation("customnpcs", "textures/gui/tradersetup.png");
private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png");
private RoleTrader role;
private ContainerNPCTrader container;
// Layout constants matching ContainerNPCTrader
private static final int COLUMN_WIDTH = ContainerNPCTrader.COLUMN_WIDTH;
private static final int COLUMN_START_X = ContainerNPCTrader.COLUMN_START_X;
private static final int ROW_HEIGHT = ContainerNPCTrader.ROW_HEIGHT;
private static final int ROW_START_Y = ContainerNPCTrader.ROW_START_Y;
private static final int CURRENCY1_OFFSET = ContainerNPCTrader.CURRENCY1_OFFSET;
private static final int CURRENCY2_OFFSET = ContainerNPCTrader.CURRENCY2_OFFSET;
private static final int OUTPUT_OFFSET = ContainerNPCTrader.OUTPUT_OFFSET;
// Data received from server via IGuiData
private long playerBalance = 0;
private int[] availableStock = new int[18];
private long[] currencyCost = new long[18];
private boolean stockEnabled = false;
// Client-side countdown: target time when stock resets (System.currentTimeMillis())
private long resetTargetTime = -1;
// Current hover status for bottom display
private String statusMessage = "";
private int statusColor = 0xFFFFFF;
public GuiNPCTrader(EntityNPCInterface npc, ContainerNPCTrader container) {
super(npc, container);
this.container = container;
role = (RoleTrader) npc.roleInterface;
closeOnEsc = true;
ySize = 224;
xSize = 223;
this.title = "role.trader";
ySize = 216;
xSize = 256;
this.title = "";
// Initialize stock to unlimited
for (int i = 0; i < 18; i++) {
availableStock[i] = Integer.MAX_VALUE;
currencyCost[i] = 0;
}
// Request trader data from server (balance, stock, currency costs)
PacketClient.sendClient(new GetTraderData());
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
public void setGuiData(NBTTagCompound compound) {
playerBalance = compound.getLong("Balance");
stockEnabled = compound.getBoolean("StockEnabled");
// Calculate target time for client-side countdown
long remainingMillis = compound.getLong("ResetTimeMillis");
if (remainingMillis > 0) {
resetTargetTime = System.currentTimeMillis() + remainingMillis;
} else {
resetTargetTime = -1;
}
int[] stock = compound.getIntArray("Stock");
if (stock != null && stock.length == 18) {
availableStock = stock;
}
for (int i = 0; i < 18; i++) {
currencyCost[i] = compound.getLong("Cost" + i);
}
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
// Reset status each frame
statusMessage = "";
statusColor = 0xFFFFFF;
this.drawWorldBackground(0);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.renderEngine.bindTexture(resource);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
// Draw "Trader" label in TOP LEFT (above the GUI)
String traderLabel = StatCollector.translateToLocal("role.trader");
fontRendererObj.drawString(traderLabel, guiLeft + 4, guiTop - 8, 0xFFFFFF);
// Draw reset timer in TOP RIGHT (above the GUI)
if (stockEnabled && resetTargetTime > 0) {
String timerText = getResetCountdownText();
int timerWidth = fontRendererObj.getStringWidth(timerText);
int timerColor = timerText.equals(StatCollector.translateToLocal("trader.reopentrader")) ? 0xFFAA00 : 0xFFFFFF;
fontRendererObj.drawString(timerText, guiLeft + xSize - timerWidth - 4, guiTop - 8, timerColor);
}
RenderHelper.enableGUIStandardItemLighting();
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glEnable(GL11.GL_LIGHTING);
mc.renderEngine.bindTexture(slot);
for (int slot = 0; slot < 18; slot++) {
int x = guiLeft + slot % 3 * 72 + 10;
int y = guiTop + slot / 3 * 21 + 6;
// Draw trade slots (3 columns x 6 rows, 80px column width)
for (int slotIdx = 0; slotIdx < 18; slotIdx++) {
int col = slotIdx % 3;
int row = slotIdx / 3;
int x = guiLeft + COLUMN_START_X + col * COLUMN_WIDTH;
int y = guiTop + ROW_START_Y + row * ROW_HEIGHT;
ItemStack item = role.inventoryCurrency.items.get(slot);
ItemStack item2 = role.inventoryCurrency.items.get(slot + 18);
// Get item currencies
ItemStack item = role.inventoryCurrency.items.get(slotIdx);
ItemStack item2 = role.inventoryCurrency.items.get(slotIdx + 18);
if (item == null) {
item = item2;
item2 = null;
}
if (NoppesUtilPlayer.compareItems(item, item2, false, false)) {
if (item != null && item2 != null && NoppesUtilPlayer.compareItems(item, item2, role.ignoreDamage, role.ignoreNBT)) {
item = item.copy();
item.stackSize += item2.stackSize;
item2 = null;
}
ItemStack sold = role.inventorySold.items.get(slot);
ItemStack sold = role.inventorySold.items.get(slotIdx);
// Draw slot backgrounds (18x18 each)
GL11.glColor4f(1, 1, 1, 1);
mc.renderEngine.bindTexture(this.slot);
drawTexturedModalRect(x + 42, y, 0, 0, 18, 18);
if (item != null && sold != null) {
// Currency slot 1
drawTexturedModalRect(x + CURRENCY1_OFFSET, y, 0, 0, 18, 18);
// Currency slot 2
drawTexturedModalRect(x + CURRENCY2_OFFSET, y, 0, 0, 18, 18);
// Output slot
drawTexturedModalRect(x + OUTPUT_OFFSET, y, 0, 0, 18, 18);
// "=" sign between currency and output
fontRendererObj.drawString("=", x + 40, y + 5, CustomNpcResourceListener.DefaultTextColor);
// Draw currency items (centered: +1 offset for 16x16 item in 18x18 slot)
if (sold != null) {
RenderHelper.enableGUIStandardItemLighting();
// Draw secondary currency (slot 1)
if (item2 != null) {
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item2, x, y + 1);
itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item2, x, y + 1);
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item2, x + CURRENCY1_OFFSET + 1, y + 1);
itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item2, x + CURRENCY1_OFFSET + 1, y + 1);
}
GL11.glColor4f(1, 1, 1, 1);
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item, x + 18, y + 1);
itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item, x + 18, y + 1);
// Draw primary currency (slot 2)
if (item != null) {
GL11.glColor4f(1, 1, 1, 1);
itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.renderEngine, item, x + CURRENCY2_OFFSET + 1, y + 1);
itemRender.renderItemOverlayIntoGUI(fontRendererObj, mc.renderEngine, item, x + CURRENCY2_OFFSET + 1, y + 1);
}
RenderHelper.disableStandardItemLighting();
fontRendererObj.drawString("=", x + 36, y + 5, CustomNpcResourceListener.DefaultTextColor);
// Draw stock count to the RIGHT of the trade (after output slot)
if (stockEnabled && availableStock[slotIdx] < Integer.MAX_VALUE) {
String stockText = String.valueOf(availableStock[slotIdx]);
int stockColor = availableStock[slotIdx] > 0 ? 0x00AA00 : 0xAA0000;
fontRendererObj.drawString(stockText, x + OUTPUT_OFFSET + 20, y + 5, stockColor);
}
// Draw dark overlay for out of stock items
if (stockEnabled && availableStock[slotIdx] <= 0) {
drawGradientRect(x + OUTPUT_OFFSET + 1, y + 1, x + OUTPUT_OFFSET + 17, y + 17, 0xC0101010, 0xC0101010);
}
}
}
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_DEPTH_TEST);
RenderHelper.enableStandardItemLighting();
super.drawGuiContainerBackgroundLayer(f, i, j);
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
// Draw player balance (BOTTOM RIGHT, below GUI)
int infoY = guiTop + ySize + 2;
String balanceText = StatCollector.translateToLocal("trader.balance") + ": $" + formatCurrency(playerBalance);
int balanceWidth = fontRendererObj.getStringWidth(balanceText);
fontRendererObj.drawString(balanceText, guiLeft + xSize - balanceWidth - 4, infoY, 0x36e82a);
}
@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
for (int slot = 0; slot < 18; slot++) {
int x = slot % 3 * 72 + 10;
int y = slot / 3 * 21 + 6;
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
for (int slotIdx = 0; slotIdx < 18; slotIdx++) {
int col = slotIdx % 3;
int row = slotIdx / 3;
int x = COLUMN_START_X + col * COLUMN_WIDTH;
int y = ROW_START_Y + row * ROW_HEIGHT;
ItemStack item = role.inventoryCurrency.items.get(slot);
ItemStack item2 = role.inventoryCurrency.items.get(slot + 18);
ItemStack item = role.inventoryCurrency.items.get(slotIdx);
ItemStack item2 = role.inventoryCurrency.items.get(slotIdx + 18);
if (item == null) {
item = item2;
item2 = null;
}
if (NoppesUtilPlayer.compareItems(item, item2, role.ignoreDamage, role.ignoreNBT)) {
if (item != null && item2 != null && NoppesUtilPlayer.compareItems(item, item2, role.ignoreDamage, role.ignoreNBT)) {
item = item.copy();
item.stackSize += item2.stackSize;
item2 = null;
}
ItemStack sold = role.inventorySold.items.get(slot);
if (item == null || sold == null)
ItemStack sold = role.inventorySold.items.get(slotIdx);
if (sold == null) {
continue;
if (this.func_146978_c(x + 43, y + 1, 16, 16, par1, par2)) {
if (!container.canBuy(slot, player)) {
GL11.glTranslatef(0, 0, 300);
if (item != null && !NoppesUtilPlayer.compareItems(player, item, role.ignoreDamage, role.ignoreNBT))
this.drawGradientRect(x + 17, y, x + 35, y + 18, 0x70771010, 0x70771010);
if (item2 != null && !NoppesUtilPlayer.compareItems(player, item2, role.ignoreDamage, role.ignoreNBT))
this.drawGradientRect(x - 1, y, x + 17, y + 18, 0x70771010, 0x70771010);
String title = StatCollector.translateToLocal("trader.insufficient");
this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 131, 0xDD0000);
GL11.glTranslatef(0, 0, -300);
} else if (!container.isSlotEnabled(slot, player)) {
String title = StatCollector.translateToLocal("trader.slotdisabled");
this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 131, 0xFF4000);
} else {
String title = StatCollector.translateToLocal("trader.sufficient");
this.fontRendererObj.drawString(title, (xSize - fontRendererObj.getStringWidth(title)) / 2, 131, 0x00DD00);
}
}
if (this.func_146978_c(x, y, 16, 16, par1, par2) && item2 != null) {
this.renderToolTip(item2, par1 - guiLeft, par2 - guiTop);
// Check if hovering over output slot (18x18 area)
if (this.func_146978_c(x + OUTPUT_OFFSET, y, 18, 18, mouseX, mouseY)) {
updateSlotStatus(slotIdx, item, item2, x, y);
}
if (this.func_146978_c(x + 18, y, 16, 16, par1, par2)) {
this.renderToolTip(item, par1 - guiLeft, par2 - guiTop);
// Tooltips for currency items
if (this.func_146978_c(x + CURRENCY1_OFFSET, y, 18, 18, mouseX, mouseY) && item2 != null) {
this.renderToolTip(item2, mouseX - guiLeft, mouseY - guiTop);
}
if (this.func_146978_c(x + CURRENCY2_OFFSET, y, 18, 18, mouseX, mouseY) && item != null) {
this.renderToolTip(item, mouseX - guiLeft, mouseY - guiTop);
}
}
// Draw status message in BOTTOM LEFT (in foreground coordinates)
if (!statusMessage.isEmpty()) {
fontRendererObj.drawString(statusMessage, 4, ySize + 4, statusColor);
}
}
/**
* Update status message when hovering over a trade slot
*/
private void updateSlotStatus(int slotIdx, ItemStack item, ItemStack item2, int x, int y) {
long cost = currencyCost[slotIdx];
String costSuffix = cost > 0 ? " ($" + formatCurrency(cost) + ")" : "";
// Check conditions in order of priority
if (stockEnabled && availableStock[slotIdx] <= 0) {
// Out of stock
statusMessage = StatCollector.translateToLocal("trader.outofstock") + costSuffix;
statusColor = 0xDD0000;
} else if (cost > 0 && playerBalance < cost) {
// Can't afford currency cost
statusMessage = StatCollector.translateToLocal("trader.insufficient.currency") + costSuffix;
statusColor = 0xDD0000;
} else if (!container.canBuy(slotIdx, player)) {
// Missing item currency - highlight which ones
GL11.glTranslatef(0, 0, 300);
if (item != null && !NoppesUtilPlayer.compareItems(player, item, role.ignoreDamage, role.ignoreNBT)) {
this.drawGradientRect(x + CURRENCY2_OFFSET, y, x + CURRENCY2_OFFSET + 18, y + 18, 0x70771010, 0x70771010);
}
if (item2 != null && !NoppesUtilPlayer.compareItems(player, item2, role.ignoreDamage, role.ignoreNBT)) {
this.drawGradientRect(x + CURRENCY1_OFFSET, y, x + CURRENCY1_OFFSET + 18, y + 18, 0x70771010, 0x70771010);
}
GL11.glTranslatef(0, 0, -300);
statusMessage = StatCollector.translateToLocal("trader.unavailable") + costSuffix;
statusColor = 0xDD0000;
} else if (!container.isSlotEnabled(slotIdx, player)) {
// Slot disabled
statusMessage = StatCollector.translateToLocal("trader.slotdisabled") + costSuffix;
statusColor = 0xFF4000;
} else {
// Can buy!
statusMessage = StatCollector.translateToLocal("trader.available") + costSuffix;
statusColor = 0x00DD00;
}
}
/**
* Get the countdown text for stock reset timer.
* Calculated client-side each frame for smooth countdown.
*/
private String getResetCountdownText() {
if (resetTargetTime <= 0) {
return "";
}
long remaining = resetTargetTime - System.currentTimeMillis();
if (remaining <= 0) {
return StatCollector.translateToLocal("trader.reopentrader");
}
// Format as HH:MM:SS or D days HH:MM:SS
long seconds = (remaining / 1000) % 60;
long minutes = (remaining / 60000) % 60;
long hours = (remaining / 3600000) % 24;
long days = remaining / 86400000;
StringBuilder sb = new StringBuilder();
sb.append(StatCollector.translateToLocal("trader.restock")).append(": ");
if (days > 0) {
sb.append(days).append("d ");
}
sb.append(String.format("%02d:%02d:%02d", hours, minutes, seconds));
return sb.toString();
}
/**
* Format currency for display (e.g., 1000 -> "1,000")
*/
private String formatCurrency(long amount) {
if (amount < 1000) {
return String.valueOf(amount);
}
StringBuilder sb = new StringBuilder();
String str = String.valueOf(amount);
int count = 0;
for (int i = str.length() - 1; i >= 0; i--) {
if (count > 0 && count % 3 == 0) {
sb.insert(0, ',');
}
sb.insert(0, str.charAt(i));
count++;
}
return sb.toString();
}
@Override
@@ -8,7 +8,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
@@ -22,6 +22,9 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
private final ResourceLocation slot = new ResourceLocation("customnpcs", "textures/gui/slot.png");
private RoleTrader role;
// Currency cost textfield IDs start at 100 (100-117 for slots 0-17)
private static final int CURRENCY_FIELD_ID_START = 100;
public GuiNpcTraderSetup(EntityNPCInterface npc, ContainerNPCTraderSetup container) {
super(npc, container);
ySize = 220;
@@ -34,17 +37,30 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
super.initGui();
buttonList.clear();
setBackground("tradersetup.png");
// Linked Market name
addLabel(new GuiNpcLabel(0, "role.marketname", guiLeft + 214, guiTop + 150));
addTextField(new GuiNpcTextField(0, this, guiLeft + 214, guiTop + 160, 180, 20, role.marketName));
addLabel(new GuiNpcLabel(1, "gui.ignoreDamage", guiLeft + 260, guiTop + 29));
addButton(new GuiNpcButtonYesNo(1, guiLeft + 340, guiTop + 24, role.ignoreDamage));
// Settings button (opens SubGuiNpcTraderSettings)
addButton(new GuiNpcButton(1, guiLeft + 214, guiTop + 184, 88, 20, "gui.settings"));
getButton(1).setHoverText("gui.settings.hover");
addLabel(new GuiNpcLabel(2, "gui.ignoreNBT", guiLeft + 260, guiTop + 51));
addButton(new GuiNpcButtonYesNo(2, guiLeft + 340, guiTop + 46, role.ignoreNBT));
// Stock Options button (opens SubGuiNpcTraderStock)
addButton(new GuiNpcButton(2, guiLeft + 306, guiTop + 184, 88, 20, "stock.options"));
getButton(2).setHoverText("stock.options.hover");
addLabel(new GuiNpcLabel(3, "gui.recordHistory", guiLeft + 260, guiTop + 73));
addButton(new GuiNpcButtonYesNo(3, guiLeft + 340, guiTop + 68, role.recordHistory));
// Currency cost textfields for each slot (FIRST - before item slots)
// Column width: 130px for better spacing
for (int i = 0; i < 18; i++) {
int x = guiLeft + i % 3 * 130 + 15; // First position after "$" label
int y = guiTop + i / 3 * 22 + 14;
long cost = role.getCurrencyCost(i);
GuiNpcTextField field = new GuiNpcTextField(CURRENCY_FIELD_ID_START + i, this, x, y, 36, 16, cost > 0 ? String.valueOf(cost) : "");
field.setMaxStringLength(8);
field.setIntegersOnly();
addTextField(field);
}
}
@Override
@@ -57,13 +73,12 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
@Override
public void actionPerformed(GuiButton guibutton) {
if (guibutton.id == 1) {
role.ignoreDamage = ((GuiNpcButtonYesNo) guibutton).getBoolean();
// Open Settings SubGui
setSubGui(new SubGuiNpcTraderSettings(role));
}
if (guibutton.id == 2) {
role.ignoreNBT = ((GuiNpcButtonYesNo) guibutton).getBoolean();
}
if (guibutton.id == 3) {
role.recordHistory = ((GuiNpcButtonYesNo) guibutton).getBoolean();
// Open Stock Options SubGui
setSubGui(new SubGuiNpcTraderStock(role));
}
}
@@ -71,19 +86,31 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
super.drawGuiContainerBackgroundLayer(f, i, j);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
// Column width: 130px for better spacing
for (int slot = 0; slot < 18; slot++) {
int x = guiLeft + slot % 3 * 94 + 7;
int x = guiLeft + slot % 3 * 130 + 7;
int y = guiTop + slot / 3 * 22 + 4;
mc.renderEngine.bindTexture(this.slot);
GL11.glColor4f(1, 1, 1, 1);
drawTexturedModalRect(x - 1, y, 0, 0, 18, 18);
drawTexturedModalRect(x + 17, y, 0, 0, 18, 18);
// "$" label for currency cost
fontRendererObj.drawString("$", x, y + 5, CustomNpcResourceListener.DefaultTextColor);
fontRendererObj.drawString("=", x + 36, y + 5, CustomNpcResourceListener.DefaultTextColor);
// Currency textfield is at x + 8 (drawn by textfield system)
// Item Cost 1 slot
mc.renderEngine.bindTexture(this.slot);
GL11.glColor4f(1, 1, 1, 1);
drawTexturedModalRect(x + 42, y, 0, 0, 18, 18);
drawTexturedModalRect(x + 50, y, 0, 0, 18, 18);
// Item Cost 2 slot
drawTexturedModalRect(x + 68, y, 0, 0, 18, 18);
// "=" sign
fontRendererObj.drawString("=", x + 88, y + 5, CustomNpcResourceListener.DefaultTextColor);
// Output slot
mc.renderEngine.bindTexture(this.slot);
GL11.glColor4f(1, 1, 1, 1);
drawTexturedModalRect(x + 104, y, 0, 0, 18, 18);
}
}
@@ -95,10 +122,23 @@ public class GuiNpcTraderSetup extends GuiContainerNPCInterface2 implements ITex
@Override
public void unFocused(GuiNpcTextField guiNpcTextField) {
String name = guiNpcTextField.getText();
if (!name.equalsIgnoreCase(role.marketName)) {
role.marketName = name;
PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, true));
int id = guiNpcTextField.id;
// Handle market name field
if (id == 0) {
String name = guiNpcTextField.getText();
if (!name.equalsIgnoreCase(role.marketName)) {
role.marketName = name;
PacketClient.sendClient(new TraderMarketSavePacket(role.marketName, true));
}
return;
}
// Handle currency cost fields (IDs 100-117)
if (id >= CURRENCY_FIELD_ID_START && id < CURRENCY_FIELD_ID_START + 18) {
int slot = id - CURRENCY_FIELD_ID_START;
long cost = guiNpcTextField.getInteger();
role.setCurrencyCost(slot, cost);
}
}
}
@@ -0,0 +1,52 @@
package noppes.npcs.client.gui.roles;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.roles.RoleTrader;
/**
* Confirmation dialog for resetting trader stock cooldown.
*/
public class SubGuiNpcTraderCooldownReset extends SubGuiInterface {
private final RoleTrader role;
public boolean confirmed = false;
public SubGuiNpcTraderCooldownReset(RoleTrader role) {
this.role = role;
setBackground("menubg.png");
xSize = 200;
ySize = 100;
closeOnEsc = true;
}
@Override
public void initGui() {
super.initGui();
int y = guiTop + 15;
addLabel(new GuiNpcLabel(0, "stock.cooldown.confirm", guiLeft + 10, y));
y += 12;
addLabel(new GuiNpcLabel(1, "stock.cooldown.warning", guiLeft + 10, y));
y += 35;
addButton(new GuiNpcButton(0, guiLeft + 30, y, 60, 20, "gui.yes"));
addButton(new GuiNpcButton(1, guiLeft + 110, y, 60, 20, "gui.no"));
}
@Override
public void buttonEvent(GuiButton guibutton) {
if (guibutton.id == 0) {
// Reset the cooldown
role.resetCooldown();
confirmed = true;
close();
} else if (guibutton.id == 1) {
close();
}
}
}
@@ -0,0 +1,66 @@
package noppes.npcs.client.gui.roles;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcButtonYesNo;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.roles.RoleTrader;
public class SubGuiNpcTraderSettings extends SubGuiInterface {
private final RoleTrader role;
public SubGuiNpcTraderSettings(RoleTrader role) {
this.role = role;
setBackground("menubg.png");
xSize = 176;
ySize = 136;
closeOnEsc = true;
}
@Override
public void initGui() {
super.initGui();
int y = guiTop + 14;
addLabel(new GuiNpcLabel(1, "gui.ignoreDamage", guiLeft + 10, y + 5));
addButton(new GuiNpcButtonYesNo(1, guiLeft + 120, y, role.ignoreDamage));
getButton(1).setHoverText("gui.ignoreDamage.hover");
y += 28;
addLabel(new GuiNpcLabel(2, "gui.ignoreNBT", guiLeft + 10, y + 5));
addButton(new GuiNpcButtonYesNo(2, guiLeft + 120, y, role.ignoreNBT));
getButton(2).setHoverText("gui.ignoreNBT.hover");
y += 28;
addLabel(new GuiNpcLabel(3, "gui.recordHistory", guiLeft + 10, y + 5));
addButton(new GuiNpcButtonYesNo(3, guiLeft + 120, y, role.recordHistory));
getButton(3).setHoverText("gui.recordHistory.hover");
y += 34;
addButton(new GuiNpcButton(0, guiLeft + (xSize - 60) / 2, y, 60, 20, "gui.done"));
}
@Override
public void buttonEvent(GuiButton button) {
switch (button.id) {
case 0:
close();
break;
case 1:
role.ignoreDamage = ((GuiNpcButtonYesNo) button).getBoolean();
break;
case 2:
role.ignoreNBT = ((GuiNpcButtonYesNo) button).getBoolean();
break;
case 3:
role.recordHistory = ((GuiNpcButtonYesNo) button).getBoolean();
break;
}
}
}
@@ -0,0 +1,159 @@
package noppes.npcs.client.gui.roles;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
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.ISubGuiListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.client.gui.util.SubGuiNpcCooldownPicker;
import noppes.npcs.constants.EnumStockReset;
import noppes.npcs.roles.RoleTrader;
public class SubGuiNpcTraderStock extends SubGuiInterface implements ISubGuiListener, ITextfieldListener {
private final RoleTrader role;
public SubGuiNpcTraderStock(RoleTrader role) {
this.role = role;
setBackground("menubg.png");
xSize = 220;
ySize = 220;
closeOnEsc = true;
}
@Override
public void initGui() {
super.initGui();
int y = guiTop + 10;
// Enable Stock
addLabel(new GuiNpcLabel(1, "stock.enable", guiLeft + 10, y + 5));
addButton(new GuiNpcButtonYesNo(1, guiLeft + 140, y, role.stock.enableStock));
getButton(1).setHoverText("stock.enable.hover");
y += 24;
// Per-Player Stock
addLabel(new GuiNpcLabel(2, "stock.perplayer", guiLeft + 10, y + 5));
addButton(new GuiNpcButtonYesNo(2, guiLeft + 140, y, role.stock.perPlayer));
getButton(2).setHoverText("stock.perplayer.hover");
y += 24;
// Reset Type
addLabel(new GuiNpcLabel(3, "stock.resettype", guiLeft + 10, y + 5));
addButton(new GuiNpcButton(3, guiLeft + 90, y, 120, 20, EnumStockReset.getDisplayNames(), role.stock.resetType.ordinal()));
getButton(3).setHoverText("stock.resettype.hover");
y += 24;
// Custom Time button (only visible for custom types)
EnumStockReset resetType = role.stock.resetType;
if (resetType == EnumStockReset.MCCUSTOM || resetType == EnumStockReset.RLCUSTOM) {
addLabel(new GuiNpcLabel(4, "stock.customtime", guiLeft + 10, y + 5));
addButton(new GuiNpcButton(4, guiLeft + 90, y, 120, 20, "gui.edit"));
getButton(4).setHoverText("stock.customtime.hover");
y += 24;
}
// Default Max Stock (applies to all slots as default)
addLabel(new GuiNpcLabel(5, "stock.defaultmax", guiLeft + 10, y + 5));
GuiNpcTextField defaultStock = new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 140, y, 60, 20, getDefaultStockString());
defaultStock.setIntegersOnly();
defaultStock.setMinMaxDefault(-1, Integer.MAX_VALUE, -1);
addTextField(defaultStock);
y += 26;
// Per-Slot Stock button
addButton(new GuiNpcButton(5, guiLeft + 10, y, 95, 20, "stock.perslot"));
getButton(5).setHoverText("stock.perslot.hover");
// Reset Stock button
addButton(new GuiNpcButton(6, guiLeft + 115, y, 95, 20, "stock.reset"));
getButton(6).setHoverText("stock.reset.hover");
y += 24;
// Reset Cooldown button
addButton(new GuiNpcButton(7, guiLeft + 10, y, 200, 20, "stock.resetcooldown"));
getButton(7).setHoverText("stock.resetcooldown.hover");
// Done button
addButton(new GuiNpcButton(0, guiLeft + (xSize - 60) / 2, guiTop + ySize - 40, 60, 20, "gui.done"));
}
private String getDefaultStockString() {
// Check if all stocks are the same, if so return that value
int first = role.stock.maxStock[0];
for (int i = 1; i < 18; i++) {
if (role.stock.maxStock[i] != first) {
return "-1"; // Mixed values, return unlimited
}
}
return String.valueOf(first);
}
@Override
public void buttonEvent(GuiButton button) {
switch (button.id) {
case 0: // Done
close();
break;
case 1: // Enable Stock
role.stock.enableStock = ((GuiNpcButtonYesNo) button).getBoolean();
break;
case 2: // Per-Player
role.stock.perPlayer = ((GuiNpcButtonYesNo) button).getBoolean();
break;
case 3: // Reset Type
int value = ((GuiNpcButton) button).getValue();
role.stock.resetType = EnumStockReset.values()[value];
initGui(); // Refresh to show/hide custom time button
break;
case 4: // Custom Time
boolean isMC = role.stock.resetType == EnumStockReset.MCCUSTOM;
setSubGui(new SubGuiNpcCooldownPicker(isMC, role.stock.customResetTime));
break;
case 5: // Per-Slot Stock
setSubGui(new SubGuiNpcTraderStockSlots(role));
break;
case 6: // Reset Stock
setSubGui(new SubGuiNpcTraderStockReset(role));
break;
case 7: // Reset Cooldown
setSubGui(new SubGuiNpcTraderCooldownReset(role));
break;
}
}
@Override
public void subGuiClosed(SubGuiInterface subGui) {
if (subGui instanceof SubGuiNpcCooldownPicker) {
long value = ((SubGuiNpcCooldownPicker) subGui).cooldownValue;
// Validate minimum: 1 tick for MC time, 1000ms (1 second) for real time
boolean isMC = role.stock.resetType == EnumStockReset.MCCUSTOM;
long minimum = isMC ? 1 : 1000;
role.stock.customResetTime = Math.max(minimum, value);
}
// Refresh after per-slot editing
if (subGui instanceof SubGuiNpcTraderStockSlots) {
initGui();
}
}
@Override
public void unFocused(GuiNpcTextField textField) {
if (textField.id == 5) {
int value = textField.getInteger();
// Apply to all slots
for (int i = 0; i < 18; i++) {
role.stock.setMaxStock(i, value);
}
}
}
}
@@ -0,0 +1,55 @@
package noppes.npcs.client.gui.roles;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.roles.RoleTrader;
/**
* Confirmation dialog for resetting trader stock.
*/
public class SubGuiNpcTraderStockReset extends SubGuiInterface {
private final RoleTrader role;
public boolean confirmed = false;
public SubGuiNpcTraderStockReset(RoleTrader role) {
this.role = role;
setBackground("menubg.png");
xSize = 200;
ySize = 100;
closeOnEsc = true;
}
@Override
public void initGui() {
super.initGui();
int y = guiTop + 15;
addLabel(new GuiNpcLabel(0, "stock.reset.confirm", guiLeft + 10, y));
y += 12;
addLabel(new GuiNpcLabel(1, "stock.reset.warning", guiLeft + 10, y));
y += 35;
addButton(new GuiNpcButton(0, guiLeft + 30, y, 60, 20, "gui.yes"));
addButton(new GuiNpcButton(1, guiLeft + 110, y, 60, 20, "gui.no"));
}
@Override
public void buttonEvent(GuiButton guibutton) {
if (guibutton.id == 0) {
// Reset the stock
long currentTime = role.stock.resetType.isRealTime()
? System.currentTimeMillis()
: (role.npc != null && role.npc.worldObj != null ? role.npc.worldObj.getTotalWorldTime() : 0);
role.stock.resetStock(currentTime);
confirmed = true;
close();
} else if (guibutton.id == 1) {
close();
}
}
}
@@ -0,0 +1,76 @@
package noppes.npcs.client.gui.roles;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.roles.RoleTrader;
/**
* Per-slot stock management dialog.
* Shows all 18 slots with their max stock values.
*/
public class SubGuiNpcTraderStockSlots extends SubGuiInterface implements ITextfieldListener {
private final RoleTrader role;
public SubGuiNpcTraderStockSlots(RoleTrader role) {
this.role = role;
setBackground("menubg.png");
xSize = 256;
ySize = 216;
closeOnEsc = true;
}
@Override
public void initGui() {
super.initGui();
// Title
addLabel(new GuiNpcLabel(0, "stock.perslot.title", guiLeft + 10, guiTop + 6));
// 18 slots in 3 columns x 6 rows
int startY = guiTop + 22;
int colWidth = 80;
for (int i = 0; i < 18; i++) {
int col = i % 3;
int row = i / 3;
int x = guiLeft + 10 + col * colWidth;
int y = startY + row * 28;
// Slot label
addLabel(new GuiNpcLabel(i + 1, "Slot " + (i + 1) + ":", x, y + 5));
// Max stock textfield
int maxStock = role.stock.maxStock[i];
String value = maxStock < 0 ? "-1" : String.valueOf(maxStock);
GuiNpcTextField field = new GuiNpcTextField(i, this, fontRendererObj, x + 42, y, 32, 18, value);
field.setIntegersOnly();
field.setMinMaxDefault(-1, Integer.MAX_VALUE, -1);
addTextField(field);
}
// Done button
addButton(new GuiNpcButton(0, guiLeft + (xSize - 60) / 2, guiTop + ySize - 26, 60, 20, "gui.done"));
}
@Override
public void buttonEvent(GuiButton button) {
if (button.id == 0) {
close();
}
}
@Override
public void unFocused(GuiNpcTextField textField) {
int slot = textField.id;
if (slot >= 0 && slot < 18) {
int value = textField.getInteger();
role.stock.setMaxStock(slot, value);
}
}
}
@@ -5,7 +5,7 @@ import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.data.IScriptUnit;
import java.util.ArrayList;
import java.util.Iterator;
@@ -14,10 +14,10 @@ import java.util.List;
public class EventGuiScriptList extends SubGuiInterface {
private GuiCustomScroll scroll1;
private GuiCustomScroll scroll2;
private ScriptContainer container;
private IScriptUnit container;
private List<String> scripts;
public EventGuiScriptList(List<String> scripts, ScriptContainer container) {
public EventGuiScriptList(List<String> scripts, IScriptUnit container) {
this.container = container;
this.setBackground("menubg.png");
this.xSize = 346;
@@ -50,9 +50,9 @@ public class EventGuiScriptList extends SubGuiInterface {
this.addScroll(this.scroll2);
this.addLabel(new GuiNpcLabel(2, "script.loadedScripts", this.guiLeft + 200, this.guiTop + 4));
ArrayList temp = new ArrayList(this.scripts);
temp.removeAll(this.container.scripts);
temp.removeAll(getScripts());
this.scroll1.setList(temp);
this.scroll2.setList(this.container.scripts);
this.scroll2.setList(getScripts());
this.addButton(new GuiNpcButton(1, this.guiLeft + 145, this.guiTop + 40, 55, 20, ">"));
this.addButton(new GuiNpcButton(2, this.guiLeft + 145, this.guiTop + 62, 55, 20, "<"));
this.addButton(new GuiNpcButton(3, this.guiLeft + 145, this.guiTop + 90, 55, 20, ">>"));
@@ -63,25 +63,25 @@ public class EventGuiScriptList extends SubGuiInterface {
protected void actionPerformed(GuiButton guibutton) {
GuiNpcButton button = (GuiNpcButton) guibutton;
if (button.id == 1 && this.scroll1.hasSelected()) {
this.container.scripts.add(this.scroll1.getSelected());
getScripts().add(this.scroll1.getSelected());
this.scroll1.selected = -1;
this.scroll2.selected = -1;
this.initGui();
}
if (button.id == 2 && this.scroll2.hasSelected()) {
this.container.scripts.remove(this.scroll2.getSelected());
getScripts().remove(this.scroll2.getSelected());
this.scroll2.selected = -1;
this.initGui();
}
if (button.id == 3) {
this.container.scripts.clear();
getScripts().clear();
Iterator var3 = this.scripts.iterator();
while (var3.hasNext()) {
String script = (String) var3.next();
this.container.scripts.add(script);
getScripts().add(script);
}
this.scroll1.selected = -1;
@@ -90,7 +90,7 @@ public class EventGuiScriptList extends SubGuiInterface {
}
if (button.id == 4) {
this.container.scripts.clear();
getScripts().clear();
this.scroll1.selected = -1;
this.scroll2.selected = -1;
this.initGui();
@@ -102,6 +102,10 @@ public class EventGuiScriptList extends SubGuiInterface {
}
public List<String> getScripts() {
return this.container.getExternalScripts();
}
public void save() {
}
}
@@ -1,17 +1,38 @@
package noppes.npcs.client.gui.script;
import noppes.npcs.janino.JaninoScript;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiMenuTopButton;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextArea;
import noppes.npcs.client.gui.util.GuiScriptTextArea;
import noppes.npcs.client.gui.util.ICustomScrollListener;
import noppes.npcs.client.gui.util.ISubGuiListener;
import noppes.npcs.client.gui.util.ITextChangeListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.janino.JaninoScript;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback, ITextChangeListener, ICustomScrollListener, ISubGuiListener {
@@ -21,7 +42,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
public List<String> allExternalScripts = new ArrayList<>();
private final int scriptLimit = 1;
public String previousHookClicked = "";
// GUI display list
List<String> hooklist = new ArrayList<>();
@@ -83,6 +104,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
}
}
}
public void initGui() {
this.ySize = (int) ((double) this.xSize * 0.56);
if ((double) this.ySize > (double) this.height * 0.95) {
@@ -95,7 +117,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
this.guiTop += 10;
int yoffset = (int) ((double) this.ySize * 0.02);
GuiMenuTopButton top;
addTopButton(new GuiMenuTopButton(-1, guiLeft + xSize-2 , guiTop - 17, "X"));
addTopButton(new GuiMenuTopButton(-1, guiLeft + xSize - 2, guiTop - 17, "X"));
this.addTopButton(top = new GuiMenuTopButton(0, this.guiLeft + 4, this.guiTop - 17, "gui.settings"));
int topXoffset = 0;
int topYoffset = 0;
@@ -135,7 +157,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
textArea.setListener(this);
this.closeOnEsc(textArea::closeOnEsc);
this.addTextField(textArea);
int left1 = this.guiLeft + this.xSize - 104;
this.addButton(new GuiNpcButton(102, left1, this.guiTop + yoffset, 60, 20, "gui.clear"));
this.addButton(new GuiNpcButton(101, left1 + 61, this.guiTop + yoffset, 60, 20, "gui.paste"));
@@ -163,10 +185,11 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
this.addLabel(new GuiNpcLabel(1, "script.language", var9, this.guiTop + 15));
String containerLang = container.getLanguage();
this.addButton(new GuiNpcButton(103, var9 + 60, this.guiTop + 10, 80, 20, new String[]{containerLang.equals("Java") ? "Janino (JVM 8)" : containerLang},
this.getScriptIndex()));
this.getLanguageIndex()));
// this.getButton(103).enabled = !this.languages.isEmpty();
this.addLabel(new GuiNpcLabel(2, "gui.enabled", var9, this.guiTop + 36));
this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20, new String[]{"gui.no", "gui.yes"}, this.container.getEnabled() ? 1 : 0));
// Note: GuiJaninoScript is deprecated; enabled button disabled
this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20, new String[]{"gui.no", "gui.yes"}, 0));
this.addButton(new GuiNpcButton(109, var9, this.guiTop + 78, 80, 20, "gui.website"));
this.addButton(new GuiNpcButton(112, var9 + 81, this.guiTop + 78, 80, 20, "gui.forum"));
@@ -280,7 +303,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
}
//Enable
else if (guibutton.id == 104) {
this.container.setEnabled(((GuiNpcButton) guibutton).getValue() == 1);
// Deprecated GUI - enabled is now per-handler, not per-unit
}
//Remove
else if (guibutton.id == 105) {
@@ -347,7 +370,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
}
private String getConsoleText() {
Map<Long, String> map = this.container.getConsoleText();
Map<Long, String> map = this.container.getConsole();
StringBuilder builder = new StringBuilder();
Iterator var3 = map.entrySet()
.iterator();
@@ -360,7 +383,7 @@ public class GuiJaninoScript extends GuiNPCInterface implements GuiYesNoCallback
return builder.toString();
}
private int getScriptIndex() {
private int getLanguageIndex() {
return 0;
}
@@ -1,65 +1,13 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.EventScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NBTTags;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.data.DataScript;
import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.controllers.data.IScriptHandlerPacket;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
import java.util.List;
public class GuiNPCEventScripts extends GuiScriptInterface {
private final DataScript script;
public GuiNPCEventScripts(EntityNPCInterface npc) {
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_NPC));
this.script = new DataScript(npc);
this.handler = this.script;
EventScriptPacket.Get();
}
public void setGuiData(NBTTagCompound compound) {
if (compound.hasKey("LoadComplete")) {
loaded = true;
return;
}
if (!compound.hasKey("Tab")) {
script.setLanguage(compound.getString("ScriptLanguage"));
script.setEnabled(compound.getBoolean("ScriptEnabled"));
super.setGuiData(compound);
} else {
int tab = compound.getInteger("Tab");
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, script);
if (script.getScripts().isEmpty()) {
for (int i = 0; i < compound.getInteger("TotalScripts"); i++) {
script.getScripts().add(new ScriptContainer(script));
}
}
script.getScripts().set(tab, container);
initGui();
}
}
public void save() {
if (loaded) {
super.save();
List<IScriptUnit> containers = this.script.getScripts();
for (int i = 0; i < containers.size(); i++) {
IScriptUnit container = containers.get(i);
EventScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
}
NBTTagCompound scriptData = new NBTTagCompound();
scriptData.setString("ScriptLanguage", this.script.getLanguage());
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
EventScriptPacket.Save(-1, containers.size(), scriptData);
}
this.handler = new DataScript(npc);
if (this.handler instanceof IScriptHandlerPacket)
((IScriptHandlerPacket) this.handler).requestData();
}
}
@@ -1,63 +0,0 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.GlobalNPCScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NBTTags;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.data.GlobalNPCDataScript;
import noppes.npcs.controllers.data.IScriptUnit;
import java.util.ArrayList;
import java.util.List;
public class GuiScriptAllNPCs extends GuiScriptInterface {
private final GlobalNPCDataScript script = new GlobalNPCDataScript(null);
public GuiScriptAllNPCs() {
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_NPC));
this.handler = this.script;
GlobalNPCScriptPacket.Get();
}
public void setGuiData(NBTTagCompound compound) {
if (compound.hasKey("LoadComplete")) {
loaded = true;
return;
}
if (!compound.hasKey("Tab")) {
script.setLanguage(compound.getString("ScriptLanguage"));
script.setEnabled(compound.getBoolean("ScriptEnabled"));
super.setGuiData(compound);
} else {
int tab = compound.getInteger("Tab");
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, script);
if (script.getScripts().isEmpty()) {
for (int i = 0; i < compound.getInteger("TotalScripts"); i++) {
script.getScripts().add(new ScriptContainer(script));
}
}
script.getScripts().set(tab, container);
initGui();
}
}
public void save() {
if (loaded) {
super.save();
List<IScriptUnit> containers = this.script.getScripts();
for (int i = 0; i < containers.size(); i++) {
IScriptUnit container = containers.get(i);
GlobalNPCScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
}
NBTTagCompound scriptData = new NBTTagCompound();
scriptData.setString("ScriptLanguage", this.script.getLanguage());
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
GlobalNPCScriptPacket.Save(-1, containers.size(), scriptData);
}
}
}
@@ -1,39 +0,0 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.BlockScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.blocks.tiles.TileScripted;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptHookController;
import java.util.ArrayList;
public class GuiScriptBlock extends GuiScriptInterface {
private final TileScripted tileScripted;
public GuiScriptBlock(int x, int y, int z) {
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_BLOCK));
this.handler = this.tileScripted = (TileScripted) player.worldObj.getTileEntity(x, y, z);
BlockScriptPacket.Get(tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord);
}
public void setGuiData(NBTTagCompound compound) {
this.tileScripted.setNBT(compound);
super.setGuiData(compound);
loaded = true;
}
@Override
protected ScriptContext getScriptContext() {
return ScriptContext.BLOCK;
}
public void save() {
if (loaded) {
super.save();
BlockScriptPacket.Save(tileScripted.xCoord, tileScripted.yCoord, tileScripted.zCoord, this.tileScripted.getNBT(new NBTTagCompound()));
}
}
}
@@ -1,56 +0,0 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.EffectScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.client.gui.global.GuiNPCManageEffects;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.data.CustomEffect;
import noppes.npcs.controllers.data.EffectScript;
import noppes.npcs.controllers.data.IScriptUnit;
import java.util.ArrayList;
public class GuiScriptEffect extends GuiScriptInterface {
public final CustomEffect effect;
private final EffectScript scriptHandler;
public GuiScriptEffect(GuiNPCManageEffects parent, CustomEffect effect) {
super();
this.parent = parent;
this.effect = effect;
this.scriptHandler = new EffectScript();
this.handler = this.scriptHandler;
this.singleContainer = true;
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_EFFECT));
EffectScriptPacket.Get(effect.id);
}
@Override
protected ScriptContext getScriptContext() {
return ScriptContext.GLOBAL;
}
protected void setHandlerContainer(IScriptUnit container) {
this.scriptHandler.container = container;
}
@Override
public void setGuiData(NBTTagCompound compound) {
setGuiDataWithOldContainer(compound);
}
protected void sendSavePacket(int index, int totalCount, NBTTagCompound scriptNBT) {
EffectScriptPacket.Save(effect.id, index, totalCount, scriptNBT);
}
@Override
public void save() {
saveWithPackets();
}
}
@@ -1,118 +0,0 @@
package noppes.npcs.client.gui.script;
import com.google.common.reflect.ClassPath;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent;
import kamkeel.npcs.network.packets.request.script.ForgeScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.NBTTags;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.IScriptUnit;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class GuiScriptForge extends GuiScriptInterface {
private final ForgeDataScript script = new ForgeDataScript();
public GuiScriptForge() {
// Add built-in "init" hook from controller
hookList.addAll(ScriptHookController.Instance.getBuiltInHooks(IScriptHookHandler.CONTEXT_FORGE));
// Dynamically discover Forge event hooks
ArrayList<ClassPath.ClassInfo> list = new ArrayList();
try {
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
} catch (IOException e) {
e.printStackTrace();
}
for (ClassPath.ClassInfo e1 : list) {
ClassPath.ClassInfo classLoader = e1;
Class infoClass = classLoader.load();
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
if (c.isEmpty()) {
c.add(infoClass);
}
Iterator var10 = c.iterator();
while (var10.hasNext()) {
Class c1 = (Class) var10.next();
if (!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
String eventName = c1.getName();
int i = eventName.lastIndexOf(".");
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
hookList.add(eventName);
}
}
}
hookList.add("onCNPCNaturalSpawn");
// Add any addon-registered hooks for the forge context
for (String addonHook : ScriptHookController.Instance.getAddonHooks(IScriptHookHandler.CONTEXT_FORGE)) {
if (!hookList.contains(addonHook)) {
hookList.add(addonHook);
}
}
this.handler = this.script;
ForgeScriptPacket.Get();
}
public void setGuiData(NBTTagCompound compound) {
if (compound.hasKey("LoadComplete")) {
loaded = true;
return;
}
if (!compound.hasKey("Tab")) {
script.setLanguage(compound.getString("ScriptLanguage"));
script.setEnabled(compound.getBoolean("ScriptEnabled"));
super.setGuiData(compound);
} else {
int tab = compound.getInteger("Tab");
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, script);
if (script.getScripts().isEmpty()) {
for (int i = 0; i < compound.getInteger("TotalScripts"); i++) {
script.getScripts().add(new ScriptContainer(script));
}
}
script.getScripts().set(tab, container);
initGui();
}
}
public void save() {
if (loaded) {
super.save();
List<IScriptUnit> containers = this.script.getScripts();
for (int i = 0; i < containers.size(); i++) {
IScriptUnit container = containers.get(i);
ForgeScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
}
NBTTagCompound scriptData = new NBTTagCompound();
scriptData.setString("ScriptLanguage", this.script.getLanguage());
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
ForgeScriptPacket.Save(-1, containers.size(), scriptData);
}
}
}
@@ -8,6 +8,9 @@ import net.minecraft.util.ResourceLocation;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.GlobalNPCDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import org.lwjgl.opengl.GL11;
import java.util.HashMap;
@@ -65,13 +68,13 @@ public class GuiScriptGlobal extends GuiNPCInterface implements IGuiData {
protected void actionPerformed(GuiButton guibutton) {
if (guibutton.id == 0) {
this.displayGuiScreen(new GuiScriptPlayers());
GuiScriptInterface.open(this, new PlayerDataScript(null));
}
if (guibutton.id == 1) {
this.displayGuiScreen(new GuiScriptForge());
GuiScriptInterface.open(this, new ForgeDataScript());
}
if (guibutton.id == 2) {
this.displayGuiScreen(new GuiScriptAllNPCs());
GuiScriptInterface.open(this, new GlobalNPCDataScript(null));
}
if (guibutton.id > 2) {
try {
@@ -1,9 +1,13 @@
package noppes.npcs.client.gui.script;
import net.minecraft.client.gui.*;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
@@ -21,25 +25,19 @@ import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.IJTextAreaListener;
import noppes.npcs.client.gui.util.ITextChangeListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.IScriptHandler;
import noppes.npcs.controllers.data.IScriptHandlerPacket;
import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.janino.JaninoScript;
import noppes.npcs.scripted.item.ScriptCustomItem;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.Set;
public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallback, IGuiData, ITextChangeListener, ICustomScrollListener, IJTextAreaListener, ITextfieldListener {
protected int activeTab = 0;
@@ -52,16 +50,21 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
protected Map<Integer, GuiScriptTextArea> textAreas = new HashMap<>();
protected GuiScreen parent;
public boolean singleContainer = false;
/** If true, uses scroll-based tab selection instead of top buttons */
/**
* If true, uses scroll-based tab selection instead of top buttons
*/
protected boolean useScrollTabs = false;
/** If true, shows settings/script toggle instead of numbered tabs */
protected boolean useSettingsToggle = false;
/**
* If true, shows settings/script toggle instead of numbered tabs
*/
protected boolean useSettingsToggle = false;
// ==================== FULLSCREEN MODE ====================
/** Whether the editor viewport is currently in fullscreen mode */
/**
* Whether the editor viewport is currently in fullscreen mode
*/
public static boolean isFullscreen = false;
/**
@@ -70,19 +73,29 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
* All padding values are in scaled GUI pixels.
*/
public static class FullscreenConfig {
/** Padding from the top edge of the screen */
/**
* Padding from the top edge of the screen
*/
public static int paddingTop = 20;
/** Padding from the bottom edge of the screen */
/**
* Padding from the bottom edge of the screen
*/
public static int paddingBottom = 20;
/** Padding from the left edge of the screen */
/**
* Padding from the left edge of the screen
*/
public static int paddingLeft = 20;
/** Padding from the right edge of the screen */
/**
* Padding from the right edge of the screen
*/
public static int paddingRight = 20;
}
/** Fullscreen toggle button drawn at top-right of viewport */
/**
* Fullscreen toggle button drawn at top-right of viewport
*/
public final FullscreenButton fullscreenButton = new FullscreenButton();
public GuiScriptInterface() {
this.drawDefaultBackground = true;
this.closeOnEsc = true;
@@ -90,6 +103,35 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.setBackground("menubg.png");
}
/**
* Create a GuiScriptInterface for a handler without displaying it.
* Useful when a caller needs to return a GuiScreen (e.g. ClientProxy).
*/
public static GuiScriptInterface create(GuiScreen parent, IScriptHandler handler) {
GuiScriptInterface gui = new GuiScriptInterface();
gui.handler = handler;
gui.parent = parent;
// Initialize hooks from handler
gui.hookList = new ArrayList<>(handler.getHooks());
// Request data from server
if (handler instanceof IScriptHandlerPacket)
((IScriptHandlerPacket) handler).requestData();
return gui;
}
/**
* Open a GuiScriptInterface for a handler.
* Wraps the script in a SingleScriptHandler automatically.
*/
public static GuiScriptInterface open(GuiScreen parent, IScriptHandler handler) {
GuiScriptInterface gui = create(parent, handler);
Minecraft.getMinecraft().displayGuiScreen(gui);
return gui;
}
public void initGui() {
// ==================== BASE LAYOUT CALCULATION ====================
this.ySize = (int) ((double) this.xSize * 0.56D);
@@ -103,6 +145,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.guiTop += 10;
int yoffset = (int) ((double) this.ySize * 0.02D);
if (hookList.isEmpty())
hookList = new ArrayList<>(handler.getHooks());
// ==================== TAB BUTTONS ====================
// Skip standard tab creation for GUIs that use custom toggle/scroll tabs
if (!useSettingsToggle) {
@@ -113,24 +158,25 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
int topXoffset = 0;
int topYoffset = 0;
if(!singleContainer) {
boolean isSingle = handler.isSingleContainer();
if (!isSingle) {
for (int ta = 0; ta < this.handler.getScripts().size(); ++ta) {
if (ta % 20 == 0 && ta > 0) {
topYoffset -= 20;
topXoffset -= top.width + 20 * 22;
}
this.addTopButton(top = new GuiMenuTopButton(ta + 1, top.xPosition + top.width + topXoffset,
top.yPosition + topYoffset, ta + 1 + ""));
top.yPosition + topYoffset, ta + 1 + ""));
topXoffset = 0;
topYoffset = 0;
scriptLimit = ta + 2;
}
}
if (singleContainer && getFirst() != null)
if (isSingle && handler.getSingleScript() != null)
this.addTopButton(
top = new GuiMenuTopButton(1, top.xPosition + top.width + topXoffset, top.yPosition + topYoffset,
"Script"));
top = new GuiMenuTopButton(1, top.xPosition + top.width + topXoffset, top.yPosition + topYoffset,
"Script"));
else if (this.handler.getScripts().size() < 100)
this.addTopButton(new GuiMenuTopButton(scriptLimit, top.xPosition + top.width, top.yPosition, "+"));
@@ -211,15 +257,15 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
GuiScriptTextArea activeArea = getActiveScriptArea();
if (activeArea == null) {
activeArea = new GuiScriptTextArea(this, 2, editorX, editorY, editorWidth, editorHeight,
container == null ? "" : container.getScript());
container == null ? "" : container.getScript());
activeArea.setListener(this);
this.closeOnEsc(activeArea::closeOnEsc);
textAreas.put(idx, activeArea);
} else {
activeArea.init(editorX, editorY, editorWidth, editorHeight,
container == null ? "" : container.getScript());
container == null ? "" : container.getScript());
}
// Set the scripting language for proper syntax highlighting
// Use the container's language if available, otherwise fall back to handler's language
String language = (container != null) ? container.getLanguage() : this.handler.getLanguage();
@@ -233,15 +279,15 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
// These allow the syntax highlighter to resolve types without explicit import statements
if (container instanceof JaninoScript) {
JaninoScript<?> janinoScript = (JaninoScript<?>) container;
// Add default imports (e.g., noppes.npcs.api.*, noppes.npcs.api.entity.*, etc.)
activeArea.addImplicitImports(janinoScript.getDefaultImports());
// Add hook types from signatures (parameters + return types)
// e.g., INpcEvent.InitEvent, Color, String, IOverlayContext, etc.
Set<String> hookTypes = janinoScript.getHookTypes();
activeArea.addImplicitImports(hookTypes.toArray(new String[0]));
// Format to update which implicit imports are actually used
activeArea.formatCodeText();
}
@@ -253,6 +299,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
});
activeArea.enableCodeHighlighting();
this.addTextField(activeArea);
// ==================== FULLSCREEN BUTTON ====================
@@ -266,13 +313,12 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.addButton(new GuiNpcButton(101, left1 + 61, this.guiTop + yoffset, 60, 20, "gui.paste"));
this.addButton(new GuiNpcButton(100, left1, this.guiTop + 21 + yoffset, 60, 20, "gui.copy"));
this.addButton(new GuiNpcButton(105, left1 + 61, this.guiTop + 21 + yoffset, 60, 20, "gui.remove"));
// Language toggle button (only if handler supports Janino)
if (handler.supportsJanino() && container != null) {
String langLabel = container.isJanino() ? "Java" : "ECMAScript";
this.addButton(new GuiNpcButton(113, left1, this.guiTop + 42 + yoffset, 121, 20, langLabel));
// Language toggle button (only if handler supports Janino and there is more than one option)
if (handler.supportsJanino() && getLanguageOptions().size() > 1 && container != null) {
this.addButton(new GuiNpcButton(113, left1, this.guiTop + 42 + yoffset, 121, 20, container.getLanguage()));
}
this.addButton(new GuiNpcButton(107, left1, this.guiTop + 66 + yoffset, 80, 20, "script.loadscript"));
GuiCustomScroll scroll = (new GuiCustomScroll(this, 0)).setUnselectable();
@@ -291,7 +337,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
*/
private void initSettingsTab(int yoffset) {
GuiNpcTextArea var8 = new GuiNpcTextArea(2, this, this.guiLeft + 4 + yoffset, this.guiTop + 6 + yoffset,
this.xSize - 160 - yoffset, (int) ((float) this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
this.xSize - 160 - yoffset, (int) ((float) this.ySize * 0.92F) - yoffset * 2, this.getConsoleText());
var8.canEdit = false;
var8.setFocused(true);
this.addTextField(var8);
@@ -300,13 +346,14 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.addButton(new GuiNpcButton(100, var9, this.guiTop + 125, 60, 20, "gui.copy"));
this.addButton(new GuiNpcButton(102, var9, this.guiTop + 146, 60, 20, "gui.clear"));
this.addLabel(new GuiNpcLabel(1, "script.language", var9, this.guiTop + 15));
List<String> languageOptions = getLanguageOptions();
this.addButton(new GuiNpcButton(103, var9 + 60, this.guiTop + 10, 80, 20,
(String[]) this.languages.keySet().toArray(new String[this.languages.keySet().size()]),
this.getScriptIndex()));
this.getButton(103).enabled = this.languages.size() > 0;
languageOptions.toArray(new String[0]),
this.getLanguageIndex(languageOptions)));
this.getButton(103).enabled = languageOptions.size() > 0;
this.addLabel(new GuiNpcLabel(2, "gui.enabled", var9, this.guiTop + 36));
this.addButton(new GuiNpcButton(104, var9 + 60, this.guiTop + 31, 50, 20,
new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled() ? 1 : 0));
new String[]{"gui.no", "gui.yes"}, this.handler.getEnabled() ? 1 : 0));
if (this.player.worldObj.isRemote) {
this.addButton(new GuiNpcButton(106, var9, this.guiTop + 55, 150, 20, "script.openfolder"));
@@ -318,6 +365,22 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.addButton(new GuiNpcButton(111, var9 + 81, this.guiTop + 99, 80, 20, "script.apisrc"));
}
public GuiScriptInterface setDimensions(int x, int y) {
this.xSize = x;
this.ySize = y;
return this;
}
/**
* Get the script context for this GUI.
* Override in subclasses to return a different context.
*
* @return The script context (default: GLOBAL, or handler's context if available)
*/
protected ScriptContext getScriptContext() {
return handler.getContext();
}
// ==================== RENDERING ====================
@Override
@@ -325,7 +388,8 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
super.drawScreen(mouseX, mouseY, partialTicks);
// Draw fullscreen button on top of everything when on script editor tab
if (this.activeTab > 0) {
// Skip for useSettingsToggle GUIs (like GuiScript) - they handle this themselves
if (this.activeTab > 0 && !useSettingsToggle && !handler.isSingleContainer()) {
fullscreenButton.draw(mouseX, mouseY);
}
}
@@ -344,11 +408,11 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
// Check fullscreen button first when on script editor tab
// BUT only if autocomplete is not visible (don't let clicks pass through autocomplete menu)
if (this.activeTab > 0 && !isOverAutocomplete
&& fullscreenButton.mouseClicked(mouseX, mouseY, mouseButton)) {
// Skip for useSettingsToggle GUIs (like GuiScript) - they handle this themselves
if (this.activeTab > 0 && !useSettingsToggle && !handler.isSingleContainer() && fullscreenButton.mouseClicked(mouseX, mouseY, mouseButton)) {
return;
}
super.mouseClicked(mouseX, mouseY, mouseButton);
}
@@ -361,11 +425,11 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
IScriptUnit container = getCurrentContainer();
if (container == null)
return;
String addString = "";
if (!this.getTextField(2).getText().isEmpty())
addString += "\n";
// Generate the appropriate stub based on language
// hook is already the proper method name from EnumScriptType.function
addString += container.generateHookStub(hook, null);
@@ -395,19 +459,66 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
return builder.toString();
}
public int getScriptIndex() {
int i = 0;
for (Iterator var2 = this.languages.keySet().iterator(); var2.hasNext(); ++i) {
String language = (String) var2.next();
if (language.equalsIgnoreCase(this.handler.getLanguage())) {
/**
* Finds the index of the current handler's language within the available options.
*
* @return The 0-based index, or 0 if not found.
*/
public int getLanguageIndex() {
return getLanguageIndex(getLanguageOptions());
}
/**
* Finds the index of the current handler's language within the provided list.
*
* @param languageOptions The list of available languages to search.
* @return The 0-based index, or 0 if not found.
*/
protected int getLanguageIndex(List<String> languageOptions) {
if (languageOptions == null || languageOptions.isEmpty())
return 0;
int i = 0;
String current = this.handler != null ? this.handler.getLanguage() : null;
for (String language : languageOptions) {
if (current != null && language.equalsIgnoreCase(current))
return i;
}
i++;
}
return 0;
}
/**
* Retrieves the list of available scripting languages for this handler.
* <p>
* This method prioritizes languages provided by the server through the {@link #languages} map.
* If "Java" is not present but the handler supports Janino, it injects "Java" into the options
* and ensures the client-side Janino script list is synchronized for the {@link EventGuiScriptList}.
*
* @return A list of language names available for selection.
*/
protected List<String> getLanguageOptions() {
List<String> options = new ArrayList<>();
if (this.languages != null && !this.languages.isEmpty())
options.addAll(this.languages.keySet());
if ((options.isEmpty() || !options.contains("Java")) && this.handler != null && this.handler.supportsJanino()) {
List<String> scripts = new ArrayList<>();
if (ScriptController.Instance != null && ScriptController.Instance.scripts != null) {
scripts.addAll(ScriptController.Instance.scripts.keySet());
}
if (this.languages == null)
this.languages = new HashMap();
if (!this.languages.containsKey("Java"))
this.languages.put("Java", scripts);
options.add("Java");
}
return options;
}
public void confirmClicked(boolean flag, int i) {
if (flag) {
if (i == 0) {
@@ -426,10 +537,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.openLink("http://www.minecraftforge.net/forum/index.php/board,122.0.html");
}
if (i == 10) {
if (singleContainer)
setHandlerContainer(null);
else
this.handler.getScripts().remove(this.activeTab - 1);
handler.removeScriptUnit(this.activeTab - 1);
this.activeTab = 0;
}
if (i == 101) {
@@ -437,10 +545,10 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.setScript();
}
if (i == 102) {
ScriptContainer container;
IScriptUnit container;
if (this.activeTab > 0) {
container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1);
container.script = "";
container = this.handler.getScripts().get(this.activeTab - 1);
container.setScript("");
} else {
this.handler.clearConsole();
if (this.handler instanceof ScriptCustomItem) {
@@ -460,7 +568,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
return textAreas.get(idx);
return null;
}
/**
* Get the current script index for text area storage.
* Override in subclasses with different tab logic.
@@ -468,7 +576,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
protected int getActiveScriptIndex() {
return this.activeTab - 1;
}
/**
* Get the current script container.
* Override in subclasses with different container access patterns.
@@ -490,28 +598,29 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
return super.getTextField(id);
}
public IScriptUnit getFirst() {
if (this.handler.getScripts().isEmpty())
return null;
return this.handler.getScripts().get(0);
}
@Override
protected void actionPerformed(GuiButton guibutton) {
if (guibutton.id >= 0 && guibutton.id < scriptLimit) {
this.setScript();
this.activeTab = guibutton.id;
this.initGui();
// Ensure JaninoScript is compiled after editing
IScriptUnit current = getCurrentContainer();
if (current != null)
current.ensureCompiled();
}
if (guibutton.id == scriptLimit) {
if (singleContainer) {
if (getFirst() == null)
setHandlerContainer(new ScriptContainer(handler));
else
if (handler.isSingleContainer()) {
if (handler.getSingleScript() == null) {
handler.addScriptUnit(new ScriptContainer(handler));
} else {
this.setScript();
}
this.activeTab = 1;
} else {
this.handler.getScripts().add(new ScriptContainer(this.handler));
handler.addScriptUnit(new ScriptContainer(this.handler));
this.activeTab = this.handler.getScripts().size();
}
this.initGui();
@@ -542,7 +651,6 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
displayGuiScreen(guiyesno);
}
ScriptContainer container;
if (guibutton.id == 102) {
GuiYesNo guiyesno = new GuiYesNo(this, StatCollector.translateToLocal("gui.clear"), StatCollector.translateToLocal("gui.sure"), 102);
displayGuiScreen(guiyesno);
@@ -568,25 +676,23 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
if (guibutton.id == 107) {
container = (ScriptContainer) this.handler.getScripts().get(this.activeTab - 1);
IScriptUnit container = getCurrentContainer();
if (container == null) {
container = new ScriptContainer(this.handler);
if (singleContainer)
setHandlerContainer(container);
else
this.handler.getScripts().add(container);
handler.addScriptUnit(container);
}
this.setSubGui(new EventGuiScriptList((List) this.languages.get(this.handler.getLanguage()), container));
String language = container != null ? container.getLanguage() : this.handler.getLanguage();
this.setSubGui(new EventGuiScriptList((List) this.languages.get(language), container));
}
// Language toggle button - switch between ECMAScript and Java
if (guibutton.id == 113) {
int idx = getActiveScriptIndex();
if (idx >= 0 && idx < handler.getScripts().size()) {
IScriptUnit currentUnit = handler.getScripts().get(idx);
IScriptUnit newUnit;
if (currentUnit.isJanino()) {
// Switch from Java to ECMAScript
newUnit = new ScriptContainer(handler);
@@ -602,13 +708,11 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
return; // Handler doesn't support Janino
}
}
// Replace the script unit in the list
handler.getScripts().set(idx, newUnit);
handler.replaceScriptUnit(idx, newUnit);
// Clear the cached text area so it recreates with new language
textAreas.remove(idx);
// Reinitialize the GUI
initGui();
}
@@ -618,77 +722,46 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
protected void setScript() {
if (this.activeTab > 0 || useScrollTabs) {
IScriptUnit container = getCurrentContainer();
if (container == null) {
container = new ScriptContainer(this.handler);
if (singleContainer)
setHandlerContainer(container);
else
this.handler.getScripts().add(container);
handler.addScriptUnit(container);
}
String text = (this.getTextField(2)).getText();
text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n");
container.setScript(text);
if (container != null) {
String text = (this.getTextField(2)).getText();
text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n");
container.setScript(text);
}
}
}
public void setGuiData(NBTTagCompound compound) {
NBTTagList data = compound.getTagList("Languages", 10);
HashMap languages = new HashMap();
for (int i = 0; i < data.tagCount(); ++i) {
NBTTagCompound comp = data.getCompoundTagAt(i);
ArrayList scripts = new ArrayList();
NBTTagList list = comp.getTagList("Scripts", 8);
for (int j = 0; j < list.tagCount(); ++j) {
scripts.add(list.getStringTagAt(j));
if (handler instanceof IScriptHandlerPacket) {
IScriptHandlerPacket.GuiDataResult result = ((IScriptHandlerPacket) handler).setGuiData(compound);
if (result.kind == IScriptHandlerPacket.GuiDataKind.LOAD_COMPLETE) {
loaded = true;
return;
}
if (result.kind == IScriptHandlerPacket.GuiDataKind.METADATA) {
loadLanguagesData(compound);
return;
}
if (result.kind == IScriptHandlerPacket.GuiDataKind.TAB) {
initGui();
return;
}
languages.put(comp.getString("Language"), scripts);
}
this.languages = languages;
this.initGui();
}
/**
* Get the script context for this GUI.
* Override in subclasses to return the appropriate context.
*
* @return The script context (default: GLOBAL)
*/
protected ScriptContext getScriptContext() {
return ScriptContext.GLOBAL;
}
// ==================== UNIFIED SCRIPT DATA HANDLING ====================
/**
* Unified setGuiData for script GUIs with old container system.
* Handles both language data and tab-specific script loading.
*/
protected void setGuiDataWithOldContainer(NBTTagCompound compound) {
if (compound.hasKey("LoadComplete")) {
loaded = true;
return;
}
if (!compound.hasKey("Tab")) {
this.handler.setLanguage(compound.getString("ScriptLanguage"));
this.handler.setEnabled(compound.getBoolean("ScriptEnabled"));
this.loadLanguagesData(compound);
} else {
int tab = compound.getInteger("Tab");
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, this.handler);
this.setHandlerContainer(container);
this.initGui();
}
loadLanguagesData(compound);
}
// ==================== UNIFIED SCRIPT DATA HANDLING ====================
/**
* Load languages data from NBT.
* Separated for potential override in subclasses if needed.
@@ -709,54 +782,31 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
languages.put(comp.getString("Language"), scripts);
}
if (handler != null && handler.supportsJanino()) {
List<String> javaScripts = (List<String>) languages.get("Java");
if (javaScripts == null || javaScripts.isEmpty()) {
javaScripts = new ArrayList<>();
if (ScriptController.Instance != null && ScriptController.Instance.scripts != null) {
javaScripts.addAll(ScriptController.Instance.scripts.keySet());
}
languages.put("Java", javaScripts);
}
}
this.languages = languages;
this.initGui();
}
/**
* Set the handler's container. Override if handler is not IScriptHandler.
*/
protected void setHandlerContainer(IScriptUnit container) {
// Default implementation - subclasses may need to cast and set differently
// e.g., ((LinkedItemScript) handler).container = container;
}
/**
* Unified save method for script GUIs with packet-based saving.
* Subclasses only need to override sendScriptPackets() and sendMetadataPacket().
*/
protected void saveWithPackets() {
if (loaded) {
this.setScript();
List<IScriptUnit> containers = this.handler.getScripts();
for (int i = 0; i < containers.size(); i++) {
IScriptUnit container = containers.get(i);
sendSavePacket(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
}
NBTTagCompound scriptData = new NBTTagCompound();
scriptData.setString("ScriptLanguage", this.handler.getLanguage());
scriptData.setBoolean("ScriptEnabled", this.handler.getEnabled());
scriptData.setTag("ScriptConsole", noppes.npcs.NBTTags.NBTLongStringMap(this.handler.getConsoleText()));
sendSavePacket(-1, containers.size(), scriptData);
}
}
/**
* Send a script container packet. Override in subclasses.
* @param index The index of this script
* @param totalCount Total number of scripts
* @param scriptNBT The script container NBT data
*/
protected void sendSavePacket(int index, int totalCount, NBTTagCompound scriptNBT) {
// Default: do nothing (for non-packet-based GUIs like GuiScriptItem)
}
public void save() {
if (loaded)
this.setScript();
if (!loaded)
return;
this.setScript();
if (handler instanceof IScriptHandlerPacket)
((IScriptHandlerPacket) handler).sync();
}
public void textUpdate(String text) {
@@ -779,6 +829,11 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
@Override
public void close() {
// Ensure JaninoScript is compiled after editing
IScriptUnit current = getCurrentContainer();
if (current != null)
current.ensureCompiled();
if (parent != null) {
this.save();
parent.setWorldAndResolution(mc, width, height);
@@ -826,14 +881,18 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
public int size = 12;
public boolean hovered = false;
/** Initialize button position relative to viewport bounds */
/**
* Initialize button position relative to viewport bounds
*/
public void initGui(int viewportEndX, int viewportY, int scrollbarOffset) {
// Position at top-right, accounting for scrollbar
this.x = viewportEndX + scrollbarOffset - size - 4;
this.y = viewportY + 4;
}
/** Draw the fullscreen toggle button */
/**
* Draw the fullscreen toggle button
*/
public void draw(int mouseX, int mouseY) {
hovered = isMouseOver(mouseX, mouseY);
int y = this.y + getYOffset();
@@ -865,7 +924,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
drawRect(right, bottom, right + cornerLen, bottom + 1, iconColor);
drawRect(right, bottom, right + 1, bottom + cornerLen, iconColor);
} else {
// Draw expand icon (corners pointing outward) ⌐¬⌙⌞
// Top-left corner pointing outward
@@ -879,23 +938,27 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
drawRect(x + inset, y + size - inset - 1, x + inset + cornerLen, y + size - inset, iconColor);
// Bottom-right corner pointing outward
drawRect(x + size - inset - 1, y + size - inset - cornerLen, x + size - inset, y + size - inset,
iconColor);
iconColor);
drawRect(x + size - inset - cornerLen, y + size - inset - 1, x + size - inset, y + size - inset,
iconColor);
iconColor);
}
}
public void drawRect(int x1, int y1, int x2, int y2, int color) {
GuiUtil.drawRectD(x1, y1, x2, y2, color);
}
/** Check if mouse is over the button */
/**
* Check if mouse is over the button
*/
public boolean isMouseOver(int mouseX, int mouseY) {
int y = this.y + getYOffset();
return mouseX >= x && mouseX < x + size && mouseY >= y && mouseY < y + size;
}
/** Handle click - returns true if click was consumed */
/**
* Handle click - returns true if click was consumed
*/
public boolean mouseClicked(int mouseX, int mouseY, int button) {
if (button == 0 && isMouseOver(mouseX, mouseY)) {
toggleFullscreen();
@@ -1,74 +0,0 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.item.ItemScriptErrorPacket;
import kamkeel.npcs.network.packets.request.script.item.ItemScriptPacket;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomItems;
import noppes.npcs.NBTTags;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.scripted.item.ScriptCustomItem;
import java.util.*;
public class GuiScriptItem extends GuiScriptInterface {
private ScriptCustomItem item;
public static Map<Long, String> consoleText = new HashMap<>();
public GuiScriptItem() {
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_ITEM));
this.handler = this.item = new ScriptCustomItem(new ItemStack(CustomItems.scripted_item));
ItemScriptErrorPacket.Get();
ItemScriptPacket.Get();
}
public void setGuiData(NBTTagCompound compound) {
if (compound.hasKey("ItemScriptConsole")) {
consoleText = NBTTags.GetLongStringMap(compound.getTagList("ItemScriptConsole", 10));
initGui();
} else {
this.item.setMCNbt(compound);
this.item.loadScriptData();
super.setGuiData(compound);
loaded = true;
}
}
@Override
protected ScriptContext getScriptContext() {
return ScriptContext.ITEM;
}
public void save() {
if (loaded) {
super.save();
ItemScriptPacket.Save(this.item.getMCNbt());
}
}
protected String getConsoleText() {
Map<Long, String> map = consoleText;
StringBuilder builder = new StringBuilder();
Iterator var3 = map.entrySet().iterator();
while (var3.hasNext()) {
Map.Entry<Long, String> entry = (Map.Entry) var3.next();
builder.insert(0, new Date((Long) entry.getKey()) + (String) entry.getValue() + "\n");
}
return builder.toString();
}
public void confirmClicked(boolean flag, int i) {
if (i == 102) {
if (activeTab <= 0) {
consoleText = new HashMap<>();
ItemScriptErrorPacket.Clear();
}
}
super.confirmClicked(flag, i);
}
}
@@ -1,55 +0,0 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.item.LinkedItemScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.client.gui.global.GuiNPCManageLinked;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.controllers.data.LinkedItem;
import noppes.npcs.controllers.data.LinkedItemScript;
import java.util.ArrayList;
public class GuiScriptLinkedItem extends GuiScriptInterface {
public final LinkedItem linkedItem;
public GuiScriptLinkedItem(GuiNPCManageLinked parent, LinkedItem linkedItem) {
super();
this.parent = parent;
this.linkedItem = linkedItem;
this.handler = new LinkedItemScript();
this.singleContainer = true;
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_LINKED_ITEM));
LinkedItemScriptPacket.Get(linkedItem.id);
}
@Override
protected ScriptContext getScriptContext() {
return ScriptContext.ITEM;
}
protected void setHandlerContainer(IScriptUnit container) {
((LinkedItemScript) handler).container = container;
}
@Override
public void setGuiData(NBTTagCompound compound) {
setGuiDataWithOldContainer(compound);
}
protected void sendSavePacket(int index, int totalCount, NBTTagCompound scriptNBT) {
LinkedItemScriptPacket.Save(linkedItem.id, index, totalCount, scriptNBT);
}
@Override
public void save() {
saveWithPackets();
}
}
@@ -1,71 +0,0 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.PlayerScriptPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.NBTTags;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.controllers.data.PlayerDataScript;
import java.util.ArrayList;
import java.util.List;
public class GuiScriptPlayers extends GuiScriptInterface {
private PlayerDataScript script = new PlayerDataScript((EntityPlayer) null);
public GuiScriptPlayers() {
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_PLAYER));
this.handler = this.script;
PlayerScriptPacket.Get();
}
public void setGuiData(NBTTagCompound compound) {
if (compound.hasKey("LoadComplete")) {
loaded = true;
return;
}
if (!compound.hasKey("Tab")) {
script.setLanguage(compound.getString("ScriptLanguage"));
script.setEnabled(compound.getBoolean("ScriptEnabled"));
super.setGuiData(compound);
} else {
int tab = compound.getInteger("Tab");
NBTTagCompound scriptCompound = compound.getCompoundTag("Script");
IScriptUnit container = IScriptUnit.createFromNBT(scriptCompound, script);
if (script.getScripts().isEmpty()) {
for (int i = 0; i < compound.getInteger("TotalScripts"); i++) {
script.getScripts().add(new ScriptContainer(script));
}
}
script.getScripts().set(tab, container);
initGui();
}
}
@Override
protected ScriptContext getScriptContext() {
return ScriptContext.PLAYER;
}
public void save() {
if (loaded) {
super.save();
List<IScriptUnit> containers = this.script.getScripts();
for (int i = 0; i < containers.size(); i++) {
IScriptUnit container = containers.get(i);
PlayerScriptPacket.Save(i, containers.size(), container.writeToNBT(new NBTTagCompound()));
}
NBTTagCompound scriptData = new NBTTagCompound();
scriptData.setString("ScriptLanguage", this.script.getLanguage());
scriptData.setBoolean("ScriptEnabled", this.script.getEnabled());
scriptData.setTag("ScriptConsole", NBTTags.NBTLongStringMap(this.script.getConsoleText()));
PlayerScriptPacket.Save(-1, containers.size(), scriptData);
}
}
}
@@ -1,69 +0,0 @@
package noppes.npcs.client.gui.script;
import kamkeel.npcs.network.packets.request.script.RecipeScriptPacket;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.handler.IScriptHookHandler;
import noppes.npcs.client.gui.global.GuiNpcManageRecipes;
import noppes.npcs.constants.ScriptContext;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptHookController;
import noppes.npcs.controllers.data.IScriptUnit;
import noppes.npcs.controllers.data.RecipeAnvil;
import noppes.npcs.controllers.data.RecipeCarpentry;
import noppes.npcs.controllers.data.RecipeScript;
import java.util.ArrayList;
public class GuiScriptRecipe extends GuiScriptInterface {
public final int recipeId;
public final boolean anvil;
public GuiScriptRecipe(GuiNpcManageRecipes parent, RecipeCarpentry recipe) {
super();
this.parent = parent;
this.handler = new RecipeScript();
this.anvil = false;
this.recipeId = recipe.id;
this.singleContainer = true;
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_RECIPE));
RecipeScriptPacket.Get(false, recipeId);
}
public GuiScriptRecipe(GuiNpcManageRecipes parent, RecipeAnvil recipe) {
super();
this.parent = parent;
this.handler = new RecipeScript();
this.anvil = true;
this.recipeId = recipe.id;
this.hookList = new ArrayList<>(ScriptHookController.Instance.getAllHooks(IScriptHookHandler.CONTEXT_RECIPE));
RecipeScriptPacket.Get(true, recipeId);
}
@Override
protected ScriptContext getScriptContext() {
return ScriptContext.GLOBAL;
}
protected void setHandlerContainer(IScriptUnit container) {
((RecipeScript) handler).container = container;
}
@Override
public void setGuiData(NBTTagCompound compound) {
setGuiDataWithOldContainer(compound);
}
protected void sendSavePacket(int index, int totalCount, NBTTagCompound scriptNBT) {
RecipeScriptPacket.Save(anvil, recipeId, index, totalCount, scriptNBT);
}
@Override
public void save() {
saveWithPackets();
}
}
@@ -42,7 +42,7 @@ public class SubGuiSelectList extends SubGuiInterface {
scroll1.setSize(140, 180);
}
addTopButton(new GuiMenuTopButton(-1, guiLeft + xSize-22 , guiTop - 17, "X"));
addTopButton(new GuiMenuTopButton(-1, guiLeft + xSize - 22, guiTop - 17, "X"));
scroll1.guiLeft = guiLeft + 4;
scroll1.guiTop = guiTop + 14;
@@ -50,7 +50,7 @@ public class GuiAnimationSelection extends SubGuiInterface implements ICustomScr
public void initGui() {
super.initGui();
this.addLabel(new GuiNpcLabel(0, "gui.animations", guiLeft + 8, guiTop + 4));
this.addLabel(new GuiNpcLabel(0, "menu.animations", guiLeft + 8, guiTop + 4));
this.addButton(new GuiNpcButton(1, guiLeft + 4, guiTop + ySize - 35, 50, 20, "gui.clear"));
this.addButton(new GuiNpcButton(2, guiLeft + xSize - 56, guiTop + ySize - 35, 50, 20, "gui.done"));
Loaded 100 of 200 files, more files were not shown because too many files have changed in this diff. Show more