This commit is contained in:
KAMKEEL committed 2021-12-21 23:52:54 -05:00
commit efdd1d6679
73 files changed
+3830 -1158

No files matched your search

+1 -2
View File
@@ -17,7 +17,6 @@ buildscript {
apply plugin: 'forge'
version = "1.3.2"
group= "com.yourname.modid" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "CustomNPC-Plus"
@@ -65,4 +64,4 @@ processResources
}
}
sourceSets {main { output.resourcesDir = output.classesDir }}
sourceSets {main { output.resourcesDir = output.classesDir }}
+3 -1
View File
@@ -178,7 +178,9 @@ public class CustomNpcs {
ScriptPlayerEventHandler scriptPlayerEventHandler = new ScriptPlayerEventHandler();
MinecraftForge.EVENT_BUS.register(scriptPlayerEventHandler);
FMLCommonHandler.instance().bus().register(scriptPlayerEventHandler.registerForgeEvents());
FMLCommonHandler.instance().bus().register(scriptPlayerEventHandler);
FMLCommonHandler.instance().bus().register(new ScriptForgeEventHandler().registerForgeEvents());
FMLCommonHandler.instance().bus().register(new ServerTickHandler());
registerNpc(EntityNPCHumanMale.class, "npchumanmale");
+17 -2
View File
@@ -35,6 +35,8 @@ public class DataAI {
// Fly Change
public int movementType = 0;
public double flySpeed = 1.0D;
public double flyGravity = 0.0D;
public EnumAnimation animationType = EnumAnimation.NONE;
public EnumStandingType standingType = EnumStandingType.RotateBody;
@@ -96,8 +98,18 @@ public class DataAI {
setMovingPath(NBTTags.getIntegerArraySet(compound.getTagList("MovingPathNew",10)));
movingPos = compound.getInteger("MovingPos");
movingPattern = compound.getInteger("MovingPatern");
movementType = compound.getInteger("MovingType");
if(!compound.hasKey("FlySpeed"))
flySpeed = 1.0D;
else
flySpeed = compound.getDouble("FlySpeed");
if(!compound.hasKey("FlyGravity"))
flyGravity = 0.0D;
else
flyGravity = compound.getDouble("FlyGravity");
startPos = compound.getIntArray("StartPosNew");
if (startPos == null || startPos.length != 3){
startPos = new int[] {
@@ -143,8 +155,11 @@ public class DataAI {
compound.setTag("MovingPathNew", NBTTags.nbtIntegerArraySet(movingPath));
compound.setInteger("MovingPos", movingPos);
compound.setInteger("MovingPatern", movingPattern);
compound.setInteger("MovingType", movementType);
compound.setDouble("FlySpeed",flySpeed);
compound.setDouble("FlyGravity",flyGravity);
npc.setAvoidWater(avoidsWater);
compound.setIntArray("StartPosNew", npc.getStartPos());
+1 -1
View File
@@ -158,7 +158,7 @@ public class DataDisplay {
cloakTexture = nbttagcompound.getString("CloakTexture");
glowTexture = nbttagcompound.getString("GlowTexture");
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, 30);
modelSize = ValueUtil.CorrectInt(nbttagcompound.getInteger("Size"), 1, Integer.MAX_VALUE);
modelType = nbttagcompound.getInteger("modelType");
showName = nbttagcompound.getInteger("ShowName");
+90 -12
View File
@@ -1,10 +1,10 @@
package noppes.npcs;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
import javax.script.ScriptEngine;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
@@ -12,9 +12,11 @@ import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.event.ScriptEvent;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.ScriptWorld;
@@ -24,8 +26,8 @@ import noppes.npcs.scripted.constants.RoleType;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
public class DataScript {
public Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>();
public class DataScript implements IScriptHandler {
public List<ScriptContainer> scripts = new ArrayList();
private final static EntityType entities = new EntityType();
private final static JobType jobs = new JobType();
private final static RoleType roles = new RoleType();
@@ -41,11 +43,15 @@ public class DataScript {
public boolean hasInited = false;
public DataScript(EntityNPCInterface npc) {
for (int i = 0; i < 12; i++) {
scripts.add(new ScriptContainer(this));
}
this.npc = npc;
if(npc instanceof EntityCustomNpc)
dummyNpc = new ScriptNpc((EntityCustomNpc) npc);
if(npc.worldObj instanceof WorldServer)
dummyWorld = new ScriptWorld((WorldServer) npc.worldObj);
dummyWorld = NpcAPI.Instance().getIWorld((WorldServer) npc.worldObj);//new ScriptWorld((WorldServer) npc.worldObj);
}
public void readFromNBT(NBTTagCompound compound) {
@@ -61,21 +67,25 @@ public class DataScript {
return compound;
}
private Map<Integer,ScriptContainer> readScript(NBTTagList list){
Map<Integer,ScriptContainer> scripts = new HashMap<Integer,ScriptContainer>();
private List<ScriptContainer> readScript(NBTTagList list){
List<ScriptContainer> scripts = new ArrayList<>();
for (int i = 0; i < 12; i++) {
scripts.add(new ScriptContainer(this));
}
for(int i = 0; i < list.tagCount(); i++){
NBTTagCompound compoundd = list.getCompoundTagAt(i);
ScriptContainer script = new ScriptContainer();
ScriptContainer script = new ScriptContainer(this);
script.readFromNBT(compoundd);
if(script.hasCode() || npc.isRemote())
scripts.put(compoundd.getInteger("Type"), script);
if(script.hasCode() || npc.isRemote())
scripts.set(compoundd.getInteger("Type"), script);
}
return scripts;
}
private NBTTagList writeScript(Map<Integer,ScriptContainer> scripts){
private NBTTagList writeScript(List<ScriptContainer> scripts){
NBTTagList list = new NBTTagList();
for(Integer type : scripts.keySet()){
for(int type = 0; type < scripts.size(); type++){
NBTTagCompound compoundd = new NBTTagCompound();
compoundd.setInteger("Type", type);
ScriptContainer script = scripts.get(type);
@@ -144,6 +154,74 @@ public class DataScript {
return enabled && ScriptController.HasStart && !npc.worldObj.isRemote && !scripts.isEmpty();
}
public void callScript(EnumScriptType var1, Event var2, Object... obs) {
}
public Map<Long, String> getConsoleText() {
Map<Long, String> map = new TreeMap();
int tab = 0;
Iterator var3 = this.getScripts().iterator();
while(var3.hasNext()) {
ScriptContainer script = (ScriptContainer)var3.next();
++tab;
Iterator var5 = script.console.entrySet().iterator();
while(var5.hasNext()) {
Map.Entry<Long, String> entry = (Map.Entry)var5.next();
map.put(entry.getKey(), " tab " + tab + ":\n" + (String)entry.getValue());
}
}
return map;
}
public void clearConsole() {
Iterator var1 = this.getScripts().iterator();
while(var1.hasNext()) {
ScriptContainer script = (ScriptContainer)var1.next();
script.console.clear();
}
}
@Override
public void callScript(EnumScriptType var1, Event var2) {
}
public boolean isClient() {
return this.npc.isRemote();
}
public boolean getEnabled() {
return this.enabled;
}
public void setEnabled(boolean bo) {
this.enabled = bo;
}
public String getLanguage() {
return this.scriptLanguage;
}
public void setLanguage(String lang) {
this.scriptLanguage = lang;
}
public List<ScriptContainer> getScripts() {
return this.scripts;
}
public String noticeString() {
//BlockPos pos = this.npc.func_180425_c();
//return MoreObjects.toStringHelper(this.npc).add("x", pos.func_177958_n()).add("y", pos.func_177956_o()).add("z", pos.func_177952_p()).toString();
return "";
}
public void setWorld(World world) {
if(world instanceof WorldServer)
dummyWorld = new ScriptWorld((WorldServer) world);
+25 -21
View File
@@ -8,9 +8,12 @@ import noppes.npcs.constants.EnumPotionType;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.util.ValueUtil;
import java.math.RoundingMode;
import java.text.DecimalFormat;
public class DataStats {
private int attackStrength = 5;
private float attackStrength = 5;
public int attackSpeed = 20, attackRange = 2, knockback = 0;
public int minDelay = 20, maxDelay = 40, rangedRange = 15, fireRate = 5, burstCount = 1, shotCount = 1, accuracy = 60;
public int aggroRange = 16;
@@ -19,7 +22,7 @@ public class DataStats {
public int potionDuration = 5; //20 = 1 second
public int potionAmp = 0;
public int maxHealth = 20;
public double maxHealth = 20;
public int respawnTime = 20;
public int spawnCycle = 0;
public boolean hideKilledBody = false;
@@ -32,10 +35,11 @@ public class DataStats {
public boolean canDrown = true;
public boolean burnInSun = false;
public boolean noFallDamage = false;
public int healthRegen = 1;
public int combatRegen = 0;
public int pDamage = 4, pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
public float healthRegen = 1;
public float combatRegen = 0;
public float pDamage = 4;
public int pImpact = 0, pSize = 5, pSpeed = 10, pArea = 0, pDur = 5;
public boolean pPhysics = true, pXlr8 = false, pGlows = false, pExplode = false;
public boolean pRender3D = false, pSpin = false, pStick = false;
public EnumPotionType pEffect = EnumPotionType.None;
@@ -55,16 +59,16 @@ public class DataStats {
public NBTTagCompound writeToNBT(NBTTagCompound compound)
{
compound.setTag("Resistances", resistances.writeToNBT());
compound.setInteger("MaxHealth", maxHealth);
compound.setDouble("MaxHealth", maxHealth);
compound.setInteger("AggroRange", aggroRange);
compound.setBoolean("HideBodyWhenKilled", hideKilledBody);
compound.setInteger("RespawnTime", respawnTime);
compound.setInteger("SpawnCycle", spawnCycle);
compound.setInteger("CreatureType", creatureType.ordinal());
compound.setInteger("HealthRegen", healthRegen);
compound.setInteger("CombatRegen", combatRegen);
compound.setFloat("HealthRegen", healthRegen);
compound.setFloat("CombatRegen", combatRegen);
compound.setInteger("AttackStrenght", attackStrength);
compound.setFloat("AttackStrenght", attackStrength);
compound.setInteger("AttackRange", attackRange);
compound.setInteger("AttackSpeed", attackSpeed);
compound.setInteger("KnockBack", knockback);
@@ -80,7 +84,7 @@ public class DataStats {
compound.setInteger("ShotCount", shotCount);
compound.setInteger("Accuracy", accuracy);
compound.setInteger("pDamage", pDamage);
compound.setFloat("pDamage", pDamage);
compound.setInteger("pImpact", pImpact);
compound.setInteger("pSize", pSize);
compound.setInteger("pSpeed", pSpeed);
@@ -113,16 +117,16 @@ public class DataStats {
public void readToNBT(NBTTagCompound compound)
{
resistances.readToNBT(compound.getCompoundTag("Resistances"));
setMaxHealth(compound.getInteger("MaxHealth"));
setMaxHealth(compound.getDouble("MaxHealth"));
hideKilledBody = compound.getBoolean("HideBodyWhenKilled");
aggroRange = compound.getInteger("AggroRange");
respawnTime = compound.getInteger("RespawnTime");
spawnCycle = compound.getInteger("SpawnCycle");
creatureType = EnumCreatureAttribute.values()[compound.getInteger("CreatureType") % EnumPotionType.values().length];
healthRegen = compound.getInteger("HealthRegen");
combatRegen = compound.getInteger("CombatRegen");
healthRegen = compound.getFloat("HealthRegen");
combatRegen = compound.getFloat("CombatRegen");
setAttackStrength(compound.getInteger("AttackStrenght"));
setAttackStrength(compound.getFloat("AttackStrenght"));
attackSpeed = compound.getInteger("AttackSpeed");
attackRange = compound.getInteger("AttackRange");
knockback = compound.getInteger("KnockBack");
@@ -138,7 +142,7 @@ public class DataStats {
shotCount = ValueUtil.CorrectInt(compound.getInteger("ShotCount"), 1, 10);
accuracy = compound.getInteger("Accuracy");
pDamage = compound.getInteger("pDamage");
pDamage = compound.getFloat("pDamage");
pImpact = compound.getInteger("pImpact");
pSize = compound.getInteger("pSize");
pSpeed = compound.getInteger("pSpeed");
@@ -168,16 +172,16 @@ public class DataStats {
npc.setImmuneToFire(immuneToFire);
}
public int getAttackStrength(){
public float getAttackStrength(){
return attackStrength;
}
public void setAttackStrength(int strength){
attackStrength = strength;
public void setAttackStrength(float strength){
attackStrength = (float)(Math.floor(strength));
npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength);
}
public void setMaxHealth(int maxHealth) {
this.maxHealth = maxHealth;
public void setMaxHealth(double maxHealth) {
this.maxHealth = Math.floor(maxHealth);
npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth);
}
}
+98 -97
View File
@@ -23,6 +23,7 @@ import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.*;
import noppes.npcs.scripted.event.PlayerEvent.ChatEvent;
import noppes.npcs.scripted.event.PlayerEvent.ContainerOpen;
@@ -53,224 +54,224 @@ public class EventHooks {
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerInit(PlayerDataScript handler) {
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(handler.getPlayer());
handler.callScript(EnumScriptType.INIT, event, "event", event);
public static void onPlayerInit(PlayerDataScript handler, ScriptPlayer player) {
noppes.npcs.scripted.event.PlayerEvent.InitEvent event = new noppes.npcs.scripted.event.PlayerEvent.InitEvent(player);
handler.callScript(EnumScriptType.INIT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTick(PlayerDataScript handler) {
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(handler.getPlayer());
handler.callScript(EnumScriptType.TICK, event, "event", event);
public static void onPlayerTick(PlayerDataScript handler, ScriptPlayer player) {
noppes.npcs.scripted.event.PlayerEvent.UpdateEvent event = new noppes.npcs.scripted.event.PlayerEvent.UpdateEvent(player);
handler.callScript(EnumScriptType.TICK, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerInteract(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.InteractEvent event) {
handler.callScript(EnumScriptType.INTERACT, event,"event", event);
handler.callScript(EnumScriptType.INTERACT, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onStartUsingItem(PlayerDataScript handler, int duration, ItemStack item){
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(handler.getPlayer(), item, duration);
handler.callScript(EnumScriptType.START_USING_ITEM, event,"event", event);
public static boolean onStartUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
PlayerEvent.StartUsingItem event = new PlayerEvent.StartUsingItem(player, item, duration);
handler.callScript(EnumScriptType.START_USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onUsingItem(PlayerDataScript handler, int duration, ItemStack item){
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(handler.getPlayer(), item, duration);
handler.callScript(EnumScriptType.USING_ITEM, event,"event", event);
public static boolean onUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
PlayerEvent.UsingItem event = new PlayerEvent.UsingItem(player, item, duration);
handler.callScript(EnumScriptType.USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onStopUsingItem(PlayerDataScript handler, int duration, ItemStack item){
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(handler.getPlayer(), item, duration);
handler.callScript(EnumScriptType.STOP_USING_ITEM, event,"event", event);
public static boolean onStopUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
PlayerEvent.StopUsingItem event = new PlayerEvent.StopUsingItem(player, item, duration);
handler.callScript(EnumScriptType.STOP_USING_ITEM, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onFinishUsingItem(PlayerDataScript handler, int duration, ItemStack item){
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(handler.getPlayer(), item, duration);
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event,"event", event);
public static void onFinishUsingItem(PlayerDataScript handler, ScriptPlayer player, int duration, ItemStack item){
PlayerEvent.FinishUsingItem event = new PlayerEvent.FinishUsingItem(player, item, duration);
handler.callScript(EnumScriptType.FINISH_USING_ITEM, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDropItems(PlayerDataScript handler, ArrayList<EntityItem> entityItems) {
public static boolean onPlayerDropItems(PlayerDataScript handler, ScriptPlayer player, ArrayList<EntityItem> entityItems) {
IItemStack[] items = new IItemStack[entityItems.size()];
for(int i = 0; i < entityItems.size(); i++){ items[i] = NpcAPI.Instance().getIItemStack(entityItems.get(i).getEntityItem()); }
DropEvent event = new DropEvent(handler.getPlayer(), items);
handler.callScript(EnumScriptType.DROP, event,"event", event);
DropEvent event = new DropEvent(player, items);
handler.callScript(EnumScriptType.DROP, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerPickupXP(PlayerDataScript handler, EntityXPOrb orb) {
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(handler.getPlayer(), orb);
handler.callScript(EnumScriptType.PICKUP_XP, event,"event", event);
public static void onPlayerPickupXP(PlayerDataScript handler, ScriptPlayer player, EntityXPOrb orb) {
PlayerEvent.PickupXPEvent event = new PlayerEvent.PickupXPEvent(player, orb);
handler.callScript(EnumScriptType.PICKUP_XP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerToss(PlayerDataScript handler, EntityItem entityItem) {
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(handler.getPlayer(), NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.TOSS, event,"event", event);
public static boolean onPlayerToss(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
PlayerEvent.TossEvent event = new PlayerEvent.TossEvent(player, NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.TOSS, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerPickUp(PlayerDataScript handler, EntityItem entityItem) {
PickUpEvent event = new PickUpEvent(handler.getPlayer(), new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.PICKUP, event,"event", event);
public static boolean onPlayerPickUp(PlayerDataScript handler, ScriptPlayer player, EntityItem entityItem) {
PickUpEvent event = new PickUpEvent(player, new ScriptItemStack(entityItem.getEntityItem()));//NpcAPI.Instance().getIItemStack(entityItem.getEntityItem()));
handler.callScript(EnumScriptType.PICKUP, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerContainerOpen(PlayerDataScript handler, Container container) {
ContainerOpen event = new ContainerOpen(handler.getPlayer(), NpcAPI.Instance().getIContainer(container));
handler.callScript(EnumScriptType.CONTAINER_OPEN, event,"event", event);
public static void onPlayerContainerOpen(PlayerDataScript handler, ScriptPlayer player, Container container) {
ContainerOpen event = new ContainerOpen(player, NpcAPI.Instance().getIContainer(container));
handler.callScript(EnumScriptType.CONTAINER_OPEN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerUseHoe(PlayerDataScript handler, ItemStack hoe, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(handler.getPlayer(), hoe, x, y, z);
handler.callScript(EnumScriptType.USE_HOE, event,"event", event);
public static void onPlayerUseHoe(PlayerDataScript handler, ScriptPlayer player, ItemStack hoe, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.UseHoe event = new noppes.npcs.scripted.event.PlayerEvent.UseHoe(player, hoe, x, y, z);
handler.callScript(EnumScriptType.USE_HOE, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerSleep(PlayerDataScript handler, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(handler.getPlayer(), x, y, z);
handler.callScript(EnumScriptType.SLEEP, event,"event", event);
public static void onPlayerSleep(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z) {
noppes.npcs.scripted.event.PlayerEvent.Sleep event = new noppes.npcs.scripted.event.PlayerEvent.Sleep(player, x, y, z);
handler.callScript(EnumScriptType.SLEEP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerWakeUp(PlayerDataScript handler, boolean setSpawn) {
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(handler.getPlayer(), setSpawn);
handler.callScript(EnumScriptType.WAKE_UP, event,"event", event);
public static void onPlayerWakeUp(PlayerDataScript handler, ScriptPlayer player, boolean setSpawn) {
noppes.npcs.scripted.event.PlayerEvent.WakeUp event = new noppes.npcs.scripted.event.PlayerEvent.WakeUp(player, setSpawn);
handler.callScript(EnumScriptType.WAKE_UP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerDeath(PlayerDataScript handler, DamageSource source, Entity entity) {
noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(handler.getPlayer(), source, entity);
handler.callScript(EnumScriptType.KILLED, event,"event", event);
public static void onPlayerDeath(PlayerDataScript handler, ScriptPlayer player, DamageSource source, Entity entity) {
noppes.npcs.scripted.event.PlayerEvent.DiedEvent event = new noppes.npcs.scripted.event.PlayerEvent.DiedEvent(player, source, entity);
handler.callScript(EnumScriptType.KILLED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKills(PlayerDataScript handler, EntityLivingBase entityLiving) {
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(handler.getPlayer(), entityLiving);
handler.callScript(EnumScriptType.KILLS, event,"event", event);
public static void onPlayerKills(PlayerDataScript handler, ScriptPlayer player, EntityLivingBase entityLiving) {
noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent event = new noppes.npcs.scripted.event.PlayerEvent.KilledEntityEvent(player, entityLiving);
handler.callScript(EnumScriptType.KILLS, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDamaged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.DamagedEvent event) {
handler.callScript(EnumScriptType.DAMAGED, event,"event", event);
handler.callScript(EnumScriptType.DAMAGED, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerLightning(PlayerDataScript handler) {
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(handler.getPlayer());
handler.callScript(EnumScriptType.LIGHTNING, event, "event", event);
public static boolean onPlayerLightning(PlayerDataScript handler, ScriptPlayer player) {
PlayerEvent.LightningEvent event = new PlayerEvent.LightningEvent(player);
handler.callScript(EnumScriptType.LIGHTNING, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerSound(PlayerDataScript handler, String name, float pitch, float volume) {
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(handler.getPlayer(), name, pitch, volume);
handler.callScript(EnumScriptType.PLAYSOUND, event,"event", event);
public static boolean onPlayerSound(PlayerDataScript handler, ScriptPlayer player, String name, float pitch, float volume) {
PlayerEvent.SoundEvent event = new PlayerEvent.SoundEvent(player, name, pitch, volume);
handler.callScript(EnumScriptType.PLAYSOUND, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerFall(PlayerDataScript handler, float distance) {
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(handler.getPlayer(),distance);
handler.callScript(EnumScriptType.FALL, event,"event", event);
public static void onPlayerFall(PlayerDataScript handler, ScriptPlayer player, float distance) {
PlayerEvent.FallEvent event = new PlayerEvent.FallEvent(player,distance);
handler.callScript(EnumScriptType.FALL, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerJump(PlayerDataScript handler) {
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(handler.getPlayer());
handler.callScript(EnumScriptType.JUMP, event,"event", event);
public static void onPlayerJump(PlayerDataScript handler, ScriptPlayer player) {
PlayerEvent.JumpEvent event = new PlayerEvent.JumpEvent(player);
handler.callScript(EnumScriptType.JUMP, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerLogin(PlayerDataScript handler) {
LoginEvent event = new LoginEvent(handler.getPlayer());
handler.callScript(EnumScriptType.LOGIN, event, "event", event);
public static void onPlayerLogin(PlayerDataScript handler, ScriptPlayer player) {
LoginEvent event = new LoginEvent(player);
handler.callScript(EnumScriptType.LOGIN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerAchievement(PlayerDataScript handler, String description) {
PlayerEvent.Achievement event = new PlayerEvent.Achievement(handler.getPlayer(), description);
handler.callScript(EnumScriptType.ACHIEVEMENT, event, "event", event);
public static void onPlayerAchievement(PlayerDataScript handler, ScriptPlayer player, String description) {
PlayerEvent.Achievement event = new PlayerEvent.Achievement(player, description);
handler.callScript(EnumScriptType.ACHIEVEMENT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerFillBucket(PlayerDataScript handler, ItemStack current, ItemStack result) {
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(handler.getPlayer(), current, result);
handler.callScript(EnumScriptType.FILL_BUCKET, event, "event", event);
public static void onPlayerFillBucket(PlayerDataScript handler, ScriptPlayer player, ItemStack current, ItemStack result) {
PlayerEvent.FillBucket event = new PlayerEvent.FillBucket(player, current, result);
handler.callScript(EnumScriptType.FILL_BUCKET, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerBonemeal(PlayerDataScript handler, int x, int y, int z, World world) {
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(handler.getPlayer(), x, y, z, world);
handler.callScript(EnumScriptType.BONEMEAL, event, "event", event);
public static void onPlayerBonemeal(PlayerDataScript handler, ScriptPlayer player, int x, int y, int z, World world) {
PlayerEvent.Bonemeal event = new PlayerEvent.Bonemeal(player, x, y, z, world);
handler.callScript(EnumScriptType.BONEMEAL, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerRespawn(PlayerDataScript handler) {
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(handler.getPlayer());
handler.callScript(EnumScriptType.RESPAWN, event, "event", event);
public static void onPlayerRespawn(PlayerDataScript handler, ScriptPlayer player) {
PlayerEvent.RespawnEvent event = new PlayerEvent.RespawnEvent(player);
handler.callScript(EnumScriptType.RESPAWN, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerLogout(PlayerDataScript handler) {
LogoutEvent event = new LogoutEvent(handler.getPlayer());
handler.callScript(EnumScriptType.LOGOUT, event, "event", event);
public static void onPlayerLogout(PlayerDataScript handler, ScriptPlayer player) {
LogoutEvent event = new LogoutEvent(player);
handler.callScript(EnumScriptType.LOGOUT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerChat(PlayerDataScript handler, ChatEvent event) {
handler.callScript(EnumScriptType.CHAT, event,"event", event);
handler.callScript(EnumScriptType.CHAT, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerBowCharge(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent event) {
handler.callScript(EnumScriptType.RANGED_CHARGE, event,"event", event);
handler.callScript(EnumScriptType.RANGED_CHARGE, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerRanged(PlayerDataScript handler, noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent event) {
handler.callScript(EnumScriptType.RANGED_LAUNCHED, event,"event", event);
handler.callScript(EnumScriptType.RANGED_LAUNCHED, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerDamagedEntity(PlayerDataScript handler, DamagedEntityEvent event) {
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event,"event", event);
handler.callScript(EnumScriptType.DAMAGED_ENTITY, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerChangeDim(PlayerDataScript handler, int fromDim, int toDim) {
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(handler.getPlayer(), fromDim, toDim);
handler.callScript(EnumScriptType.CHANGED_DIM, event,"event", event);
public static void onPlayerChangeDim(PlayerDataScript handler, ScriptPlayer player, int fromDim, int toDim) {
PlayerEvent.ChangedDimension event = new PlayerEvent.ChangedDimension(player, fromDim, toDim);
handler.callScript(EnumScriptType.CHANGED_DIM, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerMouseClicked(EntityPlayerMP player, int button, int mouseWheel, boolean buttonDown) {
PlayerDataScript handler = PlayerData.get(player).scriptData;
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent(handler.getPlayer(), button, mouseWheel, buttonDown);
handler.callScript(EnumScriptType.MOUSE_CLICKED, event,"event", event);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
PlayerEvent.MouseClickedEvent event = new PlayerEvent.MouseClickedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, mouseWheel, buttonDown);
handler.callScript(EnumScriptType.MOUSE_CLICKED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerKeyPressed(EntityPlayerMP player, int button, boolean isCtrlPressed, boolean isShiftPressed, boolean isAltPressed, boolean isMetaPressed, boolean buttonDown) {
PlayerDataScript handler = PlayerData.get(player).scriptData;
KeyPressedEvent event = new KeyPressedEvent(handler.getPlayer(), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown);
handler.callScript(EnumScriptType.KEY_PRESSED, event,"event", event);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
KeyPressedEvent event = new KeyPressedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(player), button, isCtrlPressed, isAltPressed, isShiftPressed, isMetaPressed, buttonDown);
handler.callScript(EnumScriptType.KEY_PRESSED, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static void onPlayerTimer(PlayerData data, int id) {
PlayerDataScript handler = data.scriptData;
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent(handler.getPlayer(), id);
handler.callScript(EnumScriptType.TIMER, event,"event", event);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
noppes.npcs.scripted.event.PlayerEvent.TimerEvent event = new noppes.npcs.scripted.event.PlayerEvent.TimerEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity(data.player), id);
handler.callScript(EnumScriptType.TIMER, event);
WrapperNpcAPI.EVENT_BUS.post(event);
}
public static boolean onPlayerBreak(PlayerDataScript handler, PlayerEvent.BreakEvent event) {
handler.callScript(EnumScriptType.BREAK_BLOCK, event,"event", event);
handler.callScript(EnumScriptType.BREAK_BLOCK, event);
return WrapperNpcAPI.EVENT_BUS.post(event);
}
@@ -1,172 +0,0 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package noppes.npcs;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
public class EventScriptContainer {
public static EventScriptContainer Current;
//public String type = "init";
private static String CurrentType;
public String fullscript = "";
public String script = "";
public TreeMap<Long, String> console = new TreeMap();
private HashSet<String> unknownFunctions = new HashSet();
public boolean errored = false;
public List<String> scripts = new ArrayList();
public long lastCreated = 0L;
private String currentScriptLanguage = null;
public ScriptEngine engine = null;
private IScriptHandler handler = null;
private CompiledScript compScript = null;
private boolean init = false;
public EventScriptContainer(IScriptHandler handler) {
this.handler = handler;
}
public void readFromNBT(NBTTagCompound compound) {
this.script = compound.getString("Script");
//this.type = compound.getString("Type");
this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10));
this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
this.lastCreated = 0L;
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setString("Script", this.script);
//compound.setString("Type", this.type);
compound.setTag("Console", NBTTags.NBTLongStringMap(this.console));
compound.setTag("ScriptList", NBTTags.nbtStringList(this.scripts));
return compound;
}
private String getFullCode() {
if(!this.init) {
this.fullscript = this.script;
if(!this.fullscript.isEmpty()) {
this.fullscript = this.fullscript + "\n";
}
Iterator var1 = this.scripts.iterator();
while(var1.hasNext()) {
String loc = (String)var1.next();
String code = (String)ScriptController.Instance.scripts.get(loc);
if(code != null && !code.isEmpty()) {
this.fullscript = this.fullscript + code + "\n";
}
}
}
return this.fullscript;
}
/*public void run(ScriptEngine engine){
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
engine.getContext().setWriter(pw);
engine.getContext().setErrorWriter(pw);
try {
if(compScript == null && engine instanceof Compilable)
compScript = ((Compilable)engine).compile(getFullCode());
if(compScript != null){
compScript.eval(engine.getContext());
}
else
engine.eval(getFullCode());
} catch (Exception e) {
errored = true;
appandConsole(e.getMessage());
}
appandConsole(sw.getBuffer().toString().trim());
}*/
public void run(EnumScriptType type, Event event) {
this.run((String)type.function, (Object)event);
}
public void run(String type, Object event) {
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
this.setEngine(this.handler.getLanguage());
if (this.engine != null) {
if (ScriptController.Instance.lastLoaded > this.lastCreated) {
this.lastCreated = ScriptController.Instance.lastLoaded;
this.init = false;
}
String var3 = "lock";
synchronized("lock") {
Current = this;
CurrentType = type;
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
this.engine.getContext().setWriter(pw);
this.engine.getContext().setErrorWriter(pw);
try {
if (!this.init) {
this.engine.eval(this.getFullCode());
this.init = true;
}
((Invocable)this.engine).invokeFunction(type, new Object[]{event});
} catch (NoSuchMethodException var13) {
this.unknownFunctions.add(type);
} catch (Throwable var14) {
this.errored = true;
var14.printStackTrace(pw);
} finally {
this.appandConsole(sw.getBuffer().toString().trim());
pw.close();
Current = null;
}
}
}
}
}
public void appandConsole(String message) {
if (message != null && !message.isEmpty()) {
long time = System.currentTimeMillis();
if (this.console.containsKey(time)) {
message = (String)this.console.get(time) + "\n" + message;
}
this.console.put(time, message);
while(this.console.size() > 40) {
this.console.remove(this.console.firstKey());
}
}
}
public boolean hasCode() {
return !this.getFullCode().isEmpty();
}
public void setEngine(String scriptLanguage) {
if(currentScriptLanguage != null && currentScriptLanguage.equals(scriptLanguage))
return;
engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
currentScriptLanguage = scriptLanguage;
}
}
+5 -4
View File
@@ -7,6 +7,7 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.IScriptHandler;
public class NBTTags {
@@ -408,12 +409,12 @@ public class NBTTags {
}
}
public static List<EventScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
public static List<ScriptContainer> GetScript(NBTTagList list, IScriptHandler handler) {
ArrayList scripts = new ArrayList();
for(int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound compoundd = list.getCompoundTagAt(i);
EventScriptContainer script = new EventScriptContainer(handler);
ScriptContainer script = new ScriptContainer(handler);
script.readFromNBT(compoundd);
scripts.add(script);
}
@@ -421,12 +422,12 @@ public class NBTTags {
return scripts;
}
public static NBTTagList NBTScript(List<EventScriptContainer> scripts) {
public static NBTTagList NBTScript(List<ScriptContainer> scripts) {
NBTTagList list = new NBTTagList();
Iterator var2 = scripts.iterator();
while(var2.hasNext()) {
EventScriptContainer script = (EventScriptContainer)var2.next();
ScriptContainer script = (ScriptContainer)var2.next();
NBTTagCompound compound = new NBTTagCompound();
script.writeToNBT(compound);
list.appendTag(compound);
@@ -0,0 +1,126 @@
package noppes.npcs;
import com.google.common.reflect.ClassPath;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.world.WorldServer;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.event.ForgeEvent;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Vector;
public class ScriptForgeEventHandler {
public ScriptForgeEventHandler() {
}
@SubscribeEvent
public void forgeEntity(Event event) {
if(CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
if(event instanceof TickEvent && !(((TickEvent)event).side == Side.SERVER && ((TickEvent)event).phase == TickEvent.Phase.START)) {
return;
}
if(event instanceof EntityEvent) {
EntityEvent ev2 = (EntityEvent)event;
if(ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) {
EventHooks.onForgeEntityEvent(ev2);
}
} else if(event instanceof WorldEvent) {
WorldEvent ev1 = (WorldEvent)event;
if(ev1.world instanceof WorldServer) {
EventHooks.onForgeWorldEvent(ev1);
}
} else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) {
if (event instanceof PlayerEvent) {
PlayerEvent ev = (PlayerEvent) event;
if (!(ev.player.worldObj instanceof WorldServer)) {
return;
}
}
EventHooks.onForgeEvent(new ForgeEvent(event), event);
}
}
}
public ScriptForgeEventHandler registerForgeEvents() {
try {
Method e = this.getClass().getMethod("forgeEntity", new Class[]{Event.class});
Method register = FMLCommonHandler.instance().bus().getClass().getDeclaredMethod("register", new Class[]{Class.class, Object.class, Method.class, ModContainer.class});
register.setAccessible(true);
ArrayList list = new ArrayList();
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
Iterator e1 = list.iterator();
while(true) {
ClassPath.ClassInfo classLoader;
String classes;
do {
if(!e1.hasNext()) {
if(PixelmonHelper.Enabled) {
try {
Field e2 = ClassLoader.class.getDeclaredField("classes");
e2.setAccessible(true);
ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader();
ArrayList classes1 = new ArrayList((Vector)e2.get(classLoader1));
Iterator infoClass1 = classes1.iterator();
while(infoClass1.hasNext()) {
Class c2 = (Class)infoClass1.next();
}
} catch (Exception var12) {
var12.printStackTrace();
}
return this;
}
return this;
}
classLoader = (ClassPath.ClassInfo)e1.next();
classes = classLoader.getName();
} while(classes.startsWith("net.minecraftforge.event.terraingen"));
Class infoClass = classLoader.load();
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
if(c.isEmpty()) {
c.add(infoClass);
}
Iterator var10 = c.iterator();
while(var10.hasNext()) {
Class c1 = (Class)var10.next();
if(!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, this, e, Loader.instance().activeModContainer()});
}
}
}
} catch (Exception var13) {
var13.printStackTrace();
return this;
}
}
}
@@ -28,6 +28,7 @@ import cpw.mods.fml.common.network.FMLNetworkEvent;
import cpw.mods.fml.relauncher.Side;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
@@ -43,14 +44,14 @@ import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.living.LivingFallEvent;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.event.world.*;
import net.minecraftforge.event.world.WorldEvent.PotentialSpawns;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.data.PlayerDataScript;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.ForgeEvent;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.ScriptController;
@@ -63,12 +64,16 @@ public class ScriptPlayerEventHandler {
public void onServerTick(TickEvent.PlayerTickEvent event) {
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
EntityPlayer player = event.player;
PlayerData data = PlayerData.get(player);
EventHooks.onPlayerTick(data.scriptData);
if(player.ticksExisted%10 == 0) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(player);
EventHooks.onPlayerTick(handler, scriptPlayer);
}
if(PlayerDataController.instance != null) {
PlayerDataController.instance.getPlayerData(player).scriptData = data.scriptData;
PlayerDataController.instance.getPlayerData(player).timers.update();
if(PlayerDataController.instance.getPlayerData(player).timers.size() > 0)
PlayerDataController.instance.getPlayerData(player).timers.update();
}
}
}
@@ -76,8 +81,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(EntityInteractEvent event) {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(handler.getPlayer(), 1, NpcAPI.Instance().getIEntity(event.target));
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.InteractEvent ev = new noppes.npcs.scripted.event.PlayerEvent.InteractEvent(scriptPlayer, 1, NpcAPI.Instance().getIEntity(event.target));
event.setCanceled(EventHooks.onPlayerInteract(handler, ev));
}
}
@@ -85,8 +91,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(ArrowNockEvent event) {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(handler.getPlayer());
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedChargeEvent(scriptPlayer);
EventHooks.onPlayerBowCharge(handler, ev);
}
}
@@ -94,8 +101,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(ArrowLooseEvent event) {
if(!event.entityPlayer.worldObj.isRemote && event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(handler.getPlayer(), event.bow, event.charge);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent ev = new noppes.npcs.scripted.event.PlayerEvent.RangedLaunchedEvent(scriptPlayer, event.bow, event.charge);
EventHooks.onPlayerRanged(handler, ev);
}
}
@@ -103,8 +111,9 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(BlockEvent.BreakEvent event) {
if(!event.getPlayer().worldObj.isRemote && event.world instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.getPlayer()).scriptData;
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(handler.getPlayer(), NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop());
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.getPlayer());
noppes.npcs.scripted.event.PlayerEvent.BreakEvent ev = new noppes.npcs.scripted.event.PlayerEvent.BreakEvent(scriptPlayer, NpcAPI.Instance().getIBlock(event.world, new BlockPos(event.x,event.y,event.z)), event.getExpToDrop());
event.setCanceled(EventHooks.onPlayerBreak(handler, ev));
event.setExpToDrop(ev.exp);
}
@@ -113,135 +122,151 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Start event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
event.setCanceled(EventHooks.onStartUsingItem(handler, event.duration, event.item));
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStartUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Tick event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
event.setCanceled(EventHooks.onUsingItem(handler, event.duration, event.item));
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Stop event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
event.setCanceled(EventHooks.onStopUsingItem(handler, event.duration, event.item));
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onStopUsingItem(handler, scriptPlayer, event.duration, event.item));
}
}
@SubscribeEvent
public void invoke(PlayerUseItemEvent.Finish event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onFinishUsingItem(handler, event.duration, event.item);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onFinishUsingItem(handler, scriptPlayer, event.duration, event.item);
}
}
@SubscribeEvent
public void invoke(PlayerDropsEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
event.setCanceled(EventHooks.onPlayerDropItems(handler, event.drops));
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
event.setCanceled(EventHooks.onPlayerDropItems(handler, scriptPlayer, event.drops));
}
}
@SubscribeEvent
public void invoke(PlayerPickupXpEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onPlayerPickupXP(handler, event.orb);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerPickupXP(handler, scriptPlayer, event.orb);
}
}
@SubscribeEvent
public void invoke(PlayerEvent.PlayerChangedDimensionEvent event) {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
EventHooks.onPlayerChangeDim(handler, event.fromDim, event.toDim);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerChangeDim(handler, scriptPlayer, event.fromDim, event.toDim);
}
}
@SubscribeEvent
public void invoke(PlayerEvent.ItemPickupEvent event) {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
EventHooks.onPlayerPickUp(handler, event.pickedUp);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerPickUp(handler, scriptPlayer, event.pickedUp);
}
}
@SubscribeEvent
public void invoke(PlayerOpenContainerEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onPlayerContainerOpen(handler, event.entityPlayer.openContainer);
if(event.entityPlayer.worldObj instanceof WorldServer && !(event.entityPlayer.openContainer instanceof ContainerPlayer)) {
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerContainerOpen(handler, scriptPlayer, event.entityPlayer.openContainer);
}
}
@SubscribeEvent
public void invoke(UseHoeEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onPlayerUseHoe(handler, event.current, event.x, event.y, event.z);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerUseHoe(handler, scriptPlayer, event.current, event.x, event.y, event.z);
}
}
@SubscribeEvent
public void invoke(PlayerSleepInBedEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onPlayerSleep(handler, event.x, event.y, event.z);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerSleep(handler, scriptPlayer, event.x, event.y, event.z);
}
}
@SubscribeEvent
public void invoke(PlayerWakeUpEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onPlayerWakeUp(handler, event.setSpawn);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerWakeUp(handler, scriptPlayer, event.setSpawn);
}
}
@SubscribeEvent
public void invoke(FillBucketEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onPlayerFillBucket(handler, event.current, event.result);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerFillBucket(handler, scriptPlayer, event.current, event.result);
}
}
@SubscribeEvent
public void invoke(BonemealEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onPlayerBonemeal(handler, event.x, event.y, event.z, event.world);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerBonemeal(handler, scriptPlayer, event.x, event.y, event.z, event.world);
}
}
@SubscribeEvent
public void invoke(AchievementEvent event) {
if(event.entityPlayer.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.entityPlayer).scriptData;
EventHooks.onPlayerAchievement(handler, CustomNpcs.proxy.getAchievementDesc(event.achievement));
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityPlayer);
EventHooks.onPlayerAchievement(handler, scriptPlayer, CustomNpcs.proxy.getAchievementDesc(event.achievement));
}
}
@SubscribeEvent
public void invoke(ItemTossEvent event) {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
EventHooks.onPlayerToss(handler, event.entityItem);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerToss(handler, scriptPlayer, event.entityItem);
}
}
@SubscribeEvent
public void invoke(LivingFallEvent event) {
if(event.entityLiving.worldObj instanceof WorldServer) {
PlayerDataScript handler;
if (event.entityLiving instanceof EntityPlayer) {
handler = PlayerData.get((EntityPlayer)event.entityLiving).scriptData;
EventHooks.onPlayerFall(handler, event.distance);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
EventHooks.onPlayerFall(handler, scriptPlayer, event.distance);
}
}
}
@@ -249,10 +274,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(LivingEvent.LivingJumpEvent event) {
if(event.entityLiving.worldObj instanceof WorldServer) {
PlayerDataScript handler;
if (event.entityLiving instanceof EntityPlayer) {
handler = PlayerData.get((EntityPlayer)event.entityLiving).scriptData;
EventHooks.onPlayerJump(handler);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
EventHooks.onPlayerJump(handler, scriptPlayer);
}
}
}
@@ -260,10 +285,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(EntityStruckByLightningEvent event) {
if(event.entity.worldObj instanceof WorldServer) {
PlayerDataScript handler;
if (event.entity instanceof EntityPlayer) {
handler = PlayerData.get((EntityPlayer)event.entity).scriptData;
EventHooks.onPlayerLightning(handler);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
EventHooks.onPlayerLightning(handler, scriptPlayer);
}
}
}
@@ -271,10 +296,10 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlaySoundAtEntityEvent event) {
if(event.entity.worldObj instanceof WorldServer) {
PlayerDataScript handler;
if (event.entity instanceof EntityPlayer) {
handler = PlayerData.get((EntityPlayer)event.entity).scriptData;
EventHooks.onPlayerSound(handler,event.name,event.pitch,event.volume);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entity);
EventHooks.onPlayerSound(handler,scriptPlayer,event.name,event.pitch,event.volume);
}
}
}
@@ -283,15 +308,15 @@ public class ScriptPlayerEventHandler {
public void invoke(LivingDeathEvent event) {
if(event.entityLiving.worldObj instanceof WorldServer) {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler;
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
handler = PlayerData.get((EntityPlayer)event.entityLiving).scriptData;
EventHooks.onPlayerDeath(handler, event.source, source);
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.entityLiving);
EventHooks.onPlayerDeath(handler,scriptPlayer, event.source, source);
}
if(source instanceof EntityPlayer) {
handler = PlayerData.get((EntityPlayer)source).scriptData;
EventHooks.onPlayerKills(handler, event.entityLiving);
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.source.getEntity());
EventHooks.onPlayerKills(handler,scriptPlayer, event.entityLiving);
}
}
@@ -301,17 +326,15 @@ public class ScriptPlayerEventHandler {
public void invoke(LivingHurtEvent event) {
if(event.entityLiving.worldObj instanceof WorldServer) {
Entity source = NoppesUtilServer.GetDamageSourcee(event.source);
PlayerDataScript handler;
PlayerDataScript handler = ScriptController.Instance.playerScripts;
if(event.entityLiving instanceof EntityPlayer) {
handler = PlayerData.get((EntityPlayer)event.entityLiving).scriptData;
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent(handler.getPlayer(), source, event.ammount, event.source);
noppes.npcs.scripted.event.PlayerEvent.DamagedEvent pevent = new noppes.npcs.scripted.event.PlayerEvent.DamagedEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.entityLiving), source, event.ammount, event.source);
event.setCanceled(EventHooks.onPlayerDamaged(handler, pevent));
event.ammount = pevent.damage;
}
if(source instanceof EntityPlayer) {
handler = PlayerData.get((EntityPlayer)source).scriptData;
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent(handler.getPlayer(), event.entityLiving, event.ammount, event.source);
noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent pevent1 = new noppes.npcs.scripted.event.PlayerEvent.DamagedEntityEvent((ScriptPlayer)ScriptController.Instance.getScriptForEntity((EntityPlayer)event.source.getEntity()), event.entityLiving, event.ammount, event.source);
event.setCanceled(EventHooks.onPlayerDamagedEntity(handler, pevent1));
event.ammount = pevent1.damage;
}
@@ -322,24 +345,27 @@ public class ScriptPlayerEventHandler {
@SubscribeEvent
public void invoke(PlayerEvent.PlayerRespawnEvent event) {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
EventHooks.onPlayerRespawn(handler);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerRespawn(handler, scriptPlayer);
}
}
@SubscribeEvent
public void invoke(PlayerEvent.PlayerLoggedInEvent event) {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
EventHooks.onPlayerLogin(handler);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerLogin(handler, scriptPlayer);
}
}
@SubscribeEvent
public void invoke(PlayerEvent.PlayerLoggedOutEvent event) {
if(event.player.worldObj instanceof WorldServer) {
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
EventHooks.onPlayerLogout(handler);
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
EventHooks.onPlayerLogout(handler, scriptPlayer);
}
}
@@ -348,9 +374,10 @@ public class ScriptPlayerEventHandler {
)
public void invoke(net.minecraftforge.event.ServerChatEvent event) {
if(event.player.worldObj instanceof WorldServer && !event.player.equals(EntityNPCInterface.chateventPlayer)) {
PlayerDataScript handler = PlayerData.get(event.player).scriptData;
PlayerDataScript handler = ScriptController.Instance.playerScripts;
ScriptPlayer scriptPlayer = (ScriptPlayer) ScriptController.Instance.getScriptForEntity(event.player);
String message = event.message;
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(handler.getPlayer(), event.message);
noppes.npcs.scripted.event.PlayerEvent.ChatEvent ev = new noppes.npcs.scripted.event.PlayerEvent.ChatEvent(scriptPlayer, event.message);
EventHooks.onPlayerChat(handler, ev);
event.setCanceled(ev.isCanceled());
if(!message.equals(ev.message)) {
@@ -360,118 +387,4 @@ public class ScriptPlayerEventHandler {
}
}
}
public ScriptPlayerEventHandler registerForgeEvents() {
ScriptPlayerEventHandler.ForgeEventHandler handler = new ScriptPlayerEventHandler.ForgeEventHandler();
try {
Method e = handler.getClass().getMethod("forgeEntity", new Class[]{Event.class});
Method register = FMLCommonHandler.instance().bus().getClass().getDeclaredMethod("register", new Class[]{Class.class, Object.class, Method.class, ModContainer.class});
register.setAccessible(true);
ArrayList list = new ArrayList();
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
Iterator e1 = list.iterator();
while(true) {
ClassInfo classLoader;
String classes;
do {
if(!e1.hasNext()) {
if(PixelmonHelper.Enabled) {
try {
Field e2 = ClassLoader.class.getDeclaredField("classes");
e2.setAccessible(true);
ClassLoader classLoader1 = Thread.currentThread().getContextClassLoader();
ArrayList classes1 = new ArrayList((Vector)e2.get(classLoader1));
Iterator infoClass1 = classes1.iterator();
while(infoClass1.hasNext()) {
Class c2 = (Class)infoClass1.next();
}
} catch (Exception var12) {
var12.printStackTrace();
}
return this;
}
return this;
}
classLoader = (ClassInfo)e1.next();
classes = classLoader.getName();
} while(classes.startsWith("net.minecraftforge.event.terraingen"));
Class infoClass = classLoader.load();
ArrayList c = new ArrayList(Arrays.asList(infoClass.getDeclaredClasses()));
if(c.isEmpty()) {
c.add(infoClass);
}
Iterator var10 = c.iterator();
while(var10.hasNext()) {
Class c1 = (Class)var10.next();
if(!EntityConstructing.class.isAssignableFrom(c1) && !PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers())) {
register.invoke(FMLCommonHandler.instance().bus(), new Object[]{c1, handler, e, Loader.instance().activeModContainer()});
}
}
}
} catch (Exception var13) {
var13.printStackTrace();
return this;
}
}
public class ForgeEventHandler {
public ForgeEventHandler() {
}
@SubscribeEvent
public void forgeEntity(Event event) {
if(CustomNpcs.getServer() != null && ScriptController.Instance.forgeScripts.isEnabled()) {
if(event instanceof EntityEvent) {
EntityEvent ev2 = (EntityEvent)event;
if(ev2.entity != null && ev2.entity.worldObj instanceof WorldServer) {
EventHooks.onForgeEntityEvent(ev2);
}
} else if(event instanceof WorldEvent) {
WorldEvent ev1 = (WorldEvent)event;
if(ev1.world instanceof WorldServer) {
EventHooks.onForgeWorldEvent(ev1);
}
} else if(!(event instanceof TickEvent) || ((TickEvent)event).side != Side.CLIENT) {
if(event instanceof PlayerEvent) {
PlayerEvent ev = (PlayerEvent)event;
if(!(ev.player.worldObj instanceof WorldServer)) {
return;
}
}
EventHooks.onForgeEvent(new ForgeEvent(event), event);
}
}
}
}
/*@SubscribeEvent
public void forgeTick(TickEvent.ServerTickEvent event){
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
EventHooks.onForgeEvent(new ForgeEvent(event), event);
}
}
@SubscribeEvent
public void forgeTick(TickEvent.WorldTickEvent event){
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
EventHooks.onForgeEvent(new ForgeEvent(event), event);
}
}
@SubscribeEvent
public void forgeTick(TickEvent.PlayerTickEvent event){
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
EventHooks.onForgeEvent(new ForgeEvent(event), event);
}
}*/
}
@@ -1,10 +1,12 @@
package noppes.npcs.ai;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import noppes.npcs.CustomNpcs;
import noppes.npcs.constants.AiMutex;
import noppes.npcs.entity.EntityNPCInterface;
@@ -55,7 +57,9 @@ public class EntityAIAttackTarget extends EntityAIBase
}
else{
this.entityTarget = entitylivingbase;
this.attacker.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) this.attacker).stats.aggroRange);
this.entityPathEntity = this.attacker.getNavigator().getPathToEntityLiving(entitylivingbase);
this.attacker.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
return this.entityPathEntity != null;
}
}
@@ -0,0 +1,173 @@
package noppes.npcs.ai.pathfinder;
public class FlyPath {
private FlyPathPoint[] pathPoints = new FlyPathPoint[1024];
/** The number of points in this path */
private int count;
private static final String __OBFID = "CL_00000573";
/**
* Adds a point to the path
*/
public FlyPathPoint addPoint(FlyPathPoint p_75849_1_)
{
if (p_75849_1_.index >= 0)
{
throw new IllegalStateException("OW KNOWS!");
}
else
{
if (this.count == this.pathPoints.length)
{
FlyPathPoint[] apathpoint = new FlyPathPoint[this.count << 1];
System.arraycopy(this.pathPoints, 0, apathpoint, 0, this.count);
this.pathPoints = apathpoint;
}
this.pathPoints[this.count] = p_75849_1_;
p_75849_1_.index = this.count;
this.sortBack(this.count++);
return p_75849_1_;
}
}
/**
* Clears the path
*/
public void clearPath()
{
this.count = 0;
}
/**
* Returns and removes the first point in the path
*/
public FlyPathPoint dequeue()
{
FlyPathPoint pathpoint = this.pathPoints[0];
this.pathPoints[0] = this.pathPoints[--this.count];
this.pathPoints[this.count] = null;
if (this.count > 0)
{
this.sortForward(0);
}
pathpoint.index = -1;
return pathpoint;
}
/**
* Changes the provided point's distance to target
*/
public void changeDistance(FlyPathPoint p_75850_1_, float p_75850_2_)
{
float f1 = p_75850_1_.distanceToTarget;
p_75850_1_.distanceToTarget = p_75850_2_;
if (p_75850_2_ < f1)
{
this.sortBack(p_75850_1_.index);
}
else
{
this.sortForward(p_75850_1_.index);
}
}
/**
* Sorts a point to the left
*/
private void sortBack(int p_75847_1_)
{
FlyPathPoint pathpoint = this.pathPoints[p_75847_1_];
int j;
for (float f = pathpoint.distanceToTarget; p_75847_1_ > 0; p_75847_1_ = j)
{
j = p_75847_1_ - 1 >> 1;
FlyPathPoint pathpoint1 = this.pathPoints[j];
if (f >= pathpoint1.distanceToTarget)
{
break;
}
this.pathPoints[p_75847_1_] = pathpoint1;
pathpoint1.index = p_75847_1_;
}
this.pathPoints[p_75847_1_] = pathpoint;
pathpoint.index = p_75847_1_;
}
/**
* Sorts a point to the right
*/
private void sortForward(int p_75846_1_)
{
FlyPathPoint pathpoint = this.pathPoints[p_75846_1_];
float f = pathpoint.distanceToTarget;
while (true)
{
int j = 1 + (p_75846_1_ << 1);
int k = j + 1;
if (j >= this.count)
{
break;
}
FlyPathPoint pathpoint1 = this.pathPoints[j];
float f1 = pathpoint1.distanceToTarget;
FlyPathPoint pathpoint2;
float f2;
if (k >= this.count)
{
pathpoint2 = null;
f2 = Float.POSITIVE_INFINITY;
}
else
{
pathpoint2 = this.pathPoints[k];
f2 = pathpoint2.distanceToTarget;
}
if (f1 < f2)
{
if (f1 >= f)
{
break;
}
this.pathPoints[p_75846_1_] = pathpoint1;
pathpoint1.index = p_75846_1_;
p_75846_1_ = j;
}
else
{
if (f2 >= f)
{
break;
}
this.pathPoints[p_75846_1_] = pathpoint2;
pathpoint2.index = p_75846_1_;
p_75846_1_ = k;
}
}
this.pathPoints[p_75846_1_] = pathpoint;
pathpoint.index = p_75846_1_;
}
/**
* Returns true if this path contains no points
*/
public boolean isPathEmpty()
{
return this.count == 0;
}
}
@@ -0,0 +1,130 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.entity.Entity;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.Vec3;
public class FlyPathEntity extends PathEntity{
public final PathPoint[] points;
/** PathEntity Array Index the Entity is currently targeting */
public int currentPathIndex;
/** The total length of the path */
public int pathLength;
private static final String __OBFID = "CL_00000575";
public FlyPathEntity(PathPoint[] p_i2136_1_)
{
super(p_i2136_1_);
this.points = p_i2136_1_;
this.pathLength = p_i2136_1_.length;
}
/**
* Directs this path to the next point in its array
*/
public void incrementPathIndex()
{
++this.currentPathIndex;
}
/**
* Returns true if this path has reached the end
*/
public boolean isFinished()
{
return this.currentPathIndex >= this.pathLength;
}
/**
* returns the last PathPoint of the Array
*/
public PathPoint getFinalPathPoint()
{
return this.pathLength > 0 ? this.points[this.pathLength - 1] : null;
}
/**
* return the PathPoint located at the specified PathIndex, usually the current one
*/
public PathPoint getPathPointFromIndex(int p_75877_1_)
{
return this.points[p_75877_1_];
}
public int getCurrentPathLength()
{
return this.pathLength;
}
public void setCurrentPathLength(int p_75871_1_)
{
this.pathLength = p_75871_1_;
}
public int getCurrentPathIndex()
{
return this.currentPathIndex;
}
public void setCurrentPathIndex(int p_75872_1_)
{
this.currentPathIndex = p_75872_1_;
}
/**
* Gets the vector of the PathPoint associated with the given index.
*/
public Vec3 getVectorFromIndex(Entity p_75881_1_, int p_75881_2_)
{
double d0 = (double)this.points[p_75881_2_].xCoord + (double)((int)(p_75881_1_.width + 1.0F)) * 0.5D;
double d1 = (double)this.points[p_75881_2_].yCoord;
double d2 = (double)this.points[p_75881_2_].zCoord + (double)((int)(p_75881_1_.width + 1.0F)) * 0.5D;
return Vec3.createVectorHelper(d0, d1, d2);
}
/**
* returns the current PathEntity target node as Vec3D
*/
public Vec3 getPosition(Entity p_75878_1_)
{
return this.getVectorFromIndex(p_75878_1_, this.currentPathIndex);
}
/**
* Returns true if the EntityPath are the same. Non instance related equals.
*/
public boolean isSamePath(PathEntity pathEntity)
{
FlyPathEntity p_75876_1_ = (FlyPathEntity) pathEntity;
if (p_75876_1_ == null)
{
return false;
}
else if (p_75876_1_.points.length != this.points.length)
{
return false;
}
else
{
for (int i = 0; i < this.points.length; ++i)
{
if (this.points[i].xCoord != p_75876_1_.points[i].xCoord || this.points[i].yCoord != p_75876_1_.points[i].yCoord || this.points[i].zCoord != p_75876_1_.points[i].zCoord)
{
return false;
}
}
return true;
}
}
/**
* Returns true if the final PathPoint in the PathEntity is equal to Vec3D coords.
*/
public boolean isDestinationSame(Vec3 p_75880_1_)
{
PathPoint pathpoint = this.getFinalPathPoint();
return pathpoint == null ? false : pathpoint.xCoord == (int)p_75880_1_.xCoord && pathpoint.zCoord == (int)p_75880_1_.zCoord;
}
}
@@ -0,0 +1,448 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.util.IntHashMap;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
public class FlyPathFinder extends PathFinder
{
/** Used to find obstacles */
private IBlockAccess worldMap;
/** The path being generated */
private FlyPath path = new FlyPath();
/** The points in the path */
private IntHashMap pointMap = new IntHashMap();
/** Selection of path points to add to the path */
private FlyPathPoint[] pathOptions = new FlyPathPoint[32];
/** should the PathFinder go through wodden door blocks */
private boolean isWoddenDoorAllowed;
/** should the PathFinder disregard BlockMovement type materials in its path */
private boolean isMovementBlockAllowed;
private boolean isPathingInWater;
/** tells the FathFinder to not stop pathing underwater */
private boolean canEntityDrown;
private static final String __OBFID = "CL_00000576";
public FlyPathFinder(IBlockAccess p_i2137_1_, boolean p_i2137_2_, boolean p_i2137_3_, boolean p_i2137_4_, boolean p_i2137_5_)
{
super(p_i2137_1_,p_i2137_2_,p_i2137_3_,p_i2137_4_,p_i2137_5_);
this.worldMap = p_i2137_1_;
this.isWoddenDoorAllowed = p_i2137_2_;
this.isMovementBlockAllowed = p_i2137_3_;
this.isPathingInWater = p_i2137_4_;
this.canEntityDrown = p_i2137_5_;
}
/**
* Creates a path from one entity to another within a minimum distance
*/
public FlyPathEntity createEntityPathTo(Entity p_75856_1_, Entity p_75856_2_, float p_75856_3_)
{
return this.createEntityPathTo(p_75856_1_, p_75856_2_.posX, p_75856_2_.boundingBox.minY, p_75856_2_.posZ, p_75856_3_);
}
/**
* Creates a path from an entity to a specified location within a minimum distance
*/
public FlyPathEntity createEntityPathTo(Entity p_75859_1_, int p_75859_2_, int p_75859_3_, int p_75859_4_, float p_75859_5_)
{
return this.createEntityPathTo(p_75859_1_, (double)((float)p_75859_2_ + 0.5F), (double)((float)p_75859_3_ + 0.5F), (double)((float)p_75859_4_ + 0.5F), p_75859_5_);
}
/**
* Internal implementation of creating a path from an entity to a point
*/
private FlyPathEntity createEntityPathTo(Entity p_75857_1_, double p_75857_2_, double p_75857_4_, double p_75857_6_, float p_75857_8_)
{
this.path.clearPath();
this.pointMap.clearMap();
boolean flag = this.isPathingInWater;
int i = MathHelper.floor_double(p_75857_1_.boundingBox.minY + 0.5D);
if (this.canEntityDrown && p_75857_1_.isInWater())
{
i = (int)p_75857_1_.boundingBox.minY;
for (Block block = this.worldMap.getBlock(MathHelper.floor_double(p_75857_1_.posX), i, MathHelper.floor_double(p_75857_1_.posZ)); block == Blocks.flowing_water || block == Blocks.water; block = this.worldMap.getBlock(MathHelper.floor_double(p_75857_1_.posX), i, MathHelper.floor_double(p_75857_1_.posZ)))
{
++i;
}
flag = this.isPathingInWater;
this.isPathingInWater = false;
}
else
{
i = MathHelper.floor_double(p_75857_1_.boundingBox.minY + 0.5D);
}
FlyPathPoint pathpoint2 = this.openPoint(MathHelper.floor_double(p_75857_1_.boundingBox.minX), i, MathHelper.floor_double(p_75857_1_.boundingBox.minZ));
FlyPathPoint pathpoint = this.openPoint(MathHelper.floor_double(p_75857_2_ - (double)(p_75857_1_.width / 2.0F)), MathHelper.floor_double(p_75857_4_), MathHelper.floor_double(p_75857_6_ - (double)(p_75857_1_.width / 2.0F)));
FlyPathPoint pathpoint1 = new FlyPathPoint(MathHelper.floor_float(p_75857_1_.width + 1.0F), MathHelper.floor_float(p_75857_1_.height + 1.0F), MathHelper.floor_float(p_75857_1_.width + 1.0F));
FlyPathEntity pathentity = this.addToPath(p_75857_1_, pathpoint2, pathpoint, pathpoint1, p_75857_8_);
this.isPathingInWater = flag;
return pathentity;
}
/**
* Adds a path from start to end and returns the whole path (args: unused, start, end, unused, maxDistance)
*/
private FlyPathEntity addToPath(Entity p_75861_1_, FlyPathPoint p_75861_2_, FlyPathPoint p_75861_3_, FlyPathPoint p_75861_4_, float p_75861_5_)
{
p_75861_2_.totalPathDistance = 0.0F;
p_75861_2_.distanceToNext = p_75861_2_.distanceToSquared(p_75861_3_);
p_75861_2_.distanceToTarget = p_75861_2_.distanceToNext;
this.path.clearPath();
this.path.addPoint(p_75861_2_);
FlyPathPoint pathpoint3 = p_75861_2_;
while (!this.path.isPathEmpty())
{
FlyPathPoint pathpoint4 = this.path.dequeue();
if (pathpoint4.equals(p_75861_3_))
{
return this.createEntityPath(p_75861_2_, p_75861_3_);
}
if (pathpoint4.distanceToSquared(p_75861_3_) < pathpoint3.distanceToSquared(p_75861_3_))
{
pathpoint3 = pathpoint4;
}
pathpoint4.isFirst = true;
int i = this.findPathOptions(p_75861_1_, pathpoint4, p_75861_4_, p_75861_3_, p_75861_5_);
for (int j = 0; j < i; ++j)
{
FlyPathPoint pathpoint5 = this.pathOptions[j];
float f1 = pathpoint4.totalPathDistance + pathpoint4.distanceToSquared(pathpoint5);
if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance)
{
pathpoint5.previous = pathpoint4;
pathpoint5.totalPathDistance = f1;
pathpoint5.distanceToNext = pathpoint5.distanceToSquared(p_75861_3_);
if (pathpoint5.isAssigned())
{
this.path.changeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext);
}
else
{
pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext;
this.path.addPoint(pathpoint5);
}
}
}
}
if (pathpoint3 == p_75861_2_)
{
return null;
}
else
{
return this.createEntityPath(p_75861_2_, pathpoint3);
}
}
/**
* populates pathOptions with available points and returns the number of options found (args: unused1, currentPoint,
* unused2, targetPoint, maxDistance)
*/
private int findPathOptions(Entity p_75860_1_, FlyPathPoint p_75860_2_, FlyPathPoint p_75860_3_, FlyPathPoint p_75860_4_, float p_75860_5_)
{
int i = 0;
byte b0 = 0;
if (this.getVerticalOffset(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_) == 1)
{
b0 = 1;
}
FlyPathPoint pathpoint3 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord + 1, p_75860_3_, b0);
FlyPathPoint pathpoint4 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint5 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint6 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord, p_75860_2_.zCoord - 1, p_75860_3_, b0);
FlyPathPoint pathpoint7 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord + 1, p_75860_3_, b0);
FlyPathPoint pathpoint8 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint9 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord + 1, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint10 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord + 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
FlyPathPoint pathpoint11 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord + 1, p_75860_3_, b0);
FlyPathPoint pathpoint12 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord - 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint13 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord + 1, p_75860_2_.yCoord - 1, p_75860_2_.zCoord, p_75860_3_, b0);
FlyPathPoint pathpoint14 = this.getSafePoint(p_75860_1_, p_75860_2_.xCoord, p_75860_2_.yCoord - 1, p_75860_2_.zCoord - 1, p_75860_3_, b0);
if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint3;
}
if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint4;
}
if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint5;
}
if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint6;
}
if (pathpoint7 != null && !pathpoint7.isFirst && pathpoint7.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint7;
}
if (pathpoint8 != null && !pathpoint8.isFirst && pathpoint8.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint8;
}
if (pathpoint9 != null && !pathpoint9.isFirst && pathpoint9.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint9;
}
if (pathpoint10 != null && !pathpoint10.isFirst && pathpoint10.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint10;
}
if (pathpoint11 != null && !pathpoint11.isFirst && pathpoint11.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint11;
}
if (pathpoint12 != null && !pathpoint12.isFirst && pathpoint12.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint12;
}
if (pathpoint13 != null && !pathpoint13.isFirst && pathpoint13.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint13;
}
if (pathpoint14 != null && !pathpoint14.isFirst && pathpoint14.distanceTo(p_75860_4_) < p_75860_5_)
{
this.pathOptions[i++] = pathpoint14;
}
return i;
}
/**
* Returns a point that the entity can safely move to
*/
private FlyPathPoint getSafePoint(Entity entity, int blockX, int blockY, int blockZ, FlyPathPoint pathPoint, int verticalOffsetFlag)
{
FlyPathPoint pathpoint1 = null;
int verticalOffset = this.getVerticalOffset(entity, blockX, blockY, blockZ, pathPoint);
if (verticalOffset == 2)
{
return this.openPoint(blockX, blockY, blockZ);
}
else
{
if (verticalOffset == 1)
{
pathpoint1 = this.openPoint(blockX, blockY, blockZ);
}
if (pathpoint1 == null && verticalOffsetFlag > 0 && verticalOffset != -3 && verticalOffset != -4 && this.getVerticalOffset(entity, blockX, blockY + verticalOffsetFlag, blockZ, pathPoint) == 1)
{
pathpoint1 = this.openPoint(blockX, blockY + verticalOffsetFlag, blockZ);
blockY += verticalOffsetFlag;
}
if (pathpoint1 != null)
{
int j1 = 0;
int k1 = 0;
while (blockY > 0)
{
k1 = this.getVerticalOffset(entity, blockX, blockY - 1, blockZ, pathPoint);
if (this.isPathingInWater && k1 == -1)
{
return null;
}
if (k1 != 1)
{
break;
}
if (j1++ >= entity.getMaxSafePointTries())
{
return null;
}
--blockY;
if (blockY > 0)
{
pathpoint1 = this.openPoint(blockX, blockY, blockZ);
}
}
if (k1 == -2)
{
return null;
}
}
return pathpoint1;
}
}
/**
* Returns a mapped point or creates and adds one
*/
private final FlyPathPoint openPoint(int p_75854_1_, int p_75854_2_, int p_75854_3_)
{
int l = FlyPathPoint.makeHash(p_75854_1_, p_75854_2_, p_75854_3_);
FlyPathPoint pathpoint = (FlyPathPoint)this.pointMap.lookup(l);
if (pathpoint == null)
{
pathpoint = new FlyPathPoint(p_75854_1_, p_75854_2_, p_75854_3_);
this.pointMap.addKey(l, pathpoint);
}
return pathpoint;
}
/**
* Checks if an entity collides with blocks at a position. Returns 1 if clear, 0 for colliding with any solid block,
* -1 for water(if avoiding water) but otherwise clear, -2 for lava, -3 for fence, -4 for closed trapdoor, 2 if
* otherwise clear except for open trapdoor or water(if not avoiding)
*/
public int getVerticalOffset(Entity p_75855_1_, int p_75855_2_, int p_75855_3_, int p_75855_4_, FlyPathPoint p_75855_5_)
{
return canEntityStandAt(p_75855_1_, p_75855_2_, p_75855_3_, p_75855_4_, p_75855_5_, this.isPathingInWater, this.isMovementBlockAllowed, this.isWoddenDoorAllowed);
}
public static int canEntityStandAt(Entity entity, int blockX, int blockY, int blockZ, FlyPathPoint pathPoint, boolean isPathingInWater, boolean isMovementBlockAllowed, boolean isWoddenDoorAllowed)
{
boolean flag3 = false;
for (int l = blockX; l < blockX + pathPoint.xCoord; ++l)
{
for (int i1 = blockY; i1 < blockY + pathPoint.yCoord; ++i1)
{
for (int j1 = blockZ; j1 < blockZ + pathPoint.zCoord; ++j1)
{
Block block = entity.worldObj.getBlock(l, i1, j1);
if(block == Blocks.air)
{
return 2;
}
if (block == Blocks.trapdoor)
{
flag3 = true;
}
else if (block != Blocks.flowing_water && block != Blocks.water)
{
if (!isWoddenDoorAllowed && block == Blocks.wooden_door)
{
return 0;
}
}
else
{
if (isPathingInWater)
{
return -1;
}
flag3 = true;
}
int k1 = block.getRenderType();
if (entity.worldObj.getBlock(l, i1, j1).getRenderType() == 9)
{
int j2 = MathHelper.floor_double(entity.posX);
int l1 = MathHelper.floor_double(entity.posY);
int i2 = MathHelper.floor_double(entity.posZ);
if (entity.worldObj.getBlock(j2, l1, i2).getRenderType() != 9 && entity.worldObj.getBlock(j2, l1 - 1, i2).getRenderType() != 9)
{
return -3;
}
}
else if (!block.getBlocksMovement(entity.worldObj, l, i1, j1) && (!isMovementBlockAllowed || block != Blocks.wooden_door))
{
if (k1 == 11 || block == Blocks.fence_gate || k1 == 32)
{
return -3;
}
if (block == Blocks.trapdoor)
{
return -4;
}
Material material = block.getMaterial();
if (material != Material.lava)
{
return 0;
}
if (!entity.handleLavaMovement())
{
return -2;
}
}
}
}
}
return flag3 ? 2 : 1;
}
/**
* Returns a new FlyPathEntity for a given start and end point
*/
private FlyPathEntity createEntityPath(FlyPathPoint p_75853_1_, FlyPathPoint p_75853_2_)
{
int i = 1;
FlyPathPoint pathpoint2;
for (pathpoint2 = p_75853_2_; pathpoint2.previous != null; pathpoint2 = pathpoint2.previous)
{
++i;
}
FlyPathPoint[] apathpoint = new FlyPathPoint[i];
pathpoint2 = p_75853_2_;
--i;
for (apathpoint[i] = p_75853_2_; pathpoint2.previous != null; apathpoint[i] = pathpoint2)
{
pathpoint2 = pathpoint2.previous;
--i;
}
return new FlyPathEntity(apathpoint);
}
}
@@ -0,0 +1,96 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
public class FlyPathPoint extends PathPoint
{
/** The x coordinate of this point */
public final int xCoord;
/** The y coordinate of this point */
public final int yCoord;
/** The z coordinate of this point */
public final int zCoord;
/** A hash of the coordinates used to identify this point */
public final int hash;
/** The index of this point in its assigned path */
public int index = -1;
/** The distance along the path to this point */
public float totalPathDistance;
/** The linear distance to the next point */
public float distanceToNext;
/** The distance to the target */
public float distanceToTarget;
/** The point preceding this in its assigned path */
public FlyPathPoint previous;
/** Indicates this is the origin */
public boolean isFirst;
private static final String __OBFID = "CL_00000574";
public FlyPathPoint(int p_i2135_1_, int p_i2135_2_, int p_i2135_3_)
{
super(p_i2135_1_,p_i2135_2_,p_i2135_3_);
this.xCoord = p_i2135_1_;
this.yCoord = p_i2135_2_;
this.zCoord = p_i2135_3_;
this.hash = makeHash(p_i2135_1_, p_i2135_2_, p_i2135_3_);
}
public static int makeHash(int p_75830_0_, int p_75830_1_, int p_75830_2_)
{
return p_75830_1_ & 255 | (p_75830_0_ & 32767) << 8 | (p_75830_2_ & 32767) << 24 | (p_75830_0_ < 0 ? Integer.MIN_VALUE : 0) | (p_75830_2_ < 0 ? 32768 : 0);
}
/**
* Returns the linear distance to another path point
*/
public float distanceTo(net.minecraft.pathfinding.PathPoint p_75829_1_)
{
float f = (float)(p_75829_1_.xCoord - this.xCoord);
float f1 = (float)(p_75829_1_.yCoord - this.yCoord);
float f2 = (float)(p_75829_1_.zCoord - this.zCoord);
return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
}
/**
* Returns the squared distance to another path point
*/
public float distanceToSquared(net.minecraft.pathfinding.PathPoint p_75832_1_)
{
float f = (float)(p_75832_1_.xCoord - this.xCoord);
float f1 = (float)(p_75832_1_.yCoord - this.yCoord);
float f2 = (float)(p_75832_1_.zCoord - this.zCoord);
return f * f + f1 * f1 + f2 * f2;
}
public boolean equals(Object p_equals_1_)
{
if (!(p_equals_1_ instanceof FlyPathPoint))
{
return false;
}
else
{
FlyPathPoint pathpoint = (FlyPathPoint)p_equals_1_;
return this.hash == pathpoint.hash && this.xCoord == pathpoint.xCoord && this.yCoord == pathpoint.yCoord && this.zCoord == pathpoint.zCoord;
}
}
public int hashCode()
{
return this.hash;
}
/**
* Returns true if this point has already been assigned to a path
*/
public boolean isAssigned()
{
return this.index >= 0;
}
public String toString()
{
return this.xCoord + ", " + this.yCoord + ", " + this.zCoord;
}
}
@@ -2,66 +2,102 @@ package noppes.npcs.ai.pathfinder;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityMoveHelper;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper;
import noppes.npcs.entity.EntityNPCInterface;
// Fly Change
public class FlyingMoveHelper extends EntityMoveHelper {
private EntityNPCInterface entity;
public class FlyingMoveHelper extends EntityMoveHelper{
private final EntityNPCInterface entity;
private int field_179928_h;
protected boolean update;
public double posX;
public double posY;
public double posZ;
private double posX;
private double posY;
private double posZ;
private double speed;
private boolean update;
public FlyingMoveHelper(EntityNPCInterface entity){
super(entity);
this.entity = entity;
this.posX = entity.posX;
this.posY = entity.posY;
this.posZ = entity.posZ;
}
public void onUpdateMoveHelper(){
if (this.update){
public void onUpdateMoveHelper() {
if (this.update) {
this.update = false;
double speed = this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
double speedMult = 0.6000000238418579D / 0.5D;
double d0 = this.posX - this.entity.posX;
double d1 = this.posY - this.entity.posY;
double d2 = this.posZ - this.entity.posZ;
double d3 = d0 * d0 + d1 * d1 + d2 * d2;
if (this.field_179928_h-- <= 0){
this.field_179928_h += this.entity.getRNG().nextInt(5) + 2;
d3 = (double) MathHelper.sqrt_double(d3);
double d4 = d0 * d0 + d1 * d1 + d2 * d2;
if (d3 > 1 && this.func_179926_b(this.posX, this.posY, this.posZ, d3)){
double speed = entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue() / 2.5;
this.entity.motionX += d0 / d3 * speed;
this.entity.motionY += d1 / d3 * speed;
this.entity.motionZ += d2 / d3 * speed;
this.entity.renderYawOffset = this.entity.rotationYaw = -((float)Math.atan2(this.entity.motionX, this.entity.motionZ)) * 180.0F / (float)Math.PI;
}
else{
this.update = false;
if (this.entity.hurtTime == 0 && d4 > 0.5D) {
if (this.posY != this.entity.posY) {
if (this.entity.motionY * Math.signum(this.entity.posY - this.posY) > 0.0D) {
this.entity.motionY = 0.0D;
}
double verticalSpeed = Math.abs(this.entity.posY - this.posY);
if(verticalSpeed > speed * speedMult)
verticalSpeed = speed * speedMult;
verticalSpeed += this.entity.ai.flySpeed/2.0D;
if(verticalSpeed > Math.abs(this.entity.posY - this.posY))
verticalSpeed = Math.abs(this.entity.posY - this.posY);
this.entity.motionY -= Math.signum(this.entity.posY - this.posY) * verticalSpeed;
}
double d5 = MathHelper.sqrt_double(d4);
this.entity.motionX += (d0 / d5 * speed - this.entity.motionX) * speed * speedMult;
this.entity.motionZ += (d2 / d5 * speed - this.entity.motionZ) * speed * speedMult;
}
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw,(float) ((Math.atan2(-d0, -d2) + Math.PI) * -(180F / Math.PI)),30.0F);
}
}
private boolean func_179926_b(double p_179926_1_, double p_179926_3_, double p_179926_5_, double p_179926_7_){
double d4 = (p_179926_1_ - this.entity.posX) / p_179926_7_;
double d5 = (p_179926_3_ - this.entity.posY) / p_179926_7_;
double d6 = (p_179926_5_ - this.entity.posZ) / p_179926_7_;
AxisAlignedBB axisalignedbb = this.entity.getBoundingBox();
private float limitAngle(float p_75639_1_, float p_75639_2_, float p_75639_3_)
{
float f3 = MathHelper.wrapAngleTo180_float(p_75639_2_ - p_75639_1_);
for (int i = 1; (double)i < p_179926_7_; ++i){
axisalignedbb = axisalignedbb.offset(d4, d5, d6);
if (!this.entity.worldObj.getCollidingBoundingBoxes(this.entity, axisalignedbb).isEmpty()){
return false;
}
if (f3 > p_75639_3_)
{
f3 = p_75639_3_;
}
return true;
if (f3 < -p_75639_3_)
{
f3 = -p_75639_3_;
}
return p_75639_1_ + f3;
}
/**
* Sets the speed and location to move to
*/
public void setMoveTo(double p_75642_1_, double p_75642_3_, double p_75642_5_, double p_75642_7_)
{
this.posX = p_75642_1_;
this.posY = p_75642_3_;
this.posZ = p_75642_5_;
this.speed = p_75642_7_;
this.update = true;
}
public boolean isUpdating()
{
return this.update;
}
public double getSpeed()
{
return this.speed;
}
}
@@ -1,25 +1,508 @@
package noppes.npcs.ai.pathfinder;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.pathfinding.PathFinder;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.IAttributeInstance;
import net.minecraft.init.Blocks;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.pathfinding.PathPoint;
import net.minecraft.util.MathHelper;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkCache;
import net.minecraft.world.World;
import noppes.npcs.entity.EntityNPCInterface;
public class PathNavigateFlying extends PathNavigateSwimmer {
public class PathNavigateFlying extends PathNavigate {
private EntityNPCInterface theEntity;
private World worldObj;
/** The PathEntity being followed. */
private FlyPathEntity currentPath;
private double speed;
/** The number of blocks (extra) +/- in each axis that get pulled out as cache for the pathfinder's search space */
private IAttributeInstance pathSearchRange;
private boolean noSunPathfind;
/** Time, in number of ticks, following the current path */
private int totalTicks;
/** The time when the last position check was done (to detect successful movement) */
private int ticksAtLastPos;
/** Coordinates of the entity's position last time a check was done (part of monitoring getting 'stuck') */
private Vec3 lastPosCheck = Vec3.createVectorHelper(0.0D, 0.0D, 0.0D);
/** Specifically, if a wooden door block is even considered to be passable by the pathfinder */
private boolean canPassOpenWoodenDoors = true;
/** If door blocks are considered passable even when closed */
private boolean canPassClosedWoodenDoors;
/** If water blocks are avoided (at least by the pathfinder) */
private boolean avoidsWater;
/**
* If the entity can swim. Swimming AI enables this and the pathfinder will also cause the entity to swim straight
* upwards when underwater
*/
private boolean canSwim;
private static final String __OBFID = "CL_00001627";
public PathNavigateFlying(EntityLiving p_i45873_1_, World worldIn) {
super(p_i45873_1_, worldIn);
}
protected PathFinder func_179679_a()
public PathNavigateFlying(EntityLiving p_i45873_1_, World worldIn) {
super(p_i45873_1_, worldIn);
this.theEntity = (EntityNPCInterface)p_i45873_1_;
this.worldObj = worldIn;
this.pathSearchRange = p_i45873_1_.getEntityAttribute(SharedMonsterAttributes.followRange);
}
public void setAvoidsWater(boolean p_75491_1_)
{
return new NPCPathFinder(new FlyNodeProcessor());
this.avoidsWater = p_75491_1_;
}
public boolean getAvoidsWater()
{
return this.avoidsWater;
}
public void setBreakDoors(boolean p_75498_1_)
{
this.canPassClosedWoodenDoors = p_75498_1_;
}
/**
* Sets if the entity can enter open doors
*/
public void setEnterDoors(boolean p_75490_1_)
{
this.canPassOpenWoodenDoors = p_75490_1_;
}
/**
* Returns true if the entity can break doors, false otherwise
*/
public boolean getCanBreakDoors()
{
return this.canPassClosedWoodenDoors;
}
/**
* Sets if the path should avoid sunlight
*/
public void setAvoidSun(boolean p_75504_1_)
{
this.noSunPathfind = p_75504_1_;
}
/**
* Sets the speed
*/
public void setSpeed(double p_75489_1_)
{
this.speed = p_75489_1_;
}
/**
* Sets if the entity can swim
*/
public void setCanSwim(boolean p_75495_1_)
{
this.canSwim = p_75495_1_;
}
/**
* Gets the maximum distance that the path finding will search in.
*/
public float getPathSearchRange()
{
return (float)this.pathSearchRange.getAttributeValue();
}
/**
* Returns the path to the given coordinates
*/
public FlyPathEntity getPathToXYZ(double p_75488_1_, double p_75488_3_, double p_75488_5_)
{
return !this.canNavigate() ? null : this.getEntityPathToXYZ(this.theEntity, MathHelper.floor_double(p_75488_1_), (int)p_75488_3_, MathHelper.floor_double(p_75488_5_), this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
}
/**
* Try to find and set a path to XYZ. Returns true if successful.
*/
public boolean tryMoveToXYZ(double p_75492_1_, double p_75492_3_, double p_75492_5_, double p_75492_7_)
{
FlyPathEntity pathentity = this.getPathToXYZ((double)MathHelper.floor_double(p_75492_1_), (double)((int)p_75492_3_), (double)MathHelper.floor_double(p_75492_5_));
return this.setPath(pathentity, p_75492_7_);
}
/**
* Returns the path to the given EntityLiving
*/
public FlyPathEntity getPathToEntityLiving(Entity p_75494_1_)
{
return !this.canNavigate() ? null : this.getPathEntityToEntity(this.theEntity, p_75494_1_, this.getPathSearchRange(), this.canPassOpenWoodenDoors, this.canPassClosedWoodenDoors, this.avoidsWater, this.canSwim);
}
/**
* Try to find and set a path to EntityLiving. Returns true if successful.
*/
public boolean tryMoveToEntityLiving(Entity p_75497_1_, double p_75497_2_)
{
FlyPathEntity pathentity = this.getPathToEntityLiving(p_75497_1_);
return pathentity != null && this.setPath(pathentity, p_75497_2_);
}
/**
* sets the active path data if path is 100% unique compared to old path, checks to adjust path for sun avoiding
* ents and stores end coords
*/
public boolean setPath(PathEntity pathEntity, double p_75484_2_)
{
FlyPathEntity p_75484_1_ = (FlyPathEntity) pathEntity;
if (p_75484_1_ == null)
{
this.currentPath = null;
return false;
}
else
{
if (!p_75484_1_.isSamePath(this.currentPath))
{
this.currentPath = p_75484_1_;
}
if (this.noSunPathfind)
{
this.removeSunnyPath();
}
if (this.currentPath.getCurrentPathLength() == 0)
{
return false;
}
else
{
this.speed = p_75484_2_;
Vec3 vec3 = this.getEntityPosition();
this.ticksAtLastPos = this.totalTicks;
this.lastPosCheck.xCoord = vec3.xCoord;
this.lastPosCheck.yCoord = vec3.yCoord;
this.lastPosCheck.zCoord = vec3.zCoord;
return true;
}
}
}
/**
* gets the actively used PathEntity
*/
public PathEntity getPath()
{
return this.currentPath;
}
public void onUpdateNavigation()
{
++this.totalTicks;
if (!this.noPath())
{
if (this.canNavigate())
{
this.pathFollow();
}
if (!this.noPath())
{
Vec3 vec3 = this.currentPath.getPosition(this.theEntity);
if (vec3 != null)
{
this.theEntity.getMoveHelper().setMoveTo(vec3.xCoord, vec3.yCoord, vec3.zCoord, this.speed);
}
}
}
}
private void pathFollow()
{
Vec3 vec3 = this.getEntityPosition();
int i = this.currentPath.getCurrentPathLength();
for (int j = this.currentPath.getCurrentPathIndex(); j < this.currentPath.getCurrentPathLength(); ++j)
{
if (this.currentPath.getPathPointFromIndex(j).yCoord != (int)vec3.yCoord)
{
i = j;
break;
}
}
float f = this.theEntity.width * this.theEntity.width;
int k;
for (k = this.currentPath.getCurrentPathIndex(); k < i; ++k)
{
if (vec3.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, k)) < (double)f)
{
this.currentPath.setCurrentPathIndex(k + 1);
}
}
k = MathHelper.ceiling_float_int(this.theEntity.width);
int l = (int)this.theEntity.height + 1;
int i1 = k;
for (int j1 = i - 1; j1 >= this.currentPath.getCurrentPathIndex(); --j1)
{
if (this.isDirectPathBetweenPoints(vec3, this.currentPath.getVectorFromIndex(this.theEntity, j1), k, l, i1))
{
this.currentPath.setCurrentPathIndex(j1);
break;
}
}
if (this.totalTicks - this.ticksAtLastPos > 100)
{
if (vec3.squareDistanceTo(this.lastPosCheck) < 2.25D)
{
this.clearPathEntity();
}
this.ticksAtLastPos = this.totalTicks;
this.lastPosCheck.xCoord = vec3.xCoord;
this.lastPosCheck.yCoord = vec3.yCoord;
this.lastPosCheck.zCoord = vec3.zCoord;
}
}
/**
* If null path or reached the end
*/
public boolean noPath()
{
return this.currentPath == null || this.currentPath.isFinished();
}
/**
* sets active PathEntity to null
*/
public void clearPathEntity()
{
this.currentPath = null;
}
private Vec3 getEntityPosition()
{
return Vec3.createVectorHelper(this.theEntity.posX, (double)this.getPathableYPos(), this.theEntity.posZ);
}
/**
* Gets the safe pathing Y position for the entity depending on if it can path swim or not
*/
private int getPathableYPos()
{
int i = (int)this.theEntity.boundingBox.minY;
Block block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
int j = 0;
do
{
if (block != Blocks.air)
{
return i;
}
++i;
block = this.worldObj.getBlock(MathHelper.floor_double(this.theEntity.posX), i, MathHelper.floor_double(this.theEntity.posZ));
++j;
}
while (j <= 16);
return (int)(this.theEntity.boundingBox.minY + 0.5D);
}
/**
* If on ground or swimming and can swim
*/
protected boolean canNavigate()
private boolean canNavigate()
{
return true;
}
/**
* Returns true when an entity could stand at a position, including solid blocks under the entire entity. Args:
* xOffset, yOffset, zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ
*/
private boolean isSafeToStandAt(int p_75483_1_, int p_75483_2_, int p_75483_3_, int p_75483_4_, int p_75483_5_, int p_75483_6_, Vec3 p_75483_7_, double p_75483_8_, double p_75483_10_)
{
return true;
}
/**
* Trims path data from the end to the first sun covered block
*/
private void removeSunnyPath()
{
if (!this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.theEntity.posX), (int)(this.theEntity.boundingBox.minY + 0.5D), MathHelper.floor_double(this.theEntity.posZ)))
{
for (int i = 0; i < this.currentPath.getCurrentPathLength(); ++i)
{
PathPoint pathpoint = this.currentPath.getPathPointFromIndex(i);
if (this.worldObj.canBlockSeeTheSky(pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord))
{
this.currentPath.setCurrentPathLength(i - 1);
return;
}
}
}
}
/**
* Returns true when an entity of specified size could safely walk in a straight line between the two points. Args:
* pos1, pos2, entityXSize, entityYSize, entityZSize
*/
private boolean isDirectPathBetweenPoints(Vec3 p_75493_1_, Vec3 p_75493_2_, int p_75493_3_, int p_75493_4_, int p_75493_5_)
{
int l = MathHelper.floor_double(p_75493_1_.xCoord);
int i1 = MathHelper.floor_double(p_75493_1_.zCoord);
double d0 = p_75493_2_.xCoord - p_75493_1_.xCoord;
double d1 = p_75493_2_.zCoord - p_75493_1_.zCoord;
double d2 = d0 * d0 + d1 * d1;
if (d2 < 1.0E-8D)
{
return false;
}
else
{
double d3 = 1.0D / Math.sqrt(d2);
d0 *= d3;
d1 *= d3;
p_75493_3_ += 2;
p_75493_5_ += 2;
if (!this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1))
{
return false;
}
else
{
p_75493_3_ -= 2;
p_75493_5_ -= 2;
double d4 = 1.0D / Math.abs(d0);
double d5 = 1.0D / Math.abs(d1);
double d6 = (double)(l * 1) - p_75493_1_.xCoord;
double d7 = (double)(i1 * 1) - p_75493_1_.zCoord;
if (d0 >= 0.0D)
{
++d6;
}
if (d1 >= 0.0D)
{
++d7;
}
d6 /= d0;
d7 /= d1;
int j1 = d0 < 0.0D ? -1 : 1;
int k1 = d1 < 0.0D ? -1 : 1;
int l1 = MathHelper.floor_double(p_75493_2_.xCoord);
int i2 = MathHelper.floor_double(p_75493_2_.zCoord);
int j2 = l1 - l;
int k2 = i2 - i1;
do
{
if (j2 * j1 <= 0 && k2 * k1 <= 0)
{
return true;
}
if (d6 < d7)
{
d6 += d4;
l += j1;
j2 = l1 - l;
}
else
{
d7 += d5;
i1 += k1;
k2 = i2 - i1;
}
}
while (this.isSafeToStandAt(l, (int)p_75493_1_.yCoord, i1, p_75493_3_, p_75493_4_, p_75493_5_, p_75493_1_, d0, d1));
return false;
}
}
}
/**
* Returns true if an entity does not collide with any solid blocks at the position. Args: xOffset, yOffset,
* zOffset, entityXSize, entityYSize, entityZSize, originPosition, vecX, vecZ
*/
private boolean isPositionClear(int p_75496_1_, int p_75496_2_, int p_75496_3_, int p_75496_4_, int p_75496_5_, int p_75496_6_, Vec3 p_75496_7_, double p_75496_8_, double p_75496_10_)
{
for (int k1 = p_75496_1_; k1 < p_75496_1_ + p_75496_4_; ++k1)
{
for (int l1 = p_75496_2_; l1 < p_75496_2_ + p_75496_5_; ++l1)
{
for (int i2 = p_75496_3_; i2 < p_75496_3_ + p_75496_6_; ++i2)
{
double d2 = (double)k1 + 0.5D - p_75496_7_.xCoord;
double d3 = (double)i2 + 0.5D - p_75496_7_.zCoord;
if (d2 * p_75496_8_ + d3 * p_75496_10_ >= 0.0D)
{
Block block = this.worldObj.getBlock(k1, l1, i2);
if (!block.getBlocksMovement(this.worldObj, k1, l1, i2))
{
return false;
}
}
}
}
}
return true;
}
public FlyPathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
{
this.theEntity.worldObj.theProfiler.startSection("pathfind");
int i = MathHelper.floor_double(p_72865_1_.posX);
int j = MathHelper.floor_double(p_72865_1_.posY + 1.0D);
int k = MathHelper.floor_double(p_72865_1_.posZ);
int l = (int)(p_72865_3_ + 16.0F);
int i1 = i - l;
int j1 = j - l;
int k1 = k - l;
int l1 = i + l;
int i2 = j + l;
int j2 = k + l;
ChunkCache chunkcache = new ChunkCache(this.theEntity.worldObj, i1, j1, k1, l1, i2, j2, 0);
FlyPathEntity pathentity = (new FlyPathFinder(chunkcache, p_72865_4_, p_72865_5_, p_72865_6_, p_72865_7_)).createEntityPathTo(p_72865_1_, p_72865_2_, p_72865_3_);
this.theEntity.worldObj.theProfiler.endSection();
return pathentity;
}
public FlyPathEntity getEntityPathToXYZ(Entity p_72844_1_, int p_72844_2_, int p_72844_3_, int p_72844_4_, float p_72844_5_, boolean p_72844_6_, boolean p_72844_7_, boolean p_72844_8_, boolean p_72844_9_)
{
this.theEntity.worldObj.theProfiler.startSection("pathfind");
int l = MathHelper.floor_double(p_72844_1_.posX);
int i1 = MathHelper.floor_double(p_72844_1_.posY);
int j1 = MathHelper.floor_double(p_72844_1_.posZ);
int k1 = (int)(p_72844_5_ + 8.0F);
int l1 = l - k1;
int i2 = i1 - k1;
int j2 = j1 - k1;
int k2 = l + k1;
int l2 = i1 + k1;
int i3 = j1 + k1;
ChunkCache chunkcache = new ChunkCache(this.theEntity.worldObj, l1, i2, j2, k2, l2, i3, 0);
FlyPathEntity pathentity = (new FlyPathFinder(chunkcache, p_72844_6_, p_72844_7_, p_72844_8_, p_72844_9_)).createEntityPathTo(p_72844_1_, p_72844_2_, p_72844_3_, p_72844_4_, p_72844_5_);
this.theEntity.worldObj.theProfiler.endSection();
return pathentity;
}
}
@@ -6,10 +6,13 @@ import java.util.List;
import net.minecraft.command.IEntitySelector;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAITarget;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.util.MathHelper;
import noppes.npcs.CustomNpcs;
import noppes.npcs.entity.EntityNPCInterface;
public class EntityAIClosestTarget extends EntityAITarget
{
@@ -52,10 +55,11 @@ public class EntityAIClosestTarget extends EntityAITarget
}
else
{
taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(((EntityNPCInterface) taskOwner).stats.aggroRange);
double d0 = this.getTargetDistance();
List list = this.taskOwner.worldObj.selectEntitiesWithinAABB(this.targetClass, this.taskOwner.boundingBox.expand(d0, MathHelper.ceiling_double_int(d0 / 2.0D), d0), this.field_82643_g);
Collections.sort(list, this.theNearestAttackableTargetSorter);
taskOwner.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
if (list.isEmpty())
{
return false;
@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -13,10 +13,10 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
public class EventGuiScriptList extends SubGuiInterface{
private GuiCustomScroll scroll1;
private GuiCustomScroll scroll2;
private EventScriptContainer container;
private ScriptContainer container;
private List<String> scripts;
public EventGuiScriptList(List<String> scripts, EventScriptContainer container){
public EventGuiScriptList(List<String> scripts, ScriptContainer container){
this.container = container;
setBackground("menubg.png");
xSize = 346;
@@ -4,7 +4,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.blocks.tiles.TileBorder;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -30,7 +29,7 @@ public class GuiBorderBlock extends GuiNPCInterface implements IGuiData{
addLabel(new GuiNpcLabel(0,"Height", guiLeft+ 1, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 60, guiTop + 71,40,20, tile.height + ""));
getTextField(0).numbersOnly = true;
getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, 500, 6);
addLabel(new GuiNpcLabel(1,"Message", guiLeft+ 1, guiTop + 100, 0xffffff));
@@ -5,7 +5,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.blocks.tiles.TileRedstoneBlock;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -33,39 +32,39 @@ public class GuiNpcRedstoneBlock extends GuiNPCInterface{
if(tile.isDetailed){
addLabel(new GuiNpcLabel(0,StatCollector.translateToLocal("bard.ondistance") + " X:", guiLeft+ 1, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRangeX + ""));
getTextField(0).numbersOnly = true;
getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, 50, 6);
addLabel(new GuiNpcLabel(1,"Y:", guiLeft+ 113, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 122, guiTop + 71,30,20, tile.onRangeY + ""));
getTextField(1).numbersOnly = true;
getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(0, 50, 6);
addLabel(new GuiNpcLabel(2,"Z:", guiLeft+ 155, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(2, this, fontRendererObj, guiLeft+ 164, guiTop + 71,30,20, tile.onRangeZ + ""));
getTextField(2).numbersOnly = true;
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(0, 50, 6);
addLabel(new GuiNpcLabel(3,StatCollector.translateToLocal("bard.offdistance") + " X:", guiLeft - 3, guiTop + 99, 0xffffff));
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRangeX + ""));
getTextField(3).numbersOnly = true;
getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(0, 50, 10);
addLabel(new GuiNpcLabel(4,"Y:", guiLeft+ 113, guiTop + 99, 0xffffff));
addTextField(new GuiNpcTextField(4, this, fontRendererObj, guiLeft+ 122, guiTop + 94,30,20, tile.offRangeY + ""));
getTextField(4).numbersOnly = true;
getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(0, 50, 10);
addLabel(new GuiNpcLabel(5,"Z:", guiLeft+ 155, guiTop + 99, 0xffffff));
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft+ 164, guiTop + 94,30,20, tile.offRangeZ + ""));
getTextField(5).numbersOnly = true;
getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(0, 50, 10);
}
else{
addLabel(new GuiNpcLabel(0,"bard.ondistance", guiLeft+ 1, guiTop + 76, 0xffffff));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft+ 80, guiTop + 71,30,20, tile.onRange + ""));
getTextField(0).numbersOnly = true;
getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, 50, 6);
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft - 3, guiTop + 99, 0xffffff));
addTextField(new GuiNpcTextField(3, this, fontRendererObj, guiLeft+ 80, guiTop + 94,30,20, tile.offRange + ""));
getTextField(3).numbersOnly = true;
getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(0, 50, 10);
}
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
@@ -29,7 +29,7 @@ public class GuiNpcWaypoint extends GuiNPCInterface{
addLabel(new GuiNpcLabel(1,"gui.range", guiLeft+ 1, guiTop + 97, 0xffffff));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft+ 60, guiTop + 92,200,20, tile.range + ""));
getTextField(1).numbersOnly = true;
getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(2, 60, 10);
addButton(new GuiNpcButton(0, guiLeft + 40, guiTop + 190,120,20, "Done"));
@@ -1,9 +1,6 @@
package noppes.npcs.client.gui;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiConfirmOpenLink;
@@ -30,23 +27,23 @@ import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCallback, ICustomScrollListener, IJTextAreaListener {
public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCallback, ICustomScrollListener, IJTextAreaListener {
public boolean showScript = false;
private int activeTab = 0;
public DataScript script;
public Map<String,List<String>> languages = new HashMap<String,List<String>>();
private static int activeConsole = 0;
public GuiScript(EntityNPCInterface npc) {
super(npc);
script = npc.script;
drawDefaultBackground = true;
closeOnEsc = true;
xSize = 420;
setBackground("menubg.png");
Client.sendData(EnumPacketServer.ScriptDataGet);
xSize = 420;
setBackground("menubg.png");
Client.sendData(EnumPacketServer.ScriptDataGet);
}
public void initGui() {
@@ -59,38 +56,38 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
top.active = !showScript;
addTopButton(new GuiMenuTopButton(15, top, "gui.website"));
List<String> list = new ArrayList<String>();
list.add("script.init");
list.add("script.update");
list.add("script.interact");
list.add("dialog.dialog");
list.add("script.damaged");
list.add("script.killed");
list.add("script.attack");
list.add("script.target");
list.add("script.collide");
list.add("script.kills");
list.add("script.dialog_closed");
List<String> list = new ArrayList<String>();
list.add("script.init");
list.add("script.update");
list.add("script.interact");
list.add("dialog.dialog");
list.add("script.damaged");
list.add("script.killed");
list.add("script.attack");
list.add("script.target");
list.add("script.collide");
list.add("script.kills");
list.add("script.dialog_closed");
list.add("script.timer");
if(showScript){
addLabel(new GuiNpcLabel(0, "script.hooks", guiLeft + 4, guiTop + 5));
GuiCustomScroll hooks = new GuiCustomScroll(this, 1);
hooks.setSize(68, 198);
hooks.guiLeft = guiLeft + 4;
hooks.guiTop = guiTop + 14;
hooks.setUnsortedList(list);
hooks.selected = activeTab;
addScroll(hooks);
hooks.setUnsortedList(list);
hooks.selected = activeTab;
addScroll(hooks);
ScriptContainer container = script.scripts.get(activeTab);
addTextField(new GuiNpcTextArea(2, this, guiLeft + 74, guiTop + 4, 239, 208, container == null?"":container.script));
addButton(new GuiNpcButton(102, guiLeft + 315, guiTop + 4, 50, 20, "gui.clear"));
addButton(new GuiNpcButton(101, guiLeft + 366, guiTop + 4, 50, 20, "gui.paste"));
addButton(new GuiNpcButton(100, guiLeft + 315, guiTop + 25, 50, 20, "gui.copy"));
addButton(new GuiNpcButton(108, guiLeft + 315, guiTop + 47, 80, 20, "gui.editor"));
addButton(new GuiNpcButton(107, guiLeft + 315, guiTop + 70, 80, 20, "script.loadscript"));
@@ -115,14 +112,14 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
l.add("All");
l.addAll(list);
addButton(new GuiNpcButton(105, guiLeft + 60, guiTop + 4, 80, 20, l.toArray(new String[l.size()]), activeConsole));
addLabel(new GuiNpcLabel(1, "script.language", guiLeft + 232, guiTop + 30));
addButton(new GuiNpcButton(103, guiLeft + 294, guiTop + 25, 80, 20, languages.keySet().toArray(new String[languages.keySet().size()]), getScriptIndex()));
getButton(103).enabled = languages.size() > 0;
addLabel(new GuiNpcLabel(2, "gui.enabled", guiLeft + 232, guiTop + 53));
addButton(new GuiNpcButton(104, guiLeft + 294, guiTop + 48, 50, 20, new String[]{"gui.no","gui.yes"}, script.enabled?1:0));
if(MinecraftServer.getServer() != null)
addButton(new GuiNpcButton(106, guiLeft + 232, guiTop + 71, 150, 20, "script.openfolder"));
}
@@ -139,27 +136,24 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
}
private String getConsoleText() {
String console = "";
if(activeConsole == 0){
for(ScriptContainer container : script.scripts.values()){
if(!container.console.isEmpty())
console += container.console + '\n';
}
Map<Long, String> map = this.script.getConsoleText();
StringBuilder builder = new StringBuilder();
Iterator var3 = map.entrySet().iterator();
while(var3.hasNext()) {
Map.Entry<Long, String> entry = (Map.Entry)var3.next();
builder.insert(0, new Date((Long)entry.getKey()) + (String)entry.getValue() + "\n");
}
else{
ScriptContainer container = script.scripts.get(activeConsole - 1);
if(container != null)
console = container.console;
}
return console;
return builder.toString();
}
@Override
public void confirmClicked(boolean flag, int i){
if(flag)
openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
@Override
public void confirmClicked(boolean flag, int i){
if(flag)
openLink("http://www.kodevelopment.nl/minecraft/customnpcs/scripting");
displayGuiScreen(this);
}
}
@Override
protected void actionPerformed(GuiButton guibutton) {
@@ -174,7 +168,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
}
if(guibutton.id == 15){
GuiConfirmOpenLink guiyesno = new GuiConfirmOpenLink(this, "http://www.kodevelopment.nl/minecraft/customnpcs/scripting", 0, true);
mc.displayGuiScreen(guiyesno);
mc.displayGuiScreen(guiyesno);
}
if (guibutton.id == 100) {
NoppesStringUtils.setClipboardContents(getTextField(2).getText());
@@ -186,13 +180,13 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
getTextField(2).setText("");
if(!showScript){
if(activeConsole == 0){
for(ScriptContainer container : script.scripts.values())
container.console = "";
for(ScriptContainer container : script.scripts)
container.console.clear();
}
else{
ScriptContainer container = script.scripts.get(activeConsole - 1);
if(container != null)
container.console = "";
container.console.clear();
}
}
}
@@ -212,7 +206,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
if (guibutton.id == 107) {
ScriptContainer container = script.scripts.get(activeTab);
if(container == null)
script.scripts.put(activeTab, container = new ScriptContainer());
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
setSubGui(new GuiScriptList(languages.get(script.scriptLanguage), container));
}
if (guibutton.id == 108) {
@@ -223,12 +217,12 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
}
}
}
private void setScript(){
if(showScript){
ScriptContainer container = script.scripts.get(activeTab);
if(container == null)
script.scripts.put(activeTab, container = new ScriptContainer());
script.scripts.set(activeTab, container = new ScriptContainer(this.script));
String text = getTextField(2).getText();
text = text.replace("\r\n", "\n");
text = text.replace("\r", "\n");
@@ -257,7 +251,7 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
@Override
public void save() {
setScript();
Client.sendData(EnumPacketServer.ScriptDataSave, script.writeToNBT(new NBTTagCompound()));
Client.sendData(EnumPacketServer.ScriptDataSave, script.writeToNBT(new NBTTagCompound()));
}
@Override
@@ -278,3 +272,4 @@ public class GuiScript extends GuiNPCInterface implements IGuiData, GuiYesNoCall
}
}
@@ -4,14 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.world.biome.BiomeGenBase;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNPCInterface;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.entity.EntityNPCInterface;
public class GuiScriptList extends SubGuiInterface{
private GuiCustomScroll scroll1;
@@ -1,11 +1,9 @@
package noppes.npcs.client.gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.global.GuiNPCQuestSelection;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
@@ -13,15 +11,11 @@ import noppes.npcs.client.gui.util.GuiSelectionListener;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.IGuiData;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAvailabilityDialog;
import noppes.npcs.constants.EnumAvailabilityFactionType;
import noppes.npcs.constants.EnumAvailabilityQuest;
import noppes.npcs.constants.EnumDayTime;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.Availability;
import noppes.npcs.controllers.Dialog;
import noppes.npcs.controllers.Faction;
import noppes.npcs.controllers.Quest;
public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfieldListener, GuiSelectionListener, IGuiData
{
@@ -66,7 +60,7 @@ public class SubGuiNpcAvailability extends SubGuiInterface implements ITextfield
addLabel(new GuiNpcLabel(51,"availability.minlevel", guiLeft + 4 , guiTop + 175));
this.addTextField(new GuiNpcTextField(51, this, fontRendererObj, guiLeft + 50, guiTop + 170,90, 20, availabitily.minPlayerLevel + ""));
this.getTextField(51).numbersOnly = true;
this.getTextField(51).integersOnly = true;
this.getTextField(51).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
this.addButton(new GuiNpcButton(66, guiLeft + 82, guiTop + 192,98, 20, "gui.done"));
@@ -80,7 +80,7 @@ public class SubGuiNpcFactionOptions extends SubGuiInterface implements IScrollD
addButton(new GuiNpcButton(2, guiLeft + 4, guiTop + 60, 90, 20, new String[]{"gui.increase","gui.decrease"},0));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 4, guiTop + 82, 110, 20, "10"));
getTextField(1).numbersOnly = true;
getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(1, 100000, 10);
addButton(new GuiNpcButton(3, guiLeft + 4, guiTop + 104, 60, 20, "gui.add"));
@@ -28,7 +28,7 @@ public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfiel
this.addTextField(new GuiNpcTextField(2, this, guiLeft + 8 + fontRendererObj.getStringWidth(getLabel(2).label), guiTop + 28, 70, 20, faction.defaultPoints + ""));
getTextField(2).setMaxStringLength(6);
getTextField(2).numbersOnly = true;
getTextField(2).integersOnly = true;
String title = StatCollector.translateToLocal("faction.unfriendly") + "<->" + StatCollector.translateToLocal("faction.neutral");
addLabel(new GuiNpcLabel(3, title, guiLeft + 4, guiTop + 80));
@@ -38,8 +38,8 @@ public class SubGuiNpcFactionPoints extends SubGuiInterface implements ITextfiel
addLabel(new GuiNpcLabel(4, title, guiLeft + 4, guiTop + 105));
addTextField(new GuiNpcTextField(4, this, guiLeft + 8 + fontRendererObj.getStringWidth(title), guiTop + 100, 70, 20, faction.friendlyPoints + ""));
getTextField(3).numbersOnly = true;
getTextField(4).numbersOnly = true;
getTextField(3).integersOnly = true;
getTextField(4).integersOnly = true;
if(getTextField(3).xPosition > getTextField(4).xPosition)
getTextField(4).xPosition = getTextField(3).xPosition;
@@ -28,29 +28,29 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
super.initGui();
addLabel(new GuiNpcLabel(1,"stats.meleestrength", guiLeft + 5, guiTop + 15));
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, guiTop + 10, 50, 18, stats.getAttackStrength()+""));
getTextField(1).numbersOnly = true;
getTextField(1).setMinMaxDefault(0, 99999, 5);
getTextField(1).floatsOnly = true;
getTextField(1).setMinMaxDefaultFloat(0,Float.MAX_VALUE,5);
addLabel(new GuiNpcLabel(2,"stats.meleerange", guiLeft + 5, guiTop + 45));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, guiTop + 40, 50, 18, stats.attackRange+""));
getTextField(2).numbersOnly = true;
getTextField(2).setMinMaxDefault(1, 30, 2);
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 2);
addLabel(new GuiNpcLabel(3,"stats.meleespeed", guiLeft + 5, guiTop + 75));
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, guiTop + 70, 50, 18, stats.attackSpeed+""));
getTextField(3).numbersOnly = true;
getTextField(3).setMinMaxDefault(1, 1000, 20);
getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addLabel(new GuiNpcLabel(4,"enchantment.knockback", guiLeft + 5, guiTop + 105));
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, guiTop + 100, 50, 18, stats.knockback + ""));
getTextField(4).numbersOnly = true;
getTextField(4).setMinMaxDefault(0, 4, 0);
getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
addLabel(new GuiNpcLabel(5,"stats.meleeeffect", guiLeft + 5, guiTop + 135));
addButton(new GuiNpcButton(5,guiLeft + 85, guiTop + 130, 52, 20, potionNames, stats.potionType.ordinal()));
if(stats.potionType != EnumPotionType.None) {
addLabel(new GuiNpcLabel(6,"gui.time", guiLeft + 5, guiTop + 165));
addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 85, guiTop + 160, 50, 18, stats.potionDuration + ""));
getTextField(6).numbersOnly = true;
getTextField(6).setMinMaxDefault(1, 99999, 5);
getTextField(6).integersOnly = true;
getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
if(stats.potionType != EnumPotionType.Fire) {
addLabel(new GuiNpcLabel(7,"stats.amplify", guiLeft + 5, guiTop + 195));
addButton(new GuiNpcButton(7,guiLeft + 85, guiTop + 190, 52, 20, new String[]{"gui.no", "gui.yes"} ,stats.potionAmp));
@@ -61,7 +61,7 @@ public class SubGuiNpcMeleeProperties extends SubGuiInterface implements ITextfi
public void unFocused(GuiNpcTextField textfield) {
if(textfield.id == 1){
stats.setAttackStrength(textfield.getInteger());
stats.setAttackStrength(Float.parseFloat(textfield.getText()));
}
else if(textfield.id == 2){
stats.attackRange = textfield.getInteger();
@@ -30,12 +30,24 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
this.addButton(new GuiNpcButton(0, guiLeft + 80, y, 100, 20, EnumMovingType.names(), ai.movingType.ordinal()));
// Fly Change
// this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground","movement.flying"}, ai.movementType));
this.addButton(new GuiNpcButton(15, guiLeft + 80, y += 22, 100, 20, new String[]{"movement.ground","movement.flying"}, ai.movementType));
if(ai.movementType == 1){
this.addLabel(new GuiNpcLabel(18, "fly.speed", guiLeft + 4, y + 140));
addTextField(new GuiNpcTextField(18,this, guiLeft + 80, y + 135, 40, 20, ai.flySpeed + ""));
getTextField(18).doublesOnly = true;
getTextField(18).setMinMaxDefaultDouble(0.0D,Double.MAX_VALUE,1.0D);
this.addLabel(new GuiNpcLabel(19, "fly.gravity", guiLeft + 4, y + 160));
addTextField(new GuiNpcTextField(19,this, guiLeft + 80, y + 155, 40, 20, ai.flyGravity + ""));
getTextField(19).doublesOnly = true;
getTextField(19).setMinMaxDefaultDouble(0.0D,1.0D,0.0D);
}
if(ai.movingType == EnumMovingType.Wandering){
addTextField(new GuiNpcTextField(4,this, guiLeft + 100, y += 22, 40, 20, ai.walkingRange + ""));
getTextField(4).numbersOnly = true;
getTextField(4).setMinMaxDefault(0, 1000, 5);
getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 5);
addLabel(new GuiNpcLabel(4,"gui.range", guiLeft + 4, y + 5));
addButton(new GuiNpcButton(5, guiLeft + 100, y += 22, 50, 20, new String[]{"gui.no","gui.yes"}, ai.npcInteracting?1:0));
@@ -45,15 +57,15 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
addTextField(new GuiNpcTextField(7,this, guiLeft + 99, y += 22, 24, 20, (int)ai.bodyOffsetX + ""));
addLabel(new GuiNpcLabel(17, "spawner.posoffset", guiLeft + 4, y + 5));
addLabel(new GuiNpcLabel(7,"X:", guiLeft + 115, y + 5));
getTextField(7).numbersOnly = true;
getTextField(7).integersOnly = true;
getTextField(7).setMinMaxDefault(0, 10, 5);
addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5));
addTextField(new GuiNpcTextField(8,this, guiLeft + 135, y, 24, 20, (int)ai.bodyOffsetY + ""));
getTextField(8).numbersOnly = true;
getTextField(8).integersOnly = true;
getTextField(8).setMinMaxDefault(0, 10, 5);
addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5));
addTextField(new GuiNpcTextField(9,this, guiLeft + 171, y, 24, 20, (int)ai.bodyOffsetZ + ""));
getTextField(9).numbersOnly = true;
getTextField(9).integersOnly = true;
getTextField(9).setMinMaxDefault(0, 10, 5);
this.addButton(new GuiNpcButton(3, guiLeft + 80, y += 22, 100, 20, new String[]{"stats.normal","movement.sitting","movement.lying","movement.sneaking","movement.dancing","movement.aiming", "movement.crawling", "movement.hug"},ai.animationType.ordinal()));
@@ -65,14 +77,14 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
}
else{
addTextField(new GuiNpcTextField(5,this, guiLeft + 99, y += 22, 40, 20, ai.orientation + ""));
getTextField(5).numbersOnly = true;
getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(0, 359, 0);
this.addLabel(new GuiNpcLabel(6, "movement.rotation", guiLeft + 4, y + 5));
addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 142, y + 5));
}
if(ai.standingType == EnumStandingType.NoRotation || ai.standingType == EnumStandingType.HeadRotation){
addTextField(new GuiNpcTextField(5,this, guiLeft + 165, y, 40, 20, ai.orientation + ""));
getTextField(5).numbersOnly = true;
getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(0, 359, 0);
addLabel(new GuiNpcLabel(5,"(0-359)", guiLeft + 207, y + 5));
}
@@ -92,8 +104,8 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
addLabel(new GuiNpcLabel(13,"movement.stopinteract", guiLeft + 4, y + 5));
addTextField(new GuiNpcTextField(14,this, guiLeft + 80, y += 22, 50, 18, ai.getWalkingSpeed()+""));
getTextField(14).numbersOnly = true;
getTextField(14).setMinMaxDefault(0, 10, 4);
getTextField(14).integersOnly = true;
getTextField(14).setMinMaxDefault(0, Integer.MAX_VALUE, 4);
addLabel(new GuiNpcLabel(14,"stats.walkspeed", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(66, guiLeft + 190, guiTop + 190, 60, 20, "gui.done"));
@@ -146,6 +158,7 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
}
else if (button.id == 15) {
ai.movementType = button.getValue();
initGui();
}
else if(button.id == 66){
close();
@@ -172,6 +185,12 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList
else if(textfield.id == 14){
ai.setWalkingSpeed(textfield.getInteger());
}
else if(textfield.id == 18){
ai.flySpeed = textfield.getDouble();
}
else if(textfield.id == 19){
ai.flyGravity = textfield.getDouble();
}
}
}
@@ -7,7 +7,6 @@ import noppes.npcs.client.gui.util.GuiNpcLabel;
import noppes.npcs.client.gui.util.GuiNpcTextField;
import noppes.npcs.client.gui.util.ITextfieldListener;
import noppes.npcs.client.gui.util.SubGuiInterface;
import noppes.npcs.constants.EnumAnimation;
import noppes.npcs.constants.EnumPotionType;
import noppes.npcs.constants.EnumParticleType;
@@ -30,20 +29,20 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
super.initGui();
addLabel(new GuiNpcLabel(1,"enchantment.arrowDamage", guiLeft + 5, guiTop + 15));
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 45, guiTop + 10, 50, 18, stats.pDamage+""));
getTextField(1).numbersOnly = true;
getTextField(1).setMinMaxDefault(0, 9999, 5);
getTextField(1).setFloatsOnly();
getTextField(1).setMinMaxDefaultFloat(0, Float.MAX_VALUE, 5);
addLabel(new GuiNpcLabel(2,"enchantment.arrowKnockback", guiLeft + 110, guiTop + 15));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 150, guiTop + 10, 50, 18, stats.pImpact+""));
getTextField(2).numbersOnly = true;
getTextField(2).setMinMaxDefault(0, 3, 0);
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
addLabel(new GuiNpcLabel(3,"stats.size", guiLeft + 5, guiTop + 45));
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 45, guiTop + 40, 50, 18, stats.pSize+""));
getTextField(3).numbersOnly = true;
getTextField(3).setMinMaxDefault(1, 10, 10);
getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 10);
addLabel(new GuiNpcLabel(4,"stats.speed", guiLeft + 5, guiTop + 75));
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 45, guiTop + 70, 50, 18, stats.pSpeed+""));
getTextField(4).numbersOnly = true;
getTextField(4).setMinMaxDefault(1, 50, 10);
getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 10);
addLabel(new GuiNpcLabel(5,"stats.hasgravity", guiLeft + 5, guiTop + 105));
addButton(new GuiNpcButton(0, guiLeft + 60, guiTop + 100, 60, 20, new String[]{"gui.no", "gui.yes"} ,stats.pPhysics ? 1:0));
@@ -59,8 +58,8 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
addButton(new GuiNpcButton(4,guiLeft + 60, guiTop + 160, 60, 20, potionNames, stats.pEffect.ordinal()));
if(stats.pEffect != EnumPotionType.None) {
addTextField(new GuiNpcTextField(5,this, fontRendererObj, guiLeft + 140, guiTop + 160, 60, 18, stats.pDur + ""));
getTextField(5).numbersOnly = true;
getTextField(5).setMinMaxDefault(1, 99999, 5);
getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
if(stats.pEffect != EnumPotionType.Fire) {
addButton(new GuiNpcButton(10, guiLeft + 210, guiTop + 160, 40, 20, new String[]{"stats.regular", "stats.amplified"} ,stats.pEffAmp));
}
@@ -82,7 +81,7 @@ public class SubGuiNpcProjectiles extends SubGuiInterface implements ITextfieldL
public void unFocused(GuiNpcTextField textfield) {
if(textfield.id == 1){
stats.pDamage = textfield.getInteger();
stats.pDamage = (float)(Math.floor(Float.parseFloat(textfield.getText())));
}
else if(textfield.id == 2){
stats.pImpact = textfield.getInteger();
@@ -29,36 +29,36 @@ public class SubGuiNpcRangeProperties extends SubGuiInterface implements ITextfi
int y = guiTop + 4;
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 85, y, 50, 18, stats.accuracy+""));
addLabel(new GuiNpcLabel(1,"stats.accuracy", guiLeft + 5, y + 5));
getTextField(1).numbersOnly = true;
getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(0, 100, 90);
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.rangedRange+""));
addLabel(new GuiNpcLabel(2,"stats.rangedrange", guiLeft + 5, y + 5));
getTextField(2).numbersOnly = true;
getTextField(2).setMinMaxDefault(1, 64, 2);
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 2);
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.minDelay+""));
addLabel(new GuiNpcLabel(3,"stats.mindelay", guiLeft + 5, y + 5));
getTextField(3).numbersOnly = true;
getTextField(3).setMinMaxDefault(1, 9999, 20);
getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addTextField(new GuiNpcTextField(4,this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.maxDelay+""));
addLabel(new GuiNpcLabel(4,"stats.maxdelay", guiLeft + 5, y + 5));
getTextField(4).numbersOnly = true;
getTextField(4).setMinMaxDefault(1, 9999, 20);
getTextField(4).integersOnly = true;
getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addTextField(new GuiNpcTextField(5, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.fireRate + ""));
addLabel(new GuiNpcLabel(5, "stats.burstspeed", guiLeft + 5, y + 5));
getTextField(5).numbersOnly = true;
getTextField(5).setMinMaxDefault(0, 30, 0);
getTextField(5).integersOnly = true;
getTextField(5).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
addTextField(new GuiNpcTextField(6, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.burstCount + ""));
addLabel(new GuiNpcLabel(6, "stats.burstcount", guiLeft + 5, y + 5));
getTextField(6).numbersOnly = true;
getTextField(6).setMinMaxDefault(1, 100, 20);
getTextField(6).integersOnly = true;
getTextField(6).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 85, y += 22, 100, 20, stats.fireSound));
addLabel(new GuiNpcLabel(7, "stats.firesound:", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(7, guiLeft + 187, y, 60, 20, "mco.template.button.select"));
addTextField(new GuiNpcTextField(8, this, fontRendererObj, guiLeft + 85, y += 22, 50, 18, stats.shotCount + ""));
addLabel(new GuiNpcLabel(8, "stats.shotcount", guiLeft + 5, y + 5));
getTextField(8).numbersOnly = true;
getTextField(8).setMinMaxDefault(1, 10, 1);
getTextField(8).integersOnly = true;
getTextField(8).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting));
addLabel(new GuiNpcLabel(9, "stats.aimWhileShooting", guiLeft + 5, y + 5));
@@ -27,7 +27,7 @@ public class SubGuiNpcRespawn extends SubGuiInterface implements ITextfieldListe
if(stats.respawnTime > 0){
addLabel(new GuiNpcLabel(3,"gui.time", guiLeft + 5, guiTop + 57));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 122, guiTop + 53, 50, 18, stats.respawnTime + ""));
getTextField(2).numbersOnly = true;
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
addLabel(new GuiNpcLabel(4,"stats.deadbody", guiLeft + 4, guiTop + 79));
@@ -7,7 +7,6 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.client.CustomNpcResourceListener;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.ICustomScrollListener;
@@ -63,11 +62,11 @@ public class GuiNPCManageBanks extends GuiContainerNPCInterface2 implements IScr
getTextField(0).setMaxStringLength(20);
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+10, guiTop + 80, 16, 16, ""));
getTextField(1).numbersOnly = true;
getTextField(1).integersOnly = true;
getTextField(1).setMaxStringLength(1);
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+10, guiTop + 110, 16, 16, ""));
getTextField(2).numbersOnly = true;
getTextField(2).integersOnly = true;
getTextField(2).setMaxStringLength(1);
}
@@ -32,8 +32,8 @@ public class GuiNpcQuestReward extends GuiContainerNPCInterface implements IText
addLabel(new GuiNpcLabel(1, "quest.exp", guiLeft + 4, guiTop + 45));
addTextField(new GuiNpcTextField(0, this, this.fontRendererObj, guiLeft + 4, guiTop + 55, 60, 20, quest.rewardExp + ""));
getTextField(0).numbersOnly = true;
getTextField(0).setMinMaxDefault(0, 99999, 0);
getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
}
public void actionPerformed(GuiButton guibutton){
@@ -11,7 +11,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.util.GuiContainerNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -45,13 +44,13 @@ public class GuiNPCInv extends GuiContainerNPCInterface2 implements ISliderListe
super.initGui();
addLabel(new GuiNpcLabel(0,"inv.minExp", guiLeft + 118, guiTop + 18));
addTextField(new GuiNpcTextField(0,this, fontRendererObj, guiLeft + 108, guiTop + 29, 60, 20, npc.inventory.minExp + ""));
getTextField(0).numbersOnly = true;
getTextField(0).setMinMaxDefault(0, Short.MAX_VALUE, 0);
getTextField(0).integersOnly = true;
getTextField(0).setMinMaxDefault(0, npc.inventory.maxExp, 0);
addLabel(new GuiNpcLabel(1,"inv.maxExp", guiLeft + 118, guiTop + 52));
addTextField(new GuiNpcTextField(1,this, fontRendererObj, guiLeft + 108, guiTop + 63, 60, 20, npc.inventory.maxExp + ""));
getTextField(1).numbersOnly = true;
getTextField(1).setMinMaxDefault(0, Short.MAX_VALUE, 0);
getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(npc.inventory.maxExp, Short.MAX_VALUE, 0);
addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode));
@@ -52,7 +52,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
if (ai.useRangeMelee >= 1){
addLabel(new GuiNpcLabel(20,"gui.minrange", guiLeft + 300, guiTop + 115));
addTextField(new GuiNpcTextField(6,this, fontRendererObj, guiLeft + 380, guiTop + 110, 30, 20, ai.distanceToMelee + ""));
getTextField(6).numbersOnly = true;
getTextField(6).integersOnly = true;
getTextField(6).setMinMaxDefault(1, npc.stats.aggroRange, 5);
}
addLabel(new GuiNpcLabel(19,"ai.tacticalvariant", guiLeft + 150, guiTop + 140));
@@ -70,7 +70,7 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
}
addLabel(new GuiNpcLabel(21, label, guiLeft + 300, guiTop + 140));
addTextField(new GuiNpcTextField(3,this, fontRendererObj, guiLeft + 380, guiTop + 135, 30, 20, ai.tacticalRadius + ""));
getTextField(3).numbersOnly = true;
getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(1, npc.stats.aggroRange, 5);
}
@@ -55,9 +55,9 @@ public class GuiNpcDisplay extends GuiNPCInterface2 implements ITextfieldListene
this.addButton(new GuiNpcButton(1, guiLeft + 50, y,110,20, "selectServer.edit"));
addLabel(new GuiNpcLabel(2,"display.size", guiLeft + 175, y + 5));
addTextField(new GuiNpcTextField(2,this, fontRendererObj, guiLeft + 203, y, 40, 20, display.modelSize + ""));
getTextField(2).numbersOnly = true;
getTextField(2).setMinMaxDefault(1, 30, 5);
addLabel(new GuiNpcLabel(3,"(1-30)", guiLeft + 246 , y + 5));
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(1, Integer.MAX_VALUE, 5);
//addLabel(new GuiNpcLabel(3,"(1-30)", guiLeft + 246 , y + 5));
y+=23;
addLabel(new GuiNpcLabel(4,"display.texture", guiLeft + 5, y + 5));
@@ -2,6 +2,7 @@ package noppes.npcs.client.gui.mainmenu;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.DataStats;
import noppes.npcs.client.Client;
@@ -34,12 +35,12 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
int y = guiTop + 10;
addLabel(new GuiNpcLabel(0,"stats.health", guiLeft + 5, y + 5));
addTextField(new GuiNpcTextField(0,this, guiLeft + 85, y, 50, 18, stats.maxHealth+""));
getTextField(0).numbersOnly = true;
getTextField(0).setMinMaxDefault(1, Integer.MAX_VALUE, 20);
getTextField(0).doublesOnly = true;
getTextField(0).setMinMaxDefaultDouble(0,Double.MAX_VALUE,20);
addLabel(new GuiNpcLabel(1,"stats.aggro", guiLeft + 140, y + 5));
addTextField(new GuiNpcTextField(1, this, fontRendererObj, guiLeft + 220, y, 50, 18, stats.aggroRange+""));
getTextField(1).numbersOnly = true;
getTextField(1).setMinMaxDefault(1, 64, 2);
getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(1, Integer.MAX_VALUE, 2);
addLabel(new GuiNpcLabel(34,"stats.creaturetype", guiLeft + 275, y + 5));
addButton(new GuiNpcButton(8,guiLeft + 355, y, 56, 20, new String[]{"stats.normal","stats.undead","stats.arthropod"} ,stats.creatureType.ordinal()));
@@ -63,10 +64,10 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
addLabel(new GuiNpcLabel(10,"stats.fireimmune", guiLeft + 5, y + 5));
addButton(new GuiNpcButton(5,guiLeft + 217, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.canDrown? 1:0));
addLabel(new GuiNpcLabel(11,"stats.candrown", guiLeft + 140, y + 5));
addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, stats.healthRegen + "").setNumbersOnly());
addTextField(new GuiNpcTextField(14, this, guiLeft + 355, y, 56, 20, stats.healthRegen + "").setFloatsOnly());
addLabel(new GuiNpcLabel(14,"stats.regenhealth", guiLeft + 275, y + 5));
addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y+=22, 56, 20, stats.combatRegen + "").setNumbersOnly());
addTextField(new GuiNpcTextField(16, this, guiLeft + 355, y+=22, 56, 20, stats.combatRegen + "").setFloatsOnly());
addLabel(new GuiNpcLabel(16,"stats.combatregen", guiLeft + 275, y + 5));
addButton(new GuiNpcButton(6,guiLeft + 82, y, 56, 20, new String[]{"gui.no","gui.yes"} ,stats.burnInSun? 1:0));
addLabel(new GuiNpcLabel(12,"stats.burninsun", guiLeft + 5, y + 5));
@@ -82,17 +83,17 @@ public class GuiNpcStats extends GuiNPCInterface2 implements ITextfieldListener,
@Override
public void unFocused(GuiNpcTextField textfield){
if(textfield.id == 0){
stats.maxHealth = textfield.getInteger();
npc.heal(stats.maxHealth);
stats.maxHealth = Math.floor(Double.parseDouble(textfield.getText()));
npc.heal((float)(stats.maxHealth));
}
else if(textfield.id == 1){
stats.aggroRange = textfield.getInteger();
}
else if(textfield.id == 14){
stats.healthRegen = textfield.getInteger();
stats.healthRegen = (float)(Math.floor(Float.parseFloat(textfield.getText())));
}
else if(textfield.id == 16){
stats.combatRegen = textfield.getInteger();
stats.combatRegen = (float)(Math.floor(Float.parseFloat(textfield.getText())));
}
}
@@ -50,7 +50,7 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
for (String name : quest.targets.keySet()) {
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, name));
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, quest.targets.get(name) + ""));
this.getTextField(i+3).numbersOnly = true;
this.getTextField(i+3).integersOnly = true;
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
i++;
}
@@ -58,7 +58,7 @@ public class GuiNpcQuestTypeKill extends SubGuiInterface implements ITextfieldLi
for(;i < 3; i++){
this.addTextField(new GuiNpcTextField(i, this, fontRendererObj, guiLeft + 4, guiTop + 70 + i * 22, 180, 20, ""));
this.addTextField(new GuiNpcTextField(i + 3, this, fontRendererObj, guiLeft + 186, guiTop + 70 + i * 22, 24, 20, "1"));
this.getTextField(i+3).numbersOnly = true;
this.getTextField(i+3).integersOnly = true;
this.getTextField(i+3).setMinMaxDefault(1, Integer.MAX_VALUE, 1);
}
Map<?,?> data = EntityList.stringToClassMapping;
@@ -39,16 +39,16 @@ public class GuiNpcBard extends GuiNPCInterface2
addLabel(new GuiNpcLabel(2,"bard.ondistance", guiLeft + 60, guiTop + 143));
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+160, guiTop + 138, 40, 20, job.minRange + ""));
getTextField(2).numbersOnly = true;
getTextField(2).setMinMaxDefault(2, 64, 5);
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5);
addLabel(new GuiNpcLabel(4,"bard.hasoff", guiLeft + 60, guiTop + 166));
addButton(new GuiNpcButton(4, guiLeft + 160, guiTop + 161, 60, 20, new String[]{"gui.no","gui.yes"}, job.hasOffRange?1:0));
addLabel(new GuiNpcLabel(3,"bard.offdistance", guiLeft + 60, guiTop + 189));
addTextField(new GuiNpcTextField(3,this, this.fontRendererObj, guiLeft+160, guiTop + 184, 40, 20, job.maxRange + ""));
getTextField(3).numbersOnly = true;
getTextField(3).setMinMaxDefault(2, 64, 10);
getTextField(3).integersOnly = true;
getTextField(3).setMinMaxDefault(2, Integer.MAX_VALUE, 10);
getLabel(3).enabled = job.hasOffRange;
getTextField(3).enabled = job.hasOffRange;
@@ -42,7 +42,7 @@ public class GuiNpcCompanion extends GuiNPCInterface2 implements ITextfieldListe
addLabel(new GuiNpcLabel(2, "companion.age", guiLeft + 4, y + 5));
if(role.canAge){
addTextField(new GuiNpcTextField(2, this, guiLeft + 162, y, 140, 20, role.ticksActive + ""));
getTextField(2).numbersOnly = true;
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(0, Integer.MAX_VALUE, 0);
}
@@ -48,19 +48,19 @@ public class GuiNpcConversation extends GuiNPCInterface2 implements ITextfieldLi
if(i > 0){
this.addTextField(new GuiNpcTextField(i + 14, this, this.fontRendererObj, guiLeft + 164 + offset, guiTop + 13 + i % 7 * 22, 30, 20, line.delay + ""));
this.getTextField(i + 14).numbersOnly = true;
this.getTextField(i + 14).integersOnly = true;
this.getTextField(i + 14).setMinMaxDefault(5, 1000, 40);
}
}
addLabel(new GuiNpcLabel(50, "conversation.delay", guiLeft + 202, guiTop + 175));
addTextField(new GuiNpcTextField(50, this, fontRendererObj, guiLeft + 260, guiTop + 170, 40, 20, job.generalDelay + ""));
getTextField(50).numbersOnly = true;
getTextField(50).setMinMaxDefault(10, 1000000, 12000);
getTextField(50).integersOnly = true;
getTextField(50).setMinMaxDefault(10, Integer.MAX_VALUE, 12000);
addLabel(new GuiNpcLabel(54, "gui.range", guiLeft + 202, guiTop + 196));
addTextField(new GuiNpcTextField(54, this, fontRendererObj, guiLeft + 260, guiTop + 191, 40, 20, job.range + ""));
getTextField(54).numbersOnly = true;
getTextField(54).setMinMaxDefault(4, 60, 20);
getTextField(54).integersOnly = true;
getTextField(54).setMinMaxDefault(4, Integer.MAX_VALUE, 20);
addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175));
String title = job.questTitle;
@@ -37,7 +37,7 @@ public class GuiNpcFollowerSetup extends GuiContainerNPCInterface2
int y = guiTop + 37;
y += i * 25;
GuiNpcTextField tf = new GuiNpcTextField(i,this, fontRendererObj,x, y, 24, 20, "1");
tf.numbersOnly = true;
tf.integersOnly = true;
tf.setMinMaxDefault(1, Integer.MAX_VALUE, 1);
addTextField(tf);
}
@@ -24,13 +24,13 @@ public class GuiNpcHealer extends GuiNPCInterface2
addLabel(new GuiNpcLabel(1,"Healing Speed:", guiLeft + 60, guiTop + 110));
addTextField(new GuiNpcTextField(1,this, this.fontRendererObj, guiLeft+130, guiTop + 105, 40, 20, job.speed + ""));
getTextField(1).numbersOnly = true;
getTextField(1).setMinMaxDefault(1, 10, 8);
getTextField(1).integersOnly = true;
getTextField(1).setMinMaxDefault(1, Integer.MAX_VALUE, 8);
addLabel(new GuiNpcLabel(2,"Range:", guiLeft + 60, guiTop + 133));
addTextField(new GuiNpcTextField(2,this, this.fontRendererObj, guiLeft+130, guiTop + 128, 40, 20, job.range + ""));
getTextField(2).numbersOnly = true;
getTextField(2).setMinMaxDefault(2, 20, 5);
getTextField(2).integersOnly = true;
getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5);
}
@Override
@@ -34,11 +34,11 @@ public class GuiNpcItemGiver extends GuiContainerNPCInterface2
this.addButton(new GuiNpcButton(1, guiLeft + 6, guiTop + 29, 140,20, new String[]{"Timer","Give Only Once","Daily"},role.cooldownType));
addTextField(new GuiNpcTextField(0, this, fontRendererObj, guiLeft + 55, guiTop + 54, 90, 20, role.cooldown + ""));
getTextField(0).numbersOnly = true;
getTextField(0).integersOnly = true;
addLabel(new GuiNpcLabel(0,"Cooldown:", guiLeft + 6, guiTop + 59));
addLabel(new GuiNpcLabel(1,"Items to give", guiLeft + 46, guiTop + 79));
getTextField(0).numbersOnly = true;
getTextField(0).integersOnly = true;
int i = 0;
for(String line : role.lines){
@@ -5,7 +5,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.StatCollector;
import noppes.npcs.client.Client;
import noppes.npcs.client.gui.GuiNpcMobSpawnerSelector;
import noppes.npcs.client.gui.GuiNpcSoundSelection;
import noppes.npcs.client.gui.util.GuiNPCInterface2;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -82,15 +81,15 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene
y += 23;
addLabel(new GuiNpcLabel(7,StatCollector.translateToLocal("spawner.posoffset")+" X:", guiLeft + 4, y + 5));
addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 99, y, 24, 20, job.xOffset + ""));
getTextField(7).numbersOnly = true;
getTextField(7).integersOnly = true;
getTextField(7).setMinMaxDefault(-9, 9, 0);
addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125, y + 5));
addTextField(new GuiNpcTextField(8,this, fontRendererObj, guiLeft + 135, y, 24, 20, job.yOffset + ""));
getTextField(8).numbersOnly = true;
getTextField(8).integersOnly = true;
getTextField(8).setMinMaxDefault(-9, 9, 0);
addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161, y + 5));
addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 171, y, 24, 20, job.zOffset + ""));
getTextField(9).numbersOnly = true;
getTextField(9).integersOnly = true;
getTextField(9).setMinMaxDefault(-9, 9, 0);
y += 23;
@@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.client.gui.GuiButton;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.client.gui.util.GuiCustomScroll;
import noppes.npcs.client.gui.util.GuiNpcButton;
import noppes.npcs.client.gui.util.GuiNpcLabel;
@@ -18,10 +18,10 @@ import noppes.npcs.client.gui.util.SubGuiInterface;
public class EventGuiScriptList extends SubGuiInterface {
private GuiCustomScroll scroll1;
private GuiCustomScroll scroll2;
private EventScriptContainer container;
private ScriptContainer container;
private List<String> scripts;
public EventGuiScriptList(List<String> scripts, EventScriptContainer container) {
public EventGuiScriptList(List<String> scripts, ScriptContainer container) {
this.container = container;
this.setBackground("menubg.png");
this.xSize = 346;
@@ -8,6 +8,7 @@ package noppes.npcs.client.gui.script;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.client.Client;
import noppes.npcs.constants.EnumPacketServer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.ForgeDataScript;
public class GuiScriptForge extends GuiScriptInterface {
@@ -15,7 +16,7 @@ public class GuiScriptForge extends GuiScriptInterface {
public GuiScriptForge() {
this.handler = this.script;
Client.sendData(EnumPacketServer.ScriptForgeGet);
Client.sendData(EnumPacketServer.ScriptForgeGet, new Object[0]);
}
public void setGuiData(NBTTagCompound compound) {
@@ -25,6 +26,6 @@ public class GuiScriptForge extends GuiScriptInterface {
public void save() {
super.save();
Client.sendData(EnumPacketServer.ScriptForgeSave, script.writeToNBT(new NBTTagCompound()));
Client.sendData(EnumPacketServer.ScriptForgeSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
}
}
@@ -6,15 +6,11 @@
package noppes.npcs.client.gui.script;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.Map.Entry;
import com.google.common.reflect.ClassPath;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.eventhandler.Event;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.FMLNetworkEvent;
@@ -24,17 +20,18 @@ import net.minecraft.client.gui.GuiYesNo;
import net.minecraft.client.gui.GuiYesNoCallback;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.event.world.ChunkEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
import net.minecraftforge.event.world.WorldEvent;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.NoppesStringUtils;
import noppes.npcs.client.NoppesUtil;
import noppes.npcs.client.gui.swing.GuiJTextArea;
import noppes.npcs.client.gui.util.*;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.data.ForgeDataScript;
import noppes.npcs.controllers.data.PlayerDataScript;
@@ -146,9 +143,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
ArrayList<ClassPath.ClassInfo> list = new ArrayList();
try {
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.event"));
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("cpw.mods.fml.common.gameevent"));
list.addAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event"));
list.removeAll(ClassPath.from(this.getClass().getClassLoader()).getTopLevelClassesRecursive("net.minecraftforge.event.terraingen"));
} catch (IOException e) {
e.printStackTrace();
}
@@ -163,7 +160,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
Iterator var10 = c.iterator();
while(var10.hasNext()) {
Class c1 = (Class) var10.next();
if (!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers())) {
if(!EntityEvent.EntityConstructing.class.isAssignableFrom(c1) && !WorldEvent.PotentialSpawns.class.isAssignableFrom(c1) && !TickEvent.RenderTickEvent.class.isAssignableFrom(c1) && !TickEvent.ClientTickEvent.class.isAssignableFrom(c1) && !FMLNetworkEvent.ClientCustomPacketEvent.class.isAssignableFrom(c1) && !ItemTooltipEvent.class.isAssignableFrom(c1) && Event.class.isAssignableFrom(c1) && !Modifier.isAbstract(c1.getModifiers()) && Modifier.isPublic(c1.getModifiers()) && !ChunkEvent.class.isAssignableFrom(c1) && !ChunkWatchEvent.class.isAssignableFrom(c1) && !ChunkDataEvent.class.isAssignableFrom(c1)) {
String eventName = c1.getName();
int i = eventName.lastIndexOf(".");
eventName = StringUtils.uncapitalize(eventName.substring(i + 1).replace("$", ""));
@@ -180,7 +177,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
hookLabel.color = 0xaaaaaa;
addLabel(hookLabel);
EventScriptContainer var7 = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
ScriptContainer var7 = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
GuiNpcTextArea left = new GuiNpcTextArea(2, this, this.guiLeft + yoffset, this.guiTop + yoffset, this.xSize - 110 - yoffset, (int)((double)this.ySize * 0.96D) - yoffset * 2, var7 == null?"":var7.script);
this.addTextField(left);
int left1 = this.guiLeft + this.xSize - 104;
@@ -224,9 +221,21 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
this.ySize = 256;
}
public String previousHookClicked = "";
@Override
public void customScrollClicked(int i, int j, int k, GuiCustomScroll scroll) {
//this.handler.getScripts().get(this.activeTab - 1).setType(scroll.getSelected().replace("playerscript.",""));
String hook = scroll.getSelected();
if(previousHookClicked.equals(hook)){
String addString = "";
if(!this.getTextField(2).getText().isEmpty())
addString += "\n";
addString += "function "+hook+"(event) {\n \n}\n";
this.getTextField(2).setText(this.getTextField(2).getText()+addString);
previousHookClicked = "";
} else {
previousHookClicked = hook;
}
}
@Override
@@ -236,15 +245,6 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}*/
}
/*private int getScriptHook(EventScriptContainer eventScriptContainer, List<String> list) {
for(String s : list) {
if (s.replace("playerscript.", "").equals(eventScriptContainer.type)) {
return list.indexOf(s);
}
}
return 0;
}*/
private String getConsoleText() {
Map<Long, String> map = this.handler.getConsoleText();
StringBuilder builder = new StringBuilder();
@@ -307,7 +307,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
if(guibutton.id == scriptLimit) {
this.handler.getScripts().add(new EventScriptContainer(this.handler));
this.handler.getScripts().add(new ScriptContainer(this.handler));
this.activeTab = this.handler.getScripts().size();
this.initGui();
}
@@ -336,10 +336,10 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
(this.getTextField(2)).setText(NoppesStringUtils.getClipboardContents());
}
EventScriptContainer container;
ScriptContainer container;
if(guibutton.id == 102) {
if(this.activeTab > 0) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container.script = "";
} else {
this.handler.clearConsole();
@@ -366,16 +366,16 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
if(guibutton.id == 107) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container == null) {
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
this.handler.getScripts().add(container = new ScriptContainer(this.handler));
}
this.setSubGui(new EventGuiScriptList((List)this.languages.get(this.handler.getLanguage()), container));
}
if(guibutton.id == 108) {
container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container != null) {
this.setScript();
this.AWTWindow = new GuiJTextArea(container.script).setListener(this);
@@ -386,9 +386,9 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
private void setScript() {
if(this.activeTab > 0) {
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container == null) {
this.handler.getScripts().add(container = new EventScriptContainer(this.handler));
this.handler.getScripts().add(container = new ScriptContainer(this.handler));
}
String text = (this.getTextField(2)).getText();
@@ -424,7 +424,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
}
public void textUpdate(String text) {
EventScriptContainer container = (EventScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
ScriptContainer container = (ScriptContainer)this.handler.getScripts().get(this.activeTab - 1);
if(container != null) {
container.script = text;
}
@@ -433,7 +433,7 @@ public class GuiScriptInterface extends GuiNPCInterface implements GuiYesNoCallb
@Override
public void saveText(String text) {
EventScriptContainer container = handler.getScripts().get(activeTab);
ScriptContainer container = handler.getScripts().get(activeTab);
if(container != null)
container.script = text;
initGui();
@@ -17,7 +17,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
public GuiScriptPlayers() {
this.handler = this.script;
Client.sendData(EnumPacketServer.ScriptPlayerGet);
Client.sendData(EnumPacketServer.ScriptPlayerGet, new Object[0]);
}
public void setGuiData(NBTTagCompound compound) {
@@ -27,7 +27,7 @@ public class GuiScriptPlayers extends GuiScriptInterface {
public void save() {
super.save();
Client.sendData(EnumPacketServer.ScriptPlayerSave, script.writeToNBT(new NBTTagCompound()));
Client.sendData(EnumPacketServer.ScriptPlayerSave, new Object[]{this.script.writeToNBT(new NBTTagCompound())});
}
public void close() {
@@ -8,10 +8,14 @@ import net.minecraft.client.gui.GuiTextField;
public class GuiNpcTextField extends GuiTextField{
public boolean enabled = true;
public boolean inMenu = true;
public boolean numbersOnly = false;
public boolean integersOnly = false;
public boolean doublesOnly = false;
public boolean floatsOnly = false;
private ITextfieldListener listener;
public int id;
public int min = 0,max = Integer.MAX_VALUE,def = 0;
public double minDouble = 0, maxDouble = Double.MAX_VALUE, defDouble = 0;
public float minFloat = 0, maxFloat = Float.MAX_VALUE, defFloat = 0;
private static GuiNpcTextField activeTextfield = null;
public boolean canEdit = true;
@@ -37,7 +41,7 @@ public class GuiNpcTextField extends GuiTextField{
}
private boolean charAllowed(char c, int i){
if(!numbersOnly || Character.isDigit(c))
if(!integersOnly || Character.isDigit(c))
return true;
for(int j : allowedSpecialChars)
if(j == i)
@@ -61,6 +65,7 @@ public class GuiNpcTextField extends GuiTextField{
public int getInteger(){
return Integer.parseInt(getText());
}
public boolean isInteger(){
try{
Integer.parseInt(getText());
@@ -69,6 +74,33 @@ public class GuiNpcTextField extends GuiTextField{
return false;
}
}
public double getDouble(){
return Double.parseDouble(getText());
}
public boolean isDouble() {
try{
Double.parseDouble(getText());
return true;
}catch(NumberFormatException e){
return false;
}
}
public float getFloat(){
return Float.parseFloat(getText());
}
public boolean isFloat() {
try{
Float.parseFloat(getText());
return true;
}catch(NumberFormatException e){
return false;
}
}
@Override
public void mouseClicked(int i, int j, int k){
if(!canEdit)
@@ -85,30 +117,58 @@ public class GuiNpcTextField extends GuiTextField{
}
public void unFocused(){
if(numbersOnly){
if(integersOnly && !doublesOnly && !floatsOnly){
if(isEmpty() || !isInteger())
setText(def + "");
else if( getInteger() < min)
setText(def+"");
else if(getInteger() < min)
setText(min+"");
else if(getInteger() > max)
setText(max+"");
}
else if(doublesOnly && !floatsOnly){
if(isEmpty() || !isDouble())
setText(defDouble +"");
else if(getDouble() < minDouble)
setText(minDouble +"");
else if(getDouble() > maxDouble)
setText(maxDouble +"");
}
else if(floatsOnly){
if(isEmpty() || !isFloat())
setText(defFloat +"");
else if(getFloat() < minFloat)
setText(minFloat +"");
else if(getFloat() > maxFloat)
setText(maxFloat +"");
}
if(listener != null)
listener.unFocused(this);
if(this == activeTextfield)
activeTextfield = null;
}
@Override
public void drawTextBox()
{
if(enabled)
super.drawTextBox();
}
public void setMinMaxDefault(int i, int j, int k) {
min = i;
max = j;
def = k;
public void setMinMaxDefault(int min, int max, int def) {
this.min = min;
this.max = max;
this.def = def;
}
public void setMinMaxDefaultDouble(double min, double max, double def) {
minDouble = min;
maxDouble = max;
defDouble = def;
}
public void setMinMaxDefaultFloat(float min, float max, float def) {
minFloat = min;
maxFloat = max;
defFloat = def;
}
public static void unfocus() {
GuiNpcTextField prev = activeTextfield;
@@ -122,8 +182,17 @@ public class GuiNpcTextField extends GuiTextField{
drawTextBox();
}
public GuiNpcTextField setNumbersOnly() {
numbersOnly = true;
public GuiNpcTextField setIntegersOnly() {
integersOnly = true;
return this;
}
public GuiNpcTextField setDoublesOnly() {
doublesOnly = true;
return this;
}
public GuiNpcTextField setFloatsOnly() {
floatsOnly = true;
return this;
}
@@ -73,7 +73,7 @@ public class RenderNPCInterface extends RenderLiving{
public void doRenderShadowAndFire(Entity par1Entity, double par2, double par4, double par6, float par8, float par9){
EntityNPCInterface npc = (EntityNPCInterface) par1Entity;
if(!npc.isKilled())
if(!npc.isKilled() && !npc.scriptInvisibleToPlayer(Minecraft.getMinecraft().thePlayer))
super.doRenderShadowAndFire(par1Entity, par2, par4, par6, par8, par9);
}
@@ -8,11 +8,10 @@ package noppes.npcs.controllers;
import java.util.List;
import java.util.Map;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.constants.EnumScriptType;
public interface IScriptHandler {
void callScript(EnumScriptType var1, Event var2, Object... obs);
void callScript(EnumScriptType var1, Event var2);
boolean isClient();
@@ -24,7 +23,7 @@ public interface IScriptHandler {
void setLanguage(String var1);
List<EventScriptContainer> getScripts();
List<ScriptContainer> getScripts();
String noticeString();
@@ -28,7 +28,6 @@ public class PlayerData implements IExtendedEntityProperties{
public PlayerFactionData factionData = new PlayerFactionData();
public PlayerItemGiverData itemgiverData = new PlayerItemGiverData();
public PlayerMailData mailData = new PlayerMailData();
public PlayerDataScript scriptData;
public DataTimers timers = new DataTimers(this);
public EntityNPCInterface editingNpc;
@@ -232,7 +231,6 @@ public class PlayerData implements IExtendedEntityProperties{
PlayerData data = new PlayerData();
if (data.player == null) {
data.player = player;
data.scriptData = new PlayerDataScript(player);
NBTTagCompound compound = loadPlayerData(player.getPersistentID().toString());
if (compound.hasNoTags()) {
compound = loadPlayerDataOld(player.getCommandSenderName());
@@ -1,94 +1,181 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package noppes.npcs.controllers;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.lang.reflect.Method;
import java.util.*;
import javax.script.Compilable;
import javax.script.CompiledScript;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NBTTags;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.scripted.NpcAPI;
import scala.Char;
public class ScriptContainer {
public String fullscript = "";
public String script = "";
public String console = "";
public boolean errored = false;
public List<String> scripts = new ArrayList<String>();
private long lastCreated = 0;
private CompiledScript compScript = null;
private String currentScriptLanguage = null;
public ScriptEngine engine = null;
private static final String lock = "lock";
public static ScriptContainer Current;
private static String CurrentType;
private static final HashMap<String, Object> Data = new HashMap();
public String fullscript = "";
public String script = "";
public TreeMap<Long, String> console = new TreeMap();
public boolean errored = false;
public List<String> scripts = new ArrayList();
private HashSet<String> unknownFunctions = new HashSet();
public long lastCreated = 0L;
private String currentScriptLanguage = null;
public ScriptEngine engine = null;
private IScriptHandler handler = null;
private boolean init = false;
private static Method luaCoerce;
private static Method luaCall;
private CompiledScript compScript = null;
public void readFromNBT(NBTTagCompound compound) {
script = compound.getString("Script");
console = compound.getString("ScriptConsole");
scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
lastCreated = 0;
}
public ScriptContainer(IScriptHandler handler) {
this.handler = handler;
}
public void writeToNBT(NBTTagCompound compound) {
compound.setString("Script", script);
compound.setString("ScriptConsole", console);
compound.setTag("ScriptList", NBTTags.nbtStringList(scripts));
}
public void readFromNBT(NBTTagCompound compound) {
this.script = compound.getString("Script");
//this.type = compound.getString("Type");
this.console = NBTTags.GetLongStringMap(compound.getTagList("Console", 10));
this.scripts = NBTTags.getStringList(compound.getTagList("ScriptList", 10));
this.lastCreated = 0L;
}
public String getCode() {
if(ScriptController.Instance.lastLoaded > lastCreated){
lastCreated = ScriptController.Instance.lastLoaded;
fullscript = script;
if(!fullscript.isEmpty())
fullscript += "\n";
for(String loc : scripts){
String code = ScriptController.Instance.scripts.get(loc);
if(code != null && !code.isEmpty())
fullscript += code + "\n";
}
compScript = null;
}
return fullscript;
}
public void run(ScriptEngine engine){
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
engine.getContext().setWriter(pw);
engine.getContext().setErrorWriter(pw);
try {
if(compScript == null && engine instanceof Compilable)
compScript = ((Compilable)engine).compile(getCode());
if(compScript != null){
compScript.eval(engine.getContext());
}
else
engine.eval(getCode());
} catch (Exception e) {
errored = true;
appandConsole(e.getMessage());
}
appandConsole(sw.getBuffer().toString().trim());
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setString("Script", this.script);
//compound.setString("Type", this.type);
compound.setTag("Console", NBTTags.NBTLongStringMap(this.console));
compound.setTag("ScriptList", NBTTags.nbtStringList(this.scripts));
return compound;
}
public void appandConsole(String message) {
if(message == null || message.isEmpty())
return;
console = message + "\n" + console;
}
private String getFullCode() {
if(!this.init) {
this.fullscript = this.script;
if(!this.fullscript.isEmpty()) {
this.fullscript = this.fullscript + "\n";
}
public boolean hasCode() {
return !getCode().isEmpty();
}
Iterator var1 = this.scripts.iterator();
public void setEngine(String scriptLanguage) {
if(currentScriptLanguage != null && currentScriptLanguage.equals(scriptLanguage))
return;
engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
currentScriptLanguage = scriptLanguage;
}
while(var1.hasNext()) {
String loc = (String)var1.next();
String code = (String)ScriptController.Instance.scripts.get(loc);
if(code != null && !code.isEmpty()) {
this.fullscript = this.fullscript + code + "\n";
}
}
}
return this.fullscript;
}
public void run(ScriptEngine engine){
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
this.engine.getContext().setWriter(pw);
this.engine.getContext().setErrorWriter(pw);
try {
if(compScript == null && engine instanceof Compilable)
compScript = ((Compilable)engine).compile(getFullCode());
if(compScript != null){
compScript.eval(engine.getContext());
}
else
engine.eval(getFullCode());
} catch (Throwable var14) {
this.errored = true;
var14.printStackTrace(pw);
} finally {
String errorString = sw.getBuffer().toString().trim();
this.appandConsole(errorString);
pw.close();
}
}
public void run(EnumScriptType type, Event event) {
this.run((String)type.function, (Object)event);
}
public void run(String type, Object event) {
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
this.setEngine(this.handler.getLanguage());
if (this.engine != null) {
if (ScriptController.Instance.lastLoaded > this.lastCreated) {
this.lastCreated = ScriptController.Instance.lastLoaded;
this.init = false;
}
engine.put("API", NpcAPI.Instance());
Current = this;
CurrentType = type;
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
this.engine.getContext().setWriter(pw);
this.engine.getContext().setErrorWriter(pw);
try {
if (!this.init) {
this.engine.eval(this.getFullCode());
this.init = true;
}
((Invocable)this.engine).invokeFunction(type, new Object[]{event});
} catch (NoSuchMethodException var13) {
this.unknownFunctions.add(type);
} catch (Throwable var14) {
this.errored = true;
var14.printStackTrace(pw);
} finally {
String errorString = sw.getBuffer().toString().trim();
this.appandConsole(errorString);
pw.close();
Current = null;
}
}
}
}
public void appandConsole(String message) {
if (message != null && !message.isEmpty()) {
long time = System.currentTimeMillis();
if (this.console.containsKey(time)) {
message = (String)this.console.get(time) + "\n" + message;
}
this.console.put(time, message);
while(this.console.size() > 40) {
this.console.remove(this.console.firstKey());
}
}
}
public boolean hasCode() {
return !this.getFullCode().isEmpty();
}
public void setEngine(String scriptLanguage) {
if(currentScriptLanguage != null && currentScriptLanguage.equals(scriptLanguage))
return;
engine = ScriptController.Instance.getEngineByName(scriptLanguage.toLowerCase());
currentScriptLanguage = scriptLanguage;
}
}
@@ -13,10 +13,9 @@ import java.util.TreeMap;
import java.util.Map.Entry;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.client.Minecraft;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.EventHooks;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.NBTTags;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
@@ -26,7 +25,7 @@ import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import javax.script.ScriptEngine;
public class ForgeDataScript implements IScriptHandler {
private List<EventScriptContainer> scripts = new ArrayList();
private List<ScriptContainer> scripts = new ArrayList();
private String scriptLanguage = "ECMAScript";
public long lastInited = -1L;
private boolean enabled = false;
@@ -52,7 +51,7 @@ public class ForgeDataScript implements IScriptHandler {
}
@Override
public void callScript(EnumScriptType var1, Event var2, Object... obs) {
public void callScript(EnumScriptType var1, Event var2) {
callScript(var1.function, var2);
}
@@ -68,20 +67,8 @@ public class ForgeDataScript implements IScriptHandler {
Iterator var3 = this.scripts.iterator();
while (var3.hasNext()) {
EventScriptContainer script = (EventScriptContainer) var3.next();
script.setEngine(scriptLanguage);
if(script.engine == null)
return;
Event result = (Event) script.engine.get("event");
if(result == null)
script.engine.put("event", event);
script.engine.put("API", new WrapperNpcAPI());
ScriptEngine engine = script.engine;
while(var3.hasNext()) {
ScriptContainer script = (ScriptContainer)var3.next();
script.run(type, event);
}
//});
@@ -112,7 +99,7 @@ public class ForgeDataScript implements IScriptHandler {
this.scriptLanguage = lang;
}
public List<EventScriptContainer> getScripts() {
public List<ScriptContainer> getScripts() {
return this.scripts;
}
@@ -126,7 +113,7 @@ public class ForgeDataScript implements IScriptHandler {
Iterator var3 = this.getScripts().iterator();
while(var3.hasNext()) {
EventScriptContainer script = (EventScriptContainer)var3.next();
ScriptContainer script = (ScriptContainer)var3.next();
++tab;
Iterator var5 = script.console.entrySet().iterator();
@@ -143,7 +130,7 @@ public class ForgeDataScript implements IScriptHandler {
Iterator var1 = this.getScripts().iterator();
while(var1.hasNext()) {
EventScriptContainer script = (EventScriptContainer)var1.next();
ScriptContainer script = (ScriptContainer)var1.next();
script.console.clear();
}
@@ -2,77 +2,58 @@
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package noppes.npcs.controllers.data;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;
import com.google.common.base.Preconditions;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.world.WorldServer;
import noppes.npcs.EventHooks;
import noppes.npcs.EventScriptContainer;
import noppes.npcs.controllers.ScriptContainer;
import noppes.npcs.NBTTags;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.constants.EnumScriptType;
import noppes.npcs.controllers.IScriptHandler;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.ScriptWorld;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.PlayerEvent;
import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.IWorld;
import noppes.npcs.scripted.wrapper.WrapperNpcAPI;
import javax.annotation.CheckForNull;
import javax.script.ScriptEngine;
public class PlayerDataScript implements IScriptHandler {
public List<EventScriptContainer> scripts = new ArrayList();
public List<ScriptContainer> scripts = new ArrayList();
public String scriptLanguage = "ECMAScript";
private EntityPlayer player;
private IPlayer playerAPI;
private long lastPlayerUpdate = 0L;
public long lastInited = -1L;
public boolean hadInteract = true;
public boolean enabled = false;
private Map<Long, String> console = new TreeMap();
public List<Integer> errored = new ArrayList();
public IPlayer dummyPlayer;
public IWorld dummyWorld;
public PlayerDataScript(EntityPlayer player) {
if(player != null) {
this.player = player;
if (player instanceof EntityPlayer)
dummyPlayer = (IPlayer) ScriptController.Instance.getScriptForEntity(this.player);
if (player.worldObj instanceof WorldServer)
dummyWorld = (IWorld) NpcAPI.Instance().getIWorld((WorldServer) this.player.worldObj);
}
}
public void clear() {
this.console = new TreeMap();
this.errored = new ArrayList();
this.scripts = new ArrayList();
}
public void readFromNBT(NBTTagCompound compound) {
this.scripts = NBTTags.GetScript(compound.getTagList("Scripts", 10), this);
this.scriptLanguage = compound.getString("ScriptLanguage");
this.enabled = compound.getBoolean("ScriptEnabled");
this.console = NBTTags.GetLongStringMap(compound.getTagList("ScriptConsole", 10));
}
public NBTTagCompound writeToNBT(NBTTagCompound compound) {
compound.setTag("Scripts", NBTTags.NBTScript(this.scripts));
compound.setString("ScriptLanguage", this.scriptLanguage);
@@ -81,58 +62,31 @@ public class PlayerDataScript implements IScriptHandler {
return compound;
}
public void callScript(EnumScriptType type, Event event, Object... obs) {
if(this.isEnabled()) {
EventScriptContainer script;
if(ScriptController.Instance.lastLoaded > this.lastInited || ScriptController.Instance.lastPlayerUpdate > this.lastPlayerUpdate) {
public void callScript(EnumScriptType type, Event event) {
if (this.isEnabled()) {
ScriptContainer script;
if (ScriptController.Instance.lastLoaded > this.lastInited || ScriptController.Instance.lastPlayerUpdate > this.lastPlayerUpdate) {
this.lastInited = ScriptController.Instance.lastLoaded;
//ScriptController.Instance.playerScripts.errored.clear();
if(this.player != null) {
this.scripts.clear();
Iterator i = ScriptController.Instance.playerScripts.scripts.iterator();
while(i.hasNext()) {
script = (EventScriptContainer)i.next();
EventScriptContainer s = new EventScriptContainer(this);
s.readFromNBT(script.writeToNBT(new NBTTagCompound()));
this.scripts.add(s);
}
}
errored.clear();
this.lastPlayerUpdate = ScriptController.Instance.lastPlayerUpdate;
if(type != EnumScriptType.INIT) {
EventHooks.onPlayerInit(this);
if (type != EnumScriptType.INIT) {
noppes.npcs.scripted.event.PlayerEvent playerEvent = (noppes.npcs.scripted.event.PlayerEvent)event;
EventHooks.onPlayerInit(this, (ScriptPlayer) playerEvent.player);
}
}
for(int var7 = 0; var7 < this.scripts.size(); ++var7) {
script = (EventScriptContainer)this.scripts.get(var7);
if(!ScriptController.Instance.playerScripts.errored.contains(Integer.valueOf(var7))) {
if(script == null || script.errored || !script.hasCode())
for(int i = 0; i < ScriptController.Instance.playerScripts.scripts.size(); ++i) {
script = (ScriptContainer)ScriptController.Instance.playerScripts.scripts.get(i);
if (!errored.contains(i)) {
if(script == null || script.errored || !script.hasCode() || ScriptController.Instance.playerScripts.errored.contains(i))
return;
script.setEngine(scriptLanguage);
if(script.engine == null)
return;
for(int i = 0; i + 1 < obs.length; i += 2){
Object ob = obs[i + 1];
if(ob instanceof Entity)
ob = ScriptController.Instance.getScriptForEntity((Entity)ob);
script.engine.put(obs[i].toString(), ob);
}
ScriptEngine engine = script.engine;
engine.put("world", dummyWorld);
engine.put("player", dummyPlayer);
PlayerEvent result = (PlayerEvent) engine.get("event");
if(result == null)
engine.put("event", result = new PlayerEvent(this.getPlayer()));
script.engine.put("API", new WrapperNpcAPI());
script.run(type, event);
if (script.errored) {
ScriptController.Instance.playerScripts.errored.add(var7);
ScriptController.Instance.playerScripts.errored.add(i);
}
Iterator var8 = script.console.entrySet().iterator();
@@ -140,45 +94,39 @@ public class PlayerDataScript implements IScriptHandler {
while(var8.hasNext()) {
Entry<Long, String> entry = (Entry)var8.next();
if (!ScriptController.Instance.playerScripts.console.containsKey(entry.getKey())) {
ScriptController.Instance.playerScripts.console.put(entry.getKey(), " tab " + (var7 + 1) + ":\n" + (String)entry.getValue());
ScriptController.Instance.playerScripts.console.put(entry.getKey(), " tab " + (i + 1) + ":\n" + (String)entry.getValue());
}
}
script.console.clear();
}
}
}
}
public boolean isEnabled() {
return ScriptController.Instance.playerScripts.enabled && ScriptController.HasStart && (this.player == null || !this.player.worldObj.isRemote);
}
public boolean isClient() {
return this.player.isClientWorld();
}
public boolean getEnabled() {
return ScriptController.Instance.playerScripts.enabled;
}
public void setEnabled(boolean bo) {
ScriptController.Instance.playerScripts.enabled = bo;
this.enabled = bo;
}
public String getLanguage() {
return ScriptController.Instance.playerScripts.scriptLanguage;
}
public void setLanguage(String lang) {
this.scriptLanguage = lang;
}
public List<EventScriptContainer> getScripts() {
public List<ScriptContainer> getScripts() {
return this.scripts;
}
public String noticeString() {
if(this.player == null) {
return "Global script";
@@ -187,30 +135,24 @@ public class PlayerDataScript implements IScriptHandler {
return PlayerDataScript.toStringHelper(this.player).add("x", pos.getX()).add("y", pos.getY()).add("z", pos.getZ()).toString();
}
}
public IPlayer getPlayer() {
if (this.playerAPI == null) {
this.playerAPI = (IPlayer) NpcAPI.Instance().getIEntity(this.player);
}
return this.playerAPI;
}
public Map<Long, String> getConsoleText() {
return this.console;
}
public void clearConsole() {
this.console.clear();
}
public static final class ToStringHelper {
private final String className;
private final PlayerDataScript.ToStringHelper.ValueHolder holderHead;
private PlayerDataScript.ToStringHelper.ValueHolder holderTail;
private boolean omitNullValues;
private boolean omitEmptyValues;
private ToStringHelper(String className) {
this.holderHead = new PlayerDataScript.ToStringHelper.ValueHolder();
this.holderTail = this.holderHead;
@@ -218,68 +160,52 @@ public class PlayerDataScript implements IScriptHandler {
this.omitEmptyValues = false;
this.className = (String) Preconditions.checkNotNull(className);
}
public PlayerDataScript.ToStringHelper omitNullValues() {
this.omitNullValues = true;
return this;
}
public PlayerDataScript.ToStringHelper add(String name, @CheckForNull Object value) {
return this.addHolder(name, value);
}
public PlayerDataScript.ToStringHelper add(String name, boolean value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, char value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, double value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, float value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, int value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper add(String name, long value) {
return this.addUnconditionalHolder(name, String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(@CheckForNull Object value) {
return this.addHolder(value);
}
public PlayerDataScript.ToStringHelper addValue(boolean value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(char value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(double value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(float value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(int value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
public PlayerDataScript.ToStringHelper addValue(long value) {
return this.addUnconditionalHolder(String.valueOf(value));
}
private static boolean isEmpty(Object value) {
if (value instanceof CharSequence) {
return ((CharSequence)value).length() == 0;
@@ -303,13 +229,11 @@ public class PlayerDataScript implements IScriptHandler {
return false;
}
}
public String toString() {
boolean omitNullValuesSnapshot = this.omitNullValues;
boolean omitEmptyValuesSnapshot = this.omitEmptyValues;
String nextSeparator = "";
StringBuilder builder = (new StringBuilder(32)).append(this.className).append('{');
for(PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
Object value = valueHolder.value;
if (!(valueHolder instanceof PlayerDataScript.ToStringHelper.UnconditionalValueHolder)) {
@@ -321,13 +245,11 @@ public class PlayerDataScript implements IScriptHandler {
continue;
}
}
builder.append(nextSeparator);
nextSeparator = ", ";
if (valueHolder.name != null) {
builder.append(valueHolder.name).append('=');
}
if (value != null && value.getClass().isArray()) {
Object[] objectArray = new Object[]{value};
String arrayString = Arrays.deepToString(objectArray);
@@ -336,54 +258,45 @@ public class PlayerDataScript implements IScriptHandler {
builder.append(value);
}
}
return builder.append('}').toString();
}
private PlayerDataScript.ToStringHelper.ValueHolder addHolder() {
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = new PlayerDataScript.ToStringHelper.ValueHolder();
this.holderTail = this.holderTail.next = valueHolder;
return valueHolder;
}
private PlayerDataScript.ToStringHelper addHolder(@CheckForNull Object value) {
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
return this;
}
private PlayerDataScript.ToStringHelper addHolder(String name, @CheckForNull Object value) {
PlayerDataScript.ToStringHelper.ValueHolder valueHolder = this.addHolder();
valueHolder.value = value;
valueHolder.name = (String)Preconditions.checkNotNull(name);
return this;
}
private PlayerDataScript.ToStringHelper.UnconditionalValueHolder addUnconditionalHolder() {
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = new PlayerDataScript.ToStringHelper.UnconditionalValueHolder();
this.holderTail = this.holderTail.next = valueHolder;
return valueHolder;
}
private PlayerDataScript.ToStringHelper addUnconditionalHolder(Object value) {
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
valueHolder.value = value;
return this;
}
private PlayerDataScript.ToStringHelper addUnconditionalHolder(String name, Object value) {
PlayerDataScript.ToStringHelper.UnconditionalValueHolder valueHolder = this.addUnconditionalHolder();
valueHolder.value = value;
valueHolder.name = (String)Preconditions.checkNotNull(name);
return this;
}
private static final class UnconditionalValueHolder extends PlayerDataScript.ToStringHelper.ValueHolder {
private UnconditionalValueHolder() {
super();
}
}
private static class ValueHolder {
@CheckForNull
String name;
@@ -391,13 +304,11 @@ public class PlayerDataScript implements IScriptHandler {
Object value;
@CheckForNull
PlayerDataScript.ToStringHelper.ValueHolder next;
private ValueHolder() {
}
}
}
public static PlayerDataScript.ToStringHelper toStringHelper(Object self) {
return new PlayerDataScript.ToStringHelper(self.getClass().getSimpleName());
}
}
}
@@ -1,14 +1,10 @@
package noppes.npcs.entity;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.entity.Entity;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.util.MathHelper;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
public abstract class EntityNPCFlying extends EntityNPCInterface {
@@ -16,8 +12,6 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
super(world);
}
// FLY CHANGE [WIP]
@Override
public boolean canFly(){
return ai.movementType == 1;
@@ -35,59 +29,18 @@ public abstract class EntityNPCFlying extends EntityNPCInterface {
super.updateFallState(p_180433_1_, p_180433_3_);
}
@Override
public void moveEntityWithHeading(float p_70612_1_, float p_70612_2_){
if(!canFly()){
super.moveEntityWithHeading(p_70612_1_, p_70612_2_);
return;
}
if (this.isInWater()){
this.moveFlying(p_70612_1_, p_70612_2_, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.800000011920929D;
this.motionY *= 0.800000011920929D;
this.motionZ *= 0.800000011920929D;
}
else if (this.isInsideOfMaterial(Material.lava)){
this.moveFlying(p_70612_1_, p_70612_2_, 0.02F);
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= 0.5D;
this.motionY *= 0.5D;
this.motionZ *= 0.5D;
}
else{
float f2 = 0.91F;
if (this.onGround){
f2 = this.worldObj.getBlock((int)this.posX, (int)this.boundingBox.minY - 1, (int)this.posZ).slipperiness * 0.91F;
}
float f3 = 0.16277136F / (f2 * f2 * f2);
this.moveFlying(p_70612_1_, p_70612_2_, this.onGround ? 0.1F * f3 : 0.02F);
f2 = 0.91F;
if (this.onGround){
f2 = this.worldObj.getBlock((int)this.posX, (int)this.boundingBox.minY - 1, (int)this.posZ).slipperiness * 0.91F;
}
this.moveEntity(this.motionX, this.motionY, this.motionZ);
this.motionX *= (double)f2;
this.motionY *= (double)f2;
this.motionZ *= (double)f2;
public void onLivingUpdate()
{
super.onLivingUpdate();
if(!canFly()){
return;
}
this.prevLimbSwingAmount = this.limbSwingAmount;
double d1 = this.posX - this.prevPosX;
double d0 = this.posZ - this.prevPosZ;
float f4 = MathHelper.sqrt_double(d1 * d1 + d0 * d0) * 4.0F;
if (f4 > 1.0F){
f4 = 1.0F;
if (!this.onGround && !this.velocityChanged && this.motionY < 0 && this.hurtTime == 0)
{
this.motionY *= this.ai.flyGravity;
this.velocityChanged = true;
}
this.limbSwingAmount += (f4 - this.limbSwingAmount) * 0.4F;
this.limbSwing += this.limbSwingAmount;
}
@Override
@@ -20,11 +20,11 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.pathfinding.PathNavigate;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.AxisAlignedBB;
@@ -59,6 +59,8 @@ import noppes.npcs.ai.EntityAIMoveIndoors;
import noppes.npcs.ai.EntityAIPanic;
import noppes.npcs.ai.EntityAIWander;
import noppes.npcs.ai.EntityAIWatchClosest;
import noppes.npcs.ai.pathfinder.FlyingMoveHelper;
import noppes.npcs.ai.pathfinder.PathNavigateFlying;
import noppes.npcs.ai.selector.NPCAttackSelector;
import noppes.npcs.ai.target.EntityAIClearTarget;
import noppes.npcs.ai.target.EntityAIClosestTarget;
@@ -93,7 +95,6 @@ import noppes.npcs.roles.RoleCompanion;
import noppes.npcs.roles.RoleFollower;
import noppes.npcs.roles.RoleInterface;
import noppes.npcs.scripted.entity.ScriptNpc;
import noppes.npcs.scripted.entity.ScriptPlayer;
import noppes.npcs.scripted.event.ScriptEventAttack;
import noppes.npcs.scripted.event.ScriptEventDamaged;
import noppes.npcs.scripted.event.ScriptEventKilled;
@@ -153,12 +154,19 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
public boolean updateAI = false;
// Fly Change
// public EntityMoveHelper moveHelper;
// public PathNavigate navigator;
public FlyingMoveHelper flyMoveHelper = new FlyingMoveHelper(this);
public PathNavigate flyNavigator = new PathNavigateFlying(this, worldObj);
public EntityNPCInterface(World world) {
super(world);
try{
if (canFly()) {
this.getNavigator().setCanSwim(true);
this.tasks.addTask(0, new EntityAISwimming(this));
} else {
this.tasks.addTask(0, new EntityAIWaterNav(this));
}
dialogs = new HashMap<Integer, DialogOption>();
if(!CustomNpcs.DefaultInteractLine.isEmpty())
advanced.interactLines.lines.put(0, new Line(CustomNpcs.DefaultInteractLine));
@@ -196,7 +204,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(stats.maxHealth);
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(CustomNpcs.NpcNavRange);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(this.getSpeed());
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(this.getSpeed());
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(stats.getAttackStrength());
}
@@ -402,6 +410,29 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
return true;
}
public PathNavigate getNavigator() {
if(canFly())
return this.flyNavigator;
else {
return super.getNavigator();
}
}
public EntityMoveHelper getMoveHelper() {
if(canFly())
return this.flyMoveHelper;
else {
return super.getMoveHelper();
}
}
protected void updateAITasks()
{
super.updateAITasks();
this.getNavigator().onUpdateNavigation();
this.getMoveHelper().onUpdateMoveHelper();
}
public void addInteract(EntityLivingBase entity){
if( !ai.stopAndInteract || isAttacking() || !entity.isEntityAlive())
@@ -597,17 +628,12 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
this.targetTasks.addTask(3, new EntityAIOwnerHurtByTarget(this));
this.targetTasks.addTask(4, new EntityAIOwnerHurtTarget(this));
this.tasks.addTask(0, new EntityAIWaterNav(this));
// if(canFly()){
// this.moveHelper = new FlyingMoveHelper(this);
// this.navigator = new PathNavigateFlying(this, worldObj);
// }
// else{
// this.moveHelper = new EntityMoveHelper(this);
// this.navigator = new PathNavigateGround(this, worldObj);
// this.tasks.addTask(0, new EntityAIWaterNav(this));
// }
if (canFly()) {
this.getNavigator().setCanSwim(true);
this.tasks.addTask(0, new EntityAISwimming(this));
} else {
this.tasks.addTask(0, new EntityAIWaterNav(this));
}
this.taskCount = 1;
this.doorInteractType();
@@ -905,13 +931,6 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
return true;
}
@Override
public void addVelocity(double d, double d1, double d2) {
if (isWalking() && !isKilled())
super.addVelocity(d, d1, d2);
}
@Override
public void readEntityFromNBT(NBTTagCompound compound) {
super.readEntityFromNBT(compound);
@@ -1450,7 +1469,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
public NBTTagCompound writeSpawnData() {
NBTTagCompound compound = new NBTTagCompound();
display.writeToNBT(compound);
compound.setInteger("MaxHealth", stats.maxHealth);
compound.setDouble("MaxHealth", stats.maxHealth);
compound.setTag("Armor", NBTTags.nbtItemStackList(inventory.getArmor()));
compound.setTag("Weapons", NBTTags.nbtItemStackList(inventory.getWeapons()));
compound.setInteger("Speed", ai.getWalkingSpeed());
@@ -1489,7 +1508,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
}
}
public void readSpawnData(NBTTagCompound compound) {
stats.maxHealth = compound.getInteger("MaxHealth");
stats.maxHealth = compound.getDouble("MaxHealth");
ai.setWalkingSpeed(compound.getInteger("Speed"));
stats.hideKilledBody = compound.getBoolean("DeadBody");
ai.standingType = EnumStandingType.values()[compound.getInteger("StandingState") % EnumStandingType.values().length];
@@ -1571,11 +1590,27 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
if(!ai.ignoreCobweb)
super.setInWeb();
}
@Override
public boolean canBeCollidedWith(){
return !isKilled();
}
// obviously we dont want this
@Override
public boolean canBePushed() {
return false;
}
// not any entity can collide. if you want projectiles to still be
// effective, you will have to handle those yourself
@Override
protected void collideWithEntity(Entity p_82167_1_) {}
// checks for any entity within a certain boundingbox, eg minecarts
@Override
protected void collideWithNearbyEntities() {}
public boolean canFly(){
return false;
}
@@ -101,6 +101,8 @@ public class DataTimers implements ITimers {
this.timers = new HashMap();
}
public int size() { return this.timers.size(); }
class Timer {
public int id;
private boolean repeat;
@@ -528,7 +528,7 @@ public class RoleCompanion extends RoleInterface {
public void setStats(){
ItemStack weapon = npc.inventory.getWeapon();
npc.stats.setAttackStrength((int) (1 + getSwordDamage(weapon)));
npc.stats.setAttackStrength((float) (1 + getSwordDamage(weapon)));
npc.stats.healthRegen = 0;
npc.stats.combatRegen = 0;
int ranged = getTalentLevel(EnumCompanionTalent.RANGED);
@@ -113,7 +113,7 @@ public class ScriptEntityParticle {
this.directory = directory;
}
public void setHEXcolor(int HEXcolor) {
public void setHEXColor(int HEXcolor) {
this.HEXcolor = HEXcolor;
}
@@ -1,9 +1,14 @@
package noppes.npcs.scripted;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Multimap;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
@@ -145,6 +150,126 @@ public class ScriptItemStack implements IItemStack {
}
return false;
}
public void addEnchant(int id, int strength) {
Enchantment ench = Enchantment.enchantmentsList[id];
if (ench == null) {
throw new CustomNPCsException("Unknown enchant id:" + id, new Object[0]);
} else {
this.item.addEnchantment(ench, strength);
}
}
public void setAttribute(String name, double value) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
this.item.setTagCompound(compound = new NBTTagCompound());
}
NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10);
NBTTagList newList = new NBTTagList();
NBTTagCompound nbttagcompound;
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
nbttagcompound = nbttaglist.getCompoundTagAt(i);
if (!nbttagcompound.getString("AttributeName").equals(name)) {
newList.appendTag(nbttagcompound);
}
}
if (value != 0.0D) {
AttributeModifier attributeModifier = new AttributeModifier(name, value, 0);
nbttagcompound = new NBTTagCompound();
nbttagcompound.setString("Name", attributeModifier.getName());
nbttagcompound.setDouble("Amount", attributeModifier.getAmount());
nbttagcompound.setInteger("Operation", attributeModifier.getOperation());
nbttagcompound.setLong("UUIDMost", attributeModifier.getID().getMostSignificantBits());
nbttagcompound.setLong("UUIDLeast", attributeModifier.getID().getLeastSignificantBits());
nbttagcompound.setString("AttributeName", name);
newList.appendTag(nbttagcompound);
}
compound.setTag("AttributeModifiers", newList);
}
public double getAttribute(String name) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
return 0.0D;
} else {
Multimap<String, AttributeModifier> map = this.item.getAttributeModifiers();
Iterator var4 = map.entries().iterator();
while(var4.hasNext()) {
Map.Entry entry = (Map.Entry)var4.next();
if (((String)entry.getKey()).equals(name)) {
AttributeModifier mod = (AttributeModifier)entry.getValue();
return mod.getAmount();
}
}
return 0.0D;
}
}
public String[] getLore() {
NBTTagCompound compound = this.item.getTagCompound().getCompoundTag("display");
if (compound != null && compound.func_150299_b("Lore") == 9) {
NBTTagList nbttaglist = compound.getTagList("Lore", 8);
if (nbttaglist.tagCount() < 1) {
return new String[0];
} else {
List<String> lore = new ArrayList();
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
lore.add(nbttaglist.getStringTagAt(i));
}
return (String[])((String[])lore.toArray(new String[lore.size()]));
}
} else {
return new String[0];
}
}
public void setLore(String[] lore) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
this.item.setTagCompound(compound = new NBTTagCompound());
}
NBTTagList nbttaglist = compound.getTagList("display", 10);
NBTTagList newList = new NBTTagList();
String[] var4 = lore;
int var5 = lore.length;
for(int var6 = 0; var6 < var5; ++var6) {
String s = var4[var6];
newList.appendTag(new NBTTagString(s));
}
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setTag("Lore", newList);
compound.setTag("display", nbttagcompound);
}
public boolean hasAttribute(String name) {
NBTTagCompound compound = this.item.getTagCompound();
if (compound == null) {
return false;
} else {
NBTTagList nbttaglist = compound.getTagList("AttributeModifiers", 10);
for(int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound c = nbttaglist.getCompoundTagAt(i);
if (c.getString("AttributeName").equals(name)) {
return true;
}
}
return false;
}
}
/**
* @since 1.7.10d
@@ -0,0 +1,524 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptItemStack;
import java.util.ArrayList;
import java.util.Locale;
public class ScriptDBCPlayer<T extends EntityPlayerMP> extends ScriptPlayer<T>{
public T player;
public ScriptDBCPlayer(T player){
super(player);
this.player = player;
}
public void setStat(String stat, int value) {
stat = stat.toLowerCase().trim();
switch (stat) {
case "str":
case "strength":
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStrI", value);
break;
case "dex":
case "dexterity":
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcDexI", value);
break;
case "con":
case "constitution":
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcCnsI", value);
break;
case "wil":
case "willpower":
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcWilI", value);
break;
case "mnd":
case "mind":
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcIntI", value);
break;
case "spi":
case "spirit":
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcCncI", value);
break;
}
}
public int getStat(String stat) {
stat = stat.toLowerCase().trim();
switch (stat) {
case "str":
case "strength":
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcStrI");
case "dex":
case "dexterity":
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcDexI");
case "con":
case "constitution":
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcCnsI");
case "wil":
case "willpower":
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcWilI");
case "mnd":
case "mind":
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcIntI");
case "spi":
case "spirit":
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcCncI");
}
throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" +
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]);
}
private double applyOperator(String method, double n1, double n2) {
if (method.equals("+")) {
n1 += n2;
} else if (method.equals("-")) {
n1 -= n2;
} else if (method.equals("*")) {
n1 *= n2;
} else if (method.equals("/")) {
n1 /= n2;
} else if (method.equals("%")) {
n1 %= n2;
}
return n1;
}
public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
addBonusAttribute(stat,bonusID,operation,attributeValue,true);
}
public void addBonusAttribute(String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList){
bonusAttribute("add",stat,bonusID,operation,attributeValue,endOfTheList);
}
public void addToBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
bonusAttribute("addto",stat,bonusID,operation,attributeValue,true);
}
public void setBonusAttribute(String stat, String bonusID, String operation, double attributeValue){
bonusAttribute("set",stat,bonusID,operation,attributeValue,true);
}
public void getBonusAttribute(String stat, String bonusID){
bonusAttribute("get",stat,bonusID,"*",1.0,true);
}
public void removeBonusAttribute(String stat, String bonusID){
bonusAttribute("remove",stat,bonusID,"*",1.0,true);
}
public void clearBonusAttribute(String stat){
bonusAttribute("clear",stat,"","*",1.0,true);
}
public String bonusAttribute(String action, String stat, String bonusID) {
String[] actions = new String[]{"get", "remove", "clear"};
boolean valid = false;
for(String s : actions){
if(s.equals(action.toLowerCase())){
valid = true;
}
}
if (!valid) {
throw new CustomNPCsException("Action can be: get/remove/clear", new Object[0]);
}
return bonusAttribute(action,stat,bonusID,"*",1.0,false);
}
public String bonusAttribute(String action, String stat, String bonusID, String operation, double attributeValue, boolean endOfTheList) {
String[] actions = new String[]{"add", "addto", "set", "get", "remove", "clear"};
String[] operations = new String[]{"+", "-", "*", "/", "%"};
boolean valid = false;
for(String s : actions){
if(s.equals(action.toLowerCase())){
valid = true;
}
}
if (!valid) {
throw new CustomNPCsException("Action can be: add/addTo/set/get/remove/clear", new Object[0]);
}
if(!action.equals("remove") && !action.equals("get") && !action.equals("clear")) {
valid = false;
for (String s : operations) {
if (s.equals(operation)) {
valid = true;
}
}
if (!valid) {
throw new CustomNPCsException("Operation can be: + - * / %", new Object[0]);
}
}
stat = stat.toLowerCase().trim();
switch (stat) {
case "strength":
stat = "str";
break;
case "dexterity":
stat = "dex";
break;
case "constitution":
stat = "con";
break;
case "willpower":
stat = "wil";
break;
case "mind":
stat = "mnd";
break;
case "spirit":
stat = "spi";
break;
}
if(!(stat.equals("str") || stat.equals("dex") || stat.equals("con") || stat.equals("wil") || stat.equals("mnd") || stat.equals("spi")))
throw new CustomNPCsException("Invalid stat name: " + stat + "\nValid stat names are:" +
"\nstr, dex, con, wil, mnd, spi\nstrength, dexterity, constitution, willpower, mind, spirit",new Object[0]);
String bonusValueString = operation + attributeValue;
String bonus = player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcAttrBonus"+stat);
String bonuses[] = bonus.split("\\|");
String[][] bonusValues = new String[bonuses.length][2];
if (bonuses.length > 0 && bonuses[0].length() > 0) {
for(int i = 0; i < bonuses.length; ++i) {
String[] bonusValue = bonuses[i].split("\\;");
bonusValues[i][0] = bonusValue[0];
bonusValues[i][1] = bonusValue[1];
}
}
switch (action) {
case "get":
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) {
for (String[] s : bonusValues) {
if (s[0].equals(bonusID))
return s[1];
}
}
return "";
case "clear":
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat))
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, "");
break;
case "remove":
String newBonusString = "";
if(player.getEntityData().getCompoundTag("PlayerPersisted").hasKey("jrmcAttrBonus"+stat)) {
int num = -1;
boolean number;
boolean run = false;
String[] bonusValue;
try {
num = Integer.parseInt(bonusID);
number = true;
} catch (Exception var33) {
number = false;
}
for(int i = 0; i < bonuses.length; ++i) {
bonusValue = bonuses[i].split("\\;");
bonusValues[i][0] = bonusValue[0];
if (number && i == num || !number && bonusValues[i][0].equals(bonusID)) {
bonuses[i] = "";
run = true;
break;
}
}
if (run) {
String startString = "";
for (int i = 0; i < bonuses.length; ++i) {
if (bonuses[i] != null && bonuses[i].length() > 0) {
startString = startString + bonuses[i] + (bonuses.length - 1 == i ? "" : "|");
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
}
}
break;
case "add":
boolean nbtFail = false;
for (int id = 0; id < bonuses.length; ++id) {
String[] bonusValue = bonuses[id].split("\\;");
bonusValues[id][0] = bonusValue[0];
if (bonusValues[id][0].equals(bonusID)) {
nbtFail = true;
break;
}
}
if (!nbtFail) {
if (endOfTheList) {
if (bonus.length() == 0) {
bonus = bonusID + ";" + bonusValueString;
} else {
bonus = bonus + "|" + bonusID + ";" + bonusValueString;
}
} else {
if (bonus.length() == 0) {
bonus = bonusID + ";" + bonusValueString;
} else {
bonus = bonusID + ";" + bonusValueString + "|" + bonus;
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, bonus);
}
break;
case "set": {
String noNBTText;
int startIndex = -1;
boolean number = false;
boolean run = false;
try {
startIndex = Integer.parseInt(bonusID);
number = true;
} catch (Exception var34) {
number = false;
}
for (startIndex = 0; startIndex < bonuses.length; ++startIndex) {
String[] bonusValue = bonuses[startIndex].split("\\;");
bonusValues[startIndex][0] = bonusValue[0];
if (number && startIndex == startIndex || !number && bonusValues[startIndex][0].equals(bonusID)) {
noNBTText = bonusValues[startIndex][0] + ";" + bonusValueString;
bonuses[startIndex] = "";
run = true;
bonuses[startIndex] = noNBTText;
bonusValue = bonuses[startIndex].split("\\;");
bonusValues[startIndex][0] = bonusValue[0];
bonusValues[startIndex][1] = bonusValue[1];
break;
}
}
if (run) {
String startString = "";
for (int i = 0; i < bonuses.length; ++i) {
if (bonuses[i] != null && bonuses[i].length() > 0) {
startString = startString + bonuses[i] + (bonuses.length - 1 == i ? "" : "|");
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
}
break;
}
case "addto": {
boolean number;
boolean run = false;
int id = -1;
try {
id = Integer.parseInt(bonusID);
number = true;
} catch (Exception var35) {
number = false;
}
for (int i = 0; i < bonuses.length; ++i) {
String[] bonusValue = bonuses[i].split("\\;");
bonusValues[i][0] = bonusValue[0];
if (number && i == id || !number && bonusValues[i][0].equals(bonusID)) {
if (!bonusValues[i][1].contains("nbt_") && !bonusValues[i][1].contains("NBT_") && !bonusValueString.contains("nbt_") && !bonusValueString.contains("NBT_")) {
double value = Double.parseDouble(bonusValues[i][1].substring(1));
double resultValue = applyOperator(operation, value, attributeValue);
String result = bonusValues[i][1].substring(0, 1) + resultValue;
String data = bonusValues[i][0] + ";" + result;
bonuses[i] = data;
bonusValue = bonuses[i].split("\\;");
bonusValues[i][0] = bonusValue[0];
bonusValues[i][1] = bonusValue[1];
run = true;
}
break;
}
}
if (run) {
String startString = "";
for (int i = 0; i < bonuses.length; ++i) {
if (bonuses[i] != null && bonuses[i].length() > 0) {
startString = startString + bonuses[i] + (bonuses.length - 1 == i ? "" : "|");
}
}
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcAttrBonus"+stat, startString);
}
break;
}
}
return "";
}
public void setRelease(byte release){
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcRelease",release);
}
public byte getRelease(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRelease");
}
public void setBody(int body){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcBdy",body);
}
public int getBody(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcBdy");
}
public void setStamina(int stamina){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcStamina",stamina);
}
public int getStamina(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcStamina");
}
public void setKi(int ki){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcEnrgy",ki);
}
public int getKi(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcEnrgy");
}
public void setTP(int tp){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcTpint",tp);
}
public int getTP(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcTpint");
}
public void setGravity(float gravity){
player.getEntityData().getCompoundTag("PlayerPersisted").setFloat("jrmcGravForce",gravity);
}
public float getGravity(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getFloat("jrmcGravForce");
}
public boolean isBlocking(){
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
return compound.getCompoundTag("JRMCEP").getInteger("blocking") == 1;
}
public void setHairCode(String hairCode){
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
compound.getCompoundTag("JRMCEP").setString("haircode",hairCode);
}
public String getHairCode(){
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
return compound.getCompoundTag("JRMCEP").getString("haircode");
}
public void setExtraCode(String extraCode){
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
compound.getCompoundTag("JRMCEP").setString("extracode",extraCode);
}
public String getExtraCode(){
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
return compound.getCompoundTag("JRMCEP").getString("extracode");
}
public ScriptItemStack[] getInventory(){
NBTTagCompound compound = new NBTTagCompound();
this.player.writeToNBT(compound);
NBTTagList list = compound.getCompoundTag("JRMCEP").getTagList("dbcExtraInvTag",10);
ScriptItemStack[] itemList = new ScriptItemStack[list.tagCount()];
for (int i = 0; i < list.tagCount(); i++) {
ItemStack itemStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(i));
itemList[i] = new ScriptItemStack(itemStack);
}
return itemList;
}
public void setForm(byte form){
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState",form);
}
public byte getForm(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState");
}
public void setForm2(byte form2){
player.getEntityData().getCompoundTag("PlayerPersisted").setByte("jrmcState2",form2);
}
public byte getForm2(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcState2");
}
public void setPowerPoints(int points){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcArcRsrv",points);
}
public int getPowerPoints(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcArcRsrv");
}
public void setAuraColor(int color){
player.getEntityData().getCompoundTag("PlayerPersisted").setInteger("jrmcAuraColor",color);
}
public int getAuraColor(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcAuraColor");
}
public void setFormLevel(int level){
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSltX","TR"+level);
}
public int getFormLevel(){
return Integer.parseInt(player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSltX").replace("TR",""));
}
public void setSkills(String skills){
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcSSlts",skills);
}
public String getSkills(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcSSlts");
}
public void setJRMCSE(String statusEffects){
player.getEntityData().getCompoundTag("PlayerPersisted").setString("jrmcStatusEff",statusEffects);
}
public String getJRMCSE(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getString("jrmcStatusEff");
}
public byte getDBCClass(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcClass");
}
public int getRace(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcRace");
}
public int getPowerType(){
return player.getEntityData().getCompoundTag("PlayerPersisted").getByte("jrmcPwrtyp");
}
public int getKillCount(String type){
type = type.toLowerCase().trim();
int evilKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountEvil");
int goodKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountGood");
int neutKills = player.getEntityData().getCompoundTag("PlayerPersisted").getInteger("jrmcKillCountNeut");
switch (type) {
case "evil":
return evilKills;
case "good":
return goodKills;
case "neutral":
return neutKills;
case "all":
return evilKills + goodKills + neutKills;
}
throw new CustomNPCsException("Invalid kill type: " + type + "\nValid kill types are: evil, good, neutral, all", new Object[0]);
}
}
@@ -18,14 +18,12 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagString;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.WorldServer;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.controllers.ServerCloneController;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptEntityParticle;
import noppes.npcs.scripted.ScriptItemStack;
import noppes.npcs.scripted.*;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.interfaces.IEntity;
import noppes.npcs.scripted.interfaces.INbt;
@@ -457,20 +455,17 @@ public class ScriptEntity<T extends Entity> implements IEntity {
* @param power How strong the knockback is
* @param direction The direction in which he flies back (0-360). Usually based on getRotation()
*/
@Override
public void knockback(int power, float direction){
float v = direction * (float)Math.PI / 180.0F;
entity.addVelocity(-MathHelper.sin(v) * (float)power, 0.1D + power * 0.04f, MathHelper.cos(v) * (float)power);
entity.motionX *= 0.6D;
entity.motionZ *= 0.6D;
entity.attackEntityFrom(DamageSource.outOfWorld, 0.0001F);
entity.hurtResistantTime = 0;
entity.addVelocity(-MathHelper.sin(v) * (float)power, power, MathHelper.cos(v) * (float)power);
entity.velocityChanged = true;
}
public void knockback(int xpower, int ypower, int zpower, float direction){
float v = direction * (float)Math.PI / 180.0F;
entity.addVelocity(-MathHelper.sin(v) * (float)xpower, 0.1D + ypower * 0.04f, MathHelper.cos(v) * (float)zpower);
entity.attackEntityFrom(DamageSource.outOfWorld, 0.0001F);
entity.hurtResistantTime = 0;
entity.addVelocity(-MathHelper.sin(v) * (float)xpower, ypower, MathHelper.cos(v) * (float)zpower);
entity.velocityChanged = true;
}
public void setImmune(int ticks) {
@@ -528,4 +523,8 @@ public class ScriptEntity<T extends Entity> implements IEntity {
ServerCloneController.Instance.addClone(compound, name, tab);
}
}
public ScriptWorld getWorld() {
return (ScriptWorld)NpcAPI.Instance().getIWorld((WorldServer) entity.worldObj);
}
}
@@ -1,11 +1,13 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.MathHelper;
import noppes.npcs.controllers.ScriptController;
import noppes.npcs.scripted.ScriptItemStack;
import noppes.npcs.scripted.constants.EntityType;
@@ -49,8 +51,8 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
/**
* @return Entity's max health
*/
public float getMaxHealth(){
return entity.getMaxHealth();
public double getMaxHealth(){
return entity.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue();
}
/**
* @return Whether or not this entity is attacking something
@@ -122,13 +124,9 @@ public class ScriptLivingBase<T extends EntityLivingBase> extends ScriptEntity<T
if(strength < 0)
strength = 0;
else if(strength > 255)
strength = 255;
if(duration < 0)
duration = 0;
else if(duration > 1000000)
duration = 1000000;
if(!Potion.potionTypes[effect].isInstant())
duration *= 20;
@@ -1,10 +1,10 @@
package noppes.npcs.scripted.entity;
import net.minecraft.entity.player.EntityPlayerMP;
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.controllers.Line;
import noppes.npcs.entity.EntityCustomNpc;
@@ -33,31 +33,28 @@ import noppes.npcs.scripted.roles.ScriptRoleTransporter;
import noppes.npcs.util.ValueUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> implements ICustomNpc {
public EntityCustomNpc npc;
public EntityNPCInterface npc;
public ScriptNpc(T npc){
super(npc);
this.npc = (EntityCustomNpc)npc;
this.npc = npc;
}
/**
* @return Returns the current npcs size 1-30
* @return Returns the current npcs size
*/
public int getSize(){
return npc.display.modelSize;
}
/**
* @param size The size of the npc (1-30) default is 5
* @param size The size of the npc. Default is 5
*/
public void setSize(int size){
if(size > 30)
size = 30;
else if(size < 1)
if(size < 1)
size = 1;
npc.display.modelSize = size;
npc.script.clientNeedsUpdate = true;
@@ -186,7 +183,7 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
/**
* @param health New max health
*/
public void setMaxHealth(int health){
public void setMaxHealth(double health){
npc.stats.setMaxHealth(health);
npc.script.clientNeedsUpdate = true;
}
@@ -219,6 +216,22 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.setFaction(id);
}
public void setAttackFactions(boolean attackOtherFactions){
npc.advanced.attackOtherFactions = attackOtherFactions;
}
public boolean getAttackFactions(){
return npc.advanced.attackOtherFactions;
}
public void setDefendFaction(boolean defendFaction){
npc.advanced.defendFaction = defendFaction;
}
public boolean getDefendFaction(){
return npc.advanced.defendFaction;
}
@Override
public int getType(){
return EntityType.NPC;
@@ -376,6 +389,22 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.inventory.setProjectile(item.item);
npc.script.aiNeedsUpdate = true;
}
public boolean canAimWhileShooting() {
return !npc.stats.aimWhileShooting;
}
public void aimWhileShooting(boolean aimWhileShooting) {
npc.stats.aimWhileShooting = aimWhileShooting;
}
public String getFireSound() {
return npc.stats.fireSound;
}
public void setFireSound(String fireSound) {
npc.stats.fireSound = fireSound;
}
/**
* @param slot The armor slot to return. 0:head, 1:body, 2:legs, 3:boots
@@ -402,6 +431,91 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.script.clientNeedsUpdate = true;
}
/**
*
* @param slot The slot from the NPC's drop list to return (0-8)
* @return
*/
public ScriptItemStack getLootItem(int slot) {
return new ScriptItemStack(npc.inventory.getStackInSlot(slot+7));
}
/**
*
* @param slot The slot from the NPC's drop list to change
* @param item The item the drop list slot will be changed to
*/
public void setLootItem(int slot, ScriptItemStack item) {
npc.inventory.setInventorySlotContents(slot+7, item.item);
}
/**
*
* @param slot The slot from the NPC's drop list to return (0-8)
* @return The chance of dropping the item in this slot. Returns 100 if the slot is not found.
*/
public int getLootChance(int slot) {
if(!npc.inventory.dropchance.containsKey(slot))
return 100;
return npc.inventory.dropchance.get(slot);
}
/**
*
* @param slot The slot from the NPC's drop list to change
* @param chance The new chance of dropping the item in this slot
*/
public void setLootChance(int slot, int chance) {
if(slot < 0 || slot > 8)
return;
if(chance < 0)
chance = 0;
if(chance > 100)
chance = 100;
npc.inventory.dropchance.put(slot,chance);
}
public int getLootMode(){
return npc.inventory.lootMode;
}
public void setLootMode(int lootMode){
if(lootMode < 0 || lootMode > 1)
return;
npc.inventory.lootMode = lootMode;
}
public void setMinLootXP(int lootXP) {
if(lootXP > npc.inventory.maxExp)
lootXP = npc.inventory.maxExp;
if(lootXP < 0)
lootXP = 0;
if(lootXP > Short.MAX_VALUE)
lootXP = Short.MAX_VALUE;
npc.inventory.minExp = lootXP;
}
public void setMaxLootXP(int lootXP) {
if(lootXP < npc.inventory.minExp)
lootXP = npc.inventory.minExp;
if(lootXP < 0)
lootXP = 0;
if(lootXP > Short.MAX_VALUE)
lootXP = Short.MAX_VALUE;
npc.inventory.maxExp = lootXP;
}
public int getMinLootXP(){
return npc.inventory.minExp;
}
public int getMaxLootXP(){
return npc.inventory.maxExp;
}
/**
* @param type The AnimationType
@@ -419,7 +533,81 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.ai.animationType = EnumAnimation.LYING;
else if(type == AnimationType.HUGGING)
npc.ai.animationType = EnumAnimation.HUG;
}
public void setTacticalVariant(int variant){
if(variant > EnumNavType.values().length-1)
return;
npc.ai.tacticalVariant = EnumNavType.values()[variant];
}
public int getTacticalVariant(){
return npc.ai.tacticalVariant.ordinal();
}
public void setTacticalVariant(String variant){
boolean found = false;
for(String s : EnumNavType.names()){
if(s.equals(variant))
found = true;
}
if(!found)
return;
npc.ai.tacticalVariant = EnumNavType.valueOf(variant);
}
public String getTacticalVariantName(){
return npc.ai.tacticalVariant.name();
}
public void setTacticalRadius(int tacticalRadius){
if(tacticalRadius < 0)
tacticalRadius = 0;
npc.ai.tacticalRadius = tacticalRadius;
}
public int getTacticalRadius(){
return npc.ai.tacticalRadius;
}
public void setIgnoreCobweb(boolean ignore){
npc.ai.ignoreCobweb = ignore;
}
public boolean getIgnoreCobweb(){
return npc.ai.ignoreCobweb;
}
public void setOnFoundEnemy(int onAttack){
if(onAttack < 0 || onAttack > 3)
return;
npc.ai.onAttack = onAttack;
}
public int onFoundEnemy(){
return npc.ai.onAttack;
}
public void setShelterFrom(int shelterFrom){
if(shelterFrom < 0 || shelterFrom > 2)
return;
npc.ai.findShelter = shelterFrom;
}
public int getShelterFrom(){
return npc.ai.findShelter;
}
public boolean hasLivingAnimation() {
return !npc.display.disableLivingAnimation;
}
public void setLivingAnimation(boolean livingAnimation) {
npc.display.disableLivingAnimation = !livingAnimation;
}
/**
@@ -488,14 +676,14 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
/**
* @return The melee strength
*/
public int getMeleeStrength(){
public float getMeleeStrength(){
return npc.stats.getAttackStrength();
}
/**
* @param strength The melee strength
*/
public void setMeleeStrength(int strength){
public void setMeleeStrength(float strength){
npc.stats.setAttackStrength(strength);
}
@@ -516,15 +704,15 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
/**
* @return The ranged strength
*/
public int getRangedStrength(){
public float getRangedStrength(){
return npc.stats.pDamage;
}
/**
* @param strength The ranged strength
*/
public void setRangedStrength(int strength){
npc.stats.pDamage = strength;
public void setRangedStrength(float strength){
npc.stats.pDamage = (float)(Math.floor(strength));
}
/**
@@ -555,53 +743,89 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
npc.stats.burstCount = count;
}
/**
* @param player The player to give the item to
* @param item The item given to the player
*/
public int getRespawnTime() {
return npc.stats.respawnTime;
}
public void setRespawnTime(int time) {
npc.stats.respawnTime = time;
}
public int getRespawnCycle() {
return npc.stats.spawnCycle;
}
public void setRespawnCycle(int cycle) {
if(cycle < 0)
cycle = 0;
if(cycle > 3)
cycle = 3;
npc.stats.spawnCycle = cycle;
}
public boolean getHideKilledBody() {
return npc.stats.hideKilledBody;
}
public void hideKilledBody(boolean hide) {
npc.stats.hideKilledBody = hide;
}
public boolean naturallyDespawns() {
return npc.stats.canDespawn;
}
public void setNaturallyDespawns(boolean canDespawn) {
npc.stats.canDespawn = canDespawn;
}
public void giveItem(ScriptPlayer player, ScriptItemStack item){
npc.givePlayerItem(player.player, item.item);
}
/**
* On servers the enable-command-block option in the server.properties needs to be set to true
* @param command The command to be executed
*/
public void executeCommand(String command){
NoppesUtilServer.runCommand(npc, npc.getCommandSenderName(), command, null);
}
public void setHeadScale(float x, float y, float z){
npc.modelData.head.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
npc.modelData.head.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
npc.modelData.head.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
npc.script.clientNeedsUpdate = true;
if(npc instanceof EntityCustomNpc) {
((EntityCustomNpc) this.npc).modelData.head.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
((EntityCustomNpc) this.npc).modelData.head.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
((EntityCustomNpc) this.npc).modelData.head.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
npc.script.clientNeedsUpdate = true;
}
}
public void setBodyScale(float x, float y, float z){
npc.modelData.body.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
npc.modelData.body.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
npc.modelData.body.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
npc.script.clientNeedsUpdate = true;
if(npc instanceof EntityCustomNpc) {
((EntityCustomNpc) this.npc).modelData.body.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
((EntityCustomNpc) this.npc).modelData.body.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
((EntityCustomNpc) this.npc).modelData.body.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
npc.script.clientNeedsUpdate = true;
}
}
public void setArmsScale(float x, float y, float z){
npc.modelData.arms.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
npc.modelData.arms.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
npc.modelData.arms.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
npc.script.clientNeedsUpdate = true;
if(npc instanceof EntityCustomNpc) {
((EntityCustomNpc) this.npc).modelData.arms.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
((EntityCustomNpc) this.npc).modelData.arms.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
((EntityCustomNpc) this.npc).modelData.arms.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
npc.script.clientNeedsUpdate = true;
}
}
public void setLegsScale(float x, float y, float z){
npc.modelData.legs.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
npc.modelData.legs.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
npc.modelData.legs.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
npc.script.clientNeedsUpdate = true;
if(npc instanceof EntityCustomNpc) {
((EntityCustomNpc) this.npc).modelData.legs.scaleX = ValueUtil.correctFloat(x, 0.5f, 1.5f);
((EntityCustomNpc) this.npc).modelData.legs.scaleY = ValueUtil.correctFloat(y, 0.5f, 1.5f);
((EntityCustomNpc) this.npc).modelData.legs.scaleZ = ValueUtil.correctFloat(z, 0.5f, 1.5f);
npc.script.clientNeedsUpdate = true;
}
}
/**
@@ -673,29 +897,29 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
/**
* @return Returns the combat health regen per second
*/
public int getCombatRegen(){
public float getCombatRegen(){
return npc.stats.combatRegen;
}
/**
* @param regen The combat health regen per second
*/
public void setCombatRegen(int regen){
npc.stats.combatRegen = regen;
public void setCombatRegen(float regen){
npc.stats.combatRegen = (float)(Math.floor(regen));
}
/**
* @return Returns the health regen per second when not in combat
*/
public int getHealthRegen(){
public float getHealthRegen(){
return npc.stats.healthRegen;
}
/**
* @param regen The health regen per second when not in combat
*/
public void setHealthRegen(int regen){
npc.stats.healthRegen = regen;
public void setHealthRegen(float regen){
npc.stats.healthRegen = (float)(Math.floor(regen));
}
@Override
@@ -706,4 +930,88 @@ public class ScriptNpc<T extends EntityNPCInterface> extends ScriptLiving<T> imp
public ITimers getTimers() {
return ((EntityNPCInterface)this.npc).timers;
}
public void setFly(int fly){
if(fly > 0)
fly = 1;
else fly = 0;
npc.ai.movementType = fly;
}
public boolean canFly(){
return npc.ai.movementType == 1;
}
public void setFlySpeed(double flySpeed){
if(flySpeed < 0.0D)
flySpeed = 0.0D;
npc.ai.flySpeed = flySpeed;
}
public double getFlySpeed(double flySpeed){
return npc.ai.flySpeed;
}
public void setFlyGravity(double flyGravity){
if(flyGravity < 0.0D)
flyGravity = 0.0D;
if(flyGravity > 1.0D)
flyGravity = 1.0D;
npc.ai.flyGravity = flyGravity;
}
public double getFlyGravity(double flySpeed){
return npc.ai.flyGravity;
}
public void setSpeed(int speed) {
npc.ai.setWalkingSpeed(speed);
}
public int getSpeed() {
return npc.ai.getWalkingSpeed();
}
public void setSkinType(byte type) {
npc.display.skinType = type;
npc.updateClient = true;
}
public byte getSkinType() {
return npc.display.skinType;
}
public void setSkinUrl(String url){
if(this.npc.display.url.equals(url))
return;
this.npc.display.url = url;
npc.textureLocation = null;
npc.display.skinType = 2;
npc.updateClient = true;
}
public String getSkinUrl() {
return this.npc.display.url;
}
public void setCloakTexture(String cloakTexture) {
npc.display.cloakTexture = cloakTexture;
npc.updateClient = true;
}
public String getCloakTexture() {
return npc.display.cloakTexture;
}
public void setOverlayTexture(String overlayTexture) {
npc.display.glowTexture = overlayTexture;
npc.updateClient = true;
}
public String getOverlayTexture() {
return npc.display.glowTexture;
}
}
@@ -24,6 +24,7 @@ import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptItemStack;
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
@@ -32,6 +33,9 @@ import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.util.ValueUtil;
import java.util.Iterator;
import java.util.Set;
public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T> implements IPlayer {
public T player;
public ScriptPlayer(T player){
@@ -383,4 +387,21 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
PlayerData data = PlayerDataController.instance.getPlayerData(player);
return data.getGUIOpen();
}
public ScriptDBCPlayer<T> getDBCPlayer() {
Set keySet = player.getEntityData().getCompoundTag("PlayerPersisted").func_150296_c();
Iterator iterator = keySet.iterator();
while (iterator.hasNext())
{
String s = (String)iterator.next();
if(s.contains("jrmc"))
return new ScriptDBCPlayer<T>(this.player);
}
return null;
}
public boolean blocking() {
return player.isBlocking();
}
}
@@ -6,6 +6,7 @@
package noppes.npcs.scripted.interfaces;
import net.minecraft.entity.EntityCreature;
import noppes.npcs.constants.EnumNavType;
import noppes.npcs.scripted.ScriptFaction;
import noppes.npcs.scripted.ScriptItemStack;
import noppes.npcs.scripted.entity.ScriptLivingBase;
@@ -105,7 +106,7 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @param health New max health
*/
public void setMaxHealth(int health);
public void setMaxHealth(double health);
/**
* @param bo Whether or not the npc will try to return to his home position
@@ -127,6 +128,30 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
*/
public void setFaction(int id);
/**
*
* @param attackOtherFactions True if you want the NPC to attack other factions, false otherwise.
*/
public void setAttackFactions(boolean attackOtherFactions);
/**
*
* @return Returns true if the NPC attacks other factions, false otherwise.
*/
public boolean getAttackFactions();
/**
*
* @param defendFaction True if the NPC should defend faction members, false otherwise.
*/
public void setDefendFaction(boolean defendFaction);
/**
*
* @return Returns true if the NPC should defend faction members, false otherwise.
*/
public boolean getDefendFaction();
public int getType();
public boolean typeOf(int type);
@@ -198,6 +223,30 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
*/
public void setProjectileItem(ScriptItemStack item);
/**
*
* @return Returns true if the NPC can aim while shooting.
*/
public boolean canAimWhileShooting();
/**
*
* @param aimWhileShooting Set to true if you want the NPC to aim while shooting, false otherwise.
*/
public void aimWhileShooting(boolean aimWhileShooting);
/**
*
* @return The directory of the sound that plays when a projectile is shot
*/
public String getFireSound();
/**
*
* @param fireSound The new directory of the sound that plays when a projectile is shot
*/
public void setFireSound(String fireSound);
/**
* @param slot The armor slot to return. 0:head, 1:body, 2:legs, 3:boots
* @return Returns the worn armor in slot
@@ -210,11 +259,189 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
*/
public void setArmor(int slot, ScriptItemStack item);
/**
*
* @param slot The slot from the NPC's drop list to return (0-8)
* @return The item in the NPC's drop list slot
*/
public ScriptItemStack getLootItem(int slot);
/**
*
* @param slot The slot from the NPC's drop list to change
* @param item The item the drop list slot will be changed to
*/
public void setLootItem(int slot, ScriptItemStack item);
/**
*
* @param slot The slot from the NPC's drop list to return (0-8)
* @return The chance of dropping the item in this slot. Returns 100 if the slot is not found.
*/
public int getLootChance(int slot);
/**
*
* @param slot The slot from the NPC's drop list to change
* @param chance The new chance of dropping the item in this slot
*/
public void setLootChance(int slot, int chance);
/**
*
* @return The NPC's loot mode. 0 = Normal, 1 = Auto Pickup
*/
public int getLootMode();
/**
*
* @param lootMode The NPC's loot mode. 0 = Normal, 1 = Auto Pickup
*/
public void setLootMode(int lootMode);
/**
*
* @param lootXP The new minimum XP gained from killing the NPC. If greater than the max XP, it will be set to it.
*/
public void setMinLootXP(int lootXP);
/**
*
* @param lootXP The new maximum XP gained from killing the NPC. If less than the min XP, it will be set to it.
*/
public void setMaxLootXP(int lootXP);
/**
*
* @return The minimum XP gained from killing the NPC.
*/
public int getMinLootXP();
/**
*
* @return The maximum XP gained from killing the NPC.
*/
public int getMaxLootXP();
/**
* @param type The AnimationType
*/
public void setAnimation(int type);
/**
*
* @param variant Changes the tactical variant of the NPC.
* 0 - Rush
* 1 - Dodge
* 2 - Surround
* 3 - Hit N Run
* 4 - Ambush
* 5 - Stalk
* 6 - None
*
*/
public void setTacticalVariant(int variant);
/**
*
* @return Returns the tactical variant of the NPC.
* 0 - Rush
* 1 - Dodge
* 2 - Surround
* 3 - Hit N Run
* 4 - Ambush
* 5 - Stalk
* 6 - None
*
*/
public int getTacticalVariant();
/**
*
* @param variant Sets the NPC's tactical variant by name.
*/
public void setTacticalVariant(String variant);
/**
*
* @return Returns the name of the NPc's tactical variant.
*/
public String getTacticalVariantName();
/**
*
* @param tacticalRadius Sets the radius in which the tactical variant is affected, if any. Effective for all tactical variants except Rush and None.
*/
public void setTacticalRadius(int tacticalRadius);
/**
*
* @return Gets the radius in which the tactical variant is affected, if any. Effective for all tactical variants except Rush and None.
*/
public int getTacticalRadius();
/**
*
* @param ignore True if the NPC goes through cobwebs
*/
public void setIgnoreCobweb(boolean ignore);
/**
*
* @return True if the NPC goes through cobwebs
*/
public boolean getIgnoreCobweb();
/**
*
* @return Changes what the NPC does when it finds an enemy based on the integer given.
* 0 - Retaliate
* 1 - Panic
* 2 - Retreat
* 3 - Nothing
*/
public void setOnFoundEnemy(int onAttack);
/**
*
* @return Returns an integer representing what the NPC does when it finds an enemy.
* 0 - Retaliate
* 1 - Panic
* 2 - Retreat
* 3 - Nothing
*/
public int onFoundEnemy();
/**
*
* @param shelterFrom An integer representing what conditions the NPC seeks shelter under.
* 0 - Darkenss
* 1 - Sunlight
* 2 - Disabled
*/
public void setShelterFrom(int shelterFrom);
/**
*
* @return Returns an integer representing what conditions the NPC seeks shelter under.
* 0 - Darkenss
* 1 - Sunlight
* 2 - Disabled
*/
public int getShelterFrom();
/**
*
* @return Whether the NPC has a living animation
*/
public boolean hasLivingAnimation();
/**
*
* @param livingAnimation True if you want the NPC to have a living animation, false otherwise
*/
public void setLivingAnimation(boolean livingAnimation);
/**
* @param type The visibility type of the npc, 0:visible, 1:invisible, 2:semi-visible
*/
@@ -264,12 +491,12 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @return The melee strength
*/
public int getMeleeStrength();
public float getMeleeStrength();
/**
* @param strength The melee strength
*/
public void setMeleeStrength(int strength);
public void setMeleeStrength(float strength);
/**
* @return The melee speed
@@ -284,12 +511,12 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @return The ranged strength
*/
public int getRangedStrength();
public float getRangedStrength();
/**
* @param strength The ranged strength
*/
public void setRangedStrength(int strength);
public void setRangedStrength(float strength);
/**
* @return The ranged speed
@@ -311,6 +538,54 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
*/
public void setRangedBurst(int count);
/**
*
* @return The amount of ticks before this entity respawns
*/
public int getRespawnTime();
/**
*
* @param time The new amount of ticks before this entity respawns
*/
public void setRespawnTime(int time);
/**
*
* @return Respawn: 0 - Yes (Always), 1 - Day, 2 - Night, 3 - No (Dies permanently)
*/
public int getRespawnCycle();
/**
*
* @param cycle Sets when the NPC respawns. Respawn: 0 - Yes (Always), 1 - Day, 2 - Night, 3 - No (Dies permanently)
*/
public void setRespawnCycle(int cycle);
/**
*
* @return Whether the NPC is hidden when it dies
*/
public boolean getHideKilledBody();
/**
*
* @param hide True if the NPC is hidden when it dies. False otherwise.
*/
public void hideKilledBody(boolean hide);
/**
*
* @return Returns true if the NPC naturally despawns.
*/
public boolean naturallyDespawns();
/**
*
* @param canDespawn True if the NPC should naturally despawn. False otherwise.
*/
public void setNaturallyDespawns(boolean canDespawn);
/**
* @param player The player to give the item to
* @param item The item given to the player
@@ -382,22 +657,54 @@ public interface ICustomNpc<T extends EntityCreature> extends IEntityLiving<T> {
/**
* @return Returns the combat health regen per second
*/
public int getCombatRegen();
public float getCombatRegen();
/**
* @param regen The combat health regen per second
*/
public void setCombatRegen(int regen);
public void setCombatRegen(float regen);
/**
* @return Returns the health regen per second when not in combat
*/
public int getHealthRegen();
public float getHealthRegen();
/**
* @param regen The health regen per second when not in combat
*/
public void setHealthRegen(int regen);
public void setHealthRegen(float regen);
public long getAge();
public void setFly(int fly);
public boolean canFly();
public void setFlySpeed(double flySpeed);
public double getFlySpeed(double flySpeed);
public void setFlyGravity(double flyGravity);
public double getFlyGravity(double flyGravity);
public void setSpeed(int speed);
public int getSpeed();
public void setSkinType(byte type);
public byte getSkinType();
public void setSkinUrl(String url);
public String getSkinUrl();
public void setCloakTexture(String cloakTexture);
public String getCloakTexture();
public void setOverlayTexture(String overlayTexture);
public String getOverlayTexture();
}
@@ -19,7 +19,7 @@ public interface IEntityLivingBase<T extends EntityLivingBase> extends IEntity<T
/**
* @return Entity's max health
*/
public float getMaxHealth();
public double getMaxHealth();
/**
* @return Whether or not this entity is attacking something
*/
@@ -17,4 +17,6 @@ public interface ITimers {
void reset(int var1);
void clear();
int size();
}
@@ -308,6 +308,11 @@ ai.tacticalvariant=TacticalVariant
ai.cobwebAffected=CobwebAffected
ai.movement=Movement
movement.ground=Ground
movement.flying=Flying
fly.speed=Flying Speed
fly.gravity=Flying Gravity
aitactics.rush=Rush
aitactics.stagger=Dodge
aitactics.orbit=Surround