Fix bot z position saving and sending

This commit is contained in:
Alejandro 2020-01-27 23:02:53 +02:00
parent 9b062bd760
commit aff9e75fe1
3 changed files with 10 additions and 4 deletions

View File

@ -764,7 +764,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
bot.getRoomUnit().setPreviousLocationZ(topItem.getZ()); bot.getRoomUnit().setPreviousLocationZ(topItem.getZ());
bot.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation())); bot.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation()));
} else { } else {
bot.getRoomUnit().setZ(topItem.getZ() + topItem.getBaseItem().getHeight()); bot.getRoomUnit().setZ(topItem.getZ() + Item.getCurrentHeight(topItem));
if (topItem.getBaseItem().allowLay()) { if (topItem.getBaseItem().allowLay()) {
bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + ""); bot.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + "");
@ -772,6 +772,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} else { } else {
bot.getRoomUnit().setZ(bot.getRoomUnit().getCurrentLocation().getStackHeight()); bot.getRoomUnit().setZ(bot.getRoomUnit().getCurrentLocation().getStackHeight());
bot.getRoomUnit().setPreviousLocationZ(bot.getRoomUnit().getCurrentLocation().getStackHeight());
} }
roomUnits.add(bot.getRoomUnit()); roomUnits.add(bot.getRoomUnit());
@ -1604,7 +1605,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.dance(unit, DanceType.NONE); this.dance(unit, DanceType.NONE);
//int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z; //int tileHeight = this.layout.getTile(topItem.getX(), topItem.getY()).z;
unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + ""); unit.setStatus(RoomUnitStatus.SIT, (Item.getCurrentHeight(topItem) * 1.0D) + "");
unit.setPreviousLocationZ(topItem.getZ());
unit.setZ(topItem.getZ()); unit.setZ(topItem.getZ());
unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]); unit.setRotation(RoomUserRotation.values()[topItem.getRotation()]);
unit.sitUpdate = false; unit.sitUpdate = false;

View File

@ -770,7 +770,7 @@ public class RoomManager {
habbo.getClient().sendResponse(new RoomUserDanceComposer(bot.getRoomUnit())); habbo.getClient().sendResponse(new RoomUserDanceComposer(bot.getRoomUnit()));
} }
habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit())); habbo.getClient().sendResponse(new RoomUserStatusComposer(bot.getRoomUnit(), bot.getRoomUnit().getZ()));
} }
} }

View File

@ -14,12 +14,18 @@ import java.util.Map;
public class RoomUserStatusComposer extends MessageComposer { public class RoomUserStatusComposer extends MessageComposer {
private Collection<Habbo> habbos; private Collection<Habbo> habbos;
private THashSet<RoomUnit> roomUnits; private THashSet<RoomUnit> roomUnits;
private double overrideZ = -1;
public RoomUserStatusComposer(RoomUnit roomUnit) { public RoomUserStatusComposer(RoomUnit roomUnit) {
this.roomUnits = new THashSet<>(); this.roomUnits = new THashSet<>();
this.roomUnits.add(roomUnit); this.roomUnits.add(roomUnit);
} }
public RoomUserStatusComposer(RoomUnit roomUnit, double overrideZ) {
this(roomUnit);
this.overrideZ = overrideZ;
}
public RoomUserStatusComposer(THashSet<RoomUnit> roomUnits, boolean value) { public RoomUserStatusComposer(THashSet<RoomUnit> roomUnits, boolean value) {
this.roomUnits = roomUnits; this.roomUnits = roomUnits;
} }
@ -37,7 +43,7 @@ public class RoomUserStatusComposer extends MessageComposer {
this.response.appendInt(roomUnit.getId()); this.response.appendInt(roomUnit.getId());
this.response.appendInt(roomUnit.getPreviousLocation().x); this.response.appendInt(roomUnit.getPreviousLocation().x);
this.response.appendInt(roomUnit.getPreviousLocation().y); 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()); this.response.appendInt(roomUnit.getHeadRotation().getValue());