From bc98642b9514a7cb81c7f1236890162073253b8b Mon Sep 17 00:00:00 2001 From: Kam Date: Fri, 29 Mar 2024 13:54:03 -0400 Subject: [PATCH 1/5] Better Null checks for Crate Containers --- .../npcs/containers/ContainerCrate.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/main/java/noppes/npcs/containers/ContainerCrate.java b/src/main/java/noppes/npcs/containers/ContainerCrate.java index 47205545f..0dab25a35 100644 --- a/src/main/java/noppes/npcs/containers/ContainerCrate.java +++ b/src/main/java/noppes/npcs/containers/ContainerCrate.java @@ -16,31 +16,34 @@ public class ContainerCrate extends Container { this.lowerChestInventory = par2IInventory; this.upperChestInventory = par1IInventory; - this.numRows = par2IInventory.getSizeInventory() / 9; - par2IInventory.openInventory(); - int i = (this.numRows - 4) * 18; - int j; - int k; + this.numRows = 0; + if(par2IInventory != null && par1IInventory != null){ + this.numRows = par2IInventory.getSizeInventory() / 9; + par2IInventory.openInventory(); + int i = (this.numRows - 4) * 18; + int j; + int k; - for (j = 0; j < this.numRows; ++j) - { - for (k = 0; k < 9; ++k) + for (j = 0; j < this.numRows; ++j) { - this.addSlotToContainer(new Slot(par2IInventory, k + j * 9, 8 + k * 18, 18 + j * 18)); + for (k = 0; k < 9; ++k) + { + this.addSlotToContainer(new Slot(par2IInventory, k + j * 9, 8 + k * 18, 18 + j * 18)); + } } - } - for (j = 0; j < 3; ++j) - { - for (k = 0; k < 9; ++k) + for (j = 0; j < 3; ++j) { - this.addSlotToContainer(new Slot(par1IInventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); + for (k = 0; k < 9; ++k) + { + this.addSlotToContainer(new Slot(par1IInventory, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i)); + } } - } - for (j = 0; j < 9; ++j) - { - this.addSlotToContainer(new Slot(par1IInventory, j, 8 + j * 18, 161 + i)); + for (j = 0; j < 9; ++j) + { + this.addSlotToContainer(new Slot(par1IInventory, j, 8 + j * 18, 161 + i)); + } } } @@ -103,4 +106,4 @@ public class ContainerCrate extends Container { return this.lowerChestInventory; } -} \ No newline at end of file +} From 3e1075691b82ad4af50a337eb4c4a04b7e4fcffc Mon Sep 17 00:00:00 2001 From: Kam Date: Fri, 29 Mar 2024 17:02:54 -0400 Subject: [PATCH 2/5] set Skin URL does not change from URL 64 --- src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java index 53dcf1a09..29f027248 100644 --- a/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java +++ b/src/main/java/noppes/npcs/scripted/entity/ScriptNpc.java @@ -1319,7 +1319,8 @@ public class ScriptNpc extends ScriptLiving imp return; this.npc.display.url = url; npc.textureLocation = null; - npc.display.skinType = 2; + if(npc.display.skinType < 2) + npc.display.skinType = 2; npc.script.clientNeedsUpdate = true; } From e2028dfd36672a482e0f93c10190909e552a9495 Mon Sep 17 00:00:00 2001 From: Kam Date: Fri, 29 Mar 2024 17:04:10 -0400 Subject: [PATCH 3/5] Reset Texture Location if URL changed --- src/main/java/noppes/npcs/DataDisplay.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/DataDisplay.java b/src/main/java/noppes/npcs/DataDisplay.java index 0bc50badd..2921958a5 100644 --- a/src/main/java/noppes/npcs/DataDisplay.java +++ b/src/main/java/noppes/npcs/DataDisplay.java @@ -126,6 +126,7 @@ public class DataDisplay { title = nbttagcompound.getString("Title"); + String prevUrl = url; url = nbttagcompound.getString("SkinUrl"); int prevSkinType = skinType; @@ -143,7 +144,6 @@ public class DataDisplay { } String prevTexture = texture; - texture = nbttagcompound.getString("Texture"); cloakTexture = nbttagcompound.getString("CloakTexture"); @@ -200,7 +200,7 @@ public class DataDisplay { else collidesWith = 1; - if(prevSkinType != skinType || !texture.equals(prevTexture)) + if(prevSkinType != skinType || !texture.equals(prevTexture)|| !url.equals(prevUrl)) npc.textureLocation = null; npc.updateHitbox(); } From 675267c5b1cb4ba8e35f9c5a9957dc15ea6d4bbb Mon Sep 17 00:00:00 2001 From: Kam Date: Fri, 29 Mar 2024 21:50:52 -0400 Subject: [PATCH 4/5] Not Remote check for NPC Swing --- src/main/java/noppes/npcs/entity/EntityNPCInterface.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index a47a67cca..348ca6158 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -288,9 +288,11 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti if (this.worldObj instanceof WorldServer) { - NpcEvent.SwingEvent event = new NpcEvent.SwingEvent(wrappedNPC, stack); - if(EventHooks.onNPCMeleeSwing(this, event)) - return; + if(!isRemote()){ + NpcEvent.SwingEvent event = new NpcEvent.SwingEvent(wrappedNPC, stack); + if(EventHooks.onNPCMeleeSwing(this, event)) + return; + } ((WorldServer)this.worldObj).getEntityTracker().func_151247_a(this, new S0BPacketAnimation(this, 0)); } From 3f84c0c4b1831d8cbe736cda33fb005a3501a006 Mon Sep 17 00:00:00 2001 From: Kam Date: Sat, 30 Mar 2024 15:30:35 -0400 Subject: [PATCH 5/5] Fix Block Text Loading --- src/main/java/noppes/npcs/blocks/tiles/TileScripted.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java b/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java index 649675cce..b2d3bf8b4 100644 --- a/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java +++ b/src/main/java/noppes/npcs/blocks/tiles/TileScripted.java @@ -133,14 +133,18 @@ public class TileScripted extends TileEntity implements IScriptBlockHandler { if(scaleZ <= 0) scaleZ = 1; - if(compound.hasKey("Text3")) { + if(compound.hasKey("Text1")) text1.setNBT(compound.getCompoundTag("Text1")); + if(compound.hasKey("Text2")) text2.setNBT(compound.getCompoundTag("Text2")); + if(compound.hasKey("Text3")) text3.setNBT(compound.getCompoundTag("Text3")); + if(compound.hasKey("Text4")) text4.setNBT(compound.getCompoundTag("Text4")); + if(compound.hasKey("Text5")) text5.setNBT(compound.getCompoundTag("Text5")); + if(compound.hasKey("Text6")) text6.setNBT(compound.getCompoundTag("Text6")); - } } @Override