From 3b039f67aff0eda2ca5b12dfb0a1855e097ce731 Mon Sep 17 00:00:00 2001 From: KAMKEEL <28842281+KAMKEEL@users.noreply.github.com> Date: Thu, 10 Sep 2026 04:10:09 -0400 Subject: [PATCH] Keep the script editor out of keys meant for another box --- .../npcs/client/gui/util/GuiScriptTextArea.java | 10 ++++++++++ .../noppes/npcs/entity/EntityNPCInterface.java | 15 +++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) 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 8bd2cfa45..8053e9e57 100644 --- a/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java +++ b/src/main/java/noppes/npcs/client/gui/util/GuiScriptTextArea.java @@ -1780,6 +1780,16 @@ public class GuiScriptTextArea extends GuiNpcTextField { */ @Override public boolean textboxKeyTyped(char c, int i) { + // Stay out of it while another box has the caret. + // + // GuiNPCInterface hands every key to every text field it holds, and the + // plain field returns early when it is not focused. This one overrode + // that method and never checked, so a character typed into any other + // box on the screen was also appended to the script - which reads as + // the keypress happening twice. + if (activeTextfield != null && activeTextfield != this) { + return false; + } if (KEYS_OVERLAY.keyTyped(c, i)) return true; diff --git a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java index 4ef245485..954db1f58 100644 --- a/src/main/java/noppes/npcs/entity/EntityNPCInterface.java +++ b/src/main/java/noppes/npcs/entity/EntityNPCInterface.java @@ -1338,13 +1338,17 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti this.height = newHeight; this.setPosition(posX, posY, posZ); - if (newWidth > oldWidth && !this.firstUpdate && !this.worldObj.isRemote) { + // Only push when the box really grew into a block, and only by the half-width it grew: + // setPosition already recentered it, unlike vanilla setSize which grows from the corner. + if (newWidth > oldWidth && !this.firstUpdate && !this.worldObj.isRemote + && !worldObj.getCollidingBoundingBoxes(this, boundingBox).isEmpty()) { // Lying and crawling widen the box, and moveEntity would answer that by stepping the // npc up onto whatever it now touches. Only the horizontal push is wanted here. + float push = (oldWidth - newWidth) / 2; float prevStepHeight = this.stepHeight; this.stepHeight = 0.0F; try { - this.moveEntity(oldWidth - newWidth, 0.0D, oldWidth - newWidth); + this.moveEntity(push, 0.0D, push); } finally { this.stepHeight = prevStepHeight; } @@ -1666,11 +1670,14 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti } public boolean isVeryNearAssignedPlace() { + // Scaled by the footprint: 0.2 for a default 0.6 wide npc, so big npcs are not held to a + // tolerance finer than their own body. Floored for corpses, which shrink to 0.00001. + double t = Math.max(0.2, width / 3); double xx = posX - getStartXPos(); double zz = posZ - getStartZPos(); - if (xx < -0.2 || xx > 0.2) + if (xx < -t || xx > t) return false; - return !(zz < -0.2) && !(zz > 0.2); + return !(zz < -t) && !(zz > t); } @Override