mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-17 23:55:10 +00:00
Keep the script editor out of keys meant for another box
This commit is contained in:
1 parent
517ccb09c3
commit
3b039f67af
2 files changed
+21
-4
No files matched your search
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user