Removed millisecond ticks and tick duration from animations.

This commit is contained in:
luisc committed 2025-02-12 12:15:33 -06:00
1 parent e5673a85e7
commit 3b9c38124e
12 files changed
+54 -192

No files matched your search

@@ -26,7 +26,6 @@ public class Animation implements IAnimation {
public float speed = 1.0F;
public byte smooth = 0;
public int loop = -1; //If greater than 0 and less than the amount of frames, the animation will begin looping when it reaches this frame.
public int tickDuration = 50;
public boolean whileStanding = true;
public boolean whileAttacking = true;
@@ -99,15 +98,6 @@ public class Animation implements IAnimation {
return this.name;
}
public int tickDuration() {
return this.tickDuration;
}
public IAnimation setTickDuration(int tickDuration) {
this.tickDuration = tickDuration;
return this;
}
public IAnimation setSpeed(float speed) {
this.speed = speed;
return this;
@@ -179,7 +169,7 @@ public class Animation implements IAnimation {
public long getTotalTime() {
long time = 0;
for (Frame frame : this.frames) {
time += (long) frame.duration * (frame.customized ? frame.tickDuration : this.tickDuration);
time += frame.duration;
}
return time;
}
@@ -197,12 +187,6 @@ public class Animation implements IAnimation {
smooth = compound.getByte("Smooth");
loop = compound.getInteger("Loop");
if (compound.hasKey("TickDuration")) {
this.tickDuration = compound.getInteger("TickDuration");
} else if(compound.hasKey("RenderTicks")){
this.tickDuration = compound.getBoolean("RenderTicks") ? 20 : 50;
}
ArrayList<Frame> frames = new ArrayList<Frame>();
NBTTagList list = compound.getTagList("Frames", 10);
for (int i = 0; i < list.tagCount(); i++) {
@@ -229,7 +213,6 @@ public class Animation implements IAnimation {
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);
compound.setInteger("Loop",loop);
compound.setInteger("TickDuration", tickDuration);
NBTTagList list = new NBTTagList();
for(Frame frame : frames){
@@ -9,7 +9,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import noppes.npcs.CommonProxy;
import noppes.npcs.CustomNpcs;
import noppes.npcs.DataDisplay;
import noppes.npcs.EventHooks;
import noppes.npcs.api.entity.IAnimatable;
@@ -44,7 +44,12 @@ public class AnimationData implements IAnimationData {
public AnimationData(Object parent){
this.parent = parent;
}
public static AnimationData getData(Entity entity) {
if (entity.worldObj.isRemote) {
return CustomNpcs.proxy.getClientAnimationData(entity);
}
if (entity instanceof EntityPlayerMP) {
return PlayerData.get((EntityPlayer) entity).animationData;
} else if (entity instanceof EntityNPCInterface) {
@@ -102,13 +107,6 @@ public class AnimationData implements IAnimationData {
EventHooks.onAnimationFrameEntered(this.animation, this.animation.currentFrame());
}
synchronized (CommonProxy.serverPlayingAnimations) {
if (this.isClientAnimating && this.getMCEntity() != null &&
!this.getMCEntity().worldObj.isRemote && this.animation != null) {
CommonProxy.serverPlayingAnimations.add(this);
}
}
List<EntityPlayer> entities = sendingEntity.worldObj.getEntitiesWithinAABB(EntityPlayer.class, AxisAlignedBB.getBoundingBox(
sendingEntity.posX - range, sendingEntity.posY - range, sendingEntity.posZ - range,
sendingEntity.posX + range, sendingEntity.posY + range, sendingEntity.posZ + range));
@@ -159,7 +157,7 @@ public class AnimationData implements IAnimationData {
public void increaseTime() {
Animation updateAnimation = null;
if (this.isActive(animation.parent.currentClientAnimation)) {
if (this.animation != null && this.isActive(this.animation.parent.currentClientAnimation)) {
updateAnimation = this.currentClientAnimation;
} else {
this.isClientAnimating = false;
@@ -171,7 +169,7 @@ public class AnimationData implements IAnimationData {
if (updateAnimation != null && updateAnimation.increaseTime()) {
Frame frame = (Frame) updateAnimation.currentFrame();
if (frame != null) {
this.animatingTime += frame.customized ? frame.tickDuration : updateAnimation.tickDuration;
this.animatingTime++;
}
}
}
@@ -274,9 +272,6 @@ public class AnimationData implements IAnimationData {
if (this.getMCEntity() != null && this.getMCEntity().worldObj.isRemote && newAnim != null) {
this.animatingTime = 0;
synchronized (CommonProxy.clientPlayingAnimations) {
CommonProxy.clientPlayingAnimations.add(this);
}
}
Animation prevAnim = this.animation;
@@ -14,7 +14,6 @@ public class Frame implements IFrame {
public Animation parent;
public HashMap<EnumAnimationPart,FramePart> frameParts = new HashMap<>();
public int duration = 0;
public int tickDuration = 50;
boolean customized = false;
public float speed = 1.0F;
@@ -77,15 +76,6 @@ public class Frame implements IFrame {
return this;
}
public int tickDuration() {
return !this.customized && this.parent != null ? this.parent.tickDuration : this.tickDuration;
}
public IFrame setTickDuration(int tickDuration) {
this.tickDuration = tickDuration;
return this;
}
public boolean isCustomized() {
return customized;
}
@@ -148,18 +138,9 @@ public class Frame implements IFrame {
smooth = compound.getByte("Smooth");
}
if (compound.hasKey("TickDuration")) {
customized = true;
this.tickDuration = compound.getInteger("TickDuration");
} else if(compound.hasKey("RenderTicks")){
customized = true;
this.tickDuration = compound.getBoolean("RenderTicks") ? 20 : 50;
}
if (!customized && parent != null) {
this.speed = parent.speed;
this.smooth = parent.smooth;
this.tickDuration = parent.tickDuration;
}
HashMap<EnumAnimationPart,FramePart> frameParts = new HashMap<>();
@@ -186,7 +167,6 @@ public class Frame implements IFrame {
if(customized){
compound.setFloat("Speed", speed);
compound.setByte("Smooth", smooth);
compound.setInteger("TickDuration", tickDuration);
}
NBTTagList list = new NBTTagList();
@@ -209,7 +189,6 @@ public class Frame implements IFrame {
frame.customized = this.customized;
frame.speed = this.speed;
frame.smooth = this.smooth;
frame.tickDuration = this.tickDuration;
frame.colorMarker = this.colorMarker;
return frame;
}