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.
This commit is contained in:
luisc committed 2021-12-03 00:49:10 -06:00
1 parent 44d4e74279
commit 23686dc3b8
35 files changed
+258 -189

No files matched your search

@@ -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,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,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();
@@ -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));
@@ -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();
@@ -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));
@@ -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,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);
}
@@ -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));
@@ -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,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());
}
}
@@ -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,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;
@@ -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,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));
@@ -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,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);
}
@@ -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;
@@ -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;
}