From 37a765af1948c67297e322a4db5cefe044ad1c67 Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 30 Jul 2023 15:47:03 -0400 Subject: [PATCH 01/11] Implement Ctrl + Backspace --- .../java/noppes/npcs/client/ClientProxy.java | 4 +- .../client/gui/util/GuiScriptTextArea.java | 51 ++++++++++++++++++- 2 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index ac020ac2e..8ca096278 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -544,7 +544,7 @@ public class ClientProxy extends CommonProxy { public FontContainer(String fontType, int fontSize) { textFont = new StringCache(); - textFont.setDefaultFont("Arial", fontSize, true); + textFont.setDefaultFont("Arial Unicode MS", fontSize, true); useCustomFont = !fontType.equalsIgnoreCase("minecraft"); try { if(!useCustomFont || fontType.isEmpty() || fontType.equalsIgnoreCase("default")) @@ -552,7 +552,7 @@ public class ClientProxy extends CommonProxy { else textFont.setDefaultFont(fontType, fontSize, true); } catch (Exception e) { - LogWriter.info("Failed loading font so using Arial"); + LogWriter.info("Failed loading font so using Arial Unicode MS"); } } diff --git a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java index 45ef13a27..4c1c08644 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -11,9 +11,12 @@ import net.minecraft.util.ChatAllowedCharacters; import noppes.npcs.NoppesStringUtils; import noppes.npcs.client.ClientProxy; import noppes.npcs.client.gui.util.TextContainer.LineData; +import noppes.npcs.config.ConfigClient; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; +import sun.font.TrueTypeFont; +import java.awt.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -42,11 +45,11 @@ public class GuiScriptTextArea extends GuiNpcTextField { private int cursorPosition; private int scrolledLine = 0; private boolean enableCodeHighlighting = false; - private static final char colorChar = '\uffff'; public List undoList = new ArrayList(); public List redoList = new ArrayList(); public boolean undoing = false; private long lastClicked = 0L; + // private static TrueTypeFont font = new TrueTypeFont(new Font("Arial Unicode MS", Font.PLAIN, ConfigClient.FontSize), 1); public GuiScriptTextArea(GuiScreen guiScreen, int id, int x, int y, int width, int height, String text) { super(id, guiScreen, x, y, width, height, null); @@ -309,6 +312,47 @@ public class GuiScriptTextArea extends GuiNpcTextField { endSelection = cursorPosition = startSelection; return true; } + if(isKeyComboCtrlBackspace(i)){ + String s = getSelectionBeforeText(); + if(startSelection > 0 && startSelection == endSelection){ + int nearestCondition = cursorPosition; + int g; + boolean cursorInWhitespace = Character.isWhitespace(s.charAt(cursorPosition - 1)); + if(cursorInWhitespace){ + // Find the nearest word if we are starting in whitespace + for (g = cursorPosition - 1; g >= 0; g--) { + char currentChar = s.charAt(g); + if (!Character.isWhitespace(currentChar)) { + nearestCondition = g; + break; + } + if(g == 0){ + nearestCondition = 0; + } + } + } + else { + // Find the nearest blank space or new line + for (g = cursorPosition - 1; g >= 0; g--) { + char currentChar = s.charAt(g); + if (Character.isWhitespace(currentChar) || currentChar == '\n') { + nearestCondition = g; + break; + } + if(g == 0){ + nearestCondition = 0; + } + } + } + + // Remove all text to the left up to the nearest boundary + s = s.substring(0, nearestCondition); + startSelection -= (cursorPosition - nearestCondition); + } + setText(s + getSelectionAfterText()); + endSelection = cursorPosition = startSelection; + return true; + } if(i == Keyboard.KEY_BACK){ String s = getSelectionBeforeText(); if(startSelection > 0 && startSelection == endSelection){ @@ -389,6 +433,11 @@ public class GuiScriptTextArea extends GuiNpcTextField { return keyID == 45 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown(); } + private boolean isKeyComboCtrlBackspace(int keyID) + { + return keyID == Keyboard.KEY_BACK && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown(); + } + private boolean isKeyComboCtrlV(int keyID) { return keyID == 47 && isCtrlKeyDown() && !isShiftKeyDown() && !isAltKeyDown(); From c6c212d68ead9e5bfbea2e9e5f2a36d9284ec016 Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 30 Jul 2023 15:51:08 -0400 Subject: [PATCH 02/11] Beta 2 Update --- build.gradle | 2 +- src/main/java/noppes/npcs/CustomNpcs.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index bd3b408c7..b703f4464 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ configurations { apply plugin: 'forge' -version = "1.9-beta1" +version = "1.9-beta2" group= "com.kamkeel.customnpc-plus" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "CustomNPC-Plus" diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index 23a74edf5..86f2cd41d 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -35,7 +35,7 @@ import noppes.npcs.scripted.NpcAPI; import java.io.File; import java.util.Set; -@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-beta1") +@Mod(modid = "customnpcs", name = "CustomNPC+", version = "1.9-beta2") public class CustomNpcs { @SidedProxy(clientSide = "noppes.npcs.client.ClientProxy", serverSide = "noppes.npcs.CommonProxy") From 0ba3092e51dd0bc0c1efcee47abe4122ba837ef7 Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 30 Jul 2023 16:44:28 -0400 Subject: [PATCH 03/11] Fix Dialog Alignment Saving. Default is not Bottom --- src/main/java/noppes/npcs/controllers/data/Dialog.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/controllers/data/Dialog.java b/src/main/java/noppes/npcs/controllers/data/Dialog.java index 3da2914e1..4260ea109 100644 --- a/src/main/java/noppes/npcs/controllers/data/Dialog.java +++ b/src/main/java/noppes/npcs/controllers/data/Dialog.java @@ -40,7 +40,7 @@ public class Dialog implements ICompatibilty, IDialog { public boolean showOptionLine = true; //0 - Top, 1 - Bottom, 2 (Not implemented yet) - Center - public byte alignment = 0; + public byte alignment = 1; public boolean renderGradual = false; public boolean showPreviousBlocks = true; @@ -186,7 +186,8 @@ public class Dialog implements ICompatibilty, IDialog { compound.setBoolean("DialogDisableEsc", disableEsc); compound.setBoolean("DialogDarkScreen", darkenScreen); - + compound.setByte("DialogAlignment", alignment); + if(sound != null && !sound.isEmpty()) compound.setString("DialogSound", sound); From 66540a054dc6b6568fb6b6a03c7d47b575c2ab7c Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 30 Jul 2023 16:45:49 -0400 Subject: [PATCH 04/11] Reverse Default Dialog Alignment --- .../java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java | 2 +- .../noppes/npcs/client/gui/player/GuiDialogInteract.java | 6 +++--- src/main/java/noppes/npcs/controllers/data/Dialog.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java index 126b51751..1ba143bd4 100644 --- a/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java +++ b/src/main/java/noppes/npcs/client/gui/SubGuiNpcDialogVisual.java @@ -98,7 +98,7 @@ public class SubGuiNpcDialogVisual extends SubGuiInterface implements ISubGuiLis addButton(new GuiNpcButton(10, guiLeft + 70, y += 22, 50, 20, new String[]{"gui.text", "gui.option", "display.fixed"}, dialog.titlePos)); addLabel(new GuiNpcLabel(10, "dialog.titlePos", guiLeft + 4, y + 5)); - addButton(new GuiNpcButton(24, guiLeft + 192, y, 50, 20, new String[]{"display.top", "display.bottom"}, dialog.alignment)); + addButton(new GuiNpcButton(24, guiLeft + 192, y, 50, 20, new String[]{"display.bottom", "display.top"}, dialog.alignment)); addLabel(new GuiNpcLabel(27, "display.alignment", guiLeft + 126, y + 5)); addTextField(new GuiNpcTextField(11, this, guiLeft + 120, y += 25, 40, 20, String.valueOf(dialog.textWidth))); diff --git a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java index 4a61e76b4..cb124f778 100644 --- a/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java +++ b/src/main/java/noppes/npcs/client/gui/player/GuiDialogInteract.java @@ -503,7 +503,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose int height = count - totalRows + lineOffset; int screenPos = optionStart; int y = (height * ClientProxy.Font.height()) + screenPos + scrollY; - if (dialog.alignment == 0) { + if (dialog.alignment == 1) { height = count - totalRows + lineOffset + 1; screenPos = optionStart - dialog.textHeight + ClientProxy.Font.height() + (totalRows - lineOffset); @@ -515,7 +515,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose } if (block.titlePos == 0 || mainDialogText) { - if (dialog.alignment == 0) { + if (dialog.alignment == 1) { if (y < optionStart - dialog.textHeight || y > optionStart - ClientProxy.Font.height()/2f) { return; } @@ -584,7 +584,7 @@ public class GuiDialogInteract extends GuiNPCInterface implements IGuiClose textSoundEnabled = !textSoundEnabled; } - if (dialog.alignment == 0 && totalRows * ClientProxy.Font.height() > dialog.textHeight) { + if (dialog.alignment == 1 && totalRows * ClientProxy.Font.height() > dialog.textHeight) { if ((i == mc.gameSettings.keyBindBack.getKeyCode() || i == 201) && scrollY < totalRows * ClientProxy.Font.height()) {//Page up scrollY += ClientProxy.Font.height() * 2; } diff --git a/src/main/java/noppes/npcs/controllers/data/Dialog.java b/src/main/java/noppes/npcs/controllers/data/Dialog.java index 4260ea109..9f6d40c51 100644 --- a/src/main/java/noppes/npcs/controllers/data/Dialog.java +++ b/src/main/java/noppes/npcs/controllers/data/Dialog.java @@ -39,8 +39,8 @@ public class Dialog implements ICompatibilty, IDialog { public boolean darkenScreen = true; public boolean showOptionLine = true; - //0 - Top, 1 - Bottom, 2 (Not implemented yet) - Center - public byte alignment = 1; + //0 - Bottom, 1 - Top, 2 (Not implemented yet) - Center + public byte alignment = 0; public boolean renderGradual = false; public boolean showPreviousBlocks = true; From 8e41a0973e46e0ce46f56faece88293f31089546 Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 30 Jul 2023 16:53:18 -0400 Subject: [PATCH 05/11] Comment change --- src/main/java/noppes/npcs/controllers/data/Dialog.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/controllers/data/Dialog.java b/src/main/java/noppes/npcs/controllers/data/Dialog.java index 9f6d40c51..763247ccb 100644 --- a/src/main/java/noppes/npcs/controllers/data/Dialog.java +++ b/src/main/java/noppes/npcs/controllers/data/Dialog.java @@ -39,7 +39,7 @@ public class Dialog implements ICompatibilty, IDialog { public boolean darkenScreen = true; public boolean showOptionLine = true; - //0 - Bottom, 1 - Top, 2 (Not implemented yet) - Center + //0 - Bottom, 1 - Top, 2 - Center [Unimplemented] public byte alignment = 0; public boolean renderGradual = false; From 339874da528bc685d5f20ed04c30eb97317fedf6 Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 30 Jul 2023 17:29:06 -0400 Subject: [PATCH 06/11] Fix Job Spawner not Removing Spawns --- src/main/java/noppes/npcs/PacketHandlerServer.java | 3 +++ src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/PacketHandlerServer.java b/src/main/java/noppes/npcs/PacketHandlerServer.java index 1dbe5d70b..3f554dec1 100644 --- a/src/main/java/noppes/npcs/PacketHandlerServer.java +++ b/src/main/java/noppes/npcs/PacketHandlerServer.java @@ -879,6 +879,9 @@ public class PacketHandlerServer{ else if(type == EnumPacketServer.JobSpawnerRemove){ if(npc.advanced.job != EnumJobType.Spawner) return; + JobSpawner job = (JobSpawner) npc.jobInterface; + job.setJobCompound(buffer.readInt(), null); + Server.sendData(player, EnumPacketClient.GUI_DATA, job.getTitles()); } else if(type == EnumPacketServer.RoleSave){ npc.roleInterface.readFromNBT(Server.readNBT(buffer)); 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 fddb4bd91..0c488dcb8 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java @@ -102,7 +102,8 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene setSubGui(new GuiNpcMobSpawnerSelector()); } if(button.id >= 20 && button.id < 26){ - job.setJobCompound(button.id - 19, null); + int removeID = button.id - 19; + job.setJobCompound(removeID, null); Client.sendData(EnumPacketServer.JobSpawnerRemove, button.id - 19); } if(button.id == 26){ @@ -152,6 +153,7 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene if(textfield.id == 9){ job.zOffset = textfield.getInteger(); } + save(); } @Override From 1a9b9645d5c93199ea6deb5c79999905feeffdce Mon Sep 17 00:00:00 2001 From: Kam Date: Sun, 30 Jul 2023 19:28:06 -0400 Subject: [PATCH 07/11] Add Job Spawner to Spawn on Death Option --- .../npcs/client/gui/roles/GuiNpcSpawner.java | 25 ++++++++++++++++++- .../java/noppes/npcs/roles/JobSpawner.java | 22 +++++++++------- 2 files changed, 37 insertions(+), 10 deletions(-) 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 0c488dcb8..bac58151e 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java @@ -88,7 +88,17 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene y += 23; addLabel(new GuiNpcLabel(10, "spawner.type", guiLeft + 4, y + 5)); - addButton(new GuiNpcButton(10, guiLeft + 80, y, 100, 20, new String[]{"spawner.one", "spawner.all", "spawner.random"}, job.spawnType)); + addButton(new GuiNpcButton(10, guiLeft + 80, y, 100, 20, new String[]{"spawner.one", "spawner.all", "spawner.random", "spawner.summoner"}, job.spawnType)); + + if(job.spawnType == 3){ + job.doesntDie = true; + getButton(26).setEnabled(false); + getButton(26).setDisplay(1); + + job.despawnOnTargetLost = false; + getButton(11).setEnabled(false); + getButton(11).setDisplay(0); + } } @Override @@ -111,6 +121,19 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene } if(button.id == 10){ job.spawnType = button.getValue(); + if(job.spawnType == 3){ + job.doesntDie = true; + getButton(26).setEnabled(false); + getButton(26).setDisplay(1); + + job.despawnOnTargetLost = false; + getButton(11).setEnabled(false); + getButton(11).setDisplay(0); + } + else { + getButton(26).setEnabled(true); + getButton(11).setEnabled(true); + } } if(button.id == 11){ job.despawnOnTargetLost = button.getValue() == 1; diff --git a/src/main/java/noppes/npcs/roles/JobSpawner.java b/src/main/java/noppes/npcs/roles/JobSpawner.java index 4555e0bd1..dcb0f8ec4 100644 --- a/src/main/java/noppes/npcs/roles/JobSpawner.java +++ b/src/main/java/noppes/npcs/roles/JobSpawner.java @@ -22,13 +22,6 @@ public class JobSpawner extends JobInterface{ public NBTTagCompound compound3; public NBTTagCompound compound2; public NBTTagCompound compound1; - - public String title1; - public String title2; - public String title3; - public String title4; - public String title5; - public String title6; private int number = 0; @@ -38,7 +31,9 @@ public class JobSpawner extends JobInterface{ private String id = RandomStringUtils.random(8, true, true); public boolean doesntDie = false; - + public boolean spawnsDieSummonerDies = false; + + // 0 - One By One, 1 - All at Once, 2 - Random, 3 - When Summoner Dies public int spawnType = 0; public int xOffset = 0; @@ -287,7 +282,7 @@ public class JobSpawner extends JobInterface{ public boolean aiShouldExecute() { if(isEmpty() || npc.isKilled()) return false; - + target = getTarget(); if(npc.getRNG().nextInt(30) == 1){ if(spawned.isEmpty()) @@ -326,6 +321,15 @@ public class JobSpawner extends JobInterface{ } @Override public void killed() { + if(spawnType == 3){ + spawnEntity(compound1); + spawnEntity(compound2); + spawnEntity(compound3); + spawnEntity(compound4); + spawnEntity(compound5); + spawnEntity(compound6); + number = 6; + } reset(); } From 4f1a9cefb7a99b2e071ee6b751814f8300e61678 Mon Sep 17 00:00:00 2001 From: Kam Date: Mon, 31 Jul 2023 11:38:59 -0400 Subject: [PATCH 08/11] Despawn Spawns when Summoner Dies --- .../npcs/client/gui/roles/GuiNpcSpawner.java | 98 +++++++++++++------ .../java/noppes/npcs/roles/JobSpawner.java | 9 +- 2 files changed, 73 insertions(+), 34 deletions(-) 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 bac58151e..353fe4c4a 100644 --- a/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java +++ b/src/main/java/noppes/npcs/client/gui/roles/GuiNpcSpawner.java @@ -23,6 +23,8 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene public String title4 = "gui.selectnpc"; public String title5 = "gui.selectnpc"; public String title6 = "gui.selectnpc"; + public String title7 = "gui.selectnpc"; + public String title8 = "gui.selectnpc"; public GuiNpcSpawner(EntityNPCInterface npc) { @@ -36,59 +38,69 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene int y = guiTop + 6; - this.addButton(new GuiNpcButton(20, guiLeft + 25, y,20,20, "X")); + this.addButton(new GuiNpcButton(20, guiLeft + 20, y,20,20, "X")); addLabel(new GuiNpcLabel(0, "1:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(0, guiLeft + 50, y, title1)); + this.addButton(new GuiNpcButton(0, guiLeft + 45, y, 140, 20, title1)); - y += 23; - this.addButton(new GuiNpcButton(21, guiLeft + 25, y,20,20, "X")); + addLabel(new GuiNpcLabel(6, "spawner.diesafter", guiLeft + 4 + 190, y + 5)); + this.addButton(new GuiNpcButton(26, guiLeft + 370, y,40,20, new String[]{"gui.yes","gui.no"}, job.doesntDie?1:0)); + + y += 23; + this.addButton(new GuiNpcButton(21, guiLeft + 20, y,20,20, "X")); addLabel(new GuiNpcLabel(1, "2:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(1, guiLeft + 50, y, title2)); + this.addButton(new GuiNpcButton(1, guiLeft + 45, y, 140, 20, title2)); - y += 23; - this.addButton(new GuiNpcButton(22, guiLeft + 25, y,20,20, "X")); + addLabel(new GuiNpcLabel(11, "spawner.despawn", guiLeft + 4 + 190, y + 5)); + this.addButton(new GuiNpcButton(11, guiLeft + 370, y,40,20, new String[]{"gui.no","gui.yes"}, job.despawnOnTargetLost?1:0)); + + y += 23; + this.addButton(new GuiNpcButton(22, guiLeft + 20, y,20,20, "X")); addLabel(new GuiNpcLabel(2, "3:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(2, guiLeft + 50, y, title3)); + this.addButton(new GuiNpcButton(2, guiLeft + 45, y, 140, 20, title3)); - y += 23; - this.addButton(new GuiNpcButton(23, guiLeft + 25, y,20,20, "X")); + addLabel(new GuiNpcLabel(27, "spawner.despawnsummon", guiLeft + 4 + 190, y + 5)); + this.addButton(new GuiNpcButton(27, guiLeft + 370, y,40,20, new String[]{"gui.no","gui.yes"}, job.despawnOnSummonerDeath ?0:1)); + + y += 23; + this.addButton(new GuiNpcButton(23, guiLeft + 20, y,20,20, "X")); addLabel(new GuiNpcLabel(3, "4:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(3, guiLeft + 50, y, title4)); + this.addButton(new GuiNpcButton(3, guiLeft + 45, y, 140, 20, title4)); y += 23; - this.addButton(new GuiNpcButton(24, guiLeft + 25, y,20,20, "X")); + this.addButton(new GuiNpcButton(24, guiLeft + 20, y,20,20, "X")); addLabel(new GuiNpcLabel(4, "5:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(4, guiLeft + 50, y, title5)); + this.addButton(new GuiNpcButton(4, guiLeft + 45, y, 140, 20, title5)); y += 23; - this.addButton(new GuiNpcButton(25, guiLeft + 25, y,20,20, "X")); + this.addButton(new GuiNpcButton(25, guiLeft + 20, y,20,20, "X")); addLabel(new GuiNpcLabel(5, "6:", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(5, guiLeft + 50, y, title6)); + this.addButton(new GuiNpcButton(5, guiLeft + 45, y, 140, 20, title6)); - y += 23; - addLabel(new GuiNpcLabel(6, "spawner.diesafter", guiLeft + 4, y + 5)); - this.addButton(new GuiNpcButton(26, guiLeft + 115, y,40,20, new String[]{"gui.yes","gui.no"}, job.doesntDie?1:0)); + y += 23; + y += 23; - addLabel(new GuiNpcLabel(11, "spawner.despawn", guiLeft + 170, y + 5)); - this.addButton(new GuiNpcButton(11, guiLeft + 335, y,40,20, new String[]{"gui.no","gui.yes"}, job.despawnOnTargetLost?1:0)); - - 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 + "")); + addLabel(new GuiNpcLabel(7,StatCollector.translateToLocal("spawner.posoffset")+" X:", guiLeft + 4 + 190, y + 5)); + addTextField(new GuiNpcTextField(7,this, fontRendererObj, guiLeft + 99 + 190, y, 24, 20, job.xOffset + "")); 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 + "")); + addLabel(new GuiNpcLabel(8,"Y:", guiLeft + 125 + 190, y + 5)); + addTextField(new GuiNpcTextField(8,this, fontRendererObj, guiLeft + 135 + 190, y, 24, 20, job.yOffset + "")); 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 + "")); + addLabel(new GuiNpcLabel(9,"Z:", guiLeft + 161 + 190, y + 5)); + addTextField(new GuiNpcTextField(9,this, fontRendererObj, guiLeft + 171 + 190, y, 24, 20, job.zOffset + "")); getTextField(9).integersOnly = true; getTextField(9).setMinMaxDefault(-9, 9, 0); y += 23; - addLabel(new GuiNpcLabel(10, "spawner.type", guiLeft + 4, y + 5)); - addButton(new GuiNpcButton(10, guiLeft + 80, y, 100, 20, new String[]{"spawner.one", "spawner.all", "spawner.random", "spawner.summoner"}, job.spawnType)); + addLabel(new GuiNpcLabel(10, "spawner.type", guiLeft + 4 + 190, y + 5)); + addButton(new GuiNpcButton(10, guiLeft + 80 + 190, y, 100, 20, new String[]{"spawner.one", "spawner.all", "spawner.random", "spawner.summoner"}, job.spawnType)); + + if(job.despawnOnSummonerDeath){ + job.doesntDie = true; + getButton(26).setEnabled(false); + getButton(26).setDisplay(1); + } if(job.spawnType == 3){ job.doesntDie = true; @@ -98,6 +110,10 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene job.despawnOnTargetLost = false; getButton(11).setEnabled(false); getButton(11).setDisplay(0); + + job.despawnOnSummonerDeath = false; + getButton(27).setEnabled(false); + getButton(27).setDisplay(0); } } @@ -119,6 +135,19 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene if(button.id == 26){ job.doesntDie = button.getValue() == 1; } + if(button.id == 27){ + job.despawnOnSummonerDeath = button.getValue() == 1; + if(job.despawnOnSummonerDeath){ + job.doesntDie = true; + getButton(26).setEnabled(false); + getButton(26).setDisplay(1); + } + else { + if(job.spawnType != 3){ + getButton(26).setEnabled(true); + } + } + } if(button.id == 10){ job.spawnType = button.getValue(); if(job.spawnType == 3){ @@ -129,10 +158,17 @@ public class GuiNpcSpawner extends GuiNPCInterface2 implements ITextfieldListene job.despawnOnTargetLost = false; getButton(11).setEnabled(false); getButton(11).setDisplay(0); + + job.despawnOnSummonerDeath = false; + getButton(27).setEnabled(false); + getButton(27).setDisplay(0); } else { - getButton(26).setEnabled(true); + if(!job.despawnOnSummonerDeath){ + getButton(26).setEnabled(true); + } getButton(11).setEnabled(true); + getButton(27).setEnabled(true); } } if(button.id == 11){ diff --git a/src/main/java/noppes/npcs/roles/JobSpawner.java b/src/main/java/noppes/npcs/roles/JobSpawner.java index dcb0f8ec4..d714b1dca 100644 --- a/src/main/java/noppes/npcs/roles/JobSpawner.java +++ b/src/main/java/noppes/npcs/roles/JobSpawner.java @@ -30,8 +30,10 @@ public class JobSpawner extends JobInterface{ private Map cooldown = new HashMap(); private String id = RandomStringUtils.random(8, true, true); + public boolean doesntDie = false; - public boolean spawnsDieSummonerDies = false; + public boolean despawnOnSummonerDeath = false; + public boolean despawnOnTargetLost = true; // 0 - One By One, 1 - All at Once, 2 - Random, 3 - When Summoner Dies public int spawnType = 0; @@ -42,7 +44,6 @@ public class JobSpawner extends JobInterface{ private EntityLivingBase target; - public boolean despawnOnTargetLost = true; public JobSpawner(EntityNPCInterface npc) { super(npc); @@ -65,6 +66,7 @@ public class JobSpawner extends JobInterface{ compound.setInteger("SpawnerZOffset", zOffset); compound.setBoolean("DespawnOnTargetLost", despawnOnTargetLost); + compound.setBoolean("DespawnOnSummmoner", despawnOnSummonerDeath); return compound; } @@ -109,6 +111,7 @@ public class JobSpawner extends JobInterface{ zOffset = compound.getInteger("SpawnerZOffset"); despawnOnTargetLost = compound.getBoolean("DespawnOnTargetLost"); + despawnOnSummonerDeath = compound.getBoolean("DespawnOnSummmoner"); } @@ -212,7 +215,7 @@ public class JobSpawner extends JobInterface{ public boolean shouldDelete(EntityLivingBase entity){ return npc.getDistanceToEntity(entity) > 60 || entity.isDead || entity.getHealth() <= 0 || - PixelmonHelper.Enabled && hasPixelmon() && !PixelmonHelper.isBattling(entity) || despawnOnTargetLost && target == null; + PixelmonHelper.Enabled && hasPixelmon() && !PixelmonHelper.isBattling(entity) || (despawnOnSummonerDeath && npc.isDead) || despawnOnTargetLost && target == null; } private EntityLivingBase getTarget() { From 50ef7aef622bfdbdee3cf4b7cb8490a73e01442c Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 1 Aug 2023 17:11:40 -0400 Subject: [PATCH 09/11] Fix Job Spawner Jumping and Spawning Issue --- .../java/noppes/npcs/roles/JobSpawner.java | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/src/main/java/noppes/npcs/roles/JobSpawner.java b/src/main/java/noppes/npcs/roles/JobSpawner.java index d714b1dca..7cc91140d 100644 --- a/src/main/java/noppes/npcs/roles/JobSpawner.java +++ b/src/main/java/noppes/npcs/roles/JobSpawner.java @@ -8,6 +8,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import net.minecraft.world.World; +import noppes.npcs.NoppesUtilServer; import noppes.npcs.compat.PixelmonHelper; import noppes.npcs.entity.EntityNPCInterface; import org.apache.commons.lang3.RandomStringUtils; @@ -350,36 +351,41 @@ public class JobSpawner extends JobInterface{ double x = this.npc.posX + xOffset - 0.5 + this.npc.getRNG().nextFloat(); double y = this.npc.posY + yOffset; double z = this.npc.posZ + zOffset - 0.5 + this.npc.getRNG().nextFloat(); - - World world = this.npc.getEntityWorld(); - Entity entity = EntityList.createEntityFromNBT(compound, world); - if(!(entity instanceof EntityLivingBase)) + Entity entity = NoppesUtilServer.getEntityFromNBT(compound, MathHelper.floor_double(x), MathHelper.floor_double(y), MathHelper.floor_double(z), npc.worldObj); + if(entity == null){ return null; - EntityLivingBase living = (EntityLivingBase) entity; - living.getEntityData().setString("NpcSpawnerId", id); - living.getEntityData().setInteger("NpcSpawnerNr", number); - setTarget(living, this.npc.getAttackTarget()); - entity.setPosition(x + 0.5, y + 1 + 0.2F, z + 0.5); - - if(living instanceof EntityNPCInterface){ - EntityNPCInterface snpc = (EntityNPCInterface) living; - snpc.ai.startPos = new int[]{(int) x, (int) snpc.getStartYPos(), (int) z}; - snpc.stats.spawnCycle = 3; - snpc.ai.returnToStart = false; - snpc.setPosition((float)x + 0.5F, snpc.getStartYPos(), (float)z + 0.5F); - snpc.reset(); } + entity.dimension = npc.worldObj.provider.dimensionId; + if (!entity.forceSpawn && !npc.worldObj.checkChunksExist( + (int)entity.posX,(int)entity.posY,(int)entity.posZ,(int)entity.posX,(int)entity.posY,(int)entity.posZ + )) { + return null; + } + else { + if (!(entity instanceof EntityLivingBase)) + return null; + EntityLivingBase living = (EntityLivingBase) entity; + living.getEntityData().setString("NpcSpawnerId", id); + living.getEntityData().setInteger("NpcSpawnerNr", number); + setTarget(living, this.npc.getAttackTarget()); + living.setPosition(x + 0.5, y + 1 + 0.2F, z + 0.5); - int i = MathHelper.floor_double(entity.posX / 16.0D); - int j = MathHelper.floor_double(entity.posZ / 16.0D); - entity.dimension = world.provider.dimensionId; - world.getChunkFromChunkCoords(i, j).addEntity(entity); - world.loadedEntityList.add(entity); - world.onEntityAdded(entity); + if (living instanceof EntityNPCInterface) { + EntityNPCInterface snpc = (EntityNPCInterface) living; + snpc.stats.spawnCycle = 3; + snpc.ai.returnToStart = false; + } - spawned.add(living); - return living; + int i = MathHelper.floor_double(living.posX / 16.0D); + int j = MathHelper.floor_double(living.posZ / 16.0D); + + npc.worldObj.getChunkFromChunkCoords(i, j).addEntity(living); + npc.worldObj.loadedEntityList.add(living); + npc.worldObj.onEntityAdded(living); + spawned.add(living); + return living; + } } public NBTTagCompound getCompound(int i) { From 6d0df76447372230c26365e25edecaa621458806 Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 1 Aug 2023 17:14:24 -0400 Subject: [PATCH 10/11] Allow Spawns to Naturally Despawn always --- src/main/java/noppes/npcs/roles/JobSpawner.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/noppes/npcs/roles/JobSpawner.java b/src/main/java/noppes/npcs/roles/JobSpawner.java index 7cc91140d..1bf26a893 100644 --- a/src/main/java/noppes/npcs/roles/JobSpawner.java +++ b/src/main/java/noppes/npcs/roles/JobSpawner.java @@ -375,6 +375,8 @@ public class JobSpawner extends JobInterface{ EntityNPCInterface snpc = (EntityNPCInterface) living; snpc.stats.spawnCycle = 3; snpc.ai.returnToStart = false; + snpc.stats.canDespawn = true; + snpc.stats.playerSetCanDespawn = true; } int i = MathHelper.floor_double(living.posX / 16.0D); From ee8e876e79fdd4d506ea9285cf5169fabf7f832c Mon Sep 17 00:00:00 2001 From: Kam Date: Tue, 1 Aug 2023 17:33:49 -0400 Subject: [PATCH 11/11] Fix Blocks not showing in Hanging Banners --- .../blocks/BlockWallBannerRenderer.java | 62 ++++++++++++++++--- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/src/main/java/noppes/npcs/client/renderer/blocks/BlockWallBannerRenderer.java b/src/main/java/noppes/npcs/client/renderer/blocks/BlockWallBannerRenderer.java index e905571b8..0d3653350 100644 --- a/src/main/java/noppes/npcs/client/renderer/blocks/BlockWallBannerRenderer.java +++ b/src/main/java/noppes/npcs/client/renderer/blocks/BlockWallBannerRenderer.java @@ -3,10 +3,14 @@ package noppes.npcs.client.renderer.blocks; import cpw.mods.fml.client.registry.RenderingRegistry; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import noppes.npcs.CustomItems; import noppes.npcs.blocks.BlockWallBanner; import noppes.npcs.blocks.tiles.TileWallBanner; @@ -54,23 +58,67 @@ public class BlockWallBannerRenderer extends BlockRendererInterface{ } public void doRender(double par2, double par4, double par6, int meta, ItemStack iicon) { - if (iicon.getItemSpriteNumber() == 0 && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(iicon.getItem()).getRenderType())) - return; GL11.glPushMatrix(); bindTexture(TextureMap.locationItemsTexture); - GL11.glTranslatef((float)par2 + 0.5f, (float)par4 +0.2f, (float)par6 + 0.5f); + GL11.glTranslatef((float)par2 + 0.5f, (float)par4 +1.3f, (float)par6 + 0.5f); GL11.glRotatef(180, 0, 0, 1); - GL11.glRotatef(90 * meta, 0, 1, 0); - GL11.glTranslatef(0, 0, 0.26f); + GL11.glRotatef(90 * meta, 0, 1, 0); + GL11.glTranslatef(0, 0, -0.14f); GL11.glDepthMask(false); float f2 = 0.05f; Minecraft mc = Minecraft.getMinecraft(); GL11.glScalef(f2, f2, f2); - renderer.renderItemIntoGUI(this.func_147498_b(), mc.renderEngine, iicon, -8, -8); + renderItemBanner(mc.renderEngine, iicon, -8, -8, false); GL11.glDepthMask(true); GL11.glPopMatrix(); } - + + public void renderItemBanner(TextureManager txtMng, ItemStack item, int p_77015_4_, int p_77015_5_, boolean renderEffect) + { + Object object = item.getIconIndex(); + int l; + float f; + float f3; + float f4; + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + OpenGlHelper.glBlendFunc(770, 771, 1, 0); + ResourceLocation resourcelocation = txtMng.getResourceLocation(item.getItemSpriteNumber()); + txtMng.bindTexture(resourcelocation); + + if (object == null) + { + object = ((TextureMap)Minecraft.getMinecraft().getTextureManager().getTexture(resourcelocation)).getAtlasSprite("missingno"); + } + + l = item.getItem().getColorFromItemStack(item, 0); + f3 = (float)(l >> 16 & 255) / 255.0F; + f4 = (float)(l >> 8 & 255) / 255.0F; + f = (float)(l & 255) / 255.0F; + + if (renderer.renderWithColor) + { + GL11.glColor4f(f3, f4, f, 1.0F); + } + + GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, a renderEffect can derp them up. + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + + renderer.renderIcon(p_77015_4_, p_77015_5_, (IIcon)object, 16, 16); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glDisable(GL11.GL_BLEND); + + if (renderEffect && item.hasEffect(0)) + { + renderer.renderEffect(txtMng, p_77015_4_, p_77015_5_); + } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_CULL_FACE); + } @Override