mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 13:52:23 +00:00
Animation overhaul, along with animation changes to the API.
This commit is contained in:
1 parent
bda76bafe6
commit
be18e756fc
23 files changed
+648
-1229
No files matched your search
@@ -38,12 +38,19 @@ import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.gui.ICustomGui;
|
||||
import noppes.npcs.api.handler.*;
|
||||
import noppes.npcs.api.handler.data.IAnimation;
|
||||
import noppes.npcs.api.handler.data.IFrame;
|
||||
import noppes.npcs.api.handler.data.IFramePart;
|
||||
import noppes.npcs.api.handler.data.ISound;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.api.overlay.ICustomOverlay;
|
||||
import noppes.npcs.config.ConfigScript;
|
||||
import noppes.npcs.constants.EnumAnimationPart;
|
||||
import noppes.npcs.containers.ContainerNpcInterface;
|
||||
import noppes.npcs.controllers.*;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.Frame;
|
||||
import noppes.npcs.controllers.data.FramePart;
|
||||
import noppes.npcs.controllers.data.SkinOverlay;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -559,4 +566,69 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
public String ticksToTime(long ticks) {
|
||||
return this.millisToTime(ticks * 50);
|
||||
}
|
||||
|
||||
public IAnimation createAnimation(String name) {
|
||||
return new Animation(name);
|
||||
}
|
||||
|
||||
public IFrame createFrame(int duration) {
|
||||
return new Frame(duration);
|
||||
}
|
||||
|
||||
public IFrame createFrame(int duration, float speed, byte smooth) {
|
||||
return new Frame(duration,speed,smooth);
|
||||
}
|
||||
|
||||
public IFramePart createPart(String name) {
|
||||
try {
|
||||
return new FramePart(EnumAnimationPart.valueOf(name));
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
throw new CustomNPCsException("Invalid frame part name: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
public IFramePart createPart(String name, int[] rotation, int[] pivot) {
|
||||
if (rotation.length != 3 || pivot.length != 3) {
|
||||
throw new CustomNPCsException("Rotation and pivot arrays for frame parts must have a length of 3.");
|
||||
}
|
||||
|
||||
FramePart part = (FramePart) this.createPart(name);
|
||||
part.setRotations(rotation);
|
||||
part.setPivots(pivot);
|
||||
return part;
|
||||
}
|
||||
|
||||
public IFramePart createPart(String name, int[] rotation, int[] pivot, float speed, byte smooth) {
|
||||
FramePart part = (FramePart) this.createPart(name,rotation,pivot);
|
||||
part.setSpeed(speed);
|
||||
part.setSmooth(smooth);
|
||||
return part;
|
||||
}
|
||||
|
||||
public IFramePart createPart(int partId) {
|
||||
for (EnumAnimationPart part : EnumAnimationPart.values()) {
|
||||
if (part.id == partId) {
|
||||
return new FramePart(part);
|
||||
}
|
||||
}
|
||||
throw new CustomNPCsException("Invalid frame part ID: " + partId);
|
||||
}
|
||||
|
||||
public IFramePart createPart(int partId, int[] rotation, int[] pivot) {
|
||||
if (rotation.length != 3 || pivot.length != 3) {
|
||||
throw new CustomNPCsException("Rotation and pivot arrays for frame parts must have a length of 3.");
|
||||
}
|
||||
|
||||
FramePart part = (FramePart) this.createPart(partId);
|
||||
part.setRotations(rotation);
|
||||
part.setPivots(pivot);
|
||||
return part;
|
||||
}
|
||||
|
||||
public IFramePart createPart(int partId, int[] rotation, int[] pivot, float speed, byte smooth) {
|
||||
FramePart part = (FramePart) this.createPart(partId,rotation,pivot);
|
||||
part.setSpeed(speed);
|
||||
part.setSmooth(smooth);
|
||||
return part;
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,10 @@ import noppes.npcs.api.entity.ICustomNpc;
|
||||
import noppes.npcs.api.entity.IEntityLivingBase;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.handler.IOverlayHandler;
|
||||
import noppes.npcs.api.handler.data.IAnimationData;
|
||||
import noppes.npcs.api.handler.data.IFaction;
|
||||
import noppes.npcs.api.item.IItemStack;
|
||||
import noppes.npcs.api.jobs.IJob;
|
||||
import noppes.npcs.api.jobs.IJobPuppet;
|
||||
import noppes.npcs.api.roles.IRole;
|
||||
import noppes.npcs.config.ConfigMain;
|
||||
import noppes.npcs.constants.*;
|
||||
@@ -340,8 +340,8 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
npc.reset();
|
||||
}
|
||||
|
||||
public IJobPuppet getModelData() {
|
||||
return new ScriptJobPuppet(npc);
|
||||
public IAnimationData getAnimationData() {
|
||||
return this.npc.display.animationData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,6 +19,7 @@ import noppes.npcs.api.entity.IEntity;
|
||||
import noppes.npcs.api.entity.IPlayer;
|
||||
import noppes.npcs.api.gui.ICustomGui;
|
||||
import noppes.npcs.api.handler.IOverlayHandler;
|
||||
import noppes.npcs.api.handler.data.IAnimationData;
|
||||
import noppes.npcs.api.handler.data.IDialog;
|
||||
import noppes.npcs.api.handler.data.IQuest;
|
||||
import noppes.npcs.api.handler.data.ISound;
|
||||
@@ -760,6 +761,10 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return this.getData().skinOverlays;
|
||||
}
|
||||
|
||||
public IAnimationData getAnimationData() {
|
||||
return this.getData().animationData;
|
||||
}
|
||||
|
||||
public IQuest[] getFinishedQuests() {
|
||||
PlayerQuestData data = this.getData().questData;
|
||||
List<IQuest> quests = new ArrayList();
|
||||
|
||||
@@ -1,143 +0,0 @@
|
||||
package noppes.npcs.scripted.roles;
|
||||
|
||||
import noppes.npcs.AnimationData;
|
||||
import noppes.npcs.api.handler.data.IModelPart;
|
||||
import noppes.npcs.api.jobs.IJobPuppet;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
|
||||
public class ScriptJobPuppet extends ScriptJobInterface implements IJobPuppet {
|
||||
private AnimationData job;
|
||||
public ScriptJobPuppet(EntityNPCInterface npc){
|
||||
super(npc);
|
||||
this.job = npc.display.animationData;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.job.allowAnimation = enabled;
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return this.job.allowAnimation;
|
||||
}
|
||||
|
||||
public IModelPart getPart(int part) {
|
||||
switch (part) {
|
||||
case 0:
|
||||
return job.head;
|
||||
case 1:
|
||||
return job.body;
|
||||
case 2:
|
||||
return job.larm;
|
||||
case 3:
|
||||
return job.rarm;
|
||||
case 4:
|
||||
return job.lleg;
|
||||
case 5:
|
||||
return job.rleg;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void allEnabled(boolean enabled) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this.getPart(i).setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void allAnimated(boolean animated) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this.getPart(i).setAnimated(animated);
|
||||
}
|
||||
}
|
||||
|
||||
public void allInterpolated(boolean interpolate) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this.getPart(i).setInterpolated(interpolate);
|
||||
}
|
||||
}
|
||||
|
||||
public void allFullAngles(boolean fullAngles) {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this.getPart(i).setFullAngles(fullAngles);
|
||||
}
|
||||
}
|
||||
|
||||
public void allAnimRate(float animRate) {
|
||||
if (animRate < 0)
|
||||
animRate = 0;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
this.getPart(i).setAnimRate(animRate);
|
||||
}
|
||||
}
|
||||
|
||||
public void doWhileStanding(boolean whileStanding) {
|
||||
this.job.whileStanding = whileStanding;
|
||||
}
|
||||
|
||||
public boolean doWhileStanding() {
|
||||
return this.job.whileStanding;
|
||||
}
|
||||
|
||||
public void doWhileAttacking(boolean whileAttacking) {
|
||||
this.job.whileAttacking = whileAttacking;
|
||||
}
|
||||
|
||||
public boolean doWhileAttacking() {
|
||||
return this.job.whileAttacking;
|
||||
}
|
||||
|
||||
public void doWhileMoving(boolean whileMoving) {
|
||||
this.job.whileMoving = whileMoving;
|
||||
}
|
||||
|
||||
public boolean doWhileMoving() {
|
||||
return this.job.whileMoving;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setRotationX(int part, float rotation) {
|
||||
this.getPart(part).setRotationX(rotation);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setRotationY(int part, float rotation) {
|
||||
this.getPart(part).setRotationY(rotation);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setRotationZ(int part, float rotation) {
|
||||
this.getPart(part).setRotationZ(rotation);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public float getRotationX(int part) {
|
||||
return this.getPart(part).getRotationX();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public float getRotationY(int part) {
|
||||
return this.getPart(part).getRotationY();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public float getRotationZ(int part) {
|
||||
return this.getPart(part).getRotationZ();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isEnabled(int part) {
|
||||
return this.getPart(part).isEnabled();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setEnabled(int part, boolean bo) {
|
||||
this.getPart(part).setEnabled(bo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(){
|
||||
return JobType.PUPPET;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user