Fix Built In Animation

This commit is contained in:
Kam committed 2026-01-28 16:57:49 -05:00
1 parent e73054a529
commit c339e5edbc
11 files changed
+205 -73

No files matched your search

@@ -122,12 +122,8 @@ public class AbilityDisc extends Ability implements IAbilityDisc {
discEntity.startMoving(target);
}
// If movement is locked during active phase, keep ability active until entity dies
// Otherwise signal completion immediately
if (!lockMovement.locksActive()) {
discEntity = null;
signalCompletion();
}
// Ability stays active until entity dies (prevents firing another while projectile is alive)
// Movement locking is handled separately by the base class
}
@Override
@@ -157,8 +153,8 @@ public class AbilityDisc extends Ability implements IAbilityDisc {
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// If we're tracking the entity for movement lock, check if it's dead
if (discEntity != null && discEntity.isDead) {
// Signal completion when entity dies
if (discEntity == null || discEntity.isDead) {
discEntity = null;
signalCompletion();
}
@@ -123,12 +123,8 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam {
beamEntity.startFiring(target);
}
// If movement is locked during active phase, keep ability active until entity dies
// Otherwise signal completion immediately
if (!lockMovement.locksActive()) {
beamEntity = null;
signalCompletion();
}
// Ability stays active until entity dies (prevents firing another while projectile is alive)
// Movement locking is handled separately by the base class
}
@Override
@@ -161,8 +157,8 @@ public class AbilityEnergyBeam extends Ability implements IAbilityEnergyBeam {
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// If we're tracking the entity for movement lock, check if it's dead
if (beamEntity != null && beamEntity.isDead) {
// Signal completion when entity dies
if (beamEntity == null || beamEntity.isDead) {
beamEntity = null;
signalCompletion();
}
@@ -128,18 +128,14 @@ public class AbilityLaserShot extends Ability implements IAbilityLaserShot {
world.spawnEntityInWorld(laserEntity);
// If movement is locked during active phase, keep ability active until entity dies
// Otherwise signal completion immediately
if (!lockMovement.locksActive()) {
laserEntity = null;
signalCompletion();
}
// Ability stays active until entity dies (prevents firing another while projectile is alive)
// Movement locking is handled separately by the base class
}
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// If we're tracking the entity for movement lock, check if it's dead
if (laserEntity != null && laserEntity.isDead) {
// Signal completion when entity dies
if (laserEntity == null || laserEntity.isDead) {
laserEntity = null;
signalCompletion();
}
@@ -121,12 +121,8 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
orbEntity.startMoving(target);
}
// If movement is locked during active phase, keep ability active until entity dies
// Otherwise signal completion immediately
if (!lockMovement.locksActive()) {
orbEntity = null;
signalCompletion();
}
// Ability stays active until entity dies (prevents firing another while projectile is alive)
// Movement locking is handled separately by the base class
}
@Override
@@ -155,8 +151,8 @@ public class AbilityOrb extends Ability implements IAbilityOrb {
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// If we're tracking the entity for movement lock, check if it's dead
if (orbEntity != null && orbEntity.isDead) {
// Signal completion when entity dies
if (orbEntity == null || orbEntity.isDead) {
orbEntity = null;
signalCompletion();
}
@@ -100,18 +100,14 @@ public class AbilitySweeper extends Ability implements IAbilitySweeper {
lockOnTarget);
world.spawnEntityInWorld(activeEntity);
// If movement is locked during active phase, keep ability active until entity dies
// Otherwise signal completion immediately
if (!lockMovement.locksActive()) {
activeEntity = null;
signalCompletion();
}
// Ability stays active until entity dies (prevents firing another while projectile is alive)
// Movement locking is handled separately by the base class
}
@Override
public void onActiveTick(EntityNPCInterface npc, EntityLivingBase target, World world, int tick) {
// If we're tracking the entity for movement lock, check if it's dead
if (activeEntity != null && activeEntity.isDead) {
// Signal completion when entity dies
if (activeEntity == null || activeEntity.isDead) {
activeEntity = null;
signalCompletion();
}
@@ -96,6 +96,7 @@ import kamkeel.npcs.network.packets.request.animation.AnimationGetPacket;
import kamkeel.npcs.network.packets.request.animation.AnimationRemovePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationSavePacket;
import kamkeel.npcs.network.packets.request.animation.AnimationsGetPacket;
import kamkeel.npcs.network.packets.request.animation.BuiltInAnimationGetPacket;
import kamkeel.npcs.network.packets.request.bank.BankGetPacket;
import kamkeel.npcs.network.packets.request.bank.BankRemovePacket;
import kamkeel.npcs.network.packets.request.bank.BankSavePacket;
@@ -469,6 +470,7 @@ public class PacketHandler {
REQUEST_PACKET.registerPacket(new AnimationGetPacket());
REQUEST_PACKET.registerPacket(new AnimationRemovePacket());
REQUEST_PACKET.registerPacket(new AnimationSavePacket());
REQUEST_PACKET.registerPacket(new BuiltInAnimationGetPacket());
// Moving Path
REQUEST_PACKET.registerPacket(new MovingPathSavePacket());
@@ -93,6 +93,7 @@ public enum EnumRequestPacket {
AnimationGet,
AnimationRemove,
AnimationSave,
BuiltInAnimationGet,
RemoteNpcsGet,
RemoteTpToNpc,
@@ -0,0 +1,72 @@
package kamkeel.npcs.network.packets.request.animation;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import io.netty.buffer.ByteBuf;
import kamkeel.npcs.network.AbstractPacket;
import kamkeel.npcs.network.PacketChannel;
import kamkeel.npcs.network.PacketHandler;
import kamkeel.npcs.network.PacketUtil;
import kamkeel.npcs.network.enums.EnumItemPacketType;
import kamkeel.npcs.network.enums.EnumRequestPacket;
import kamkeel.npcs.network.packets.data.large.GuiDataPacket;
import kamkeel.npcs.util.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.controllers.AnimationController;
import noppes.npcs.controllers.data.Animation;
import noppes.npcs.controllers.data.BuiltInAnimation;
import java.io.IOException;
/**
* Packet to request a built-in animation by name.
* Built-in animations don't have IDs, so we fetch by name.
*/
public final class BuiltInAnimationGetPacket extends AbstractPacket {
public static String packetName = "Request|BuiltInAnimationGet";
private String animationName;
public BuiltInAnimationGetPacket() {
}
public BuiltInAnimationGetPacket(String animationName) {
this.animationName = animationName;
}
@Override
public Enum getType() {
return EnumRequestPacket.BuiltInAnimationGet;
}
@Override
public PacketChannel getChannel() {
return PacketHandler.REQUEST_PACKET;
}
@SideOnly(Side.CLIENT)
@Override
public void sendData(ByteBuf out) throws IOException {
ByteBufUtils.writeString(out, animationName);
}
@Override
public void receiveData(ByteBuf in, EntityPlayer player) throws IOException {
if (!(player instanceof EntityPlayerMP))
return;
if (!PacketUtil.verifyItemPacket(packetName, EnumItemPacketType.WAND, player))
return;
String name = ByteBufUtils.readString(in);
BuiltInAnimation animation = AnimationController.getInstance().getBuiltInAnimation(name);
if (animation != null) {
NBTTagCompound compound = animation.writeToNBT();
// Mark as built-in so client knows
compound.setBoolean("BuiltIn", true);
GuiDataPacket.sendGuiData((EntityPlayerMP) player, compound);
}
}
}