From 23686dc3b82cd73bc9906d38ab9e079360d51b2b Mon Sep 17 00:00:00 2001 From: luisc Date: Fri, 3 Dec 2021 00:49:10 -0600 Subject: [PATCH] Enabled fly button in movement, and extended max values for several NPC attributes, converting some to floats and doubles. NPCs fly with speed based on their movement speed now. --- src/main/java/noppes/npcs/DataDisplay.java | 2 +- src/main/java/noppes/npcs/DataStats.java | 39 ++++---- .../npcs/ai/target/EntityAIClosestTarget.java | 6 +- .../npcs/client/gui/GuiBorderBlock.java | 3 +- .../npcs/client/gui/GuiNpcRedstoneBlock.java | 17 ++-- .../npcs/client/gui/GuiNpcWaypoint.java | 2 +- .../client/gui/SubGuiNpcAvailability.java | 8 +- .../client/gui/SubGuiNpcFactionOptions.java | 2 +- .../client/gui/SubGuiNpcFactionPoints.java | 6 +- .../client/gui/SubGuiNpcMeleeProperties.java | 14 +-- .../npcs/client/gui/SubGuiNpcMovement.java | 14 +-- .../npcs/client/gui/SubGuiNpcProjectiles.java | 15 ++- .../client/gui/SubGuiNpcRangeProperties.java | 14 +-- .../npcs/client/gui/SubGuiNpcRespawn.java | 2 +- .../client/gui/global/GuiNPCManageBanks.java | 5 +- .../client/gui/global/GuiNpcQuestReward.java | 2 +- .../npcs/client/gui/mainmenu/GuiNPCInv.java | 5 +- .../npcs/client/gui/mainmenu/GuiNpcAI.java | 4 +- .../client/gui/mainmenu/GuiNpcDisplay.java | 6 +- .../npcs/client/gui/mainmenu/GuiNpcStats.java | 19 ++-- .../gui/questtypes/GuiNpcQuestTypeKill.java | 4 +- .../npcs/client/gui/roles/GuiNpcBard.java | 4 +- .../client/gui/roles/GuiNpcCompanion.java | 2 +- .../client/gui/roles/GuiNpcConversation.java | 6 +- .../client/gui/roles/GuiNpcFollowerSetup.java | 2 +- .../npcs/client/gui/roles/GuiNpcHealer.java | 4 +- .../client/gui/roles/GuiNpcItemGiver.java | 4 +- .../npcs/client/gui/roles/GuiNpcSpawner.java | 7 +- .../npcs/client/gui/util/GuiNpcTextField.java | 91 ++++++++++++++++--- .../noppes/npcs/entity/EntityNPCFlying.java | 44 ++++----- .../npcs/entity/EntityNPCInterface.java | 26 +++--- .../java/noppes/npcs/roles/RoleCompanion.java | 2 +- .../scripted/entity/ScriptLivingBase.java | 4 - .../npcs/scripted/entity/ScriptNpc.java | 40 ++++---- .../npcs/scripted/interfaces/ICustomNpc.java | 22 +++-- 35 files changed, 258 insertions(+), 189 deletions(-) diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index f7697233f..1bda8ee33 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -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"); diff --git a/src/main/java/noppes/npcs/DataStats.java b/src/main/java/noppes/npcs/DataStats.java index f011ee324..d841d596c 100644 --- a/src/main/java/noppes/npcs/DataStats.java +++ b/src/main/java/noppes/npcs/DataStats.java @@ -10,7 +10,7 @@ import noppes.npcs.util.ValueUtil; 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 +19,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 +32,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 +56,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 +81,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 +114,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 +139,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,15 +169,15 @@ public class DataStats { npc.setImmuneToFire(immuneToFire); } - public int getAttackStrength(){ + public float getAttackStrength(){ return attackStrength; } - public void setAttackStrength(int strength){ + public void setAttackStrength(float strength){ attackStrength = strength; npc.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(attackStrength); } - public void setMaxHealth(int maxHealth) { + public void setMaxHealth(double maxHealth) { this.maxHealth = maxHealth; npc.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(maxHealth); } diff --git a/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java b/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java index 6bf82b4b3..454d1fb71 100644 --- a/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java +++ b/src/main/java/noppes/npcs/ai/target/EntityAIClosestTarget.java @@ -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; diff --git a/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java b/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java index fe5464912..d0ee018bc 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java +++ b/src/main/java/noppes/npcs/client/gui/GuiBorderBlock.java @@ -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)); diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java b/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java index f48b634f3..b965a877c 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcRedstoneBlock.java @@ -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")); diff --git a/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java b/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java index 602292ca0..bd1c40785 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java +++ b/src/main/java/noppes/npcs/client/gui/GuiNpcWaypoint.java @@ -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")); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java index beee1673b..a1708aa89 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcAvailability.java @@ -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")); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java index 021f43165..4f4fa1469 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionOptions.java @@ -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")); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java index 909bb11ab..0f018ea15 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcFactionPoints.java @@ -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; diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java index f33aceda7..2990de28d 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMeleeProperties.java @@ -28,28 +28,28 @@ 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, Integer.MAX_VALUE, 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).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).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).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).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)); @@ -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(); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java index 276f4eec0..329d304d0 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcMovement.java @@ -34,7 +34,7 @@ public class SubGuiNpcMovement extends SubGuiInterface implements ITextfieldList if(ai.movingType == EnumMovingType.Wandering){ addTextField(new GuiNpcTextField(4,this, guiLeft + 100, y += 22, 40, 20, ai.walkingRange + "")); - getTextField(4).numbersOnly = true; + getTextField(4).integersOnly = true; getTextField(4).setMinMaxDefault(0, Integer.MAX_VALUE, 5); addLabel(new GuiNpcLabel(4,"gui.range", guiLeft + 4, y + 5)); @@ -45,15 +45,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 +65,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,7 +92,7 @@ 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).integersOnly = true; getTextField(14).setMinMaxDefault(0, Integer.MAX_VALUE, 4); addLabel(new GuiNpcLabel(14,"stats.walkspeed", guiLeft + 5, y + 5)); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java index 7814ee228..dea73dc45 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcProjectiles.java @@ -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,19 +29,19 @@ 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, Integer.MAX_VALUE, 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).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).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).integersOnly = true; getTextField(4).setMinMaxDefault(1, Integer.MAX_VALUE, 10); addLabel(new GuiNpcLabel(5,"stats.hasgravity", guiLeft + 5, guiTop + 105)); @@ -59,7 +58,7 @@ 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).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.parseFloat(textfield.getText()); } else if(textfield.id == 2){ stats.pImpact = textfield.getInteger(); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java index 2df1ddced..9810d7085 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRangeProperties.java @@ -29,35 +29,35 @@ 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).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).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).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).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).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).integersOnly = true; getTextField(8).setMinMaxDefault(1, Integer.MAX_VALUE, 1); addButton(new GuiNpcButtonYesNo(9, guiLeft + 100, y += 22, stats.aimWhileShooting)); diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java index 26f28e05f..16d5f191c 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcRespawn.java @@ -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)); diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java index 647177b4f..0a544a5cb 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNPCManageBanks.java @@ -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); } diff --git a/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java b/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java index a27090ab7..2a0d5bd3c 100644 --- a/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java +++ b/src/main/java/noppes/npcs/client/gui/global/GuiNpcQuestReward.java @@ -32,7 +32,7 @@ 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).integersOnly = true; getTextField(0).setMinMaxDefault(0, Integer.MAX_VALUE, 0); } diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java index f18b87dae..c5c8ceb30 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNPCInv.java @@ -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,12 +44,12 @@ 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).integersOnly = true; getTextField(0).setMinMaxDefault(0, Short.MAX_VALUE, 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).integersOnly = true; getTextField(1).setMinMaxDefault(0, Short.MAX_VALUE, 0); addButton(new GuiNpcButton(10, guiLeft + 88, guiTop + 88, 80, 20, new String[]{"stats.normal", "inv.auto"}, npc.inventory.lootMode)); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java index 10e367774..1abd1cdd1 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcAI.java @@ -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); } diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java index bbabae2a4..4503f4a31 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcDisplay.java @@ -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)); diff --git a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java index 51608c45f..447458af3 100644 --- a/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java +++ b/src/main/java/noppes/npcs/client/gui/mainmenu/GuiNpcStats.java @@ -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,11 +35,11 @@ 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).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 = 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.parseFloat(textfield.getText()); } else if(textfield.id == 16){ - stats.combatRegen = textfield.getInteger(); + stats.combatRegen = Float.parseFloat(textfield.getText()); } } diff --git a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java index 386caec09..a753c28bc 100644 --- a/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java +++ b/src/main/java/noppes/npcs/client/gui/questtypes/GuiNpcQuestTypeKill.java @@ -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; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java index 0f91fb138..d79ea5025 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcBard.java @@ -39,7 +39,7 @@ 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).integersOnly = true; getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5); addLabel(new GuiNpcLabel(4,"bard.hasoff", guiLeft + 60, guiTop + 166)); @@ -47,7 +47,7 @@ public class GuiNpcBard extends GuiNPCInterface2 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).integersOnly = true; getTextField(3).setMinMaxDefault(2, Integer.MAX_VALUE, 10); getLabel(3).enabled = job.hasOffRange; diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java index f4d016082..865965a66 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcCompanion.java @@ -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); } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java index a6ef74a9a..c8f64f800 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcConversation.java @@ -48,18 +48,18 @@ 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).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).integersOnly = true; getTextField(54).setMinMaxDefault(4, Integer.MAX_VALUE, 20); addLabel(new GuiNpcLabel(51, "quest.quest", guiLeft + 13, guiTop + 175)); diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java index c63388c9f..86ad48590 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcFollowerSetup.java @@ -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); } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java index 48bdedeaa..615efbd12 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcHealer.java @@ -24,12 +24,12 @@ 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).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).integersOnly = true; getTextField(2).setMinMaxDefault(2, Integer.MAX_VALUE, 5); } diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java index c5d855632..cd51ccc11 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcItemGiver.java @@ -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){ diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java index 9e7170d7b..376288e50 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java @@ -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; diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java index 5b0ba8454..a01b0283c 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiNpcTextField.java @@ -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; } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java index 0906283ee..93db80325 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCFlying.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCFlying.java @@ -1,20 +1,17 @@ package noppes.npcs.entity; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; +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 { public EntityNPCFlying(World world) { super(world); + this.getNavigator().setCanSwim(true); + this.tasks.addTask(0, new EntityAISwimming(this)); } // FLY CHANGE [WIP] @@ -43,15 +40,14 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { return; } - this.motionY *= 0.6000000238418579D; - double d1; - double d3; - double d5; + double speed = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue(); + double speedMult = 0.6000000238418579D/0.5D; - if (!this.worldObj.isRemote && this.getAttackTarget() != null) + this.motionY *= speed*speedMult; + + Entity entity = this.getAttackTarget(); + if (!this.worldObj.isRemote) { - Entity entity = this.getAttackTarget(); - if (entity != null) { if (this.posY < entity.posY) @@ -61,26 +57,26 @@ public abstract class EntityNPCFlying extends EntityNPCInterface { this.motionY = 0.0D; } - this.motionY += (0.5D - this.motionY) * 0.6000000238418579D; + this.motionY += (speed - this.motionY) * speed*speedMult; } double d0 = entity.posX - this.posX; - d1 = entity.posZ - this.posZ; - d3 = d0 * d0 + d1 * d1; + double d1 = entity.posY - this.posY; + double d2 = entity.posZ - this.posZ; + double d3 = d0 * d0 + d2 * d2; if (d3 > 9.0D) { - d5 = (double)MathHelper.sqrt_double(d3); - this.motionX += (d0 / d5 * 0.5D - this.motionX) * 0.6000000238418579D; - this.motionZ += (d1 / d5 * 0.5D - this.motionZ) * 0.6000000238418579D; - - this.motionX *= this.ai.getWalkingSpeed()/10.0D; - this.motionZ *= this.ai.getWalkingSpeed()/10.0D; + double d5 = (double)MathHelper.sqrt_double(d3); + this.motionX += (d0 / d5 * speed - this.motionX) * speed*speedMult; + this.motionZ += (d2 / d5 * speed - this.motionZ) * speed*speedMult; } + + this.rotationYaw = (float)((Math.atan2(-d0,-d2)+Math.PI)*-(180F/Math.PI)); } } - if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D) + if (this.motionX * this.motionX + this.motionZ * this.motionZ > 0.05000000074505806D && isEntityAlive()) { this.rotationYaw = (float)Math.atan2(this.motionZ, this.motionX) * (180F / (float)Math.PI) - 90.0F; } diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index d0e95bf22..f3ece40fa 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -196,7 +196,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()); } @@ -599,15 +599,17 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti 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.moveHelper = new FlyingMoveHelper(this); + //this.navigator = new PathNavigateFlying(this, worldObj); + this.getNavigator().setCanSwim(true); + this.tasks.addTask(0, new EntityAISwimming(this)); + } + else{ + //this.moveHelper = new EntityMoveHelper(this); + //this.navigator = new PathNavigateGround(this, worldObj); + this.tasks.addTask(0, new EntityAIWaterNav(this)); + } this.taskCount = 1; this.doorInteractType(); @@ -1450,7 +1452,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 +1491,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]; diff --git a/src/main/java/noppes/npcs/roles/RoleCompanion.java b/src/main/java/noppes/npcs/roles/RoleCompanion.java index eb425094f..853745bc1 100644 --- a/src/main/java/noppes/npcs/roles/RoleCompanion.java +++ b/src/main/java/noppes/npcs/roles/RoleCompanion.java @@ -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); diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java index 705de1b55..efbab1cd8 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptLivingBase.java @@ -122,13 +122,9 @@ public class ScriptLivingBase extends ScriptEntity 255) - strength = 255; if(duration < 0) duration = 0; - else if(duration > 1000000) - duration = 1000000; if(!Potion.potionTypes[effect].isInstant()) duration *= 20; diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 14240d037..2148890d3 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1,6 +1,5 @@ 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; @@ -33,7 +32,6 @@ 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 extends ScriptLiving implements ICustomNpc { @@ -45,19 +43,17 @@ public class ScriptNpc extends ScriptLiving imp } /** - * @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 +182,7 @@ public class ScriptNpc extends ScriptLiving imp /** * @param health New max health */ - public void setMaxHealth(int health){ + public void setMaxHealth(double health){ npc.stats.setMaxHealth(health); npc.script.clientNeedsUpdate = true; } @@ -488,14 +484,14 @@ public class ScriptNpc extends ScriptLiving 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,14 +512,14 @@ public class ScriptNpc extends ScriptLiving 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){ + public void setRangedStrength(float strength){ npc.stats.pDamage = strength; } @@ -673,28 +669,28 @@ public class ScriptNpc extends ScriptLiving 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){ + public void setCombatRegen(float regen){ npc.stats.combatRegen = 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){ + public void setHealthRegen(float regen){ npc.stats.healthRegen = regen; } @@ -706,4 +702,16 @@ public class ScriptNpc extends ScriptLiving imp public ITimers getTimers() { return ((EntityNPCInterface)this.npc).timers; } + + public boolean canFly(){ + return npc.ai.movementType == 1; + } + + public void setFly(int fly){ + if(fly > 0) + fly = 1; + else fly = 0; + + npc.ai.movementType = fly; + } } diff --git a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java b/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java index 69c78d02d..c1f6c2cef 100644 --- a/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java +++ b/src/main/java/noppes/npcs/scripted/interfaces/ICustomNpc.java @@ -105,7 +105,7 @@ public interface ICustomNpc extends IEntityLiving { /** * @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 @@ -264,12 +264,12 @@ public interface ICustomNpc extends IEntityLiving { /** * @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 +284,12 @@ public interface ICustomNpc extends IEntityLiving { /** * @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 @@ -382,22 +382,26 @@ public interface ICustomNpc extends IEntityLiving { /** * @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 boolean canFly(); + + public void setFly(int fly); }