From aff9e75fe1a24dc3b68b076fc07f0006a383f60c Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Mon, 27 Jan 2020 23:02:53 +0200 Subject: [PATCH] Fix bot z position saving and sending --- src/main/java/com/eu/habbo/habbohotel/rooms/Room.java | 4 ++-- .../java/com/eu/habbo/habbohotel/rooms/RoomManager.java | 2 +- .../outgoing/rooms/users/RoomUserStatusComposer.java | 8 +++++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 49f5c894..652b5cfd 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -764,7 +764,7 @@ public class Room implements Comparable, ISerialize, Runnable { bot.getRoomUnit().setPreviousLocationZ(topItem.getZ()); bot.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation())); } else { - bot.getRoomUnit().setZ(topItem.getZ() + topItem.getBaseItem().getHeight()); + bot.getRoomUnit().setZ(topItem.getZ() + Item.getCurrentHeight(topItem)); if (topItem.getBaseItem().allowLay()) { bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + ""); @@ -772,6 +772,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } else { bot.getRoomUnit().setZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); + bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); } roomUnits.add(bot.getRoomUnit()); @@ -1604,7 +1605,6 @@ public class Room implements Comparable, ISerialize, Runnable { this.dance(unit, DanceType.NONE); //int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z; unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + ""); - unit.setPreviousLocationZ(topItem.getZ()); unit.setZ(topItem.getZ()); unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]); unit.sitUpdate = false; diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 9157886e..60c67a59 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -770,7 +770,7 @@ public class RoomManager { habbo.getClient().sendResponse(new RoomUserDanceComposer(bot.getRoomUnit())); } - habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit())); + habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit(), bot.getRoomUnit().getZ())); } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java index 652511e8..28f89597 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUserStatusComposer.java @@ -14,12 +14,18 @@ import java.util.Map; public class RoomUserStatusComposer extends MessageComposer { private Collection habbos; private THashSet roomUnits; + private double overrideZ = -1; public RoomUserStatusComposer(RoomUnit roomUnit) { this.roomUnits = new THashSet<>(); this.roomUnits.add(roomUnit); } + public RoomUserStatusComposer(RoomUnit roomUnit, double overrideZ) { + this(roomUnit); + this.overrideZ = overrideZ; + } + public RoomUserStatusComposer(THashSet roomUnits, boolean value) { this.roomUnits = roomUnits; } @@ -37,7 +43,7 @@ public class RoomUserStatusComposer extends MessageComposer { this.response.appendInt(roomUnit.getId()); this.response.appendInt(roomUnit.getPreviousLocation().x); this.response.appendInt(roomUnit.getPreviousLocation().y); - this.response.appendString(roomUnit.getPreviousLocationZ() + ""); + this.response.appendString((this.overrideZ != -1 ? this.overrideZ : roomUnit.getPreviousLocationZ()) + ""); this.response.appendInt(roomUnit.getHeadRotation().getValue());