:upo: Fix roller problems

This commit is contained in:
duckietm
2026-01-06 16:30:45 +01:00
parent 5a29ac2c8e
commit d37be312e2
@@ -23,7 +23,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
private final Room room;
private int x;
private int y;
private final HabboItem oldTopItem;
private HabboItem oldTopItem;
public RoomUnitOnRollerComposer(RoomUnit roomUnit, HabboItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, Room room) {
this.roomUnit = roomUnit;
@@ -65,8 +65,17 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
this.response.appendString(this.newZ + "");
if (this.roller != null && room.getLayout() != null) {
// Update location immediately to prevent desync issues where the unit gets
// "stuck" rolling because subsequent roller cycles see the unit at the old position
if (!this.roomUnit.isWalking() && this.roomUnit.getCurrentLocation() == this.oldLocation) {
this.roomUnit.setLocation(this.newLocation);
this.roomUnit.setZ(this.newZ);
this.roomUnit.setPreviousLocationZ(this.newZ);
}
// Delay the walk on/off events to allow the visual animation to complete
Emulator.getThreading().run(() -> {
if(!this.roomUnit.isWalking() && this.roomUnit.getCurrentLocation() == this.oldLocation) {
if (!this.roomUnit.isWalking()) {
HabboItem topItem = this.room.getTopItemAt(this.oldLocation.x, this.oldLocation.y);
HabboItem topItemNewLocation = this.room.getTopItemAt(this.newLocation.x, this.newLocation.y);
@@ -78,10 +87,6 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
}
}
this.roomUnit.setLocation(this.newLocation);
this.roomUnit.setZ(this.newLocation.getStackHeight());
this.roomUnit.setPreviousLocationZ(this.newLocation.getStackHeight());
if (topItemNewLocation != null && topItemNewLocation != roller && oldTopItem != topItemNewLocation) {
try {
topItemNewLocation.onWalkOn(this.roomUnit, this.room, new Object[]{this});