mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 19:15:11 +00:00
Reorganize
This commit is contained in:
1 parent
18968bf7c7
commit
f58a6010d9
106 files changed
+377
-392
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;
|
||||
@@ -296,7 +296,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 +306,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 +326,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 +340,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 +373,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 +381,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 +394,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 +418,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 +441,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 +483,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 +502,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);
|
||||
|
||||
@@ -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;
|
||||
@@ -1095,7 +1094,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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -4,7 +4,7 @@ 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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
@@ -995,7 +994,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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user