Merge branch 'dev' into syntax-highlighter-unified

This commit is contained in:
bigguy345 committed 2026-03-02 00:26:51 +02:00
commit 29f0282fe4
43 files changed
+767 -199

No files matched your search

@@ -1113,11 +1113,8 @@ public abstract class AbstractDataAbilities {
if (hasExecutingAbility) {
AbilityPhase phase = currentAbility.getPhase();
// Cannot cancel during DAZED (already interrupted)
if (phase == AbilityPhase.DAZED) return;
// Only allow cancel during active phases
if (phase != AbilityPhase.WINDUP && phase != AbilityPhase.ACTIVE
&& phase != AbilityPhase.BURST_DELAY) return;
// Only allow cancel during WINDUP phase
if (phase != AbilityPhase.WINDUP) return;
// Remove telegraph
removeTelegraph(currentAbility);
@@ -649,9 +649,11 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
// Search matches either the display name or the typeId (strip color codes for matching)
String stripped = displayName.replaceAll("\u00A7.", "");
if (search.isEmpty() || stripped.toLowerCase().contains(search) || typeId.toLowerCase().contains(search)) {
// Lime green for concurrent-capable types, gray for other built-in types
if (AbilityController.Instance.isConcurrentCapableType(typeId)) {
displayName = "\u00A7a" + displayName;
// Pink for custom ability, light blue for concurrent-capable types, gray for other built-in types
if (typeId.equals("ability.cnpc.custom")) {
displayName = "\u00A7d" + displayName;
} else if (AbilityController.Instance.isConcurrentCapableType(typeId)) {
displayName = "\u00A7b" + displayName;
} else if (AbilityController.Instance.isBuiltInType(typeId)) {
displayName = "\u00A77" + displayName;
}
@@ -661,6 +663,21 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
}
Collections.sort(list, (a, b) -> String.CASE_INSENSITIVE_ORDER.compare(
a.replaceAll("\u00A7.", ""), b.replaceAll("\u00A7.", "")));
// Pin Custom Ability to top of list
String customEntry = null;
for (String name : list) {
String tid = displayNameToTypeId.get(name);
if (tid != null && tid.equals("ability.cnpc.custom")) {
customEntry = name;
break;
}
}
if (customEntry != null) {
list.remove(customEntry);
list.add(0, customEntry);
}
return list;
}
@@ -189,7 +189,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
}
if (ability.isConcurrentCapable()) {
sw.addLabel(new GuiNpcLabel(baseId + 3,
StatCollector.translateToLocal("ability.concurrentInfo"), 5, infoY, 0x55FF55));
StatCollector.translateToLocal("ability.concurrentInfo"), 5, infoY, 0x55FFFF));
}
}
@@ -268,7 +268,7 @@ public class SubGuiAbilityConfig extends SubGuiInterface implements ITextfieldLi
}
if (conditions.size() < MAX_CONDITIONS) {
sw.addButton(new GuiNpcButton(BTN_ADD_COND, L_LABEL_X, y, 50, 20, "gui.add"));;
sw.addButton(new GuiNpcButton(BTN_ADD_COND, L_LABEL_X, y, 50, 20, "gui.add"));
y += ROW_H;
}
@@ -86,7 +86,7 @@ public class SubGuiAbilityTypeSelect extends SubGuiInterface implements ICustomS
if (typeId.equals("ability.cnpc.custom")) {
displayName = "\u00A7d" + displayName;
} else if (AbilityController.Instance.isConcurrentCapableType(typeId)) {
displayName = "\u00A7a" + displayName;
displayName = "\u00A7b" + displayName;
}
allDisplayNameToTypeId.put(displayName, typeId);
}
@@ -402,7 +402,7 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
// Concurrent toggle (only shown if resolved ability is concurrent-capable, never for first entry)
if (i > 0 && resolvedAbility != null && resolvedAbility.isConcurrentCapable()) {
String cLabel = entry.isConcurrentEnabled() ? "\u00A7aC" : "\u00A77C";
String cLabel = entry.isConcurrentEnabled() ? "\u00A7bC" : "\u00A77C";
GuiNpcButton cBtn = new GuiNpcButton(ENTRY_BASE + i * ENTRY_STRIDE + 5, L_LABEL_X + 288, y, 20, 20, cLabel);
cBtn.setHoverText("ability.hover.concurrent");
sw.addButton(cBtn);
@@ -309,7 +309,7 @@ public class FieldDef {
}
public boolean hasRange() {
return min != Float.NEGATIVE_INFINITY || max != Float.POSITIVE_INFINITY;
return min != 0 || max != Float.POSITIVE_INFINITY;
}
public Class<? extends Enum<?>> getEnumClass() {
@@ -1,9 +1,10 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.entity.data.IHitboxData;
import noppes.npcs.config.ConfigMain;
public class HitboxData {
public class HitboxData implements IHitboxData {
private float widthScale = 1f;
private float heightScale = 1f;
@@ -96,6 +96,21 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
*/
private static final int CANCEL_WINDOW_TICKS = 10;
/**
* Position tracking for teleport detection during ability execution.
* If the player moves more than {@link #TELEPORT_THRESHOLD_SQ} in a single tick,
* the ability is interrupted as if the player changed dimensions.
*/
private transient double lastAbilityTickX, lastAbilityTickY, lastAbilityTickZ;
private transient boolean trackingAbilityPosition = false;
/**
* Squared distance threshold for teleport detection (48 blocks).
* Normal sprint speed is ~5.6 blocks/tick; this threshold is well above
* any legitimate per-tick movement including ability-driven dashes.
*/
private static final double TELEPORT_THRESHOLD_SQ = 48.0 * 48.0;
// ═══════════════════════════════════════════════════════════════════
// CONSTRUCTOR
// ═══════════════════════════════════════════════════════════════════
@@ -257,7 +272,30 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
// Tick active toggles (independent of currentAbility)
tickActiveToggles();
if (chainDelayRemaining > 0 || (currentAbility != null && currentAbility.isExecuting())) {
boolean hasActiveAbility = chainDelayRemaining > 0 || (currentAbility != null && currentAbility.isExecuting());
if (hasActiveAbility) {
// Detect large position jump (teleport) while ability is executing.
// Must run BEFORE tickCurrentAbility / applyPositionLock so the raw
// teleported position is visible before any lock snaps it back.
if (trackingAbilityPosition) {
double dx = player.posX - lastAbilityTickX;
double dy = player.posY - lastAbilityTickY;
double dz = player.posZ - lastAbilityTickZ;
if (dx * dx + dy * dy + dz * dz > TELEPORT_THRESHOLD_SQ) {
// Player was teleported — clear ability state (same as dimension change)
trackingAbilityPosition = false;
resetOnTeleport();
return;
}
}
// Update tracked position for next tick's comparison
lastAbilityTickX = player.posX;
lastAbilityTickY = player.posY;
lastAbilityTickZ = player.posZ;
trackingAbilityPosition = true;
tickCurrentAbility();
// Apply rotation and position locks after ability tick
@@ -267,6 +305,8 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
// Sync lock state to client (only sends when flags change)
syncAbilityStateIfNeeded(player);
} else {
trackingAbilityPosition = false;
// Safety: release orphaned locks if no ability is executing
if (rotationLocked || positionLocked) {
releaseRotationControl();
@@ -610,12 +650,10 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
if (!hasExecutingAbility && !isInChainDelay) return false;
// Don't allow cancel during DAZED
// Only allow cancel during WINDUP phase
if (hasExecutingAbility) {
AbilityPhase phase = currentAbility.getPhase();
if (phase == AbilityPhase.DAZED) return false;
if (phase != AbilityPhase.WINDUP && phase != AbilityPhase.ACTIVE
&& phase != AbilityPhase.BURST_DELAY) return false;
if (phase != AbilityPhase.WINDUP) return false;
}
long worldTime = getWorldTime();
@@ -698,6 +736,15 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
* Keeps active toggles (dimension change shouldn't reset ongoing effects).
*/
public void resetOnDimensionChange() {
trackingAbilityPosition = false;
onEntityReconstructed(true, false);
}
/**
* Reset ability state when a large-distance teleport is detected during execution.
* Same behavior as dimension change — silent cleanup, clear cooldowns, keep toggles.
*/
public void resetOnTeleport() {
onEntityReconstructed(true, false);
}
@@ -719,6 +766,8 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
* The caller must trigger a full ability sync afterwards (e.g. via syncToClient).
*/
public void resetOnLogin() {
trackingAbilityPosition = false;
// Silently clean up any stale executing ability
if (currentAbility != null && currentAbility.isExecuting()) {
removeTelegraph(currentAbility);
@@ -1,8 +1,9 @@
package noppes.npcs.controllers.data;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.api.entity.data.ITintData;
public class TintData {
public class TintData implements ITintData {
private boolean tintEnabled = false;
private boolean hurtTintEnabled = true;
private boolean generalTintEnabled = false;
+16 -2
View File
@@ -84,13 +84,27 @@ public class ItemStaff extends ItemNpcInterface implements IProjectileCallback {
public void onUsingTick(ItemStack stack, EntityPlayer player, int count) {
int tick = getMaxItemUseDuration(stack) - count;
int chargeTime = 20 + material.getHarvestLevel() * 8;
if (player.worldObj.isRemote) {
spawnParticle(stack, player);
// Reset charge tick on client to prevent client-side timeout
// (resetChargeTick is not synced via DataWatcher, so the client's
// chargeTick would keep climbing and falsely trigger CHARGE_TIMEOUT_GRACE)
if (tick > chargeTime && stack.stackTagCompound != null) {
Entity existing = player.worldObj
.getEntityByID(stack.stackTagCompound.getInteger("MagicProjectile"));
if (existing instanceof EntityAbilityOrb) {
EntityAbilityOrb orb = (EntityAbilityOrb) existing;
if (orb.isCharging()) {
orb.resetChargeTick();
}
}
}
return;
}
int chargeTime = 20 + material.getHarvestLevel() * 8;
// Keep a fully-charged orb alive while the player is still holding
if (tick > chargeTime && stack.stackTagCompound != null) {
Entity existing = ((WorldServer) player.worldObj)
@@ -49,5 +49,6 @@ public class ScriptEnergyOrb<T extends EntityAbilityOrb> extends ScriptEnergyPro
entity.motionY = (dy / len) * entity.getSpeed();
entity.motionZ = (dz / len) * entity.getSpeed();
}
entity.startMoving(null);
}
}
@@ -1,6 +1,7 @@
package noppes.npcs.scripted.entity;
import kamkeel.npcs.entity.EntityEnergyProjectile;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import noppes.npcs.NoppesUtilServer;
@@ -11,7 +12,9 @@ import noppes.npcs.api.entity.ICustomNpc;
import noppes.npcs.api.entity.IEnergyProjectile;
import noppes.npcs.api.entity.IEntityLivingBase;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.api.entity.data.IHitboxData;
import noppes.npcs.api.entity.data.IModelData;
import noppes.npcs.api.entity.data.ITintData;
import noppes.npcs.api.handler.IActionManager;
import noppes.npcs.api.handler.IOverlayHandler;
import noppes.npcs.api.handler.data.IAnimationData;
@@ -421,6 +424,62 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return this.npc.advanced.killLines;
}
public boolean getOrderedLines() {
return npc.advanced.orderedLines;
}
public void setOrderedLines(boolean ordered) {
npc.advanced.orderedLines = ordered;
}
public String getIdleSound() {
return npc.advanced.idleSound;
}
public void setIdleSound(String sound) {
npc.advanced.idleSound = sound;
}
public String getAngrySound() {
return npc.advanced.angrySound;
}
public void setAngrySound(String sound) {
npc.advanced.angrySound = sound;
}
public String getHurtSound() {
return npc.advanced.hurtSound;
}
public void setHurtSound(String sound) {
npc.advanced.hurtSound = sound;
}
public String getDeathSound() {
return npc.advanced.deathSound;
}
public void setDeathSound(String sound) {
npc.advanced.deathSound = sound;
}
public String getStepSound() {
return npc.advanced.stepSound;
}
public void setStepSound(String sound) {
npc.advanced.stepSound = sound;
}
public boolean getDisablePitch() {
return npc.advanced.disablePitch;
}
public void setDisablePitch(boolean disablePitch) {
npc.advanced.disablePitch = disablePitch;
}
/**
* Kill the npc, doesnt't despawn it
*/
@@ -848,6 +907,171 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return npc.ais.tacticalRadius;
}
public int getTacticalChance() {
return npc.ais.tacticalChance;
}
public void setTacticalChance(int chance) {
npc.ais.tacticalChance = chance;
}
public boolean getCanSwim() {
return npc.ais.canSwim;
}
public void setCanSwim(boolean canSwim) {
npc.ais.canSwim = canSwim;
}
public boolean getReactsToFire() {
return npc.ais.reactsToFire;
}
public void setReactsToFire(boolean reactsToFire) {
npc.ais.reactsToFire = reactsToFire;
}
public boolean getAvoidsWater() {
return npc.ais.avoidsWater;
}
public void setAvoidsWater(boolean avoidsWater) {
npc.ais.avoidsWater = avoidsWater;
}
public boolean getAvoidsSun() {
return npc.ais.avoidsSun;
}
public void setAvoidsSun(boolean avoidsSun) {
npc.ais.avoidsSun = avoidsSun;
}
public boolean getDirectLOS() {
return npc.ais.directLOS;
}
public void setDirectLOS(boolean directLOS) {
npc.ais.directLOS = directLOS;
}
public int getLeapType() {
return npc.ais.leapType;
}
public void setLeapType(int leapType) {
npc.ais.leapType = leapType;
}
public boolean getCanSprint() {
return npc.ais.canSprint;
}
public void setCanSprint(boolean canSprint) {
npc.ais.canSprint = canSprint;
}
public boolean getStopAndInteract() {
return npc.ais.stopAndInteract;
}
public void setStopAndInteract(boolean stopAndInteract) {
npc.ais.stopAndInteract = stopAndInteract;
}
public int getDoorInteract() {
return npc.ais.doorInteract;
}
public void setDoorInteract(int doorInteract) {
npc.ais.doorInteract = doorInteract;
}
public int getWalkingRange() {
return npc.ais.walkingRange;
}
public void setWalkingRange(int range) {
npc.ais.walkingRange = range;
}
public boolean getNpcInteracting() {
return npc.ais.npcInteracting;
}
public void setNpcInteracting(boolean npcInteracting) {
npc.ais.npcInteracting = npcInteracting;
}
public boolean getMovingPause() {
return npc.ais.movingPause;
}
public void setMovingPause(boolean movingPause) {
npc.ais.movingPause = movingPause;
}
public int getMovingPattern() {
return npc.ais.movingPattern;
}
public void setMovingPattern(int pattern) {
if (pattern < 0) pattern = 0;
if (pattern > 1) pattern = 1;
npc.ais.movingPattern = pattern;
}
public int getCanFireIndirect() {
return npc.ais.canFireIndirect;
}
public void setCanFireIndirect(int canFireIndirect) {
npc.ais.canFireIndirect = canFireIndirect;
}
public int getUseRangeMelee() {
return npc.ais.useRangeMelee;
}
public void setUseRangeMelee(int useRangeMelee) {
npc.ais.useRangeMelee = useRangeMelee;
}
public int getDistanceToMelee() {
return npc.ais.distanceToMelee;
}
public void setDistanceToMelee(int distance) {
npc.ais.distanceToMelee = distance;
}
public float getBodyOffsetX() {
return npc.ais.bodyOffsetX;
}
public void setBodyOffsetX(float offsetX) {
npc.ais.bodyOffsetX = offsetX;
npc.script.clientNeedsUpdate = true;
}
public float getBodyOffsetY() {
return npc.ais.bodyOffsetY;
}
public void setBodyOffsetY(float offsetY) {
npc.ais.bodyOffsetY = offsetY;
npc.script.clientNeedsUpdate = true;
}
public float getBodyOffsetZ() {
return npc.ais.bodyOffsetZ;
}
public void setBodyOffsetZ(float offsetZ) {
npc.ais.bodyOffsetZ = offsetZ;
npc.script.clientNeedsUpdate = true;
}
public void setIgnoreCobweb(boolean ignore) {
npc.stats.ignoreCobweb = ignore;
}
@@ -1152,6 +1376,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return npc instanceof EntityCustomNpc ? ((EntityCustomNpc) npc).modelData : null;
}
public IHitboxData getHitboxData() {
return npc.display.hitboxData;
}
public ITintData getTintData() {
return npc.display.tintData;
}
public void setHeadScale(float x, float y, float z) {
if (npc instanceof EntityCustomNpc) {
((EntityCustomNpc) this.npc).modelData.modelScale.head.scaleX = ValueUtil.clamp(x, 0.5f, 1.5f);
@@ -1250,6 +1482,66 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return npc.stats.resistances.knockback;
}
public boolean getDamageDisabled() {
return npc.stats.resistances.disableDamage;
}
public void setDamageDisabled(boolean disabled) {
npc.stats.resistances.disableDamage = disabled;
}
public boolean getNoFallDamage() {
return npc.stats.noFallDamage;
}
public void setNoFallDamage(boolean noFallDamage) {
npc.stats.noFallDamage = noFallDamage;
}
public boolean getImmuneToFire() {
return npc.stats.immuneToFire;
}
public void setImmuneToFire(boolean immuneToFire) {
npc.stats.immuneToFire = immuneToFire;
npc.setImmuneToFire(immuneToFire);
}
public boolean getPotionImmune() {
return npc.stats.potionImmune;
}
public void setPotionImmune(boolean potionImmune) {
npc.stats.potionImmune = potionImmune;
}
public boolean getBurnInSun() {
return npc.stats.burnInSun;
}
public void setBurnInSun(boolean burnInSun) {
npc.stats.burnInSun = burnInSun;
}
public boolean getAttackInvisible() {
return npc.stats.attackInvisible;
}
public void setAttackInvisible(boolean attackInvisible) {
npc.stats.attackInvisible = attackInvisible;
}
public int getCreatureType() {
return npc.stats.creatureType.ordinal();
}
public void setCreatureType(int type) {
EnumCreatureAttribute[] values = EnumCreatureAttribute.values();
if (type >= 0 && type < values.length) {
npc.stats.creatureType = values[type];
}
}
/**
* @param type Retaliation type. 0:normal, 1:panic, 2:retreat, 3:nothing
*/
@@ -1432,6 +1724,15 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
return npc.display.skinOverlayData.overlayList.get(0).getTexture();
}
public String getGlowTexture() {
return npc.display.glowTexture;
}
public void setGlowTexture(String texture) {
npc.display.glowTexture = texture;
npc.script.clientNeedsUpdate = true;
}
public IOverlayHandler getOverlays() {
return npc.display.skinOverlayData;
}