mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-19 01:29:05 +00:00
A various amount of fixes!!!!!
This commit is contained in:
1 parent
083d38b9d3
commit
5d16e79767
40 files changed
+111
-417
No files matched your search
@@ -1184,7 +1184,7 @@ public class AbilityController implements IAbilityHandler {
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public Boolean fireCheckConditionsForPlayer(AbilityCondition condition, EntityLivingBase player) {
|
||||
@@ -1249,7 +1249,7 @@ public class AbilityController implements IAbilityHandler {
|
||||
public boolean isAllowedByPlayer(String typeId) {
|
||||
if (abilityTypes.containsKey(typeId)) {
|
||||
Ability temp = abilityTypes.get(typeId).get();
|
||||
return temp.getAllowedBy() == UserType.PLAYER_ONLY;
|
||||
return temp.getAllowedBy().allowsPlayer();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1258,7 +1258,7 @@ public class AbilityController implements IAbilityHandler {
|
||||
public boolean isAllowedByNPC(String typeId) {
|
||||
if (abilityTypes.containsKey(typeId)) {
|
||||
Ability temp = abilityTypes.get(typeId).get();
|
||||
return temp.getAllowedBy() == UserType.NPC_ONLY;
|
||||
return temp.getAllowedBy().allowsNpc();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -1479,8 +1479,8 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
lockMovement = LockMode.fromOrdinal(nbt.getInteger("lockMovement"));
|
||||
rotationMode = RotationMode.fromOrdinal(nbt.getInteger("rotationMode"));
|
||||
rotationPhase = LockMode.fromOrdinal(nbt.getInteger("rotationPhase"));
|
||||
windUpColor = nbt.getInteger("windUpColor");
|
||||
activeColor = nbt.getInteger("activeColor");
|
||||
windUpColor = nbt.hasKey("windUpColor") ? nbt.getInteger("windUpColor") : 0x80FF4400;
|
||||
activeColor = nbt.hasKey("activeColor") ? nbt.getInteger("activeColor") : 0xC0FF0000;
|
||||
windUpSound = nbt.getString("windUpSound");
|
||||
activeSound = nbt.getString("activeSound");
|
||||
windUpAnimationId = nbt.getInteger("windUpAnimationId");
|
||||
@@ -1496,7 +1496,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
telegraphType = TelegraphType.CIRCLE;
|
||||
}
|
||||
telegraphHeightOffset = nbt.getFloat("telegraphHeightOffset");
|
||||
customData = nbt.getCompoundTag("customData");
|
||||
customData = (NBTTagCompound) nbt.getCompoundTag("customData").copy();
|
||||
allowedBy = UserType.fromOrdinal(nbt.getInteger("allowedBy"));
|
||||
ignoreCooldown = nbt.getBoolean("ignoreCooldown");
|
||||
perAbilityCooldown = nbt.getBoolean("perAbilityCooldown");
|
||||
@@ -1520,7 +1520,7 @@ public abstract class Ability implements IAbility, IAbilityAction {
|
||||
burstEnabled = nbt.getBoolean("burstEnabled");
|
||||
burstAmount = nbt.getInteger("burstAmount");
|
||||
burstDelay = nbt.getInteger("burstDelay");
|
||||
burstReplayAnimations = nbt.getBoolean("burstReplayAnimations");
|
||||
burstReplayAnimations = nbt.hasKey("burstReplayAnimations") ? nbt.getBoolean("burstReplayAnimations") : true;
|
||||
burstOverlap = nbt.getBoolean("burstOverlap");
|
||||
|
||||
// Conditions
|
||||
|
||||
+2
-2
@@ -17,6 +17,7 @@ public class ConditionHitCount extends AbilityCondition {
|
||||
public ConditionHitCount() {
|
||||
this.typeId = "condition.cnpc.hit_count";
|
||||
this.name = "condition.hit_count";
|
||||
this.conditionFilter = ConditionFilter.CASTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,8 +65,7 @@ public class ConditionHitCount extends AbilityCondition {
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public String getConditionSummary() {
|
||||
String filterLabel = StatCollector.translateToLocal(getFilter().toString());
|
||||
return "[" + filterLabel + "] Hit " + requiredHits + " times in " + withinTicks + " ticks";
|
||||
return "[Caster] Hit " + requiredHits + " times in " + withinTicks + " ticks";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -99,6 +99,7 @@ public class ConditionItem extends AbilityCondition {
|
||||
private boolean checkOffhand(EntityLivingBase entity) {
|
||||
// No offhand for players
|
||||
if (entity instanceof EntityPlayer) return false;
|
||||
if (!(entity instanceof EntityNPCInterface)) return false;
|
||||
|
||||
ItemStack item = ((EntityNPCInterface) entity).getOffHand();
|
||||
return matchesItem(item);
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public abstract class ConditionThreshold extends AbilityCondition {
|
||||
EQUAL {
|
||||
@Override
|
||||
public boolean test(float value, float threshold) {
|
||||
return value == threshold;
|
||||
return Math.abs(value - threshold) < 0.001f;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
|
||||
if (allAllowPlayer && allAllowNpc) return UserType.BOTH;
|
||||
if (allAllowPlayer) return UserType.PLAYER_ONLY;
|
||||
if (allAllowNpc) return UserType.NPC_ONLY;
|
||||
return UserType.NPC_ONLY;
|
||||
return UserType.NONE;
|
||||
}
|
||||
|
||||
public List<AbilityCondition> getConditions() {
|
||||
@@ -441,6 +441,6 @@ public class ChainedAbility implements IChainedAbility, IAbilityAction {
|
||||
}
|
||||
|
||||
// Custom data (for external mods)
|
||||
customData = nbt.getCompoundTag("customData");
|
||||
customData = (NBTTagCompound) nbt.getCompoundTag("customData").copy();
|
||||
}
|
||||
}
|
||||
-291
@@ -1,291 +0,0 @@
|
||||
package kamkeel.npcs.controllers.data.ability.data.energy;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
import noppes.npcs.api.IPos;
|
||||
import noppes.npcs.api.ability.data.IEnergyTrajectoryData;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class EnergyTrajectoryData implements IEnergyTrajectoryData {
|
||||
public int currentPath = 0;
|
||||
private final List<Path> trajectory = new ArrayList<>();
|
||||
|
||||
public EnergyTrajectoryData() {
|
||||
}
|
||||
|
||||
public EnergyTrajectoryData(int startingPath, Path... paths) {
|
||||
trajectory.addAll(Arrays.asList(paths));
|
||||
this.currentPath = startingPath < trajectory.size() && startingPath >= 0 ? startingPath : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentPath() {
|
||||
return currentPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentPath(int currentPath) {
|
||||
this.currentPath = currentPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDelay(int path) {
|
||||
if (getPath(path) == null) return -1;
|
||||
return getPath(path).getDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDelay(int path, int ticks) {
|
||||
if (getPath(path) == null) return;
|
||||
getPath(path).setDelay(ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPos getPos(int path) {
|
||||
IPath p = getPath(path);
|
||||
return p == null ? null : p.getPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPos(int path, IPos pos) {
|
||||
IPath p = getPath(path);
|
||||
if (p != null) p.setPos(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConcluded(int path) {
|
||||
IPath p = getPath(path);
|
||||
return p != null && p.isConcluded();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConcluded(int path, boolean concluded) {
|
||||
IPath p = getPath(path);
|
||||
if (p != null) p.setConcluded(concluded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX(int path) {
|
||||
IPath p = getPath(path);
|
||||
return p == null ? 0 : p.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY(int path) {
|
||||
IPath p = getPath(path);
|
||||
return p == null ? 0 : p.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ(int path) {
|
||||
IPath p = getPath(path);
|
||||
return p == null ? 0 : p.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setX(int path, double x) {
|
||||
IPath p = getPath(path);
|
||||
if (p != null) p.setX(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setY(int path, double y) {
|
||||
IPath p = getPath(path);
|
||||
if (p != null) p.setY(y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZ(int path, double z) {
|
||||
IPath p = getPath(path);
|
||||
if (p != null) p.setZ(z);
|
||||
}
|
||||
|
||||
public IPath getPath(int path) {
|
||||
if (path < 0 || path >= trajectory.size()) return null;
|
||||
return trajectory.get(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPath(int path, IPos pos) {
|
||||
setPath(path, pos, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPath(int path, IPos pos, int delay) {
|
||||
setPath(path, pos.getX(), pos.getY(), pos.getZ(), delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPath(int path, double x, double y, double z) {
|
||||
setPath(path, x, y, z, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPath(int path, double x, double y, double z, int delay) {
|
||||
Path newPath = new Path(
|
||||
NpcAPI.Instance().getIPos(x, y, z),
|
||||
delay
|
||||
);
|
||||
|
||||
while (trajectory.size() <= path) {
|
||||
trajectory.add(null);
|
||||
}
|
||||
|
||||
trajectory.set(path, newPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath createPath(IPos pos) {
|
||||
return new Path(pos, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath createPath(IPos pos, int delay) {
|
||||
return new Path(pos, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath createPath(double x, double y, double z) {
|
||||
return createPath(x, y, z, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPath createPath(double x, double y, double z, int delay) {
|
||||
return new Path(NpcAPI.Instance().getIPos(x, y, z), delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forEach(BiConsumer<Integer, IPath> lambda) {
|
||||
for (int i = 0; i < trajectory.size(); i++) {
|
||||
lambda.accept(i, trajectory.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return trajectory.size();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return trajectory.isEmpty();
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("currentPath", currentPath);
|
||||
|
||||
for (int i = 0; i < trajectory.size(); i++) {
|
||||
Path path = trajectory.get(i);
|
||||
NBTTagCompound pathNbt = new NBTTagCompound();
|
||||
path.writeNBT(pathNbt);
|
||||
nbt.setTag("Path_" + i, pathNbt);
|
||||
}
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
this.currentPath = nbt.getInteger("currentPath");
|
||||
trajectory.clear();
|
||||
|
||||
int i = 0;
|
||||
while (nbt.hasKey("Path_" + i, Constants.NBT.TAG_COMPOUND)) {
|
||||
NBTTagCompound pathNbt = nbt.getCompoundTag("Path_" + i);
|
||||
Path path = (Path) createPath(0, 0, 0);
|
||||
path.readNBT(pathNbt);
|
||||
trajectory.add(path);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Path implements IEnergyTrajectoryData.IPath {
|
||||
public IPos pos;
|
||||
public int delayTicks;
|
||||
public boolean concluded;
|
||||
|
||||
public Path(IPos pos, int delayTicks) {
|
||||
this.pos = pos;
|
||||
this.delayTicks = delayTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPos getPos() {
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPos(IPos pos) {
|
||||
this.pos = pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDelay() {
|
||||
return delayTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDelay(int delayTicks) {
|
||||
this.delayTicks = delayTicks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConcluded() {
|
||||
return concluded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConcluded(boolean concluded) {
|
||||
this.concluded = concluded;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getX() {
|
||||
return pos.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setX(double x) {
|
||||
this.pos = NpcAPI.Instance().getIPos(x, getY(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getY() {
|
||||
return pos.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setY(double y) {
|
||||
this.pos = NpcAPI.Instance().getIPos(getX(), y, getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getZ() {
|
||||
return pos.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setZ(double z) {
|
||||
this.pos = NpcAPI.Instance().getIPos(pos.getX(), pos.getY(), z);
|
||||
}
|
||||
|
||||
public void writeNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("delay", delayTicks);
|
||||
nbt.setBoolean("concluded", concluded);
|
||||
nbt.setDouble("X", getX());
|
||||
nbt.setDouble("Y", getY());
|
||||
nbt.setDouble("Z", getZ());
|
||||
}
|
||||
|
||||
public void readNBT(NBTTagCompound nbt) {
|
||||
this.delayTicks = nbt.getInteger("delay");
|
||||
this.concluded = nbt.getBoolean("concluded");
|
||||
|
||||
double x = nbt.getDouble("X");
|
||||
double y = nbt.getDouble("Y");
|
||||
double z = nbt.getDouble("Z");
|
||||
|
||||
this.pos = NpcAPI.Instance().getIPos(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,8 @@ package kamkeel.npcs.controllers.data.ability.enums;
|
||||
public enum UserType {
|
||||
NPC_ONLY,
|
||||
PLAYER_ONLY,
|
||||
BOTH;
|
||||
BOTH,
|
||||
NONE;
|
||||
|
||||
public boolean allowsNpc() {
|
||||
return this == NPC_ONLY || this == BOTH;
|
||||
|
||||
+4
-1
@@ -60,6 +60,7 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
|
||||
// ==================== NPC START POSITION ====================
|
||||
private double npcStartX, npcStartY, npcStartZ;
|
||||
private boolean hasStartPosition = false;
|
||||
|
||||
// ==================== PREVIEW CONTENT ====================
|
||||
private TelegraphInstance previewTelegraph;
|
||||
@@ -98,6 +99,7 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
this.npcStartX = npc.posX;
|
||||
this.npcStartY = npc.posY;
|
||||
this.npcStartZ = npc.posZ;
|
||||
this.hasStartPosition = true;
|
||||
|
||||
// Create invisible fake target NPC for targeting
|
||||
createFakeTarget(npc);
|
||||
@@ -127,6 +129,7 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
this.npcStartX = npc.posX;
|
||||
this.npcStartY = npc.posY;
|
||||
this.npcStartZ = npc.posZ;
|
||||
this.hasStartPosition = true;
|
||||
|
||||
// Resolve all entries to deep-copied abilities
|
||||
chainAbilities = new ArrayList<>();
|
||||
@@ -315,7 +318,7 @@ public class AbilityPreviewExecutor implements PreviewEntityHandler {
|
||||
previewEntities.clear();
|
||||
|
||||
// Reset NPC position to start position (undo movement from Slam/Charge/Dash)
|
||||
if (previewNpc != null && npcStartX != 0 && npcStartY != 0 && npcStartZ != 0) {
|
||||
if (previewNpc != null && hasStartPosition) {
|
||||
previewNpc.posX = npcStartX;
|
||||
previewNpc.posY = npcStartY;
|
||||
previewNpc.posZ = npcStartZ;
|
||||
|
||||
@@ -249,10 +249,10 @@ public class AbilityCharge extends AbilityMovement implements IAbilityCharge {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.chargeSpeed = nbt.getFloat("chargeSpeed");
|
||||
this.damage = nbt.getFloat("damage");
|
||||
this.knockback = nbt.getFloat("knockback");
|
||||
this.hitWidth = nbt.getFloat("hitWidth");
|
||||
this.chargeSpeed = nbt.hasKey("chargeSpeed") ? Math.max(0.01f, nbt.getFloat("chargeSpeed")) : 0.8f;
|
||||
this.damage = nbt.hasKey("damage") ? nbt.getFloat("damage") : 8.0f;
|
||||
this.knockback = nbt.hasKey("knockback") ? nbt.getFloat("knockback") : 3.0f;
|
||||
this.hitWidth = nbt.hasKey("hitWidth") ? nbt.getFloat("hitWidth") : 1.5f;
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -252,8 +252,8 @@ public class AbilityDash extends AbilityMovement implements IAbilityDash {
|
||||
} catch (Exception e) {
|
||||
this.dashMode = DashMode.DEFENSIVE;
|
||||
}
|
||||
this.dashDistance = nbt.getFloat("dashDistance");
|
||||
this.dashSpeed = nbt.getFloat("dashSpeed");
|
||||
this.dashDistance = nbt.hasKey("dashDistance") ? nbt.getFloat("dashDistance") : 4.0f;
|
||||
this.dashSpeed = nbt.hasKey("dashSpeed") ? Math.max(0.01f, nbt.getFloat("dashSpeed")) : 0.5f;
|
||||
}
|
||||
|
||||
// Getters & Setters
|
||||
|
||||
@@ -194,7 +194,7 @@ public class AbilityGuard extends Ability implements IAbilityGuard {
|
||||
return AnimationController.Instance.get(counterAnimationId);
|
||||
}
|
||||
|
||||
if (!counterAnimationName.isEmpty()) {
|
||||
if (counterAnimationName != null && !counterAnimationName.isEmpty()) {
|
||||
return AnimationController.Instance.get(counterAnimationName, true);
|
||||
}
|
||||
|
||||
@@ -247,8 +247,8 @@ public class AbilityGuard extends Ability implements IAbilityGuard {
|
||||
|
||||
@Override
|
||||
public void readTypeNBT(NBTTagCompound nbt) {
|
||||
this.durationTicks = nbt.getInteger("durationTicks");
|
||||
this.damageReduction = nbt.getFloat("damageReduction");
|
||||
this.durationTicks = nbt.hasKey("durationTicks") ? nbt.getInteger("durationTicks") : 60;
|
||||
this.damageReduction = nbt.hasKey("damageReduction") ? nbt.getFloat("damageReduction") : 0.5f;
|
||||
this.canCounter = nbt.getBoolean("canCounter");
|
||||
this.counterWindow = nbt.getInteger("counterWindow");
|
||||
try {
|
||||
@@ -353,7 +353,7 @@ public class AbilityGuard extends Ability implements IAbilityGuard {
|
||||
}
|
||||
|
||||
public void setCounterAnimationName(String name) {
|
||||
this.counterAnimationName = name;
|
||||
this.counterAnimationName = name != null ? name : "";
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@@ -4,8 +4,10 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import kamkeel.npcs.controllers.data.ability.Ability;
|
||||
import kamkeel.npcs.controllers.data.ability.enums.LockMode;
|
||||
import kamkeel.npcs.controllers.data.ability.enums.TargetFilter;
|
||||
import kamkeel.npcs.controllers.data.ability.enums.TargetingMode;
|
||||
import kamkeel.npcs.controllers.data.ability.enums.UserType;
|
||||
import kamkeel.npcs.controllers.data.ability.util.AbilityTargetHelper;
|
||||
import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphType;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -389,6 +391,7 @@ public class AbilityTeleport extends Ability implements IAbilityTeleport {
|
||||
for (Entity entity : entities) {
|
||||
if (!(entity instanceof EntityLivingBase)) continue;
|
||||
if (entity == caster) continue;
|
||||
if (!AbilityTargetHelper.shouldAffect(caster, entity, TargetFilter.ENEMIES, false)) continue;
|
||||
|
||||
EntityLivingBase living = (EntityLivingBase) entity;
|
||||
double dist = Math.sqrt(Math.pow(living.posX - x, 2) + Math.pow(living.posZ - z, 2));
|
||||
@@ -435,8 +438,8 @@ public class AbilityTeleport extends Ability implements IAbilityTeleport {
|
||||
} catch (Exception e) {
|
||||
this.mode = TeleportMode.BLINK;
|
||||
}
|
||||
this.blinkCount = nbt.getInteger("blinkCount");
|
||||
this.blinkDelayTicks = nbt.getInteger("blinkDelayTicks");
|
||||
this.blinkCount = nbt.hasKey("blinkCount") ? nbt.getInteger("blinkCount") : 3;
|
||||
this.blinkDelayTicks = nbt.hasKey("blinkDelayTicks") ? nbt.getInteger("blinkDelayTicks") : 10;
|
||||
this.blinkRadius = nbt.getFloat("blinkRadius");
|
||||
this.behindDistance = nbt.getFloat("behindDistance");
|
||||
this.requireLineOfSight = nbt.getBoolean("requireLineOfSight");
|
||||
|
||||
@@ -66,7 +66,7 @@ public class AbilityBeam extends AbilityEnergyProjectile<EntityAbilityBeam> impl
|
||||
caster.worldObj, caster, target,
|
||||
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord,
|
||||
beamWidth, headSize,
|
||||
resolved, combatData, homingData, lightningData, lifespanData, trajectoryData,
|
||||
resolved, combatData, homingData, lightningData, lifespanData,
|
||||
lockMovement.locksActive());
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ public class AbilityDisc extends AbilityEnergyProjectile<EntityAbilityDisc> impl
|
||||
caster.worldObj, caster, target,
|
||||
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord,
|
||||
discRadius, discThickness,
|
||||
resolved, combatData, homingData, lightningData, lifespanData, trajectoryData,
|
||||
resolved, combatData, homingData, lightningData, lifespanData,
|
||||
boomerang, boomerangDelay);
|
||||
}
|
||||
|
||||
|
||||
-5
@@ -9,7 +9,6 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyCombatData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyHomingData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.ProjectileData;
|
||||
import kamkeel.npcs.controllers.data.telegraph.Telegraph;
|
||||
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
|
||||
@@ -44,9 +43,6 @@ public abstract class AbilityEnergyProjectile<E extends EntityEnergyProjectile>
|
||||
protected int projectileCount = 1;
|
||||
protected int fireDelay = 0;
|
||||
|
||||
// Trajectory data
|
||||
protected EnergyTrajectoryData trajectoryData;
|
||||
|
||||
// Shared combat/movement data
|
||||
protected final EnergyCombatData combatData;
|
||||
protected final EnergyHomingData homingData;
|
||||
@@ -74,7 +70,6 @@ public abstract class AbilityEnergyProjectile<E extends EntityEnergyProjectile>
|
||||
this.combatData = combatData;
|
||||
this.homingData = homingData;
|
||||
this.lifespanData = lifespanData;
|
||||
this.trajectoryData = new EnergyTrajectoryData();
|
||||
this.burstOverlap = true;
|
||||
initProjectiles(1);
|
||||
}
|
||||
|
||||
+1
-1
@@ -118,7 +118,7 @@ public class AbilityLaserShot extends AbilityEnergyProjectile<EntityAbilityLaser
|
||||
caster.worldObj, caster, target,
|
||||
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord,
|
||||
laserWidth,
|
||||
resolved, combatData, lightningData, lifespanData, trajectoryData,
|
||||
resolved, combatData, lightningData, lifespanData,
|
||||
expansionSpeed, lingerTicks);
|
||||
return laser;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class AbilityOrb extends AbilityEnergyProjectile<EntityAbilityOrb> implem
|
||||
return new EntityAbilityOrb(
|
||||
caster.worldObj, caster, target,
|
||||
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord, orbSize,
|
||||
resolved, combatData, homingData, lightningData, lifespanData, trajectoryData);
|
||||
resolved, combatData, homingData, lightningData, lifespanData);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,7 +61,7 @@ public class AbilitySlicer extends AbilityEnergyProjectile<EntityEnergySlicer> {
|
||||
caster.worldObj, caster, target,
|
||||
spawnPos.xCoord, spawnPos.yCoord, spawnPos.zCoord,
|
||||
sliceWidth, sliceThickness,
|
||||
resolved, combatData, homingData, lightningData, lifespanData, trajectoryData
|
||||
resolved, combatData, homingData, lightningData, lifespanData
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyHomingData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData;
|
||||
import kamkeel.npcs.util.AnchorPointHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -139,12 +138,12 @@ public class EntityAbilityBeam extends EntityEnergyProjectile {
|
||||
float beamWidth, float headSize,
|
||||
EnergyDisplayData display, EnergyCombatData combat,
|
||||
EnergyHomingData homing, EnergyLightningData lightning,
|
||||
EnergyLifespanData lifespan, EnergyTrajectoryData trajectory,
|
||||
EnergyLifespanData lifespan,
|
||||
boolean anchoredMode) {
|
||||
super(world);
|
||||
|
||||
// Initialize base properties via parent
|
||||
initProjectile(owner, target, x, y, z, headSize, display, combat, lightning, lifespan, trajectory);
|
||||
initProjectile(owner, target, x, y, z, headSize, display, combat, lightning, lifespan);
|
||||
|
||||
// Beam-specific properties from homing data
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyHomingData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData;
|
||||
import kamkeel.npcs.util.AnchorPointHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -58,12 +57,12 @@ public class EntityAbilityDisc extends EntityEnergyProjectile {
|
||||
float discRadius, float discThickness,
|
||||
EnergyDisplayData display, EnergyCombatData combat,
|
||||
EnergyHomingData homing, EnergyLightningData lightning,
|
||||
EnergyLifespanData lifespan, EnergyTrajectoryData trajectory,
|
||||
EnergyLifespanData lifespan,
|
||||
boolean boomerang, int boomerangDelay) {
|
||||
super(world);
|
||||
|
||||
// Initialize base properties
|
||||
initProjectile(owner, target, x, y, z, 1.0f, display, combat, lightning, lifespan, trajectory);
|
||||
initProjectile(owner, target, x, y, z, 1.0f, display, combat, lightning, lifespan);
|
||||
|
||||
this.homingData = homing;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyCombatData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -60,11 +59,11 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
float laserWidth,
|
||||
EnergyDisplayData display, EnergyCombatData combat,
|
||||
EnergyLightningData lightning, EnergyLifespanData lifespan,
|
||||
EnergyTrajectoryData trajectory, float expansionSpeed, int lingerTicks) {
|
||||
float expansionSpeed, int lingerTicks) {
|
||||
super(world);
|
||||
|
||||
// Initialize base properties (laser doesn't rotate)
|
||||
initProjectile(owner, target, x, y, z, laserWidth, display, combat, lightning, lifespan, trajectory);
|
||||
initProjectile(owner, target, x, y, z, laserWidth, display, combat, lightning, lifespan);
|
||||
this.displayData.rotationSpeed = 0.0f;
|
||||
|
||||
// Laser-specific properties
|
||||
@@ -90,12 +89,16 @@ public class EntityAbilityLaser extends EntityEnergyProjectile {
|
||||
this.dirX = look.xCoord;
|
||||
this.dirY = look.yCoord;
|
||||
this.dirZ = look.zCoord;
|
||||
} else {
|
||||
} else if (owner != null) {
|
||||
float yaw = (float) Math.toRadians(owner.rotationYaw);
|
||||
float pitch = (float) Math.toRadians(owner.rotationPitch);
|
||||
this.dirX = -Math.sin(yaw) * Math.cos(pitch);
|
||||
this.dirY = -Math.sin(pitch);
|
||||
this.dirZ = Math.cos(yaw) * Math.cos(pitch);
|
||||
} else {
|
||||
this.dirX = 1.0;
|
||||
this.dirY = 0.0;
|
||||
this.dirZ = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyHomingData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
@@ -33,11 +32,11 @@ public class EntityAbilityOrb extends EntityEnergyProjectile {
|
||||
double x, double y, double z, float orbSize,
|
||||
EnergyDisplayData display, EnergyCombatData combat,
|
||||
EnergyHomingData homing, EnergyLightningData lightning,
|
||||
EnergyLifespanData lifespan, EnergyTrajectoryData trajectory) {
|
||||
EnergyLifespanData lifespan) {
|
||||
super(world);
|
||||
|
||||
// Initialize base properties
|
||||
initProjectile(owner, target, x, y, z, orbSize, display, combat, lightning, lifespan, trajectory);
|
||||
initProjectile(owner, target, x, y, z, orbSize, display, combat, lightning, lifespan);
|
||||
|
||||
this.homingData = homing;
|
||||
|
||||
@@ -114,17 +113,13 @@ public class EntityAbilityOrb extends EntityEnergyProjectile {
|
||||
}
|
||||
|
||||
private void updateMovement() {
|
||||
if (!isTrajectoryConcluded()) {
|
||||
updateTrajectory();
|
||||
} else {
|
||||
if (ticksExisted > HOMING_STARTUP_TICKS) {
|
||||
int homingTicks = ticksExisted - HOMING_STARTUP_TICKS;
|
||||
if (homingTicks >= HOMING_RAMP_TICKS) {
|
||||
updateHoming();
|
||||
} else {
|
||||
float ramp = homingTicks / (float) HOMING_RAMP_TICKS;
|
||||
updateHomingWithRamp(ramp);
|
||||
}
|
||||
if (ticksExisted > HOMING_STARTUP_TICKS) {
|
||||
int homingTicks = ticksExisted - HOMING_STARTUP_TICKS;
|
||||
if (homingTicks >= HOMING_RAMP_TICKS) {
|
||||
updateHoming();
|
||||
} else {
|
||||
float ramp = homingTicks / (float) HOMING_RAMP_TICKS;
|
||||
updateHomingWithRamp(ramp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -137,24 +132,6 @@ public class EntityAbilityOrb extends EntityEnergyProjectile {
|
||||
homingData.homingStrength = originalStrength;
|
||||
}
|
||||
|
||||
private void updateTrajectory() {
|
||||
if (isTrajectoryConcluded()) return;
|
||||
// i really fucking hate math
|
||||
|
||||
}
|
||||
|
||||
private boolean isTrajectoryConcluded() {
|
||||
if (trajectoryData.isEmpty()) return true;
|
||||
|
||||
for (int i = 0; i < trajectoryData.size(); i++) {
|
||||
if (!trajectoryData.getPath(i).isConcluded()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void checkBlockCollision() {
|
||||
handleBlockImpact(rayTraceBlocks(posX, posY, posZ, posX + motionX, posY + motionY, posZ + motionZ), true);
|
||||
}
|
||||
|
||||
@@ -159,10 +159,9 @@ public class EntityAbilitySweeper extends EntityEnergyAbility {
|
||||
|
||||
// Update rotation
|
||||
currentAngle += sweepSpeed;
|
||||
if (currentAngle >= 360) {
|
||||
while (currentAngle >= 360) {
|
||||
currentAngle -= 360;
|
||||
completedRotations++;
|
||||
// Rotation completed
|
||||
}
|
||||
|
||||
// Server handles damage
|
||||
|
||||
@@ -12,7 +12,6 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyHomingData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData;
|
||||
import kamkeel.npcs.network.packets.data.energyexplosion.EnergyExplosionSpawnPacket;
|
||||
import kamkeel.npcs.util.AnchorPointHelper;
|
||||
import net.minecraft.block.Block;
|
||||
@@ -114,8 +113,6 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
// ==================== HOMING PROPERTIES ====================
|
||||
protected EnergyHomingData homingData = new EnergyHomingData();
|
||||
|
||||
// ==================== TRAJECTORY PROPERTIES ====================
|
||||
protected EnergyTrajectoryData trajectoryData = new EnergyTrajectoryData();
|
||||
protected Map<Integer, Integer> pathDelays;
|
||||
|
||||
// ==================== TRACKING ====================
|
||||
@@ -174,8 +171,7 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
protected void initProjectile(EntityLivingBase owner, EntityLivingBase target,
|
||||
double x, double y, double z, float size,
|
||||
EnergyDisplayData display, EnergyCombatData combat,
|
||||
EnergyLightningData lightning, EnergyLifespanData lifespan,
|
||||
EnergyTrajectoryData trajectory) {
|
||||
EnergyLightningData lightning, EnergyLifespanData lifespan) {
|
||||
this.setPosition(x, y, z);
|
||||
this.startX = x;
|
||||
this.startY = y;
|
||||
@@ -191,7 +187,6 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
this.combatData = combat;
|
||||
this.lifespanData = lifespan; // deathWorldTime will be set on first tick when world is available
|
||||
this.lightningData = lightning;
|
||||
this.trajectoryData = trajectory;
|
||||
syncProjectileColorWatchers();
|
||||
|
||||
// Initialize render size
|
||||
@@ -2203,7 +2198,6 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
combatData.readNBT(nbt);
|
||||
homingData.readNBT(nbt);
|
||||
lifespanData.readNBT(nbt);
|
||||
trajectoryData.readNBT(nbt);
|
||||
syncProjectileColorWatchers();
|
||||
}
|
||||
|
||||
@@ -2238,7 +2232,6 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility {
|
||||
combatData.writeNBT(nbt);
|
||||
homingData.writeNBT(nbt);
|
||||
lifespanData.writeNBT(nbt);
|
||||
trajectoryData.writeNBT(nbt);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,6 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyHomingData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -40,10 +39,10 @@ public class EntityEnergySlicer extends EntityEnergyProjectile {
|
||||
float sliceWidth, float sliceThickness,
|
||||
EnergyDisplayData display, EnergyCombatData combat,
|
||||
EnergyHomingData homing, EnergyLightningData lightning,
|
||||
EnergyLifespanData lifespan, EnergyTrajectoryData trajectory) {
|
||||
EnergyLifespanData lifespan) {
|
||||
super(world);
|
||||
|
||||
initProjectile(owner, target, x, y, z, sliceWidth, display, combat, lightning, lifespan, trajectory);
|
||||
initProjectile(owner, target, x, y, z, sliceWidth, display, combat, lightning, lifespan);
|
||||
this.homingData = homing;
|
||||
this.sliceWidth = sliceWidth;
|
||||
this.sliceThickness = sliceThickness;
|
||||
|
||||
+1
@@ -55,5 +55,6 @@ public final class AbilityHotbarSelectPacket extends AbstractPacket {
|
||||
data.abilityData.setSelectedIndex(index);
|
||||
}
|
||||
}
|
||||
data.save();
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,7 @@ public final class AbilityTogglePacket extends AbstractPacket {
|
||||
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
if (playerData == null || playerData.abilityData == null) return;
|
||||
if (!playerData.abilityData.hasUnlockedAbility(key)) return;
|
||||
|
||||
int newState = playerData.abilityData.toggleAbility(key);
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.network.AbstractPacket;
|
||||
import kamkeel.npcs.network.PacketChannel;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.PacketUtil;
|
||||
import kamkeel.npcs.network.enums.EnumItemPacketType;
|
||||
import kamkeel.npcs.network.enums.EnumRequestPacket;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -39,6 +41,8 @@ public class AbilitiesGetAllPacket extends AbstractPacket {
|
||||
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
|
||||
if (!(player instanceof EntityPlayerMP))
|
||||
return;
|
||||
if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player))
|
||||
return;
|
||||
|
||||
NoppesUtilServer.sendAbilityTypesInfo((EntityPlayerMP) player);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ public final class AbilitiesNpcSavePacket extends AbstractPacket {
|
||||
return;
|
||||
|
||||
NBTTagCompound compound = ByteBufUtils.readNBT(in);
|
||||
if (compound == null) return;
|
||||
npc.abilities.readFromNBT(compound);
|
||||
}
|
||||
}
|
||||
@@ -434,7 +434,7 @@ public abstract class AbstractDataAbilities {
|
||||
EntityLivingBase entity = getEntity();
|
||||
List<String> toRemove = null;
|
||||
|
||||
for (Map.Entry<String, AbilityToggleEntry> mapEntry : activeToggles.entrySet()) {
|
||||
for (Map.Entry<String, AbilityToggleEntry> mapEntry : new ArrayList<>(activeToggles.entrySet())) {
|
||||
AbilityToggleEntry entry = mapEntry.getValue();
|
||||
entry.incrementTick();
|
||||
|
||||
|
||||
@@ -1109,7 +1109,7 @@ public class DataAbilities extends AbstractDataAbilities {
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
enabled = compound.getBoolean("AbilitiesEnabled");
|
||||
enabled = compound.hasKey("AbilitiesEnabled") ? compound.getBoolean("AbilitiesEnabled") : true;
|
||||
minCooldown = compound.getInteger("AbilityMinCooldown");
|
||||
maxCooldown = compound.getInteger("AbilityMaxCooldown");
|
||||
|
||||
|
||||
@@ -212,7 +212,7 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
|
||||
if (allAllowPlayer && allAllowNpc) return UserType.BOTH;
|
||||
if (allAllowPlayer) return UserType.PLAYER_ONLY;
|
||||
if (allAllowNpc) return UserType.NPC_ONLY;
|
||||
return UserType.NPC_ONLY;
|
||||
return UserType.NONE;
|
||||
}
|
||||
|
||||
// ═══════════════════════════════════════════════════════════════════════════
|
||||
@@ -750,7 +750,9 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
|
||||
} else {
|
||||
entries.add(ChainedAbilityEntry.reference(consumed.getReferenceId(), 0));
|
||||
}
|
||||
consumedSlotIndices.add(slotIndex);
|
||||
if (!consumedSlotIndices.contains(slotIndex)) {
|
||||
consumedSlotIndices.add(slotIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,8 +119,7 @@ public class AbilityHotbarSlotRenderer extends Gui {
|
||||
if (iconNaturalSize <= 0) iconNaturalSize = 16f;
|
||||
float iconScale = targetSize / iconNaturalSize;
|
||||
GL11.glScalef(iconScale, iconScale, 1);
|
||||
GL11.glColor4f(1, 1, 1, slotAlpha);
|
||||
icon.draw(getToggleState());
|
||||
icon.draw(getToggleState(), slotAlpha);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,10 @@ public class AbilityIcon extends Gui {
|
||||
}
|
||||
|
||||
public void draw(int state) {
|
||||
draw(state, 1.0f);
|
||||
}
|
||||
|
||||
public void draw(int state, float alpha) {
|
||||
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
|
||||
|
||||
ImageData imageData = null;
|
||||
@@ -68,7 +72,7 @@ public class AbilityIcon extends Gui {
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
GL11.glColor4f(1, 1, 1, alpha);
|
||||
|
||||
Tessellator t;
|
||||
|
||||
|
||||
+26
-21
@@ -15,16 +15,19 @@ import noppes.npcs.controllers.data.AbilityHotbarData;
|
||||
import noppes.npcs.controllers.data.PlayerData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* SubGui for selecting an ability to assign to a hotbar slot.
|
||||
* Uses ability keys internally to avoid duplicate display name collisions.
|
||||
*/
|
||||
public class SubGuiSelectAbilityForSlot extends SubGuiInterface implements ICustomScrollListener, ITextfieldListener {
|
||||
private HashMap<String, String> displayToKey = new HashMap<>();
|
||||
private LinkedHashMap<String, String> keyToDisplay = new LinkedHashMap<>();
|
||||
private List<String> scrollKeys = new ArrayList<>();
|
||||
private GuiCustomScroll scrollAbilities;
|
||||
private String selected = null;
|
||||
private int selectedIndex = -1;
|
||||
private String search = "";
|
||||
|
||||
public boolean confirmed = false;
|
||||
@@ -36,7 +39,6 @@ public class SubGuiSelectAbilityForSlot extends SubGuiInterface implements ICust
|
||||
this.slotIndex = slotIndex;
|
||||
this.closeOnEsc = true;
|
||||
this.drawDefaultBackground = true;
|
||||
guiLeft -= 10;
|
||||
xSize = 256 + 10;
|
||||
this.setBackground("menubg.png");
|
||||
}
|
||||
@@ -44,7 +46,7 @@ public class SubGuiSelectAbilityForSlot extends SubGuiInterface implements ICust
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
guiTop += 10;
|
||||
guiTop = (this.height - ySize) / 2 + 10;
|
||||
|
||||
if (scrollAbilities == null) {
|
||||
scrollAbilities = new GuiCustomScroll(this, 0, 0);
|
||||
@@ -66,7 +68,7 @@ public class SubGuiSelectAbilityForSlot extends SubGuiInterface implements ICust
|
||||
}
|
||||
|
||||
private void loadAbilities() {
|
||||
displayToKey.clear();
|
||||
keyToDisplay.clear();
|
||||
PlayerData playerData = ClientCacheHandler.playerData;
|
||||
if (playerData == null || playerData.abilityData == null) {
|
||||
return;
|
||||
@@ -85,7 +87,7 @@ public class SubGuiSelectAbilityForSlot extends SubGuiInterface implements ICust
|
||||
AbilityController.Instance.resolveAbility(key) : null;
|
||||
displayName = ability != null ? ability.getDisplayName() : key;
|
||||
}
|
||||
displayToKey.put(displayName, key);
|
||||
keyToDisplay.put(key, displayName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,9 +95,9 @@ public class SubGuiSelectAbilityForSlot extends SubGuiInterface implements ICust
|
||||
public void actionPerformed(GuiButton button) {
|
||||
int id = button.id;
|
||||
|
||||
if (id == 0 && selected != null) {
|
||||
if (id == 0 && selectedIndex >= 0 && selectedIndex < scrollKeys.size()) {
|
||||
confirmed = true;
|
||||
selectedAbilityKey = displayToKey.get(selected);
|
||||
selectedAbilityKey = scrollKeys.get(selectedIndex);
|
||||
this.close();
|
||||
}
|
||||
if (id == 1) {
|
||||
@@ -109,15 +111,16 @@ public class SubGuiSelectAbilityForSlot extends SubGuiInterface implements ICust
|
||||
|
||||
@Override
|
||||
public void customScrollClicked(int i, int i1, int i2, GuiCustomScroll guiCustomScroll) {
|
||||
if (guiCustomScroll == scrollAbilities)
|
||||
selected = scrollAbilities.getSelected();
|
||||
if (guiCustomScroll == scrollAbilities) {
|
||||
selectedIndex = scrollAbilities.selected;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void customScrollDoubleClicked(String selection, GuiCustomScroll guiCustomScroll) {
|
||||
if (guiCustomScroll == scrollAbilities && selection != null) {
|
||||
if (guiCustomScroll == scrollAbilities && selectedIndex >= 0 && selectedIndex < scrollKeys.size()) {
|
||||
confirmed = true;
|
||||
selectedAbilityKey = displayToKey.get(selection);
|
||||
selectedAbilityKey = scrollKeys.get(selectedIndex);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
@@ -135,21 +138,23 @@ public class SubGuiSelectAbilityForSlot extends SubGuiInterface implements ICust
|
||||
return;
|
||||
search = getTextField(55).getText().toLowerCase();
|
||||
scrollAbilities.resetScroll();
|
||||
selectedIndex = -1;
|
||||
scrollAbilities.setList(getSearchList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> getSearchList() {
|
||||
if (search.isEmpty()) {
|
||||
return new ArrayList<>(displayToKey.keySet());
|
||||
}
|
||||
scrollKeys.clear();
|
||||
List<String> displayNames = new ArrayList<>();
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
for (String name : displayToKey.keySet()) {
|
||||
if (name.toLowerCase().contains(search))
|
||||
list.add(name);
|
||||
for (Map.Entry<String, String> entry : keyToDisplay.entrySet()) {
|
||||
String displayName = entry.getValue();
|
||||
if (search.isEmpty() || displayName.toLowerCase().contains(search)) {
|
||||
scrollKeys.add(entry.getKey());
|
||||
displayNames.add(displayName);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return displayNames;
|
||||
}
|
||||
}
|
||||
@@ -741,7 +741,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
// Clean up any executing ability silently (no script events — already fired on old entity)
|
||||
if (currentAbility != null && currentAbility.isExecuting()) {
|
||||
removeTelegraph(currentAbility);
|
||||
currentAbility.cleanup();
|
||||
currentAbility.interrupt();
|
||||
stopAbilityAnimation();
|
||||
releaseRotationControl();
|
||||
@@ -813,7 +812,6 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
|
||||
// Silently clean up any stale executing ability
|
||||
if (currentAbility != null && currentAbility.isExecuting()) {
|
||||
removeTelegraph(currentAbility);
|
||||
currentAbility.cleanup();
|
||||
currentAbility.interrupt();
|
||||
stopAbilityAnimation();
|
||||
releaseRotationControl();
|
||||
|
||||
@@ -7,7 +7,6 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyHomingData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData;
|
||||
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData;
|
||||
import kamkeel.npcs.entity.EntityAbilityOrb;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -117,8 +116,6 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback {
|
||||
EnergyLightningData lightning = new EnergyLightningData();
|
||||
EnergyLifespanData lifespan = new EnergyLifespanData(100, 72000);
|
||||
EnergyHomingData homing = new EnergyHomingData();
|
||||
EnergyTrajectoryData trajectory = new EnergyTrajectoryData();
|
||||
|
||||
homing.speed = 0.5f;
|
||||
homing.homingStrength = 0.35f;
|
||||
homing.homingRange = 20f;
|
||||
@@ -126,7 +123,7 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback {
|
||||
EntityAbilityOrb orb = new EntityAbilityOrb(
|
||||
player.worldObj, player, null,
|
||||
player.posX, player.posY + player.getEyeHeight(), player.posZ,
|
||||
1.0f, colorData, combat, homing, lightning, lifespan, trajectory
|
||||
1.0f, colorData, combat, homing, lightning, lifespan
|
||||
);
|
||||
|
||||
orb.setupCharging(
|
||||
|
||||
Reference in new issue
Block a user