mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 20:25:13 +00:00
More fixes to global NPC scripts not executing on servers, and added more functions to IEntityLivingBase.
This commit is contained in:
1 parent
8d52e9356c
commit
699b24e467
6 files changed
+51
-21
No files matched your search
@@ -256,8 +256,8 @@ public class DataAI {
|
||||
return npc.getDistanceSq(pos[0] + 0.5, pos[1], pos[2] + 0.5);
|
||||
}
|
||||
|
||||
public void setWalkingSpeed(int speed){
|
||||
this.moveSpeed = speed;
|
||||
public void setWalkingSpeed(double speed){
|
||||
this.moveSpeed = (int)speed;
|
||||
npc.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(npc.getSpeed());
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ public class DataStats {
|
||||
public float getAttackStrength(){
|
||||
return attackStrength;
|
||||
}
|
||||
public void setAttackStrength(float strength){
|
||||
public void setAttackStrength(double strength){
|
||||
attackStrength = (float)(Math.floor(strength));
|
||||
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,5 @@ public class GuiScriptAllNPCs extends GuiScriptInterface {
|
||||
|
||||
public void close() {
|
||||
super.close();
|
||||
ScriptController.Instance.npcScripts.errored.clear();
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,6 @@ public class NPCDataScript implements IScriptHandler {
|
||||
public long lastInited = -1L;
|
||||
public boolean enabled = false;
|
||||
private Map<Long, String> console = new TreeMap();
|
||||
public List<Integer> errored = new ArrayList();
|
||||
|
||||
public NPCDataScript(EntityNPCInterface npc) {
|
||||
if(npc != null) {
|
||||
@@ -34,7 +33,6 @@ public class NPCDataScript implements IScriptHandler {
|
||||
}
|
||||
public void clear() {
|
||||
this.console = new TreeMap();
|
||||
this.errored = new ArrayList();
|
||||
this.scripts = new ArrayList();
|
||||
}
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
@@ -71,20 +69,19 @@ public class NPCDataScript implements IScriptHandler {
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return CustomNpcs.GlobalNPCScripts && ScriptController.Instance.npcScripts.enabled && ScriptController.HasStart && (this.npc == null || !this.npc.worldObj.isRemote);
|
||||
return CustomNpcs.GlobalNPCScripts && this.enabled && ScriptController.HasStart && this.scripts.size() > 0;
|
||||
}
|
||||
public boolean isClient() {
|
||||
return this.npc.isClientWorld();
|
||||
}
|
||||
public boolean getEnabled() {
|
||||
return ScriptController.Instance.npcScripts.enabled;
|
||||
return this.enabled;
|
||||
}
|
||||
public void setEnabled(boolean bo) {
|
||||
ScriptController.Instance.npcScripts.enabled = bo;
|
||||
this.enabled = bo;
|
||||
}
|
||||
public String getLanguage() {
|
||||
return ScriptController.Instance.npcScripts.scriptLanguage;
|
||||
return this.scriptLanguage;
|
||||
}
|
||||
public void setLanguage(String lang) {
|
||||
this.scriptLanguage = lang;
|
||||
|
||||
@@ -53,13 +53,47 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
|
||||
public void hurt(float damage, IDamageSource damageSource) {
|
||||
entity.attackEntityFrom(damageSource.getMCDamageSource(),damage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Entity's max health
|
||||
*/
|
||||
|
||||
public double getMaxHealth(){
|
||||
return entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue();
|
||||
}
|
||||
|
||||
public double getFollowRange() {
|
||||
return entity.getEntityAttribute(SharedMonsterAttributes.followRange).getAttributeValue();
|
||||
}
|
||||
|
||||
public double getKnockbackResistance() {
|
||||
return entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).getAttributeValue();
|
||||
}
|
||||
|
||||
public double getSpeed() {
|
||||
return entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
|
||||
}
|
||||
|
||||
public double getMeleeStrength() {
|
||||
return entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue();
|
||||
}
|
||||
|
||||
public void setMaxHealth(double health){
|
||||
entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(health);
|
||||
}
|
||||
|
||||
public void setFollowRange(double range) {
|
||||
entity.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(range);
|
||||
}
|
||||
|
||||
public void setKnockbackResistance(double knockbackResistance) {
|
||||
entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(knockbackResistance);
|
||||
}
|
||||
|
||||
public void setSpeed(double speed) {
|
||||
entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(speed);
|
||||
}
|
||||
|
||||
public void setMeleeStrength(double attackDamage) {
|
||||
entity.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackDamage);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether or not this entity is attacking something
|
||||
*/
|
||||
|
||||
@@ -779,14 +779,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
/**
|
||||
* @return The melee strength
|
||||
*/
|
||||
public float getMeleeStrength(){
|
||||
public double getMeleeStrength(){
|
||||
return npc.stats.getAttackStrength();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param strength The melee strength
|
||||
*/
|
||||
public void setMeleeStrength(float strength){
|
||||
public void setMeleeStrength(double strength){
|
||||
npc.stats.setAttackStrength(strength);
|
||||
}
|
||||
|
||||
@@ -1007,14 +1007,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
/**
|
||||
* @param resistance Knockback resistance (0-2) default is 1
|
||||
*/
|
||||
public void setKnockbackResistance(float resistance){
|
||||
npc.stats.resistances.knockback = ValueUtil.correctFloat(resistance, 0, 2);
|
||||
public void setKnockbackResistance(double resistance){
|
||||
npc.stats.resistances.knockback = ValueUtil.correctFloat((float) resistance, 0, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns Knockback Resistance
|
||||
*/
|
||||
public float getKnockbackResistance(){
|
||||
public double getKnockbackResistance(){
|
||||
return npc.stats.resistances.knockback;
|
||||
}
|
||||
|
||||
@@ -1141,11 +1141,11 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
|
||||
return this.npc.ai.hasFlyLimit;
|
||||
}
|
||||
|
||||
public void setSpeed(int speed) {
|
||||
public void setSpeed(double speed) {
|
||||
npc.ai.setWalkingSpeed(speed);
|
||||
}
|
||||
|
||||
public int getSpeed() {
|
||||
public double getSpeed() {
|
||||
return npc.ai.getWalkingSpeed();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user