mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 13:25:10 +00:00
Added get/setRotationType to ScriptNpc. Added get/setMotion for x, y, z components to ScriptEntity. Fixed an NPC wand crash.
This commit is contained in:
1 parent
e676c808e3
commit
e6f97784ff
6 files changed
+68
-27
No files matched your search
@@ -23,6 +23,7 @@ import noppes.npcs.scripted.ScriptWorld;
|
||||
import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.constants.JobType;
|
||||
import noppes.npcs.scripted.constants.RoleType;
|
||||
import noppes.npcs.scripted.interfaces.ICustomNpc;
|
||||
import noppes.npcs.scripted.interfaces.IWorld;
|
||||
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
|
||||
|
||||
@@ -36,7 +37,7 @@ public class DataScript implements IScriptHandler {
|
||||
private EntityNPCInterface npc;
|
||||
public boolean enabled = false;
|
||||
|
||||
public ScriptNpc dummyNpc;
|
||||
public ICustomNpc dummyNpc;
|
||||
public IWorld dummyWorld;
|
||||
public boolean clientNeedsUpdate = false;
|
||||
public boolean aiNeedsUpdate = false;
|
||||
@@ -48,8 +49,8 @@ public class DataScript implements IScriptHandler {
|
||||
}
|
||||
|
||||
this.npc = npc;
|
||||
if(npc instanceof EntityCustomNpc)
|
||||
dummyNpc = new ScriptNpc((EntityCustomNpc) npc);
|
||||
dummyNpc = new ScriptNpc<>(npc);
|
||||
|
||||
if(npc.worldObj instanceof WorldServer)
|
||||
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
|
||||
}
|
||||
|
||||
@@ -31,13 +31,7 @@ import noppes.npcs.LogWriter;
|
||||
import noppes.npcs.controllers.data.ForgeDataScript;
|
||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
import noppes.npcs.scripted.entity.ScriptAnimal;
|
||||
import noppes.npcs.scripted.entity.ScriptEntity;
|
||||
import noppes.npcs.scripted.entity.ScriptLiving;
|
||||
import noppes.npcs.scripted.entity.ScriptLivingBase;
|
||||
import noppes.npcs.scripted.entity.ScriptMonster;
|
||||
import noppes.npcs.scripted.entity.ScriptPixelmon;
|
||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
import noppes.npcs.scripted.entity.*;
|
||||
import noppes.npcs.scripted.ScriptWorld;
|
||||
import noppes.npcs.util.JsonException;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
@@ -256,7 +250,7 @@ public class ScriptController {
|
||||
if(entity == null)
|
||||
return null;
|
||||
if(entity instanceof EntityNPCInterface)
|
||||
return ((EntityNPCInterface) entity).script.dummyNpc;
|
||||
return (ScriptNpc)((EntityNPCInterface) entity).script.dummyNpc;
|
||||
else{
|
||||
ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject");
|
||||
if(data != null)
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
* @param x The entities x position
|
||||
*/
|
||||
public void setX(double x){
|
||||
entity.posX = x;
|
||||
entity.setPosition(x, entity.posY, entity.posZ);;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
* @param y The entities y position
|
||||
*/
|
||||
public void setY(double y){
|
||||
entity.posY = y;
|
||||
entity.setPosition(entity.posX, y, entity.posZ);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +129,52 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
* @param z The entities x position
|
||||
*/
|
||||
public void setZ(double z){
|
||||
entity.posZ = z;
|
||||
entity.setPosition(entity.posX, entity.posY, z);;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The entities z motion
|
||||
*/
|
||||
public double getMotionX(){
|
||||
return entity.motionX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param x The entities x motion
|
||||
*/
|
||||
public void setMotionX(double x){
|
||||
entity.motionX = x;
|
||||
entity.velocityChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The entities x motion
|
||||
*/
|
||||
public double getMotionY(){
|
||||
return entity.motionY;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param y The entities y motion
|
||||
*/
|
||||
public void setMotionY(double y){
|
||||
entity.motionY = y;
|
||||
entity.velocityChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The entities y motion
|
||||
*/
|
||||
public double getMotionZ(){
|
||||
return entity.motionZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param z The entities z motion
|
||||
*/
|
||||
public void setMotionZ(double z){
|
||||
entity.motionZ = z;
|
||||
entity.velocityChanged = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,10 +2,7 @@ package noppes.npcs.scripted.entity;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import noppes.npcs.NoppesUtilServer;
|
||||
import noppes.npcs.constants.EnumAnimation;
|
||||
import noppes.npcs.constants.EnumJobType;
|
||||
import noppes.npcs.constants.EnumNavType;
|
||||
import noppes.npcs.constants.EnumRoleType;
|
||||
import noppes.npcs.constants.*;
|
||||
import noppes.npcs.controllers.Line;
|
||||
import noppes.npcs.entity.EntityCustomNpc;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
@@ -90,6 +87,17 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
npc.ai.orientation = (int)rotation;
|
||||
super.setRotation(rotation);
|
||||
}
|
||||
public void setRotationType(int rotationType){
|
||||
for (EnumStandingType e : EnumStandingType.values()) {
|
||||
if (e.ordinal() == rotationType) {
|
||||
npc.ai.standingType = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int getRotationType(){
|
||||
return npc.ai.standingType.ordinal();
|
||||
}
|
||||
/**
|
||||
* @param name The name of the npc
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ public class ScriptJobFollower extends ScriptJobInterface{
|
||||
public ScriptNpc getFollowingNpc(){
|
||||
if(!isFollowing())
|
||||
return null;
|
||||
return job.following.script.dummyNpc;
|
||||
return (ScriptNpc)job.following.script.dummyNpc;
|
||||
}
|
||||
|
||||
public boolean isFollowing(){
|
||||
|
||||
@@ -59,17 +59,10 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
}
|
||||
|
||||
public IEntity getIEntity(Entity entity) {
|
||||
/*
|
||||
if (entity != null && !entity.worldObj.isRemote) {
|
||||
return (entity instanceof EntityNPCInterface ? ((EntityNPCInterface)entity).wrappedNPC : entity instanceof EntityPlayerMP ? getIPlayer((EntityPlayerMP) entity) : WrapperEntityData.get(entity));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
*/
|
||||
if(entity == null)
|
||||
return null;
|
||||
if(entity instanceof EntityNPCInterface)
|
||||
return ((EntityNPCInterface) entity).script.dummyNpc;
|
||||
return ((EntityNPCInterface)entity).wrappedNPC;
|
||||
else{
|
||||
ScriptEntityData data = (ScriptEntityData) entity.getExtendedProperties("ScriptedObject");
|
||||
if(data != null)
|
||||
|
||||
Reference in new issue
Block a user