From 30714e92a54caef74faf1beff7d2276db90839e5 Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:35:51 +0300 Subject: [PATCH 1/9] fix missprint (minutes/minute) --- .../npcs/client/gui/player/GuiMailbox.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java b/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java index f3028e3df..db9d959b6 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiMailbox.java @@ -18,11 +18,11 @@ import java.util.Comparator; import java.util.List; public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScrollListener, GuiYesNoCallback{ - + private GuiCustomScroll scroll; private PlayerMailData data; private PlayerMail selected; - + public GuiMailbox() { super(); xSize = 256; @@ -39,7 +39,7 @@ public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScro scroll.guiLeft = guiLeft + 4; scroll.guiTop = guiTop + 4; addScroll(scroll); - + String title = StatCollector.translateToLocal("mailbox.name"); int x = (xSize - this.fontRendererObj.getStringWidth(title)) / 2; @@ -73,7 +73,7 @@ public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScro } int minutes = (int) (selected.timePast / 60000); if(minutes == 1) - return minutes + " " + StatCollector.translateToLocal("mailbox.minutes"); + return minutes + " " + StatCollector.translateToLocal("mailbox.minute"); else return minutes + " " + StatCollector.translateToLocal("mailbox.minutes"); } @@ -103,7 +103,7 @@ public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScro displayGuiScreen(guiyesno); } } - + @Override public void mouseClicked(int i, int j, int k) { @@ -121,13 +121,13 @@ public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScro @Override public void save() { // TODO Auto-generated method stub - + } @Override public void setGuiData(NBTTagCompound compound) { PlayerMailData data = new PlayerMailData(); data.loadNBTData(compound); - + List list = new ArrayList(); Collections.sort(data.playermail, new Comparator(){ public int compare(PlayerMail o1, PlayerMail o2){ @@ -150,7 +150,7 @@ public class GuiMailbox extends GuiNPCInterface implements IGuiData, ICustomScro GuiCustomScroll guiCustomScroll) { selected = data.playermail.get(guiCustomScroll.selected); initGui(); - + if(selected != null && !selected.beenRead){ selected.beenRead = true; NoppesUtilPlayer.sendData(EnumPlayerPacket.MailRead, selected.time, selected.sender); From 002a64cb883991120d5631a99305ceb3d33f3ed6 Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:37:16 +0300 Subject: [PATCH 2/9] fix the strange places --- .../npcs/client/gui/util/TextContainer.java | 4 +--- .../npcs/controllers/data/Availability.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/util/TextContainer.java b/src/main/java/noppes/npcs/client/gui/util/TextContainer.java index 5ee8c8e5e..5eee41b99 100644 --- a/src/main/java/noppes/npcs/client/gui/util/TextContainer.java +++ b/src/main/java/noppes/npcs/client/gui/util/TextContainer.java @@ -31,9 +31,7 @@ public class TextContainer { public TextContainer(String text){ - this.text = text; - text.replaceAll("\\r?\\n|\\r", "\n"); - double l = 1d; + this.text = text.replaceAll("\\r?\\n|\\r", "\n"); } public void init(int width, int height){ diff --git a/src/main/java/noppes/npcs/controllers/data/Availability.java b/src/main/java/noppes/npcs/controllers/data/Availability.java index 1b039d730..1407569a8 100644 --- a/src/main/java/noppes/npcs/controllers/data/Availability.java +++ b/src/main/java/noppes/npcs/controllers/data/Availability.java @@ -270,7 +270,7 @@ public class Availability implements ICompatibilty, IAvailability { } public int getDialog(int i) { - if (i < 0 && i > 3) { + if (i < 0 || i > 3) { throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else if (i == 0) { return this.dialogId; @@ -282,7 +282,7 @@ public class Availability implements ICompatibilty, IAvailability { } public void setDialog(int i, int id, int type) { - if (i < 0 && i > 3) { + if (i < 0 || i > 3) { throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else { EnumAvailabilityDialog e = EnumAvailabilityDialog.values()[MathHelper.clamp_int(type, 0, 2)]; @@ -304,7 +304,7 @@ public class Availability implements ICompatibilty, IAvailability { } public void removeDialog(int i) { - if (i < 0 && i > 3) { + if (i < 0 || i > 3) { throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else { if (i == 0) { @@ -325,7 +325,7 @@ public class Availability implements ICompatibilty, IAvailability { } public int getQuest(int i) { - if (i < 0 && i > 3) { + if (i < 0 || i > 3) { throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else if (i == 0) { return this.questId; @@ -337,7 +337,7 @@ public class Availability implements ICompatibilty, IAvailability { } public void setQuest(int i, int id, int type) { - if (i < 0 && i > 3) { + if (i < 0 || i > 3) { throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else { EnumAvailabilityQuest e = EnumAvailabilityQuest.values()[MathHelper.clamp_int(type, 0, 5)]; @@ -359,7 +359,7 @@ public class Availability implements ICompatibilty, IAvailability { } public void removeQuest(int i) { - if (i < 0 && i > 3) { + if (i < 0 || i > 3) { throw new CustomNPCsException(i + " isnt between 0 and 3", new Object[0]); } else { if (i == 0) { @@ -380,7 +380,7 @@ public class Availability implements ICompatibilty, IAvailability { } public void setFaction(int i, int id, int type, int stance) { - if (i < 0 && i > 1) { + if (i < 0 || i > 1) { throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]); } else { EnumAvailabilityFactionType e = EnumAvailabilityFactionType.values()[MathHelper.clamp_int(type, 0, 2)]; @@ -399,7 +399,7 @@ public class Availability implements ICompatibilty, IAvailability { } public void removeFaction(int i) { - if (i < 0 && i > 1) { + if (i < 0 || i > 1) { throw new CustomNPCsException(i + " isnt between 0 and 1", new Object[0]); } else { if (i == 0) { From 21a1dd0ba9a4696fe0252afa53158c6f9fb92f5f Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:37:49 +0300 Subject: [PATCH 3/9] fix missprint --- .../npcs/controllers/LinkedNpcController.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/noppes/npcs/controllers/LinkedNpcController.java b/src/main/java/noppes/npcs/controllers/LinkedNpcController.java index 3685affd6..c2b563b87 100644 --- a/src/main/java/noppes/npcs/controllers/LinkedNpcController.java +++ b/src/main/java/noppes/npcs/controllers/LinkedNpcController.java @@ -18,7 +18,7 @@ import java.util.List; public class LinkedNpcController { public static LinkedNpcController Instance; public List list = new ArrayList(); - + public LinkedNpcController(){ Instance = this; load(); @@ -30,14 +30,14 @@ public class LinkedNpcController { LogWriter.except(e); } } - + public File getDir(){ File dir = new File(CustomNpcs.getWorldSaveDirectory(), "linkednpcs"); if(!dir.exists()) dir.mkdir(); return dir; } - + private void loadNpcs(){ LogWriter.info("Loading Linked Npcs"); File dir = getDir(); @@ -56,12 +56,12 @@ public class LinkedNpcController { } } } - + this.list = list; } LogWriter.info("Done loading Linked Npcs"); } - + public void save(){ for(LinkedData npc : list){ try { @@ -71,17 +71,17 @@ public class LinkedNpcController { } } } - + private void saveNpc(LinkedData npc) throws IOException { File file = new File(getDir(), npc.name + ".json_new"); - File file1 = new File(getDir(), npc.name + ".json"); + File file1 = new File(getDir(), npc.name + ".json"); try{ NBTJsonUtil.SaveFile(file, npc.getNBT()); if(file1.exists()){ file1.delete(); } file.renameTo(file1); - + } catch (JsonException e) { LogWriter.except(e); } @@ -91,16 +91,16 @@ public class LinkedNpcController { public String name = "LinkedNpc"; public long time = 0; public NBTTagCompound data = new NBTTagCompound(); - + public LinkedData(){ time = System.currentTimeMillis(); } - + public void setNBT(NBTTagCompound compound){ name = compound.getString("LinkedName"); data = compound.getCompoundTag("NPCData"); } - + public NBTTagCompound getNBT(){ NBTTagCompound compound = new NBTTagCompound(); compound.setString("LinkedName", name); @@ -120,32 +120,32 @@ public class LinkedNpcController { } else{ npc.linkedData = data; - if(npc.posX == 0 && npc.posY == 0 && npc.posX == 0) + if(npc.posX == 0 && npc.posY == 0 && npc.posZ == 0) return; npc.linkedLast = data.time; List points = npc.ai.getMovingPath(); NBTTagCompound compound = NBTTags.NBTMerge(readNpcData(npc), data.data); - + npc.display.readToNBT(compound); npc.stats.readToNBT(compound); npc.advanced.readToNBT(compound); npc.inventory.readEntityFromNBT(compound); if(compound.hasKey("ModelData")) ((EntityCustomNpc)npc).modelData.readFromNBT(compound.getCompoundTag("ModelData")); - + npc.ai.readToNBT(compound); npc.transform.readToNBT(compound); npc.ai.setMovingPath(points); - + npc.updateClient = true; } } - + private void cleanTags(NBTTagCompound compound){ compound.removeTag("MovingPathNew"); } - + public LinkedData getData(String name){ for(LinkedData data : list){ if(data.name.equalsIgnoreCase(name)) @@ -153,7 +153,7 @@ public class LinkedNpcController { } return null; } - + private NBTTagCompound readNpcData(EntityNPCInterface npc){ NBTTagCompound compound = new NBTTagCompound(); npc.display.writeToNBT(compound); @@ -165,14 +165,14 @@ public class LinkedNpcController { compound.setTag("ModelData", ((EntityCustomNpc)npc).modelData.writeToNBT()); return compound; } - + public void saveNpcData(EntityNPCInterface npc) { NBTTagCompound compound = readNpcData(npc); cleanTags(compound); - + if(npc.linkedData.data.equals(compound)) return; - + npc.linkedData.data = compound; npc.linkedData.time = System.currentTimeMillis(); save(); @@ -185,11 +185,11 @@ public class LinkedNpcController { } save(); } - + public void addData(String name){ if(getData(name) != null || name.isEmpty()) return; - + LinkedData data = new LinkedData(); data.name = name; list.add(data); From 37ad1755fdfc6a3dc9eb4f5bf0c376f80d4a31b1 Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:38:44 +0300 Subject: [PATCH 4/9] fix loss of the block --- src/main/java/noppes/npcs/roles/JobHealer.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/noppes/npcs/roles/JobHealer.java b/src/main/java/noppes/npcs/roles/JobHealer.java index e7727ef57..6f8d5f391 100644 --- a/src/main/java/noppes/npcs/roles/JobHealer.java +++ b/src/main/java/noppes/npcs/roles/JobHealer.java @@ -31,16 +31,16 @@ public class JobHealer extends JobInterface{ speed = nbttagcompound.getInteger("HealerSpeed"); } private List toHeal = new ArrayList(); - + //TODO heal food, heal potion effects, heal more types of entities besides just the player and npcs public boolean aiShouldExecute() { healTicks++; - if (healTicks < speed * 10) + if (healTicks < speed * 10) return false; - - for(Object plObj: npc.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, npc.boundingBox.expand(range, range/2, range))){ + + for(Object plObj: npc.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, npc.boundingBox.expand(range, range/2.0, range))){ EntityLivingBase entity = (EntityLivingBase) plObj; - + if(entity instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer) entity; if(player.getHealth() < player.getMaxHealth() && !npc.faction.isAggressiveToPlayer(player)) @@ -51,7 +51,7 @@ public class JobHealer extends JobInterface{ if(npc.getHealth() < npc.getMaxHealth() && !this.npc.faction.isAggressiveToNpc(npc)) toHeal.add(npc); } - + } healTicks = 0; @@ -65,7 +65,7 @@ public class JobHealer extends JobInterface{ } toHeal.clear(); } - + public void heal(EntityLivingBase entity, float amount){ entity.heal(amount); NoppesUtilServer.spawnParticle(entity, "heal",entity.dimension); From e963ead882de995e4f5a883a64d60f695685e24c Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:39:43 +0300 Subject: [PATCH 5/9] fix the comparison with yourself --- .../noppes/npcs/scripted/entity/ScriptDBCPlayer.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java index 5d5f7a992..473e0bd00 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptDBCPlayer.java @@ -272,21 +272,21 @@ public class ScriptDBCPlayer extends ScriptPlayer i break; case "set": { String noNBTText; - int startIndex = -1; + int num = -1; boolean number = false; boolean run = false; try { - startIndex = Integer.parseInt(bonusID); + num = Integer.parseInt(bonusID); number = true; } catch (Exception var34) { number = false; } - for (startIndex = 0; startIndex < bonuses.length; ++startIndex) { + for (int startIndex = 0; startIndex < bonuses.length; ++startIndex) { String[] bonusValue = bonuses[startIndex].split("\\;"); bonusValues[startIndex][0] = bonusValue[0]; - if (number && startIndex == startIndex || !number && bonusValues[startIndex][0].equals(bonusID)) { + if (number && startIndex == num || !number && bonusValues[startIndex][0].equals(bonusID)) { noNBTText = bonusValues[startIndex][0] + ";" + bonusValueString; bonuses[startIndex] = ""; run = true; @@ -795,4 +795,4 @@ public class ScriptDBCPlayer extends ScriptPlayer i } return ""; } -} \ No newline at end of file +} From f2e85c134754ef7697a2774a401e9ed54da59168 Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:42:50 +0300 Subject: [PATCH 6/9] maybe it should be like this? --- .../npcs/client/gui/EventGuiScriptList.java | 6 +++--- .../noppes/npcs/client/gui/GuiScriptList.java | 18 +++++++++--------- .../npcs/client/gui/SubGuiNpcBiomes.java | 18 +++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/EventGuiScriptList.java b/src/main/java/noppes/npcs/client/gui/EventGuiScriptList.java index 5e06ea31b..4c3ffb308 100644 --- a/src/main/java/noppes/npcs/client/gui/EventGuiScriptList.java +++ b/src/main/java/noppes/npcs/client/gui/EventGuiScriptList.java @@ -65,7 +65,7 @@ public class EventGuiScriptList extends SubGuiInterface{ if(scroll1.hasSelected()){ container.scripts.add(scroll1.getSelected()); scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } } @@ -82,13 +82,13 @@ public class EventGuiScriptList extends SubGuiInterface{ container.scripts.add(script); } scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } if(button.id == 4){ container.scripts.clear(); scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } if(button.id == 66){ diff --git a/src/main/java/noppes/npcs/client/gui/GuiScriptList.java b/src/main/java/noppes/npcs/client/gui/GuiScriptList.java index a37f4f43e..c14c48139 100644 --- a/src/main/java/noppes/npcs/client/gui/GuiScriptList.java +++ b/src/main/java/noppes/npcs/client/gui/GuiScriptList.java @@ -15,7 +15,7 @@ public class GuiScriptList extends SubGuiInterface{ private GuiCustomScroll scroll2; private ScriptContainer container; private List scripts; - + public GuiScriptList(List scripts, ScriptContainer container){ this.container = container; setBackground("menubg.png"); @@ -36,7 +36,7 @@ public class GuiScriptList extends SubGuiInterface{ scroll1.guiTop = guiTop + 14; this.addScroll(scroll1); addLabel(new GuiNpcLabel(1, "script.availableScripts", guiLeft + 4, guiTop + 4)); - + if(scroll2 == null){ scroll2 = new GuiCustomScroll(this,1); scroll2.setSize(140, 180); @@ -55,7 +55,7 @@ public class GuiScriptList extends SubGuiInterface{ addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>")); addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<")); - + addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); } @@ -65,16 +65,16 @@ public class GuiScriptList extends SubGuiInterface{ if(scroll1.hasSelected()){ container.scripts.add(scroll1.getSelected()); scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); - } + } } if(button.id == 2){ if(scroll2.hasSelected()){ container.scripts.remove(scroll2.getSelected()); scroll2.selected = -1; initGui(); - } + } } if(button.id == 3){ container.scripts.clear(); @@ -82,13 +82,13 @@ public class GuiScriptList extends SubGuiInterface{ container.scripts.add(script); } scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } if(button.id == 4){ container.scripts.clear(); scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } if(button.id == 66){ @@ -97,7 +97,7 @@ public class GuiScriptList extends SubGuiInterface{ } @Override public void save() { - + } } diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java index 83eccfdb6..2ab4c1277 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcBiomes.java @@ -16,7 +16,7 @@ public class SubGuiNpcBiomes extends SubGuiInterface private SpawnData data; private GuiCustomScroll scroll1; private GuiCustomScroll scroll2; - + public SubGuiNpcBiomes(SpawnData data){ this.data = data; setBackground("menubg.png"); @@ -35,7 +35,7 @@ public class SubGuiNpcBiomes extends SubGuiInterface scroll1.guiTop = guiTop + 14; this.addScroll(scroll1); addLabel(new GuiNpcLabel(1, "spawning.availableBiomes", guiLeft + 4, guiTop + 4)); - + if(scroll2 == null){ scroll2 = new GuiCustomScroll(this,1); scroll2.setSize(140, 180); @@ -44,7 +44,7 @@ public class SubGuiNpcBiomes extends SubGuiInterface scroll2.guiTop = guiTop + 14; this.addScroll(scroll2); addLabel(new GuiNpcLabel(2, "spawning.spawningBiomes", guiLeft + 200, guiTop + 4)); - + List biomes = new ArrayList(); for (BiomeGenBase base : BiomeGenBase.getBiomeGenArray()) { if (base != null && base.biomeName != null && !data.biomes.contains(base.biomeName)) { @@ -59,8 +59,8 @@ public class SubGuiNpcBiomes extends SubGuiInterface addButton(new GuiNpcButton(3, guiLeft + 145, guiTop + 90, 55, 20, ">>")); addButton(new GuiNpcButton(4, guiLeft + 145, guiTop + 112, 55, 20, "<<")); - - + + addButton(new GuiNpcButton(66, guiLeft + 260, guiTop + 194, 60, 20, "gui.done")); } @@ -72,14 +72,14 @@ public class SubGuiNpcBiomes extends SubGuiInterface scroll1.selected = -1; scroll1.selected = -1; initGui(); - } + } } if(button.id == 2){ if(scroll2.hasSelected()){ data.biomes.remove(scroll2.getSelected()); scroll2.selected = -1; initGui(); - } + } } if(button.id == 3){ data.biomes.clear(); @@ -89,13 +89,13 @@ public class SubGuiNpcBiomes extends SubGuiInterface } } scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } if(button.id == 4){ data.biomes.clear(); scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } if(button.id == 66){ From 7244d8fcd7962c07c13e5652e4980e4e6b31ea8d Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:44:28 +0300 Subject: [PATCH 7/9] fix a potential NPE --- .../java/noppes/npcs/client/gui/model/GuiCreationScreen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java index 1aec9f0b4..823ed7c86 100644 --- a/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java +++ b/src/main/java/noppes/npcs/client/gui/model/GuiCreationScreen.java @@ -349,7 +349,7 @@ public class GuiCreationScreen extends GuiModelInterface implements ICustomScrol private void updateTexture(){ try{ EntityLivingBase entity = playerdata.getEntity(npc); - if (entity.equals(npc.modelData.entity)) { + if (entity != null && entity.equals(npc.modelData.entity)) { return; } From 5180e3cc4bf09e4c9f7eb486d5246b135868ce91 Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:49:17 +0300 Subject: [PATCH 8/9] maybe it should be like this? part 2 --- .../npcs/client/gui/roles/GuiNpcGuard.java | 34 +++++++++---------- .../client/gui/script/EventGuiScriptList.java | 6 ++-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java index b5365e465..128b73470 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcGuard.java @@ -16,13 +16,13 @@ import noppes.npcs.roles.JobGuard; import java.util.ArrayList; import java.util.List; -public class GuiNpcGuard extends GuiNPCInterface2{ +public class GuiNpcGuard extends GuiNPCInterface2{ private JobGuard role; private GuiCustomScroll scroll1; private GuiCustomScroll scroll2; - + public GuiNpcGuard(EntityNPCInterface npc){ - super(npc); + super(npc); role = (JobGuard) npc.jobInterface; } @@ -37,10 +37,10 @@ public class GuiNpcGuard extends GuiNPCInterface2{ this.addLabel(new GuiNpcLabel(2, "guard.creepers", guiLeft + 275, guiTop + 9)); this.addButton(new GuiNpcButton(2, guiLeft + 360, guiTop + 4, 50, 20, new String[]{"gui.no", "gui.yes"},role.attackCreepers?1:0)); getButton(2).enabled = role.attackHostileMobs; - + this.addLabel(new GuiNpcLabel(3, "guard.specifictargets", guiLeft + 10, guiTop + 31)); - this.addButton(new GuiNpcButton(3, guiLeft + 85, guiTop + 26, 50, 20, new String[]{"gui.no", "gui.yes"},role.specific?1:0)); - + this.addButton(new GuiNpcButton(3, guiLeft + 85, guiTop + 26, 50, 20, new String[]{"gui.no", "gui.yes"},role.specific?1:0)); + if(role.specific){ if(scroll1 == null){ scroll1 = new GuiCustomScroll(this,0); @@ -50,7 +50,7 @@ public class GuiNpcGuard extends GuiNPCInterface2{ scroll1.guiTop = guiTop + 58; this.addScroll(scroll1); addLabel(new GuiNpcLabel(11, "guard.availableTargets", guiLeft + 4, guiTop + 48)); - + if(scroll2 == null){ scroll2 = new GuiCustomScroll(this,1); scroll2.setSize(175, 154); @@ -59,7 +59,7 @@ public class GuiNpcGuard extends GuiNPCInterface2{ scroll2.guiTop = guiTop + 58; this.addScroll(scroll2); addLabel(new GuiNpcLabel(12, "guard.currentTargets", guiLeft + 235, guiTop + 48)); - + List all = new ArrayList(); for(Object entity : EntityList.stringToClassMapping.keySet()){ String name = "entity." + entity + ".name"; @@ -71,11 +71,11 @@ public class GuiNpcGuard extends GuiNPCInterface2{ } scroll1.setList(all); scroll2.setList(role.targets); - - + + addButton(new GuiNpcButton(11, guiLeft + 180, guiTop + 80, 55, 20, ">")); addButton(new GuiNpcButton(12, guiLeft + 180, guiTop + 102, 55, 20, "<")); - + addButton(new GuiNpcButton(13, guiLeft + 180, guiTop + 130, 55, 20, ">>")); addButton(new GuiNpcButton(14, guiLeft + 180, guiTop + 152, 55, 20, "<<")); } @@ -92,11 +92,11 @@ public class GuiNpcGuard extends GuiNPCInterface2{ } if(button.id == 2){ role.attackCreepers = button.getValue()==1; - } + } if(button.id == 3){ role.specific = button.getValue()==1; initGui(); - } + } if(button.id == 11){ if(scroll1.hasSelected()){ @@ -104,14 +104,14 @@ public class GuiNpcGuard extends GuiNPCInterface2{ scroll1.selected = -1; scroll1.selected = -1; initGui(); - } + } } if(button.id == 12){ if(scroll2.hasSelected()){ role.targets.remove(scroll2.getSelected()); scroll2.selected = -1; initGui(); - } + } } if(button.id == 13){ role.targets.clear(); @@ -124,13 +124,13 @@ public class GuiNpcGuard extends GuiNPCInterface2{ } role.targets = all; scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } if(button.id == 14){ role.targets.clear(); scroll1.selected = -1; - scroll1.selected = -1; + scroll2.selected = -1; initGui(); } } diff --git a/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java b/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java index 876f3c02e..b75c53976 100644 --- a/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java +++ b/src/main/java/noppes/npcs/client/gui/script/EventGuiScriptList.java @@ -65,7 +65,7 @@ public class EventGuiScriptList extends SubGuiInterface { if(button.id == 1 && this.scroll1.hasSelected()) { this.container.scripts.add(this.scroll1.getSelected()); this.scroll1.selected = -1; - this.scroll1.selected = -1; + this.scroll2.selected = -1; this.initGui(); } @@ -85,14 +85,14 @@ public class EventGuiScriptList extends SubGuiInterface { } this.scroll1.selected = -1; - this.scroll1.selected = -1; + this.scroll2.selected = -1; this.initGui(); } if(button.id == 4) { this.container.scripts.clear(); this.scroll1.selected = -1; - this.scroll1.selected = -1; + this.scroll2.selected = -1; this.initGui(); } From f168eb34d558e67fb8eb717b9bfbb5a8903edf95 Mon Sep 17 00:00:00 2001 From: Mark Zharkov Date: Thu, 6 Feb 2025 22:50:02 +0300 Subject: [PATCH 9/9] fix strange field --- src/main/java/noppes/npcs/scripted/event/NpcEvent.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java index 98c51e6ba..f93ec6b51 100644 --- a/src/main/java/noppes/npcs/scripted/event/NpcEvent.java +++ b/src/main/java/noppes/npcs/scripted/event/NpcEvent.java @@ -345,7 +345,6 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { public final IDialog dialogObj; public final int dialog; - public final int option; public DialogEvent(ICustomNpc npc, EntityPlayer player, int id, int optionId, Dialog dialog) { super(npc); @@ -355,7 +354,6 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { this.dialogObj = dialog; this.dialog = id; - this.option = optionId; } public String getHookName() { @@ -375,7 +373,7 @@ public class NpcEvent extends CustomNPCsEvent implements INpcEvent { } public int getOptionId() { - return option; + return optionId; } /**