mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-20 14:39:43 +00:00
Revert Animation Events
This commit is contained in:
1 parent
4c46496c82
commit
1ffddd3ce9
31 files changed
+208
-696
No files matched your search
@@ -1,15 +1,10 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.CustomNpcs;
|
||||
import noppes.npcs.DataDisplay;
|
||||
import noppes.npcs.EventHooks;
|
||||
import noppes.npcs.api.handler.data.IAnimation;
|
||||
import noppes.npcs.api.handler.data.IAnimationData;
|
||||
import noppes.npcs.api.handler.data.IFrame;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.controllers.AnimationController;
|
||||
@@ -29,7 +24,7 @@ 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 renderTicks = false; // If true, MC ticks are used. If false, render ticks are used.
|
||||
|
||||
public boolean whileStanding = true;
|
||||
public boolean whileAttacking = true;
|
||||
@@ -53,10 +48,6 @@ public class Animation implements IAnimation {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public IAnimationData getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
|
||||
public IFrame currentFrame() {
|
||||
return currentFrame < frames.size() ? frames.get(currentFrame) : null;
|
||||
}
|
||||
@@ -102,15 +93,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;
|
||||
@@ -129,6 +111,15 @@ public class Animation implements IAnimation {
|
||||
return this.smooth;
|
||||
}
|
||||
|
||||
public IAnimation useRenderTicks(boolean renderTicks) {
|
||||
this.renderTicks = renderTicks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean useRenderTicks() {
|
||||
return this.renderTicks;
|
||||
}
|
||||
|
||||
public IAnimation doWhileStanding(boolean whileStanding) {
|
||||
this.whileStanding = whileStanding;
|
||||
return this;
|
||||
@@ -179,14 +170,6 @@ public class Animation implements IAnimation {
|
||||
id = newID;
|
||||
}
|
||||
|
||||
public long getTotalTime() {
|
||||
long time = 0;
|
||||
for (Frame frame : this.frames) {
|
||||
time += (long) frame.duration * (frame.customized ? frame.tickDuration : this.tickDuration);
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
if(compound.hasKey("ID")){
|
||||
id = compound.getInteger("ID");
|
||||
@@ -200,11 +183,7 @@ 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;
|
||||
}
|
||||
renderTicks = compound.getBoolean("RenderTicks");
|
||||
|
||||
ArrayList<Frame> frames = new ArrayList<Frame>();
|
||||
NBTTagList list = compound.getTagList("Frames", 10);
|
||||
@@ -220,9 +199,6 @@ public class Animation implements IAnimation {
|
||||
this.whileStanding = compound.getBoolean("WhileStanding");
|
||||
this.whileMoving = compound.getBoolean("WhileWalking");
|
||||
this.whileAttacking = compound.getBoolean("WhileAttacking");
|
||||
|
||||
this.currentFrame = compound.getInteger("CurrentFrame");
|
||||
this.currentFrameTime = compound.getInteger("CurrentFrameTime");
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(){
|
||||
@@ -232,7 +208,8 @@ public class Animation implements IAnimation {
|
||||
compound.setFloat("Speed", speed);
|
||||
compound.setByte("Smooth", smooth);
|
||||
compound.setInteger("Loop",loop);
|
||||
compound.setInteger("TickDuration", tickDuration);
|
||||
|
||||
compound.setBoolean("RenderTicks", renderTicks);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
for(Frame frame : frames){
|
||||
@@ -244,24 +221,20 @@ public class Animation implements IAnimation {
|
||||
compound.setBoolean("WhileStanding", whileStanding);
|
||||
compound.setBoolean("WhileWalking", whileMoving);
|
||||
compound.setBoolean("WhileAttacking", whileAttacking);
|
||||
|
||||
compound.setInteger("CurrentFrame", currentFrame);
|
||||
compound.setInteger("CurrentFrameTime", currentFrameTime);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public boolean increaseTime() {
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void increaseTime() {
|
||||
if (paused)
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (this.parent != null && this.currentFrame < this.frames.size()) {
|
||||
this.parent.finishedFrame = this.currentFrame;
|
||||
}
|
||||
|
||||
this.currentFrameTime++;
|
||||
if (this.currentFrame() != null && this.currentFrameTime == this.currentFrame().getDuration()) {
|
||||
EventHooks.onAnimationFrameExited(this, this.currentFrame());
|
||||
|
||||
if (this.currentFrameTime == this.currentFrame().getDuration()) {
|
||||
Frame prevFrame = (Frame) this.currentFrame();
|
||||
Frame nextFrame = null;
|
||||
this.currentFrameTime = 0;
|
||||
@@ -271,13 +244,6 @@ public class Animation implements IAnimation {
|
||||
} else if (this.loop >= 0 && this.loop < this.frames.size()) {
|
||||
this.currentFrame = this.loop;
|
||||
}
|
||||
|
||||
if (this.currentFrame() != null) {
|
||||
EventHooks.onAnimationFrameEntered(this, this.currentFrame());
|
||||
} else {
|
||||
EventHooks.onAnimationEnded(this);
|
||||
}
|
||||
|
||||
if (nextFrame != null) {
|
||||
for (EnumAnimationPart part : EnumAnimationPart.values()) {
|
||||
if (prevFrame.frameParts.containsKey(part) && nextFrame.frameParts.containsKey(part)) {
|
||||
@@ -286,32 +252,23 @@ public class Animation implements IAnimation {
|
||||
}
|
||||
}
|
||||
} else if (this.parent != null && this.currentFrame > this.loop) {
|
||||
this.parent.finishedTime = this.parent.getMCEntity().getAge();
|
||||
this.parent.finishedTime = this.parent.animationEntity.getAge();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void jumpToCurrentFrame() {
|
||||
this.jumpToFrameAtTime(this.currentFrame, 0);
|
||||
this.currentFrameTime = 0;
|
||||
Frame frame = (Frame) this.currentFrame();
|
||||
if(frame != null){
|
||||
for (EnumAnimationPart part : EnumAnimationPart.values()) {
|
||||
if(part != null){
|
||||
if (frame.frameParts.containsKey(part)) {
|
||||
frame.frameParts.get(part).jumpToCurrentFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void jumpToFrameAtTime(int frameIndex, int time) {
|
||||
this.currentFrame = frameIndex;
|
||||
this.currentFrameTime = time;
|
||||
|
||||
Frame frame = (Frame) this.currentFrame();
|
||||
if(frame != null){
|
||||
for (EnumAnimationPart part : EnumAnimationPart.values()) {
|
||||
if(part != null){
|
||||
if (frame.frameParts.containsKey(part)) {
|
||||
frame.frameParts.get(part).jumpToCurrentFrame();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,21 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
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.*;
|
||||
import noppes.npcs.api.entity.IAnimatable;
|
||||
import noppes.npcs.api.entity.ICustomNpc;
|
||||
import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.DataDisplay;
|
||||
import noppes.npcs.Server;
|
||||
import noppes.npcs.api.handler.data.IAnimation;
|
||||
import noppes.npcs.api.handler.data.IAnimationData;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.NpcAPI;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -32,48 +29,20 @@ public class AnimationData implements IAnimationData {
|
||||
|
||||
public Animation animation;
|
||||
public boolean allowAnimation = false;
|
||||
public long animatingTime = 0;
|
||||
|
||||
public Animation currentClientAnimation;
|
||||
private boolean isClientAnimating;
|
||||
|
||||
private final HashSet<Integer> cachedAnimationIDs = new HashSet<>();
|
||||
|
||||
//Client-side values
|
||||
public EntityLivingBase animationEntity;
|
||||
public int finishedTime = -1;
|
||||
public int finishedFrame = -1;
|
||||
|
||||
public AnimationData(Object parent){
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public static AnimationData getData(Entity entity) {
|
||||
if (entity instanceof EntityPlayerMP) {
|
||||
return PlayerData.get((EntityPlayer) entity).animationData;
|
||||
} else if (entity instanceof EntityNPCInterface) {
|
||||
return ((EntityNPCInterface)entity).display.animationData;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public IAnimatable getEntity() {
|
||||
IEntity<?> entity = NpcAPI.Instance().getIEntity(this.getMCEntity());
|
||||
if (entity instanceof IAnimatable) {
|
||||
return (IAnimatable) entity;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public EntityLivingBase getMCEntity() {
|
||||
if (this.parent instanceof DataDisplay) {
|
||||
return ((DataDisplay) this.parent).npc;
|
||||
} else {
|
||||
if (this.parent instanceof PlayerData) {
|
||||
return ((PlayerData) this.parent).player;
|
||||
} else {
|
||||
return (EntityPlayer) this.parent;
|
||||
}
|
||||
if (parent instanceof DataDisplay) {
|
||||
this.animationEntity = ((DataDisplay) parent).npc;
|
||||
} else if (parent instanceof EntityPlayer) {
|
||||
this.animationEntity = (EntityLivingBase) parent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,30 +57,6 @@ public class AnimationData implements IAnimationData {
|
||||
if(sendingEntity.dimension != sendingEntity.worldObj.provider.dimensionId)
|
||||
sendingEntity.dimension = sendingEntity.worldObj.provider.dimensionId;
|
||||
|
||||
this.animatingTime = 0;
|
||||
|
||||
boolean prevIsClientAnimating = this.isClientAnimating && this.currentClientAnimation.currentFrame() != null;
|
||||
this.isClientAnimating = this.allowAnimation && this.animation != null;
|
||||
if (prevIsClientAnimating && (!this.isClientAnimating || this.animation != this.currentClientAnimation)) {
|
||||
EventHooks.onAnimationEnded(this.currentClientAnimation);
|
||||
}
|
||||
if (this.isClientAnimating) {
|
||||
this.currentClientAnimation = this.animation;
|
||||
}
|
||||
|
||||
if (this.animation != null && this.allowAnimation) {
|
||||
if (EventHooks.onAnimationStarted(this.animation))
|
||||
return;
|
||||
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));
|
||||
@@ -124,21 +69,13 @@ public class AnimationData implements IAnimationData {
|
||||
if (animationNBT == null && this.animation != null && !animationData.isCached(this.animation.getID())) {
|
||||
animationNBT = this.animation.writeToNBT();
|
||||
}
|
||||
animationData.viewAnimation(this.animation, this, animationNBT);
|
||||
animationData.viewAnimation(this.animation, sendingEntity, this, animationNBT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isClientAnimating() {
|
||||
return this.isClientAnimating;
|
||||
}
|
||||
|
||||
public boolean isActive() {
|
||||
return this.isActive(this.animation);
|
||||
}
|
||||
|
||||
public boolean isActive(Animation animation) {
|
||||
if (!this.allowAnimation || animation == null || animation.currentFrame == animation.frames.size() || animation.currentFrame() == null)
|
||||
if (!this.allowAnimation || this.animation == null || this.animation.currentFrame == this.animation.frames.size() || animation.currentFrame() == null)
|
||||
return false;
|
||||
|
||||
if (this.parent instanceof DataDisplay) {
|
||||
@@ -163,22 +100,6 @@ public class AnimationData implements IAnimationData {
|
||||
}
|
||||
}
|
||||
|
||||
public void increaseTime() {
|
||||
Animation updateAnimation = null;
|
||||
if (this.isActive()) {
|
||||
updateAnimation = this.animation;
|
||||
} else if (this.isActive(animation.parent.currentClientAnimation)) {
|
||||
updateAnimation = this.currentClientAnimation;
|
||||
}
|
||||
|
||||
if (updateAnimation != null && updateAnimation.increaseTime()) {
|
||||
Frame frame = (Frame) updateAnimation.currentFrame();
|
||||
if (frame != null) {
|
||||
this.animatingTime += frame.customized ? frame.tickDuration : updateAnimation.tickDuration;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCached(int id) {
|
||||
return this.cachedAnimationIDs.contains(id);
|
||||
}
|
||||
@@ -195,63 +116,27 @@ public class AnimationData implements IAnimationData {
|
||||
this.cachedAnimationIDs.clear();
|
||||
}
|
||||
|
||||
public void viewAnimation(Animation animation, AnimationData animationData, NBTTagCompound animationNBT) {
|
||||
this.viewAnimation(animation, animationData, animationNBT, animationData.allowAnimation, -1, -1);
|
||||
}
|
||||
|
||||
public void viewAnimation(Animation animation, AnimationData animationData, NBTTagCompound animationNBT, boolean enabled, int currentFrame, int time) {
|
||||
boolean prevEnabled = animationData.allowAnimation;
|
||||
animationData.allowAnimation = enabled;
|
||||
NBTTagCompound data = animationData.viewWriteNBT(new NBTTagCompound());
|
||||
animationData.allowAnimation = prevEnabled;
|
||||
|
||||
if (animation != null && currentFrame >= 0 && currentFrame < animation.frames.size()) {
|
||||
data.setInteger("Frame", currentFrame);
|
||||
data.setInteger("Time", time);
|
||||
}
|
||||
|
||||
public void viewAnimation(Animation animation, EntityLivingBase entity, AnimationData animationData, NBTTagCompound animationNBT) {
|
||||
NBTTagCompound data = animationData.writeToNBT(new NBTTagCompound());
|
||||
if (animation != null) {
|
||||
if (this.cachedAnimationIDs.contains(animation.getID()) && !data.hasKey("Frame")) {
|
||||
if (this.cachedAnimationIDs.contains(animation.getID())) {
|
||||
data.setInteger("AnimationID", animation.getID());
|
||||
} else {
|
||||
data.setTag("Animation", animationNBT);
|
||||
}
|
||||
}
|
||||
|
||||
IAnimatable animatable = animationData.getEntity();
|
||||
Entity entity = ((IEntity<?>) animatable).getMCEntity();
|
||||
if (!(entity instanceof EntityPlayer)) {
|
||||
data.setInteger("EntityId", entity.getEntityId());
|
||||
}
|
||||
|
||||
Server.sendData((EntityPlayerMP) ((PlayerData) parent).player, EnumPacketClient.UPDATE_ANIMATIONS, data, entity.getCommandSenderName());
|
||||
}
|
||||
|
||||
public NBTTagCompound viewWriteNBT(NBTTagCompound compound) {
|
||||
compound.setBoolean("AllowAnimation", allowAnimation);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void viewReadFromNBT(NBTTagCompound compound) {
|
||||
this.setEnabled(compound.getBoolean("AllowAnimation"));
|
||||
}
|
||||
|
||||
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
|
||||
if (this.currentClientAnimation != null) {
|
||||
compound.setTag("CurrentAnimation", currentClientAnimation.writeToNBT());
|
||||
compound.setBoolean("IsClientAnimating", isClientAnimating);
|
||||
}
|
||||
compound.setBoolean("AllowAnimation", allowAnimation);
|
||||
return compound;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
if (compound.hasKey("CurrentAnimation")) {
|
||||
this.currentClientAnimation = new Animation();
|
||||
this.currentClientAnimation.parent = this;
|
||||
this.currentClientAnimation.readFromNBT(compound.getCompoundTag("CurrentAnimation"));
|
||||
this.isClientAnimating = compound.getBoolean("IsClientAnimating");
|
||||
}
|
||||
this.setEnabled(compound.getBoolean("AllowAnimation"));
|
||||
}
|
||||
|
||||
@@ -269,50 +154,33 @@ public class AnimationData implements IAnimationData {
|
||||
}
|
||||
|
||||
public void setAnimation(IAnimation animation) {
|
||||
Animation newAnim = null;
|
||||
if (animation != null) {
|
||||
newAnim = new Animation();
|
||||
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) {
|
||||
this.animation = (Animation) animation;
|
||||
} else {
|
||||
Animation newAnim = new Animation();
|
||||
newAnim.readFromNBT(((Animation) animation).writeToNBT());
|
||||
newAnim.currentFrame = 0;
|
||||
newAnim.currentFrameTime = 0;
|
||||
newAnim.parent = this;
|
||||
}
|
||||
|
||||
|
||||
if (this.getMCEntity() != null && this.getMCEntity().worldObj.isRemote && newAnim != null) {
|
||||
this.animatingTime = 0;
|
||||
synchronized (CommonProxy.clientPlayingAnimations) {
|
||||
CommonProxy.clientPlayingAnimations.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
Animation prevAnim = this.animation;
|
||||
this.animation = newAnim;
|
||||
|
||||
if (this.getMCEntity() != null && this.getMCEntity().worldObj.isRemote &&
|
||||
this.isActive() && prevAnim != null && newAnim != null && !newAnim.frames.isEmpty()) {
|
||||
Frame frame = (Frame) prevAnim.currentFrame();
|
||||
if (frame != null) {
|
||||
Frame firstFrame = newAnim.frames.get(0);
|
||||
for (Map.Entry<EnumAnimationPart, FramePart> entry : frame.frameParts.entrySet()) {
|
||||
if (firstFrame.frameParts.containsKey(entry.getKey())) {
|
||||
FramePart prevFramePart = entry.getValue();
|
||||
FramePart newFramePart = firstFrame.frameParts.get(entry.getKey());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
newFramePart.prevPivots[i] = prevFramePart.prevPivots[i];
|
||||
newFramePart.prevRotations[i] = prevFramePart.prevRotations[i];
|
||||
if (this.isActive() && !newAnim.frames.isEmpty()) {
|
||||
Frame frame = (Frame) this.animation.currentFrame();
|
||||
if (frame != null) {
|
||||
Frame firstFrame = newAnim.frames.get(0);
|
||||
for (Map.Entry<EnumAnimationPart, FramePart> entry : frame.frameParts.entrySet()) {
|
||||
if (firstFrame.frameParts.containsKey(entry.getKey())) {
|
||||
FramePart prevFramePart = entry.getValue();
|
||||
FramePart newFramePart = firstFrame.frameParts.get(entry.getKey());
|
||||
for (int i = 0; i < 3; i++) {
|
||||
newFramePart.prevPivots[i] = prevFramePart.prevPivots[i];
|
||||
newFramePart.prevRotations[i] = prevFramePart.prevRotations[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.animation = newAnim;
|
||||
newAnim.parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
public IAnimation getAnimation() {
|
||||
return animation;
|
||||
}
|
||||
|
||||
public long getAnimatingTime() {
|
||||
return this.animatingTime;
|
||||
}
|
||||
}
|
||||
@@ -236,14 +236,13 @@ public class DataScript implements INpcScriptHandler {
|
||||
|
||||
@Override
|
||||
public void callScript(EnumScriptType type, Event event) {
|
||||
ScriptController.Instance.globalNpcScripts.callScript(type, event);
|
||||
callScript(type, event, "$$IGNORED$$", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callScript(String hookName, Event event) {
|
||||
try {
|
||||
EnumScriptType enumScriptType = EnumScriptType.valueOfIgnoreCase(hookName);
|
||||
EnumScriptType enumScriptType = EnumScriptType.valueOf(hookName);
|
||||
this.callScript(enumScriptType, event);
|
||||
} catch (IllegalArgumentException ignored) {}
|
||||
}
|
||||
|
||||
@@ -14,14 +14,12 @@ 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;
|
||||
public byte smooth = 0;
|
||||
public boolean renderTicks = false; // If true, MC ticks are used. If false, render ticks are used.
|
||||
|
||||
private int colorMarker = 0xFFFFFF;
|
||||
private String comment = "";
|
||||
|
||||
public Frame(){}
|
||||
|
||||
@@ -77,15 +75,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;
|
||||
}
|
||||
@@ -113,6 +102,15 @@ public class Frame implements IFrame {
|
||||
return this;
|
||||
}
|
||||
|
||||
public IFrame useRenderTicks(boolean renderTicks) {
|
||||
this.renderTicks = renderTicks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean useRenderTicks() {
|
||||
return this.renderTicks;
|
||||
}
|
||||
|
||||
public int getColorMarker() {
|
||||
return this.colorMarker;
|
||||
}
|
||||
@@ -121,22 +119,11 @@ public class Frame implements IFrame {
|
||||
this.colorMarker = color;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound){
|
||||
duration = compound.getInteger("Duration");
|
||||
if (compound.hasKey("ColorMarker")) {
|
||||
this.setColorMarker(compound.getInteger("ColorMarker"));
|
||||
}
|
||||
if (compound.hasKey("Comment")) {
|
||||
this.comment = compound.getString("Comment");
|
||||
}
|
||||
|
||||
// Customized = TRUE if Speed or Smooth Exist
|
||||
if(compound.hasKey("Speed")){
|
||||
@@ -147,19 +134,15 @@ public class Frame implements IFrame {
|
||||
customized = true;
|
||||
smooth = compound.getByte("Smooth");
|
||||
}
|
||||
|
||||
if (compound.hasKey("TickDuration")) {
|
||||
customized = true;
|
||||
this.tickDuration = compound.getInteger("TickDuration");
|
||||
} else if(compound.hasKey("RenderTicks")){
|
||||
if(compound.hasKey("RenderTicks")){
|
||||
customized = true;
|
||||
this.tickDuration = compound.getBoolean("RenderTicks") ? 20 : 50;
|
||||
renderTicks = compound.getBoolean("RenderTicks");
|
||||
}
|
||||
|
||||
if (!customized && parent != null) {
|
||||
if (!customized) {
|
||||
this.speed = parent.speed;
|
||||
this.smooth = parent.smooth;
|
||||
this.tickDuration = parent.tickDuration;
|
||||
this.renderTicks = parent.renderTicks;
|
||||
}
|
||||
|
||||
HashMap<EnumAnimationPart,FramePart> frameParts = new HashMap<>();
|
||||
@@ -181,12 +164,11 @@ public class Frame implements IFrame {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInteger("Duration", duration);
|
||||
compound.setInteger("ColorMarker", this.colorMarker);
|
||||
compound.setString("Comment", this.comment);
|
||||
|
||||
if(customized){
|
||||
compound.setFloat("Speed", speed);
|
||||
compound.setByte("Smooth", smooth);
|
||||
compound.setInteger("TickDuration", tickDuration);
|
||||
compound.setBoolean("RenderTicks", renderTicks);
|
||||
}
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
@@ -209,7 +191,7 @@ public class Frame implements IFrame {
|
||||
frame.customized = this.customized;
|
||||
frame.speed = this.speed;
|
||||
frame.smooth = this.smooth;
|
||||
frame.tickDuration = this.tickDuration;
|
||||
frame.renderTicks = this.renderTicks;
|
||||
frame.colorMarker = this.colorMarker;
|
||||
return frame;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package noppes.npcs.controllers.data;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -98,7 +97,7 @@ public class PlayerDataScript implements INpcScriptHandler {
|
||||
}
|
||||
|
||||
public boolean isClient() {
|
||||
return false;
|
||||
return this.player.isClientWorld();
|
||||
}
|
||||
public boolean getEnabled() {
|
||||
return ScriptController.Instance.playerScripts.enabled;
|
||||
|
||||
Reference in new issue
Block a user