From 114147a23b99203eefe67594c32a1b87aa9b5086 Mon Sep 17 00:00:00 2001 From: kuroppoi <68156848+kuroppoi@users.noreply.github.com> Date: Fri, 22 Jul 2022 22:03:31 +0200 Subject: [PATCH] Bats hang from the ceiling, doofus! --- .../gameserver/behavior/parts/IdleBehavior.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gameserver/src/main/java/brainwine/gameserver/behavior/parts/IdleBehavior.java b/gameserver/src/main/java/brainwine/gameserver/behavior/parts/IdleBehavior.java index 64bb753..0ef11ad 100644 --- a/gameserver/src/main/java/brainwine/gameserver/behavior/parts/IdleBehavior.java +++ b/gameserver/src/main/java/brainwine/gameserver/behavior/parts/IdleBehavior.java @@ -10,12 +10,14 @@ import com.fasterxml.jackson.annotation.JsonSetter; import brainwine.gameserver.behavior.Behavior; import brainwine.gameserver.entity.FacingDirection; import brainwine.gameserver.entity.npc.Npc; +import brainwine.gameserver.util.Vector2i; public class IdleBehavior extends Behavior { protected int delay = 60; protected int duration = 60; protected double random = 0.5; + protected Vector2i groundOffset = new Vector2i(0, 1); protected String[] animations = new String[] {"idle"}; protected long until; protected boolean idle; @@ -33,7 +35,7 @@ public class IdleBehavior extends Behavior { Random random = ThreadLocalRandom.current(); long now = System.currentTimeMillis(); - if(entity.isOnGround()) { + if(entity.isBlocked(groundOffset.getX(), groundOffset.getY())) { if(now > until) { idle = !idle; until = getNextUntil(); @@ -78,6 +80,11 @@ public class IdleBehavior extends Behavior { this.random = random; } + @JsonSetter("grounded") + public void setGroundOffset(Vector2i groundOffset) { + this.groundOffset = groundOffset; + } + @JsonSetter("animation") public void setAnimations(String... animations) { this.animations = animations;