Merge branch 'dev' into syntax-highlighter-unified

This commit is contained in:
Kam committed 2026-02-22 16:46:18 -05:00
commit c0ce53a814
150 files changed
+3376 -1479

No files matched your search

@@ -2,11 +2,11 @@ package noppes.npcs;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.ChainedAbilityEntry;
import kamkeel.npcs.controllers.data.ability.enums.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.entry.ChainedAbilityEntry;
import kamkeel.npcs.controllers.data.ability.ConcurrentSlot;
import kamkeel.npcs.controllers.data.ability.ToggleEntry;
import kamkeel.npcs.controllers.data.ability.data.entry.AbilityToggleEntry;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
@@ -268,6 +268,15 @@ public abstract class AbstractDataAbilities {
return currentAbility != null && currentAbility.isExecuting();
}
/**
* True when an executing ability grants invulnerability for its current phase.
*/
public boolean isCurrentAbilityInvulnerable() {
return currentAbility != null
&& currentAbility.isExecuting()
&& currentAbility.isInvulnerableForCurrentPhase();
}
/**
* Get the currently executing ability.
*/
@@ -296,7 +305,7 @@ public abstract class AbstractDataAbilities {
/**
* Currently active toggles. Key = ability key, Value = toggle entry with state and tick counter.
*/
protected Map<String, ToggleEntry> activeToggles = new LinkedHashMap<>();
protected Map<String, AbilityToggleEntry> activeToggles = new LinkedHashMap<>();
/**
* Cycle a toggle ability to its next state.
@@ -306,7 +315,7 @@ public abstract class AbstractDataAbilities {
* @return The new state (0 = off, 1+ = active state number)
*/
public int toggleAbility(String key) {
ToggleEntry existing = activeToggles.get(key);
AbilityToggleEntry existing = activeToggles.get(key);
if (existing != null) {
int currentState = existing.getState();
int maxStates = existing.getAbility().getToggleStates();
@@ -326,7 +335,7 @@ public abstract class AbstractDataAbilities {
* @return 0 if not active, 1+ for active state
*/
public int getToggleState(String key) {
ToggleEntry entry = activeToggles.get(key);
AbilityToggleEntry entry = activeToggles.get(key);
return entry != null ? entry.getState() : 0;
}
@@ -340,7 +349,7 @@ public abstract class AbstractDataAbilities {
}
return;
}
ToggleEntry existing = activeToggles.get(key);
AbilityToggleEntry existing = activeToggles.get(key);
if (existing != null) {
int currentState = existing.getState();
if (currentState != state) {
@@ -373,7 +382,7 @@ public abstract class AbstractDataAbilities {
if (fireToggleEvent(ability, 0, state)) return false;
ToggleEntry entry = new ToggleEntry(ability, state);
AbilityToggleEntry entry = new AbilityToggleEntry(ability, state);
activeToggles.put(key, entry);
ability.onToggleOn(getEntity());
ability.onToggleStateChanged(getEntity(), 0, state);
@@ -381,7 +390,7 @@ public abstract class AbstractDataAbilities {
return true;
}
private int cycleToggleState(String key, ToggleEntry entry, int oldState, int newState) {
private int cycleToggleState(String key, AbilityToggleEntry entry, int oldState, int newState) {
Ability ability = entry.getAbility();
if (newState < 1 || newState > ability.getToggleStates()) return oldState;
@@ -394,7 +403,7 @@ public abstract class AbstractDataAbilities {
}
private void deactivateToggle(String key) {
ToggleEntry entry = activeToggles.get(key);
AbilityToggleEntry entry = activeToggles.get(key);
if (entry == null) return;
int oldState = entry.getState();
@@ -418,8 +427,8 @@ public abstract class AbstractDataAbilities {
EntityLivingBase entity = getEntity();
List<String> toRemove = null;
for (Map.Entry<String, ToggleEntry> mapEntry : activeToggles.entrySet()) {
ToggleEntry entry = mapEntry.getValue();
for (Map.Entry<String, AbilityToggleEntry> mapEntry : activeToggles.entrySet()) {
AbilityToggleEntry entry = mapEntry.getValue();
entry.incrementTick();
if (entry.getAbility().hasActiveToggle()) {
@@ -441,7 +450,7 @@ public abstract class AbstractDataAbilities {
if (toRemove != null) {
for (String key : toRemove) {
ToggleEntry entry = activeToggles.remove(key);
AbilityToggleEntry entry = activeToggles.remove(key);
if (entry != null) {
int oldState = entry.getState();
entry.getAbility().onToggleOff(entity);
@@ -483,8 +492,8 @@ public abstract class AbstractDataAbilities {
protected void clearActiveToggles() {
if (activeToggles.isEmpty()) return;
EntityLivingBase entity = getEntity();
for (Map.Entry<String, ToggleEntry> mapEntry : activeToggles.entrySet()) {
ToggleEntry entry = mapEntry.getValue();
for (Map.Entry<String, AbilityToggleEntry> mapEntry : activeToggles.entrySet()) {
AbilityToggleEntry entry = mapEntry.getValue();
entry.getAbility().onToggleOff(entity);
entry.getAbility().onToggleStateChanged(entity, entry.getState(), 0);
}
@@ -502,7 +511,7 @@ public abstract class AbstractDataAbilities {
Ability ability = AbilityController.Instance != null
? AbilityController.Instance.resolveAbility(key) : null;
if (ability != null && ability.isToggleable()) {
activeToggles.put(key, new ToggleEntry(ability, state));
activeToggles.put(key, new AbilityToggleEntry(ability, state));
}
} else {
activeToggles.remove(key);
+6 -6
View File
@@ -122,7 +122,7 @@ import java.util.HashSet;
import java.util.Set;
import java.util.function.Consumer;
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.11-beta6.1")
@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.11-beta7")
public class CustomNpcs {
@SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy")
@@ -292,15 +292,15 @@ public class CustomNpcs {
registerNewEntity(EntityChairMount.class, "CustomNpcChairMount", 64, 10, false);
registerNewEntity(EntityProjectile.class, "throwableitem", 64, 3, true);
registerNewEntity(EntityMagicProjectile.class, "magicprojectile", 64, 3, true);
registerNewEntity(EntityAbilityOrb.class, "abilityorb", 64, 3, true);
registerNewEntity(EntityAbilityDisc.class, "abilitydisc", 64, 3, true);
registerNewEntity(EntityAbilityLaser.class, "abilitylaser", 64, 3, true);
registerNewEntity(EntityAbilityBeam.class, "abilitybeam", 64, 3, true);
registerNewEntity(EntityAbilityOrb.class, "abilityorb", 64, 1, true);
registerNewEntity(EntityAbilityDisc.class, "abilitydisc", 64, 1, true);
registerNewEntity(EntityAbilityLaser.class, "abilitylaser", 64, 1, true);
registerNewEntity(EntityAbilityBeam.class, "abilitybeam", 64, 1, true);
registerNewEntity(EntityAbilitySweeper.class, "abilitysweeper", 64, 3, true);
registerNewEntity(EntityAbilityZone.class, "abilityzone", 64, 3, true);
registerNewEntity(EntityAbilityDome.class, "energydome", 64, 3, true);
registerNewEntity(EntityAbilityPanel.class, "energypanel", 64, 3, true);
registerNewEntity(EntityEnergySlicer.class, "energyslicer", 64, 3, true);
registerNewEntity(EntityEnergySlicer.class, "energyslicer", 64, 1, true);
new RecipeController();
+11 -9
View File
@@ -3,10 +3,10 @@ package noppes.npcs;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityAction;
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.ToggleEntry;
import kamkeel.npcs.controllers.data.ability.enums.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.data.entry.AbilityToggleEntry;
import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.network.packets.data.telegraph.TelegraphRemovePacket;
@@ -14,7 +14,6 @@ import kamkeel.npcs.network.packets.data.telegraph.TelegraphSpawnPacket;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.DamageSource;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.entity.EntityNPCInterface;
@@ -556,12 +555,15 @@ public class DataAbilities extends AbstractDataAbilities {
* @return true if ability was interrupted
*/
public boolean onDamage(DamageSource source, float amount) {
// Track hit for hit count condition
recordHit();
if (currentAbility == null || !currentAbility.isExecuting()) {
return false;
}
if (currentAbility.isInvulnerableForCurrentPhase()) {
return false;
}
// Track hit for hit count condition
recordHit();
net.minecraft.entity.Entity sourceEntity = source.getEntity();
EntityLivingBase attacker = sourceEntity instanceof EntityLivingBase ? (EntityLivingBase) sourceEntity : null;
@@ -1095,7 +1097,7 @@ public class DataAbilities extends AbstractDataAbilities {
// Active toggles (compound format with state)
NBTTagList toggleList = new NBTTagList();
for (Map.Entry<String, ToggleEntry> entry : activeToggles.entrySet()) {
for (Map.Entry<String, AbilityToggleEntry> entry : activeToggles.entrySet()) {
NBTTagCompound toggleNbt = new NBTTagCompound();
toggleNbt.setString("Key", entry.getKey());
toggleNbt.setInteger("State", entry.getValue().getState());
@@ -629,7 +629,12 @@ public class ScriptPlayerEventHandler {
// Handle ability damage interactions (Guard counter, damage reduction)
PlayerData pData = PlayerData.get((EntityPlayer) event.entityLiving);
if (pData != null && pData.abilityData != null && pData.abilityData.isExecutingAbility()) {
event.ammount = pData.abilityData.onDamage(event.source, event.ammount);
if (pData.abilityData.isCurrentAbilityInvulnerable()) {
event.ammount = 0;
cancel = true;
} else {
event.ammount = pData.abilityData.onDamage(event.source, event.ammount);
}
}
PlayerDataScript handler = ScriptController.Instance.getPlayerScripts((EntityPlayer) event.entityLiving);
@@ -16,6 +16,7 @@ public class ClientAbilityState {
public static boolean hasAbilityMovement = false;
public static boolean positionLocked = false;
public static boolean wasFlyingAtLock = false;
public static boolean activePhase = false;
public static float lockedYaw = 0;
public static float lockedPitch = 0;
@@ -28,6 +29,7 @@ public class ClientAbilityState {
hasAbilityMovement = (flags & PlayerAbilityStatePacket.FLAG_HAS_ABILITY_MOVEMENT) != 0;
positionLocked = (flags & PlayerAbilityStatePacket.FLAG_POSITION_LOCKED) != 0;
wasFlyingAtLock = (flags & PlayerAbilityStatePacket.FLAG_WAS_FLYING_AT_LOCK) != 0;
activePhase = (flags & PlayerAbilityStatePacket.FLAG_ACTIVE_PHASE) != 0;
lockedYaw = yaw;
lockedPitch = pitch;
}
@@ -56,6 +58,7 @@ public class ClientAbilityState {
hasAbilityMovement = false;
positionLocked = false;
wasFlyingAtLock = false;
activePhase = false;
lockedYaw = 0;
lockedPitch = 0;
}
@@ -14,9 +14,12 @@ import kamkeel.npcs.client.renderer.RenderAbilitySweeper;
import kamkeel.npcs.client.renderer.RenderAbilityZone;
import kamkeel.npcs.client.renderer.RenderAbilityDome;
import kamkeel.npcs.client.renderer.RenderAbilityPanel;
import kamkeel.npcs.client.renderer.EnergyChargePreviewRenderer;
import kamkeel.npcs.client.renderer.RenderEnergyExplosion;
import kamkeel.npcs.client.renderer.RenderEnergySlicer;
import kamkeel.npcs.client.renderer.TelegraphRenderer;
import kamkeel.npcs.client.renderer.lightning.LightningHandler;
import kamkeel.npcs.controllers.data.energycharge.EnergyChargePreviewManager;
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
import kamkeel.npcs.entity.EntityAbilityBeam;
import kamkeel.npcs.entity.EntityAbilityDisc;
@@ -26,6 +29,7 @@ import kamkeel.npcs.entity.EntityAbilitySweeper;
import kamkeel.npcs.entity.EntityAbilityZone;
import kamkeel.npcs.entity.EntityAbilityDome;
import kamkeel.npcs.entity.EntityAbilityPanel;
import kamkeel.npcs.entity.EntityEnergyExplosion;
import kamkeel.npcs.entity.EntityEnergySlicer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
@@ -283,6 +287,7 @@ public class ClientProxy extends CommonProxy {
RenderingRegistry.registerEntityRenderingHandler(EntityAbilityDome.class, new RenderAbilityDome());
RenderingRegistry.registerEntityRenderingHandler(EntityAbilityPanel.class, new RenderAbilityPanel());
RenderingRegistry.registerEntityRenderingHandler(EntityEnergySlicer.class, new RenderEnergySlicer());
RenderingRegistry.registerEntityRenderingHandler(EntityEnergyExplosion.class, new RenderEnergyExplosion());
RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc());
@@ -358,6 +363,10 @@ public class ClientProxy extends CommonProxy {
TelegraphManager.initClient();
MinecraftForge.EVENT_BUS.register(new TelegraphRenderer());
// Energy charge preview rendering system
EnergyChargePreviewManager.initClient();
MinecraftForge.EVENT_BUS.register(new EnergyChargePreviewRenderer());
// Lightning effect rendering system
MinecraftForge.EVENT_BUS.register(new LightningHandler());
@@ -8,6 +8,7 @@ import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.relauncher.Side;
import kamkeel.npcs.client.renderer.lightning.LightningBolt;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.energycharge.EnergyChargePreviewManager;
import kamkeel.npcs.controllers.data.telegraph.TelegraphManager;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.data.RequestProperSpawnData;
@@ -53,6 +54,7 @@ public class ClientTickHandler {
private long buttonTime = 0L;
private final int[] ignoreKeys = new int[]{157, 29, 54, 42, 184, 56, 220, 219};
private boolean lastSpecialKeyDown = false;
private boolean wasMovementSuppressed = false;
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onClientTick(TickEvent.ClientTickEvent event) {
@@ -62,6 +64,9 @@ public class ClientTickHandler {
ClientCacheHandler.clearCache();
ClientAbilityState.reset();
RequestProperSpawnData.clear();
if (EnergyChargePreviewManager.ClientInstance != null) {
EnergyChargePreviewManager.ClientInstance.clear();
}
}
this.prevWorld = mc.theWorld;
}
@@ -80,9 +85,15 @@ public class ClientTickHandler {
lastSpecialKeyDown = specialKeyDown;
}
boolean suppressMovement = mc.currentScreen == null && ClientAbilityState.shouldSuppressMovementInput();
if (!suppressMovement && wasMovementSuppressed) {
syncMovementKeyStates(mc);
}
wasMovementSuppressed = suppressMovement;
// Suppress player input during ability-controlled phases.
// Only suppress when no GUI screen is open (screens already capture input).
if (mc.currentScreen == null && ClientAbilityState.shouldSuppressMovementInput()) {
if (suppressMovement) {
// Unpress movement keybinds at the source BEFORE updatePlayerMoveState() reads them.
KeyBinding.setKeyBindState(mc.gameSettings.keyBindForward.getKeyCode(), false);
KeyBinding.setKeyBindState(mc.gameSettings.keyBindBack.getKeyCode(), false);
@@ -164,6 +175,11 @@ public class ClientTickHandler {
TelegraphManager.ClientInstance.tick(mc.theWorld);
}
// Tick packet-driven energy charge previews
if (EnergyChargePreviewManager.ClientInstance != null) {
EnergyChargePreviewManager.ClientInstance.tick(mc.theWorld);
}
// Update lightning bolts for ability effects
LightningBolt.updateAll();
@@ -292,6 +308,27 @@ public class ClientTickHandler {
|| keyCode == mc.gameSettings.keyBindSprint.getKeyCode();
}
private void syncMovementKeyStates(Minecraft mc) {
syncKeyBindingState(mc.gameSettings.keyBindForward);
syncKeyBindingState(mc.gameSettings.keyBindBack);
syncKeyBindingState(mc.gameSettings.keyBindLeft);
syncKeyBindingState(mc.gameSettings.keyBindRight);
syncKeyBindingState(mc.gameSettings.keyBindJump);
syncKeyBindingState(mc.gameSettings.keyBindSneak);
syncKeyBindingState(mc.gameSettings.keyBindSprint);
}
private void syncKeyBindingState(KeyBinding keyBinding) {
int keyCode = keyBinding.getKeyCode();
boolean pressed;
if (keyCode < 0) {
pressed = Mouse.isButtonDown(keyCode + 100);
} else {
pressed = Keyboard.isKeyDown(keyCode);
}
KeyBinding.setKeyBindState(keyCode, pressed);
}
private boolean isIgnoredKey(int key) {
int[] var2 = this.ignoreKeys;
int var3 = var2.length;
@@ -4,8 +4,8 @@ import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityAction;
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.ChainedAbilityEntry;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.entry.ChainedAbilityEntry;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.AbilitiesGetAllPacket;
import kamkeel.npcs.network.packets.request.ability.AbilitiesNpcGetPacket;
@@ -84,8 +84,12 @@ public class SubGuiAbilitySaveConfirm extends SubGuiInterface implements ISubGui
@Override
public void subGuiClosed(SubGuiInterface subgui) {
if (subgui instanceof SubGuiDuplicateNameConfirm) {
if (((SubGuiDuplicateNameConfirm) subgui).isConfirmed()) {
SubGuiDuplicateNameConfirm confirm = (SubGuiDuplicateNameConfirm) subgui;
if (confirm.isConfirmed()) {
doSave();
} else if (confirm.isBack()) {
// Keep this save-confirm dialog open.
return;
} else {
close();
}
@@ -4,11 +4,11 @@ import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityAction;
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.ChainedAbilityEntry;
import kamkeel.npcs.controllers.data.ability.AbilityIconData;
import kamkeel.npcs.controllers.data.ability.IChainedAbilityFieldProvider;
import kamkeel.npcs.controllers.data.ability.UserType;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.entry.ChainedAbilityEntry;
import kamkeel.npcs.controllers.data.ability.data.AbilityIconData;
import kamkeel.npcs.controllers.data.ability.gui.IChainedAbilityFieldProvider;
import kamkeel.npcs.controllers.data.ability.enums.UserType;
import kamkeel.npcs.controllers.data.ability.conditions.AbilityCondition;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.CustomAbilitySavePacket;
@@ -563,6 +563,8 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
return true;
case 2: // Up
if (entryIndex > 0) {
// Commit any focused delay field before reordering
GuiNpcTextField.unfocus();
ChainedAbilityEntry entry = entries.remove(entryIndex);
entries.add(entryIndex - 1, entry);
// Can't be concurrent at position 0
@@ -574,12 +576,16 @@ public class SubGuiChainedAbilityConfig extends SubGuiInterface implements IText
return true;
case 3: // Down
if (entryIndex < entries.size() - 1) {
// Commit any focused delay field before reordering
GuiNpcTextField.unfocus();
ChainedAbilityEntry entry = entries.remove(entryIndex);
entries.add(entryIndex + 1, entry);
initGui();
}
return true;
case 4: // Delete
// Commit any focused delay field before removing
GuiNpcTextField.unfocus();
entries.remove(entryIndex);
initGui();
return true;
@@ -10,7 +10,13 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
*/
public class SubGuiDuplicateNameConfirm extends SubGuiInterface {
private boolean confirmed = false;
public enum Result {
CONTINUE,
BACK,
CANCEL
}
private Result result = Result.CANCEL;
public SubGuiDuplicateNameConfirm() {
setBackground("menubg.png");
@@ -26,22 +32,38 @@ public class SubGuiDuplicateNameConfirm extends SubGuiInterface {
addLabel(new GuiNpcLabel(0, "ability.duplicate.name", guiLeft + 10, y));
y += 30;
addButton(new GuiNpcButton(0, guiLeft + 20, y, 80, 20, "gui.continue"));
addButton(new GuiNpcButton(1, guiLeft + 120, y, 80, 20, "gui.cancel"));
addButton(new GuiNpcButton(0, guiLeft + 10, y, 65, 20, "gui.continue"));
addButton(new GuiNpcButton(1, guiLeft + 78, y, 65, 20, "gui.back"));
addButton(new GuiNpcButton(2, guiLeft + 146, y, 65, 20, "gui.cancel"));
}
@Override
public void buttonEvent(GuiButton guibutton) {
if (guibutton.id == 0) {
confirmed = true;
result = Result.CONTINUE;
close();
} else if (guibutton.id == 1) {
confirmed = false;
result = Result.BACK;
close();
} else if (guibutton.id == 2) {
result = Result.CANCEL;
close();
}
}
public Result getResult() {
return result;
}
public boolean isConfirmed() {
return confirmed;
return result == Result.CONTINUE;
}
public boolean isBack() {
return result == Result.BACK;
}
public boolean isCancelled() {
return result == Result.CANCEL;
}
}
@@ -245,6 +245,9 @@ public class GuiFieldBuilder {
case STRING: {
String sVal = def.getValue() != null ? def.getValue().toString() : "";
GuiNpcTextField tf = new GuiNpcTextField(widgetId, parent, fontRenderer, fieldX, y, fieldW, 20, sVal);
if ("gui.name".equals(def.getLabel())) {
tf.setFileNameSafe();
}
if (!def.isEnabled()) tf.setEnabled(false);
if (hover != null) tf.setHoverText(hover);
sw.addTextField(tf);
@@ -3,7 +3,7 @@ package noppes.npcs.client.gui.global;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityVariant;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.network.PacketClient;
import kamkeel.npcs.network.packets.request.ability.BuiltInAbilityGetPacket;
import kamkeel.npcs.network.packets.request.ability.ChainedAbilitiesGetPacket;
@@ -24,8 +24,8 @@ import noppes.npcs.client.gui.advanced.SubGuiAbilityTypeSelect;
import noppes.npcs.client.gui.advanced.SubGuiAbilityVariantSelect;
import noppes.npcs.client.gui.advanced.SubGuiChainedAbilityConfig;
import noppes.npcs.client.gui.advanced.SubGuiDuplicateNameConfirm;
import noppes.npcs.client.gui.util.AbilityPreviewExecutor;
import noppes.npcs.client.gui.util.GuiAbilityInterface;
import kamkeel.npcs.controllers.data.ability.preview.AbilityPreviewExecutor;
import kamkeel.npcs.controllers.data.ability.gui.GuiAbilityInterface;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -104,7 +104,6 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
// ==================== PENDING SAVE ====================
private Ability pendingSaveAbility = null;
private boolean pendingNewCreation = false;
// ==================== PENDING VARIANT ====================
private String pendingTypeId = null;
@@ -511,13 +510,6 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
Ability newAbility = AbilityController.Instance.create(pendingTypeId);
if (newAbility != null) {
gui.getVariants().get(idx).apply(newAbility);
if (hasDuplicateName(newAbility)) {
pendingSaveAbility = newAbility;
pendingNewCreation = true;
pendingTypeId = null;
setSubGui(new SubGuiDuplicateNameConfirm());
return true;
}
pendingTypeId = null;
openConfig(newAbility);
return true;
@@ -544,12 +536,6 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
if (variants.size() == 1) {
variants.get(0).apply(newAbility);
}
if (hasDuplicateName(newAbility)) {
pendingSaveAbility = newAbility;
pendingNewCreation = true;
setSubGui(new SubGuiDuplicateNameConfirm());
return true;
}
openConfig(newAbility);
return true;
}
@@ -561,27 +547,22 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
* @return true if a SubGui was opened (caller should return early, skipping initGui)
*/
private boolean handleDuplicateNameClosed(SubGuiDuplicateNameConfirm gui) {
if (gui.isConfirmed() && pendingSaveAbility != null) {
if (pendingNewCreation) {
openConfig(pendingSaveAbility);
pendingSaveAbility = null;
pendingNewCreation = false;
return true;
} else {
PacketClient.sendClient(new CustomAbilitySavePacket(pendingSaveAbility.writeNBT()));
pendingSaveAbility = null;
}
} else if (pendingSaveAbility != null) {
if (pendingNewCreation) {
pendingSaveAbility = null;
pendingNewCreation = false;
} else {
Ability ability = pendingSaveAbility;
pendingSaveAbility = null;
setSubGui(ability.createConfigGui(this));
return true;
}
if (pendingSaveAbility == null) return false;
if (gui.isConfirmed()) {
PacketClient.sendClient(new CustomAbilitySavePacket(pendingSaveAbility.writeNBT()));
pendingSaveAbility = null;
return false;
}
if (gui.isBack()) {
Ability ability = pendingSaveAbility;
pendingSaveAbility = null;
setSubGui(ability.createConfigGui(this));
return true;
}
pendingSaveAbility = null;
return false;
}
@@ -590,7 +571,6 @@ public class GuiNpcManageAbilities extends GuiAbilityInterface
*/
private boolean handlePendingSave() {
if (hasDuplicateName(pendingSaveAbility)) {
pendingNewCreation = false;
setSubGui(new SubGuiDuplicateNameConfirm());
return true;
}
@@ -4,11 +4,12 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.data.IAbilityAction;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.packets.player.ability.AbilityHotbarSelectPacket;
import net.minecraft.client.Minecraft;
import noppes.npcs.client.ClientProxy;
import noppes.npcs.client.ClientAbilityState;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.ScaledResolution;
@@ -189,6 +190,7 @@ public class AbilityHotbarComponent extends HudComponent {
int centerX = overlayWidth / 2;
int centerY = overlayHeight / 2;
boolean activePhase = ClientAbilityState.activePhase;
// Compute text visibility: 0=Shown, 1=Hidden, 2=Held
boolean showText;
@@ -246,16 +248,16 @@ public class AbilityHotbarComponent extends HudComponent {
if (rawSlotIndex == -1) {
// Deselect slot — draw empty marker
drawDeselectSlot(cx, cy, scaledSize, isCenter, slotAlpha);
drawDeselectSlot(cx, cy, scaledSize, isCenter, slotAlpha, activePhase);
} else {
slots[rawSlotIndex].drawCarousel(mc, sr, slotCooldown, cx, cy, scaledSize, isCenter, slotAlpha, showText);
slots[rawSlotIndex].drawCarousel(mc, sr, slotCooldown, cx, cy, scaledSize, isCenter, slotAlpha, showText, activePhase);
}
}
GL11.glPopMatrix();
}
private void drawDeselectSlot(int cx, int cy, int size, boolean isCenter, float alpha) {
private void drawDeselectSlot(int cx, int cy, int size, boolean isCenter, float alpha, boolean activePhase) {
float radius = size / 2f;
float baseAlpha = isCenter ? 0.9f : 0.6f;
float a = baseAlpha * alpha;
@@ -268,7 +270,13 @@ public class AbilityHotbarComponent extends HudComponent {
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
if (isCenter) {
if (activePhase) {
if (isCenter) {
GL11.glColor4f(0.65f, 0.14f, 0.14f, a);
} else {
GL11.glColor4f(0.38f, 0.10f, 0.10f, a);
}
} else if (isCenter) {
GL11.glColor4f(0.5f, 0.2f, 0.2f, a);
} else {
GL11.glColor4f(0.3f, 0.3f, 0.3f, a);
@@ -292,7 +300,13 @@ public class AbilityHotbarComponent extends HudComponent {
}
// Draw X mark
if (isCenter) {
if (activePhase) {
if (isCenter) {
GL11.glColor4f(1.0f, 0.45f, 0.35f, alpha);
} else {
GL11.glColor4f(0.75f, 0.30f, 0.30f, alpha * 0.8f);
}
} else if (isCenter) {
GL11.glColor4f(0.8f, 0.4f, 0.4f, alpha);
} else {
GL11.glColor4f(0.5f, 0.5f, 0.5f, alpha * 0.8f);
@@ -3,8 +3,8 @@ package noppes.npcs.client.gui.hud.ability;
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.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.IAbilityAction;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
@@ -48,7 +48,7 @@ public class AbilityHotbarSlotRenderer extends Gui {
public void drawCarousel(Minecraft mc, ScaledResolution sr, float cooldownProgress,
int cx, int cy, int size, boolean isCenter, float slotAlpha,
boolean showText) {
boolean showText, boolean activePhase) {
float nameAlpha = this.nameAlpha;
boolean isHorizontal = ConfigClient.AbilityHotbarHorizontal;
if (size <= 0 || slotAlpha <= 0) return;
@@ -61,21 +61,54 @@ public class AbilityHotbarSlotRenderer extends Gui {
boolean altTexture = ConfigClient.AbilityHotbarAltTexture;
if (altTexture) {
drawRoundedRect(-radius, -radius, radius, radius, 0.6f, 0.6f, 0.6f, 0.75f * alpha, false);
float fillR;
float fillG;
float fillB;
float outlineR;
float outlineG;
float outlineB;
if (activePhase) {
if (isCenter) {
drawRoundedRect(-radius, -radius, radius, radius, 0.8f, 0.8f, 0.2f, alpha, true);
fillR = 0.95f;
fillG = 0.26f;
fillB = 0.22f;
outlineR = 1.0f;
outlineG = 0.52f;
outlineB = 0.28f;
} else {
drawRoundedRect(-radius, -radius, radius, radius, 0.4f, 0.4f, 0.4f, alpha * 0.8f, true);
fillR = 0.36f;
fillG = 0.14f;
fillB = 0.14f;
outlineR = 0.65f;
outlineG = 0.22f;
outlineB = 0.20f;
}
} else if (isCenter) {
fillR = 0.8f;
fillG = 0.8f;
fillB = 0.2f;
outlineR = 0.8f;
outlineG = 0.8f;
outlineB = 0.2f;
} else {
if (isCenter) {
drawCircle(radius, 0.8f, 0.8f, 0.2f, 0.66f * alpha, false);
drawCircle(radius, 0.8f, 0.8f, 0.2f, alpha, true);
} else {
drawCircle(radius, 1f, 1f, 1f, 0.66f * alpha, false);
drawCircle(radius, 0.4f, 0.4f, 0.4f, alpha * 0.8f, true);
}
fillR = 0.4f;
fillG = 0.4f;
fillB = 0.4f;
outlineR = 1f;
outlineG = 1f;
outlineB = 1f;
}
if (altTexture) {
float baseR = activePhase ? 0.30f : 0.6f;
float baseG = activePhase ? 0.12f : 0.6f;
float baseB = activePhase ? 0.12f : 0.6f;
drawRoundedRect(-radius, -radius, radius, radius, baseR, baseG, baseB, 0.75f * alpha, false);
drawRoundedRect(-radius, -radius, radius, radius, fillR, fillG, fillB, alpha * 0.8f, true);
} else {
drawCircle(radius, outlineR, outlineG, outlineB, 0.66f * alpha, false);
drawCircle(radius, fillR, fillG, fillB, alpha * 0.8f, true);
}
// Ability icon
@@ -3,9 +3,9 @@ package noppes.npcs.client.gui.hud.ability;
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.AbilityIconData;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.data.AbilityIconData;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.IAbilityAction;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.Tessellator;
@@ -2,8 +2,8 @@ package noppes.npcs.client.gui.player.inventory;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.IAbilityAction;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.packets.player.ability.AbilityHotbarSavePacket;
import kamkeel.npcs.network.packets.player.ability.AbilityHotbarSelectPacket;
@@ -2,7 +2,7 @@ package noppes.npcs.client.gui.player.inventory;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.client.ClientCacheHandler;
import noppes.npcs.client.gui.util.GuiCustomScroll;
@@ -1,636 +0,0 @@
package noppes.npcs.client.gui.util;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.ChainedAbilityEntry;
import kamkeel.npcs.controllers.data.ability.PreviewEntityHandler;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.AnimationData;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Client-side executor for previewing abilities in the GUI.
* <p>
* Uses unified execution: calls the REAL ability methods (onWindUpTick, onExecute, onActiveTick)
* with previewMode=true. Abilities skip damage/effects/sounds when isPreview() returns true.
* <p>
* Lifecycle:
* 1. WINDUP phase - real onWindUpTick() called, telegraph shown, entities may spawn
* 2. ACTIVE phase - real onExecute() then onActiveTick() called, physics simulated
* 3. EXTENDED phase - 100 extra ticks to observe results (entities continue updating)
* 4. IDLE - preview complete
*/
@SideOnly(Side.CLIENT)
public class AbilityPreviewExecutor implements PreviewEntityHandler {
// ==================== PREVIEW STATE ====================
private Ability previewAbility;
private EntityNPCInterface previewNpc;
/**
* Executor's own phase tracking (separate from ability.getPhase())
*/
private enum ExecutorPhase {IDLE, WINDUP, ACTIVE, EXTENDED, CHAIN_DELAY}
private ExecutorPhase executorPhase = ExecutorPhase.IDLE;
private int currentTick = 0;
private boolean playing = false;
private boolean paused = false;
// ==================== TIMING ====================
private static final int EXTENDED_DURATION = 100;
private int maxPreviewDuration = 200;
// ==================== FAKE TARGET ====================
private EntityNPCInterface fakeTarget;
private static final double TARGET_DISTANCE = 5.0;
// ==================== NPC START POSITION ====================
private double npcStartX, npcStartY, npcStartZ;
// ==================== PREVIEW CONTENT ====================
private TelegraphInstance previewTelegraph;
private List<Entity> previewEntities = new ArrayList<>();
// ==================== CHAIN PREVIEW ====================
private ChainedAbility previewChain;
private List<Ability> chainAbilities;
private List<Integer> chainDelays;
private int chainIndex = -1;
private int chainDelayRemaining = 0;
private boolean chainWindUpAll = true;
// ==================== CALLBACKS ====================
private GuiAbilityInterface parentGui;
public AbilityPreviewExecutor() {
}
public void setParentGui(GuiAbilityInterface gui) {
this.parentGui = gui;
}
/**
* Start previewing a single ability using unified execution.
* Sets previewMode=true on the ability, then calls its real methods.
*/
public void startPreview(Ability ability, EntityNPCInterface npc) {
stop();
this.previewNpc = npc;
this.playing = true;
this.paused = false;
// Save NPC start position for restoring later
this.npcStartX = npc.posX;
this.npcStartY = npc.posY;
this.npcStartZ = npc.posZ;
// Create invisible fake target NPC for targeting
createFakeTarget(npc);
// Start tracking NPC movement
if (parentGui != null) {
parentGui.startTrackingMovement();
}
beginAbilityPreview(ability);
}
/**
* Start previewing a chained ability — plays all entries in sequence with delays.
* Each entry is resolved and deep-copied to avoid modifying originals.
*/
public void startChainPreview(ChainedAbility chain, EntityNPCInterface npc) {
stop();
this.previewNpc = npc;
this.playing = true;
this.paused = false;
this.previewChain = chain;
this.chainWindUpAll = chain.isWindUpAll();
// Save NPC start position for restoring later
this.npcStartX = npc.posX;
this.npcStartY = npc.posY;
this.npcStartZ = npc.posZ;
// Resolve all entries to deep-copied abilities
chainAbilities = new ArrayList<>();
chainDelays = new ArrayList<>();
for (ChainedAbilityEntry entry : chain.getEntries()) {
Ability resolved = entry.resolve();
if (resolved != null && AbilityController.Instance != null) {
Ability copy = AbilityController.Instance.fromNBT(resolved.writeNBT());
if (copy != null) {
chainAbilities.add(copy);
chainDelays.add(entry.getDelayTicks());
}
}
}
if (chainAbilities.isEmpty()) {
playing = false;
return;
}
// Create invisible fake target NPC for targeting
createFakeTarget(npc);
// Start tracking NPC movement
if (parentGui != null) {
parentGui.startTrackingMovement();
}
chainIndex = 0;
beginAbilityPreview(chainAbilities.get(0));
}
/**
* Begin previewing a single ability (shared by single and chain preview).
* Cleans up the previous ability if any (for chain advancement).
*/
private void beginAbilityPreview(Ability ability) {
// Clean up previous ability if any (for chain advancement)
if (previewAbility != null) {
previewAbility.cleanup();
previewAbility.setPreviewMode(false);
previewAbility.setPreviewEntityHandler(null);
previewAbility.reset();
}
this.previewAbility = ability;
this.currentTick = 0;
this.maxPreviewDuration = ability.getMaxPreviewDuration();
// Enable preview mode on the ability
ability.setPreviewMode(true);
ability.setPreviewEntityHandler(this);
// Use the ability's real start() method with the fake target
ability.start(fakeTarget);
// Skip windup for non-first chain entries when windUpAll is false
boolean skipWindup = previewChain != null && !chainWindUpAll && chainIndex > 0;
if (ability.getWindUpTicks() <= 0 || skipWindup) {
// No windup — go straight to active
this.executorPhase = ExecutorPhase.ACTIVE;
transitionToActive();
} else {
// Normal windup flow
this.executorPhase = ExecutorPhase.WINDUP;
// Create telegraph for preview
previewTelegraph = ability.createTelegraph(previewNpc, fakeTarget);
// Start windup animation
Animation windUpAnim = ability.getWindUpAnimation();
if (windUpAnim != null) {
AnimationData data = previewNpc.display.animationData;
data.setEnabled(true);
data.setAnimation(windUpAnim);
data.animation.paused = false;
}
}
}
/**
* Create an invisible fake target NPC placed in front of the preview NPC.
*/
private void createFakeTarget(EntityNPCInterface npc) {
if (npc.worldObj == null) return;
try {
fakeTarget = new EntityCustomNpc(npc.worldObj);
float facingYaw = GuiAbilityInterface.NPC_FACING_YAW;
double yawRad = Math.toRadians(facingYaw);
double targetX = npc.posX - Math.sin(yawRad) * TARGET_DISTANCE;
double targetY = npc.posY;
double targetZ = npc.posZ + Math.cos(yawRad) * TARGET_DISTANCE;
fakeTarget.setPosition(targetX, targetY, targetZ);
fakeTarget.prevPosX = targetX;
fakeTarget.prevPosY = targetY;
fakeTarget.prevPosZ = targetZ;
} catch (Exception e) {
fakeTarget = null;
}
}
public EntityLivingBase getFakeTarget() {
return fakeTarget;
}
public void play() {
if (previewAbility == null || executorPhase == ExecutorPhase.IDLE) {
return;
}
playing = true;
paused = false;
if (previewNpc != null) {
AnimationData data = previewNpc.display.animationData;
if (data.animation != null) {
data.animation.paused = false;
}
}
}
public void pause() {
paused = true;
// Immediately sync prevPos to pos for NPC and all entities to prevent interpolation jitter
syncPrevPositions();
if (previewNpc != null) {
AnimationData data = previewNpc.display.animationData;
if (data.animation != null) {
data.animation.paused = true;
}
}
}
/**
* Sync prevPos to pos for the NPC and all preview entities.
* Prevents rendering interpolation jitter when standing still or paused.
*/
private void syncPrevPositions() {
if (previewNpc != null) {
previewNpc.prevPosX = previewNpc.posX;
previewNpc.prevPosY = previewNpc.posY;
previewNpc.prevPosZ = previewNpc.posZ;
}
for (Entity entity : previewEntities) {
if (entity != null && !entity.isDead) {
entity.prevPosX = entity.posX;
entity.prevPosY = entity.posY;
entity.prevPosZ = entity.posZ;
}
}
}
public void stop() {
// Clean up the ability
if (previewAbility != null) {
previewAbility.cleanup();
previewAbility.setPreviewMode(false);
previewAbility.setPreviewEntityHandler(null);
previewAbility.reset();
}
playing = false;
paused = false;
executorPhase = ExecutorPhase.IDLE;
currentTick = 0;
// Clear chain state
previewChain = null;
chainAbilities = null;
chainDelays = null;
chainIndex = -1;
chainDelayRemaining = 0;
previewTelegraph = null;
if (parentGui != null) {
for (Entity entity : previewEntities) {
parentGui.removePreviewEntity(entity);
}
parentGui.stopTrackingMovement();
parentGui.setPreviewTelegraph(null);
}
previewEntities.clear();
// Reset NPC position to start position (undo movement from Slam/Charge/Dash)
if (previewNpc != null && npcStartX != 0 && npcStartY != 0 && npcStartZ != 0) {
previewNpc.posX = npcStartX;
previewNpc.posY = npcStartY;
previewNpc.posZ = npcStartZ;
previewNpc.prevPosX = npcStartX;
previewNpc.prevPosY = npcStartY;
previewNpc.prevPosZ = npcStartZ;
previewNpc.motionX = 0;
previewNpc.motionY = 0;
previewNpc.motionZ = 0;
}
fakeTarget = null;
if (previewNpc != null) {
AnimationData data = previewNpc.display.animationData;
data.setAnimation(new Animation());
data.animation.paused = false;
}
}
/**
* Tick the preview forward. Calls real ability methods.
*/
public void tick() {
if (!playing || previewAbility == null || previewNpc == null) {
return;
}
if (paused) {
// Sync prevPos to pos for NPC and all entities to prevent interpolation jitter while paused
syncPrevPositions();
return;
}
// Sync NPC's prevPos to current pos BEFORE any updates to prevent jitter when standing still
previewNpc.prevPosX = previewNpc.posX;
previewNpc.prevPosY = previewNpc.posY;
previewNpc.prevPosZ = previewNpc.posZ;
currentTick++;
if (previewTelegraph != null) {
previewTelegraph.tick(null);
}
tickEntities();
switch (executorPhase) {
case WINDUP:
tickWindup();
break;
case ACTIVE:
tickActive();
break;
case EXTENDED:
tickExtended();
break;
case CHAIN_DELAY:
tickChainDelay();
break;
default:
break;
}
}
private void tickWindup() {
// Call the REAL windup tick method
previewAbility.onWindUpTick(previewNpc, fakeTarget, currentTick);
if (currentTick >= previewAbility.getWindUpTicks()) {
transitionToActive();
}
}
private void tickActive() {
// Call the REAL active tick method
previewAbility.onActiveTick(previewNpc, fakeTarget, currentTick);
// Simulate physics for movement abilities
simulatePhysics();
// Check if the ability signaled completion (phase went to IDLE)
if (previewAbility.getPhase() == AbilityPhase.IDLE) {
if (hasNextChainEntry()) {
transitionToChainDelay();
} else {
transitionToExtended();
}
return;
}
// Safety timeout
if (currentTick >= maxPreviewDuration) {
if (hasNextChainEntry()) {
transitionToChainDelay();
} else {
transitionToExtended();
}
}
}
private void tickExtended() {
// Continue ticking entities so they can finish their animations
if (currentTick >= EXTENDED_DURATION) {
playing = false;
}
}
// ==================== CHAIN ADVANCEMENT ====================
private boolean hasNextChainEntry() {
return previewChain != null && chainAbilities != null && chainIndex < chainAbilities.size() - 1;
}
private void transitionToChainDelay() {
executorPhase = ExecutorPhase.CHAIN_DELAY;
currentTick = 0;
// Use the NEXT entry's delay
int nextIndex = chainIndex + 1;
chainDelayRemaining = (nextIndex < chainDelays.size()) ? chainDelays.get(nextIndex) : 0;
// Clear current animation
if (previewNpc != null) {
AnimationData data = previewNpc.display.animationData;
data.setAnimation(new Animation());
}
}
private void tickChainDelay() {
if (chainDelayRemaining > 0) {
chainDelayRemaining--;
return;
}
advanceChainEntry();
}
private void advanceChainEntry() {
chainIndex++;
if (chainIndex >= chainAbilities.size()) {
transitionToExtended();
return;
}
beginAbilityPreview(chainAbilities.get(chainIndex));
}
private void transitionToActive() {
executorPhase = ExecutorPhase.ACTIVE;
currentTick = 0;
previewTelegraph = null;
// Call the REAL onExecute method (fires entities, initiates movement, etc.)
previewAbility.onExecute(previewNpc, fakeTarget);
// Start active animation
Animation activeAnim = previewAbility.getActiveAnimation();
if (activeAnim != null && previewNpc != null) {
AnimationData data = previewNpc.display.animationData;
data.setAnimation(activeAnim);
data.animation.paused = false;
}
}
private void transitionToExtended() {
executorPhase = ExecutorPhase.EXTENDED;
currentTick = 0;
if (previewNpc != null) {
AnimationData data = previewNpc.display.animationData;
data.setAnimation(new Animation());
}
}
/**
* Simulate basic physics for movement abilities (Slam, Charge, Dash).
* Applies gravity, drag, and ground clamping to NPC position.
*/
private void simulatePhysics() {
if (!previewAbility.hasAbilityMovement()) return;
if (previewNpc == null) return;
// Save previous position for interpolation
previewNpc.prevPosX = previewNpc.posX;
previewNpc.prevPosY = previewNpc.posY;
previewNpc.prevPosZ = previewNpc.posZ;
// Apply velocity
previewNpc.posX += previewNpc.motionX;
previewNpc.posY += previewNpc.motionY;
previewNpc.posZ += previewNpc.motionZ;
// Apply gravity
previewNpc.motionY -= 0.08;
previewNpc.motionY *= 0.98;
// Apply horizontal drag
previewNpc.motionX *= 0.91;
previewNpc.motionZ *= 0.91;
// Ground clamp: if below start position and falling, stop
if (previewNpc.posY < npcStartY && previewNpc.motionY < 0) {
previewNpc.posY = npcStartY;
previewNpc.motionY = 0;
previewNpc.onGround = true;
}
previewNpc.fallDistance = 0;
}
private void tickEntities() {
Iterator<Entity> iter = previewEntities.iterator();
while (iter.hasNext()) {
Entity entity = iter.next();
if (entity == null || entity.isDead) {
if (parentGui != null) {
parentGui.removePreviewEntity(entity);
}
iter.remove();
continue;
}
entity.onUpdate();
}
}
// ==================== PreviewEntityHandler ====================
@Override
public void onEntitySpawned(Entity entity) {
if (entity == null) return;
previewEntities.add(entity);
if (parentGui != null) {
parentGui.addPreviewEntity(entity);
}
}
@Override
public void onEntityRemoved(Entity entity) {
if (entity == null) return;
previewEntities.remove(entity);
if (parentGui != null) {
parentGui.removePreviewEntity(entity);
}
}
// ==================== GETTERS ====================
public boolean isPlaying() {
return playing;
}
public boolean isPaused() {
return paused;
}
public boolean isActive() {
return playing || paused;
}
public boolean isChainPreview() {
return previewChain != null;
}
public AbilityPhase getPhase() {
switch (executorPhase) {
case WINDUP:
return AbilityPhase.WINDUP;
case ACTIVE:
return AbilityPhase.ACTIVE;
default:
return AbilityPhase.IDLE;
}
}
public int getCurrentTick() {
return currentTick;
}
public TelegraphInstance getTelegraph() {
return previewTelegraph;
}
public List<Entity> getPreviewEntities() {
return previewEntities;
}
public Ability getPreviewAbility() {
return previewAbility;
}
public EntityNPCInterface getPreviewNpc() {
return previewNpc;
}
public String getStatusString() {
if (!playing && !paused) {
return "Stopped";
}
String chainPrefix = "";
if (previewChain != null && chainAbilities != null) {
chainPrefix = "Chain " + (chainIndex + 1) + "/" + chainAbilities.size() + " - ";
}
if (paused) {
return chainPrefix + "Paused";
} else if (executorPhase == ExecutorPhase.WINDUP) {
return chainPrefix + "Windup: " + currentTick + "/" + (previewAbility != null ? previewAbility.getWindUpTicks() : 0);
} else if (executorPhase == ExecutorPhase.ACTIVE) {
return chainPrefix + "Active: " + currentTick + "/" + maxPreviewDuration;
} else if (executorPhase == ExecutorPhase.EXTENDED) {
return chainPrefix + "Extended: " + currentTick + "/" + EXTENDED_DURATION;
} else if (executorPhase == ExecutorPhase.CHAIN_DELAY) {
return chainPrefix + "Delay: " + chainDelayRemaining;
}
return "";
}
}
@@ -1,409 +0,0 @@
package noppes.npcs.client.gui.util;
import kamkeel.npcs.client.renderer.TelegraphRenderer;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import noppes.npcs.client.ClientEventHandler;
import noppes.npcs.entity.EntityNPCInterface;
import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import java.util.ArrayList;
import java.util.List;
/**
* Base GUI class for ability preview with fixed camera.
* <p>
* Key concepts:
* - NPC positioned on left side of preview area
* - NPC faces a fixed direction (NPC_FACING_YAW)
* - Viewing direction can be rotated (rotates entire 3D space)
* - Fixed zoom level
* - Preview entities rendered in same coordinate space as NPC
* - NPC position changes (e.g. slam jump) tracked and rendered
*/
public class GuiAbilityInterface extends GuiNPCInterface2 {
// ==================== FIXED CAMERA SETTINGS ====================
/**
* Fixed camera zoom level (higher = more zoomed in)
*/
protected static float CAMERA_ZOOM = 45.0f;
/**
* NPC facing direction - affects anchor points and visual facing
*/
protected static float NPC_FACING_YAW = 160.0f;
/**
* Camera pitch (slight downward angle)
*/
protected static float CAMERA_PITCH = 10.0f;
// ==================== VIEWING ROTATION ====================
/**
* Viewing direction rotation (rotates entire 3D space)
*/
protected static float viewRotation = 0.0f;
private GuiNpcButton btnLeft, btnRight;
// ==================== NPC STATE ====================
public EntityNPCInterface npc;
/**
* NPC starting position (saved when preview starts, used to track movement)
*/
protected double npcStartX, npcStartY, npcStartZ;
/**
* Whether we're tracking NPC movement
*/
protected boolean trackingNpcMovement = false;
/**
* Entities to render in preview space
*/
protected List<Entity> previewEntities = new ArrayList<>();
/**
* Current telegraph to render in preview
*/
protected TelegraphInstance previewTelegraph;
// ==================== LAYOUT ====================
/**
* Preview area bounds
*/
protected int previewX, previewY, previewWidth, previewHeight;
/**
* NPC render position on screen
*/
protected int npcScreenX, npcScreenY;
public int xOffset = 0;
public int yOffset = 0;
public GuiAbilityInterface(EntityNPCInterface npc) {
this(npc, true);
}
/**
* @param npc The NPC for preview rendering
* @param hasMenuNpc If false, the top menu tabs (Display, Stats, etc.) are hidden.
* Use false when opened from the global menu without a real NPC.
*/
public GuiAbilityInterface(EntityNPCInterface npc, boolean hasMenuNpc) {
super(hasMenuNpc ? npc : null);
this.npc = npc;
this.drawDefaultBackground = false;
CAMERA_ZOOM = 30f;
NPC_FACING_YAW = 310f;
CAMERA_PITCH = 5f;
}
@Override
public void initGui() {
super.initGui();
// Calculate preview area (left side of GUI)
previewX = guiLeft + 10;
previewY = guiTop + 10;
previewWidth = 200;
previewHeight = 180;
// NPC position: left side of preview, slightly below center
npcScreenX = previewX + (int) (previewWidth * 0.33f) + xOffset;
npcScreenY = previewY + (int) (previewHeight * 0.85f) + yOffset;
// Viewing rotation buttons (below preview area)
int btnY = guiTop + 192;
addButton(btnLeft = new GuiNpcButton(680, guiLeft + 10, btnY, 20, 20, "<"));
addButton(btnRight = new GuiNpcButton(681, guiLeft + 32, btnY, 20, 20, ">"));
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
// Handle held rotation buttons
if (Mouse.isButtonDown(0)) {
if (btnLeft != null && btnLeft.mousePressed(mc, mouseX, mouseY)) {
viewRotation += partialTicks * 2;
} else if (btnRight != null && btnRight.mousePressed(mc, mouseX, mouseY)) {
viewRotation -= partialTicks * 2;
}
}
// Draw background and UI elements
super.drawScreen(mouseX, mouseY, partialTicks);
// Draw the 3D preview
drawPreview(mouseX, mouseY, partialTicks);
}
/**
* Draw the 3D preview with NPC and entities.
*/
protected void drawPreview(int mouseX, int mouseY, float partialTicks) {
if (hasSubGui())
return;
GL11.glColor4f(1, 1, 1, 1);
// Enable scissor to clip rendering to preview area
GL11.glEnable(GL11.GL_SCISSOR_TEST);
setScissorClip(previewX, previewY, previewWidth, previewHeight);
// Always use the standard NPC animation renderer for ability preview
EntityLivingBase renderEntity = this.npc;
// Set NPC facing direction (affects anchor points and visual facing)
npc.prevRenderYawOffset = npc.renderYawOffset = NPC_FACING_YAW;
npc.prevRotationYaw = npc.rotationYaw = NPC_FACING_YAW;
npc.prevRotationYawHead = npc.rotationYawHead = NPC_FACING_YAW;
// Also set on render entity
renderEntity.prevRenderYawOffset = renderEntity.renderYawOffset = NPC_FACING_YAW;
renderEntity.prevRotationYaw = renderEntity.rotationYaw = NPC_FACING_YAW;
renderEntity.prevRotationYawHead = renderEntity.rotationYawHead = NPC_FACING_YAW;
renderEntity.rotationPitch = 0;
// Calculate NPC position delta for movement rendering (e.g. slam jump)
// Interpolate with partial ticks for smooth movement between frames
double npcDeltaX = 0, npcDeltaY = 0, npcDeltaZ = 0;
if (trackingNpcMovement) {
double interpX = npc.prevPosX + (npc.posX - npc.prevPosX) * partialTicks;
double interpY = npc.prevPosY + (npc.posY - npc.prevPosY) * partialTicks;
double interpZ = npc.prevPosZ + (npc.posZ - npc.prevPosZ) * partialTicks;
npcDeltaX = interpX - npcStartX;
npcDeltaY = interpY - npcStartY;
npcDeltaZ = interpZ - npcStartZ;
}
// ==================== BEGIN 3D RENDERING ====================
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glPushMatrix();
// Move to NPC render position on screen
GL11.glTranslatef(npcScreenX, npcScreenY, 300F);
// Apply zoom (scale)
GL11.glScalef(-CAMERA_ZOOM, CAMERA_ZOOM, CAMERA_ZOOM);
// Flip for screen coordinates (Y is inverted)
GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
// Apply slight camera pitch (looking down at scene)
GL11.glRotatef(CAMERA_PITCH, 1.0F, 0.0F, 0.0F);
// Apply VIEWING rotation (rotates entire space, not just NPC)
GL11.glRotatef(viewRotation, 0.0F, 1.0F, 0.0F);
// Setup lighting (standard item lighting for consistent colors)
GL11.glRotatef(135F, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
GL11.glRotatef(-135F, 0.0F, 1.0F, 0.0F);
// Adjust for entity offset
GL11.glTranslatef(0.0F, renderEntity.yOffset, 0.0F);
RenderManager.instance.playerViewY = 180F;
ClientEventHandler.renderingEntityInGUI = true;
// Render the NPC at its position delta (for movement like slam jumps)
RenderManager.instance.renderEntityWithPosYaw(renderEntity, npcDeltaX, npcDeltaY, npcDeltaZ, 0.0F, partialTicks);
// Render preview entities at their positions relative to NPC start position
renderPreviewEntities(partialTicks);
// Render telegraph in preview space
renderPreviewTelegraph(partialTicks);
ClientEventHandler.renderingEntityInGUI = false;
GL11.glPopMatrix();
// Cleanup GL state
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
GL11.glDisable(GL11.GL_TEXTURE_2D);
OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
// Disable scissor
GL11.glDisable(GL11.GL_SCISSOR_TEST);
// Clear depth buffer so UI renders on top
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
}
/**
* Render preview entities in the same coordinate space as the NPC.
* Called WITHIN the 3D matrix transformation.
*/
protected void renderPreviewEntities(float partialTicks) {
// Save current GL state that NPC render may have changed
boolean lightingWasEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING);
// Use the start position as the reference point for entity offsets
double refX = trackingNpcMovement ? npcStartX : npc.posX;
double refY = trackingNpcMovement ? npcStartY : npc.posY;
double refZ = trackingNpcMovement ? npcStartZ : npc.posZ;
for (Entity entity : previewEntities) {
if (entity == null || entity.isDead) continue;
// Calculate entity position relative to reference (NPC start position)
double offsetX = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks - refX;
double offsetY = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks - refY;
double offsetZ = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks - refZ;
// The NPC model was translated by npc.yOffset, so we need to subtract it
offsetY -= npc.yOffset;
// Reset GL state before each entity to ensure colors render correctly
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
GL11.glDisable(GL11.GL_LIGHTING);
try {
RenderManager.instance.renderEntityWithPosYaw(entity, offsetX, offsetY, offsetZ, entity.rotationYaw, partialTicks);
} catch (Exception e) {
// Ignore rendering errors
}
}
// Restore lighting state for any subsequent rendering
if (lightingWasEnabled) {
GL11.glEnable(GL11.GL_LIGHTING);
}
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
/**
* Render the telegraph in the 3D preview space.
* Called within the GL matrix transformation.
*/
protected void renderPreviewTelegraph(float partialTicks) {
if (previewTelegraph == null) return;
if (TelegraphRenderer.Instance == null) return;
// Telegraph position is in world coords - convert to preview space
double refX = trackingNpcMovement ? npcStartX : npc.posX;
double refY = trackingNpcMovement ? npcStartY : npc.posY;
double refZ = trackingNpcMovement ? npcStartZ : npc.posZ;
double offsetX = previewTelegraph.getInterpolatedX(partialTicks) - refX;
double offsetY = previewTelegraph.getInterpolatedY(partialTicks) - refY;
double offsetZ = previewTelegraph.getInterpolatedZ(partialTicks) - refZ;
// Adjust for NPC yOffset (same as entities)
offsetY -= npc.yOffset;
TelegraphRenderer.Instance.renderTelegraphInGUI(previewTelegraph, offsetX, offsetY, offsetZ, 1.0f, partialTicks);
}
public void setPreviewTelegraph(TelegraphInstance telegraph) {
this.previewTelegraph = telegraph;
}
/**
* Set scissor clip for preview area.
*/
protected void setScissorClip(int x, int y, int width, int height) {
ScaledResolution sr = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int scale = sr.getScaleFactor();
int scaledY = mc.displayHeight - (y + height) * scale;
GL11.glScissor(x * scale, scaledY, width * scale, height * scale);
}
// ==================== MOVEMENT TRACKING ====================
/**
* Start tracking NPC movement from current position.
*/
public void startTrackingMovement() {
npcStartX = npc.posX;
npcStartY = npc.posY;
npcStartZ = npc.posZ;
trackingNpcMovement = true;
}
/**
* Stop tracking NPC movement.
*/
public void stopTrackingMovement() {
trackingNpcMovement = false;
}
// ==================== PREVIEW ENTITY MANAGEMENT ====================
public void addPreviewEntity(Entity entity) {
if (entity != null && !previewEntities.contains(entity)) {
previewEntities.add(entity);
}
}
public void removePreviewEntity(Entity entity) {
previewEntities.remove(entity);
}
public void clearPreviewEntities() {
previewEntities.clear();
}
public List<Entity> getPreviewEntities() {
return previewEntities;
}
public float getNpcFacingYaw() {
return NPC_FACING_YAW;
}
// ==================== BACKGROUND ====================
@Override
protected void drawBackground() {
super.drawBackground();
drawGradientRect(previewX, previewY, previewX + previewWidth, previewY + previewHeight,
0xc0101010, 0xd0101010);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
}
// ==================== STANDARD OVERRIDES ====================
@Override
public boolean doesGuiPauseGame() {
return false;
}
@Override
public void keyTyped(char par1, int par2) {
boolean hadSubGui = hasSubGui();
super.keyTyped(par1, par2);
if (par2 == 1 && !hadSubGui) {
close();
}
}
public void close() {
this.mc.displayGuiScreen((GuiScreen) null);
this.mc.setIngameFocus();
}
@Override
public void save() {
}
@Override
protected void actionPerformed(GuiButton btn) {
if (btn.id == 670) {
close();
}
}
}
@@ -96,7 +96,10 @@ public class GuiMenuTopButton extends GuiNpcButton {
@Override
public boolean mousePressed(Minecraft minecraft, int i, int j) {
boolean bo = !active && getVisible() && hover;
int h = this.height - (active ? 0 : 2);
boolean bo = !active && getVisible()
&& i >= xPosition && j >= yPosition
&& i < xPosition + getWidth() && j < yPosition + h;
if (bo && listener != null) {
listener.actionPerformed(this);
return false;
@@ -1,6 +1,7 @@
package noppes.npcs.client.gui.util;
import kamkeel.npcs.util.TextSplitter;
import kamkeel.npcs.util.FileNameHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiScreen;
@@ -26,6 +27,7 @@ public class GuiNpcTextField extends GuiTextField {
public float minFloat = 0, maxFloat = Float.MAX_VALUE, defFloat = 0;
protected static GuiNpcTextField activeTextfield = null;
public boolean canEdit = true;
private boolean fileNameSafe = false;
public String hoverableText = "";
private boolean wasHovered = false;
private int hoverCount = 0;
@@ -71,6 +73,11 @@ public class GuiNpcTextField extends GuiTextField {
public boolean textboxKeyTyped(char c, int i) {
if (!canEdit || !isFocused())
return false;
if (fileNameSafe && !GuiScreen.isCtrlKeyDown() && !isFileNameCharAllowed(c, i)) {
return false;
}
// Allow Ctrl shortcuts (select all, copy, paste, cut) to bypass char filter
if (GuiScreen.isCtrlKeyDown()) {
// For Ctrl+V (paste) on numeric fields, filter clipboard to valid chars
@@ -87,7 +94,17 @@ public class GuiNpcTextField extends GuiTextField {
}
return true;
}
return super.textboxKeyTyped(c, i);
if (i == 47 && fileNameSafe) {
String clipboard = GuiScreen.getClipboardString();
if (clipboard != null) {
String filtered = filterFileNameClipboard(clipboard);
if (!filtered.isEmpty())
writeText(filtered);
}
return true;
}
boolean handled = super.textboxKeyTyped(c, i);
return handled;
}
if (!charAllowed(c, i))
return false;
@@ -179,6 +196,9 @@ public class GuiNpcTextField extends GuiTextField {
else if (getFloat() > maxFloat)
setText(maxFloat + "");
}
if (fileNameSafe) {
normalizeFileNameText();
}
setCursorPositionZero();
if (listener != null)
listener.unFocused(this);
@@ -238,6 +258,51 @@ public class GuiNpcTextField extends GuiTextField {
return this;
}
public GuiNpcTextField setFileNameSafe() {
fileNameSafe = true;
normalizeFileNameText();
return this;
}
private boolean isSpecialNavigationKey(int keyCode) {
for (int allowed : allowedSpecialChars) {
if (allowed == keyCode) {
return true;
}
}
return false;
}
private boolean isFileNameCharAllowed(char c, int keyCode) {
if (isSpecialNavigationKey(keyCode) || c < 32) {
return true;
}
return Character.isLetterOrDigit(c) || c == '_' || c == '-' || c == ' ';
}
private String filterFileNameClipboard(String clipboard) {
StringBuilder filtered = new StringBuilder(clipboard.length());
for (int idx = 0; idx < clipboard.length(); idx++) {
char c = clipboard.charAt(idx);
if (Character.isLetterOrDigit(c) || c == '_' || c == '-') {
filtered.append(c);
} else if (Character.isWhitespace(c)) {
filtered.append(' ');
}
}
return filtered.toString();
}
private void normalizeFileNameText() {
String current = getText();
String sanitized = FileNameHelper.sanitizeTextInput(current);
if (sanitized.equals(current)) return;
int cursor = getCursorPosition();
setText(sanitized);
setCursorPosition(Math.min(cursor, sanitized.length()));
}
public void setHoverText(String text) {
this.hoverableText = StatCollector.translateToLocal(text);
}
@@ -1,6 +1,6 @@
package noppes.npcs.client.gui.util;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
/**
* Callback for when a chained ability is saved from the config SubGui.
@@ -422,7 +422,7 @@ public class ModelMPM extends ModelNPCMale {
Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha());
glColor(overlayData.getColor(), overlayData.getAlpha());
GL11.glDepthMask(!npc.isInvisible());
@@ -522,6 +522,14 @@ public class ModelMPM extends ModelNPCMale {
}
private static void glColor(int color, float alpha) {
float r = ((color >> 16) & 0xFF) / 255.0F;
float g = ((color >> 8) & 0xFF) / 255.0F;
float b = (color & 0xFF) / 255.0F;
GL11.glColor4f(r, g, b, alpha);
}
@Override
public void setRotationAngles(float limbSwing, float limbSwingAmount,
float ageInTicks, float netHeadYaw, float headPitch,
@@ -79,7 +79,7 @@ public class RenderCNPCPlayer extends RenderPlayer {
RenderHelper.disableStandardItemLighting();
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.alpha);
glColor(overlayData.getColor(), overlayData.getAlpha());
GL11.glDepthMask(!player.isInvisible());
@@ -97,6 +97,14 @@ public class RenderCNPCPlayer extends RenderPlayer {
return true;
}
private static void glColor(int color, float alpha) {
float r = ((color >> 16) & 0xFF) / 255.0F;
float g = ((color >> 8) & 0xFF) / 255.0F;
float b = (color & 0xFF) / 255.0F;
GL11.glColor4f(r, g, b, alpha);
}
public void postRenderOverlay() {
GL11.glPopMatrix();
@@ -482,7 +482,7 @@ public class RenderNPCInterface extends RenderLiving {
Minecraft.getMinecraft().entityRenderer.disableLightmap((double) 0);
}
GL11.glColor4f(1.0F, 1.0F, 1.0F, overlayData.getAlpha());
glColor(overlayData.getColor(), overlayData.getAlpha());
GL11.glDepthMask(!npc.isInvisible());
@@ -521,6 +521,14 @@ public class RenderNPCInterface extends RenderLiving {
}
}
private static void glColor(int color, float alpha) {
float r = ((color >> 16) & 0xFF) / 255.0F;
float g = ((color >> 8) & 0xFF) / 255.0F;
float b = (color & 0xFF) / 255.0F;
GL11.glColor4f(r, g, b, alpha);
}
@Override
protected float handleRotationFloat(EntityLivingBase par1EntityLiving, float par2) {
EntityNPCInterface npc = (EntityNPCInterface) par1EntityLiving;
@@ -17,6 +17,7 @@ public class ConfigClient {
public final static String MODEL = "Model";
public final static String TEXTURE = "Texture";
public final static String HUD = "Hud";
public final static String RENDERING = "Rendering";
/**
@@ -52,6 +53,10 @@ public class ConfigClient {
public static Property HideEffectsBarProperty;
public static boolean HideEffectsBar = false;
// Rendering Properties
public static Property LowResExplosionProperty;
public static boolean LowResExplosion = false;
/**
* Questing Properties
**/
@@ -277,6 +282,14 @@ public class ConfigClient {
HideEffectsBarProperty = config.get(VISUAL, "Hide Effects Bar", false, "Hides CNPC+ Inventory Effects Bar");
HideEffectsBar = HideEffectsBarProperty.getBoolean(false);
LowResExplosionProperty = config.get(
RENDERING,
"Low Res Explosion",
false,
"Disables most Energy Explosion voxel rendering and keeps particle effects only."
);
LowResExplosion = LowResExplosionProperty.getBoolean(false);
DialogSpeedProperty = config.get(VISUAL, "Dialog Speed", true, "Only set for gradual dialogs");
DialogSpeed = DialogSpeedProperty.getInt(10);
@@ -10,8 +10,14 @@ public class ConfigEnergy {
public static Configuration config;
public final static String DOMES = "Domes";
public final static String EXPLOSIONS = "Explosions";
public static String[] DomeItemBlacklist;
/**
* Server-side toggle for energy projectile terrain destruction.
* Disabled by default to avoid block grief.
*/
public static boolean EnableEnergyExplosionBlockDamage;
public static void init(File configFile) {
config = new Configuration(configFile);
@@ -26,6 +32,13 @@ public class ConfigEnergy {
+ "Format: modid:itemname (e.g., minecraft:ender_pearl)"
);
EnableEnergyExplosionBlockDamage = config.getBoolean(
"Enable Energy Explosion Block Damage", EXPLOSIONS,
false,
"If true, explosive ENERGY projectile abilities can destroy terrain.\n"
+ "This is intended for server-side use and is disabled by default."
);
} catch (Exception e) {
FMLLog.log(Level.ERROR, e, "CustomNPC+ has had a problem loading its energy configuration");
} finally {
@@ -2,10 +2,10 @@ package noppes.npcs.controllers.data;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.controllers.data.ability.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.ToggleEntry;
import kamkeel.npcs.controllers.data.ability.enums.AbilityPhase;
import kamkeel.npcs.controllers.data.ability.data.ChainedAbility;
import kamkeel.npcs.controllers.data.ability.data.IAbilityAction;
import kamkeel.npcs.controllers.data.ability.data.entry.AbilityToggleEntry;
import kamkeel.npcs.controllers.data.ability.type.AbilityGuard;
import kamkeel.npcs.controllers.data.telegraph.TelegraphInstance;
import kamkeel.npcs.network.packets.data.ability.AbilityCooldownSyncPacket;
@@ -23,7 +23,6 @@ import net.minecraft.util.DamageSource;
import noppes.npcs.AbstractDataAbilities;
import noppes.npcs.EventHooks;
import noppes.npcs.LogWriter;
import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.api.ability.IPlayerAbilityData;
import noppes.npcs.api.entity.IPlayer;
import noppes.npcs.controllers.ScriptController;
@@ -807,6 +806,9 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
if (currentAbility == null || !currentAbility.isExecuting()) {
return amount;
}
if (currentAbility.isInvulnerableForCurrentPhase()) {
return 0;
}
net.minecraft.entity.Entity sourceEntity = source.getEntity();
EntityLivingBase attacker = sourceEntity instanceof EntityLivingBase ? (EntityLivingBase) sourceEntity : null;
@@ -938,6 +940,9 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
if (wasFlyingAtLock) {
flags |= PlayerAbilityStatePacket.FLAG_WAS_FLYING_AT_LOCK;
}
if (currentAbility.getPhase() == AbilityPhase.ACTIVE) {
flags |= PlayerAbilityStatePacket.FLAG_ACTIVE_PHASE;
}
return flags;
}
@@ -995,7 +1000,7 @@ public class PlayerAbilityData extends AbstractDataAbilities implements IPlayerA
// Active toggles (compound format with state)
NBTTagList toggleList = new NBTTagList();
for (Map.Entry<String, ToggleEntry> entry : activeToggles.entrySet()) {
for (Map.Entry<String, AbilityToggleEntry> entry : activeToggles.entrySet()) {
NBTTagCompound toggleNbt = new NBTTagCompound();
toggleNbt.setString("Key", entry.getKey());
toggleNbt.setInteger("State", entry.getValue().getState());
@@ -2,7 +2,6 @@ package noppes.npcs.controllers.data;
import kamkeel.npcs.controllers.AbilityController;
import kamkeel.npcs.controllers.data.ability.Ability;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.packets.data.ability.AbilityHotbarSyncPacket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -10,8 +10,10 @@ public class SkinOverlay implements ISkinOverlay {
public boolean glow = true;
public boolean blend = true;
public float alpha = 1.0F;
public float size = 1.0F;
public int color = 0xFFFFFF;
public float speedX = 0.0F;
public float speedY = 0.0F;
@@ -78,6 +80,15 @@ public class SkinOverlay implements ISkinOverlay {
return size;
}
public void setColor(int color) {
this.color = Math.max(0, color);
this.updateClient();
}
public int getColor() {
return color;
}
public void setTextureScale(float scaleX, float scaleY) {
this.scaleX = scaleX;
this.scaleY = scaleY;
@@ -131,6 +142,11 @@ public class SkinOverlay implements ISkinOverlay {
this.blend = compound.getBoolean("SkinOverlayBlend");
this.alpha = compound.getFloat("SkinOverlayAlpha");
this.size = compound.getFloat("SkinOverlaySize");
if(compound.hasKey("SkinOverlayColor")){
this.color = compound.getInteger("SkinOverlayColor");
} else {
this.color = 0xFFFFFF;
}
this.speedX = compound.getFloat("SkinOverlaySpeedX");
this.speedY = compound.getFloat("SkinOverlaySpeedY");
this.scaleX = compound.getFloat("SkinOverlayScaleX");
@@ -146,6 +162,7 @@ public class SkinOverlay implements ISkinOverlay {
compound.setBoolean("SkinOverlayBlend", this.getBlend());
compound.setFloat("SkinOverlayAlpha", this.getAlpha());
compound.setFloat("SkinOverlaySize", this.getSize());
compound.setInteger("SkinOverlayColor", this.getColor());
compound.setFloat("SkinOverlaySpeedX", this.getSpeedX());
compound.setFloat("SkinOverlaySpeedY", this.getSpeedY());
compound.setFloat("SkinOverlayScaleX", this.getTextureScaleX());
@@ -659,6 +659,9 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
if (damagesource.damageType != null && damagesource.damageType.equals("outOfWorld") && isKilled()) {
reset();
}
if (this.abilities != null && this.abilities.isCurrentAbilityInvulnerable()) {
return false;
}
// Check for custom weapon attack speed - bypass immunity if enough time has passed
Entity sourceEntity = damagesource.getEntity();
@@ -1834,12 +1837,15 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
try {
readSpawnData(ByteBufUtils.readNBT(buf));
} catch (IOException e) {
RequestProperSpawnData.reportMissingData(this);
if(this.worldObj != null && this.worldObj.isRemote){
RequestProperSpawnData.reportMissingData(this);
}
}
}
public void readSpawnData(NBTTagCompound compound) {
if ((compound.hasNoTags() || !compound.hasKey("MaxHealth", Constants.NBT.TAG_DOUBLE))) {
if (this.worldObj != null && this.worldObj.isRemote &&
(compound.hasNoTags() || !compound.hasKey("MaxHealth", Constants.NBT.TAG_DOUBLE))) {
RequestProperSpawnData.reportMissingData(this);
return;
}
@@ -1,13 +1,13 @@
package noppes.npcs.items;
import kamkeel.npcs.controllers.data.ability.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.data.EnergyAnchorData;
import kamkeel.npcs.controllers.data.ability.data.EnergyCombatData;
import kamkeel.npcs.controllers.data.ability.data.EnergyDisplayData;
import kamkeel.npcs.controllers.data.ability.data.EnergyHomingData;
import kamkeel.npcs.controllers.data.ability.data.EnergyLifespanData;
import kamkeel.npcs.controllers.data.ability.data.EnergyLightningData;
import kamkeel.npcs.controllers.data.ability.data.EnergyTrajectoryData;
import kamkeel.npcs.controllers.data.ability.enums.AnchorPoint;
import kamkeel.npcs.controllers.data.ability.data.energy.EnergyAnchorData;
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.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;
@@ -161,6 +161,22 @@ public class ScriptEnergyProjectile<T extends EntityEnergyProjectile> extends Sc
entity.setExplosionDamageFalloff(falloff);
}
public int getHitType() {
return entity.getHitType();
}
public void setHitType(int hitType) {
entity.setHitType(hitType);
}
public int getMultiHitDelayTicks() {
return entity.getMultiHitDelayTicks();
}
public void setMultiHitDelayTicks(int delayTicks) {
entity.setMultiHitDelayTicks(delayTicks);
}
// ==================== MOVEMENT ====================
public float getSpeed() {
@@ -45,14 +45,6 @@ public class ScriptEnergySlicer<T extends EntityEnergySlicer> extends ScriptEner
entity.setSliceThickness(thickness);
}
public boolean isPiercing() {
return entity.isPiercing();
}
public void setPiercing(boolean piercing) {
entity.setPiercing(piercing);
}
// ==================== FIRE ====================
@Override