Make user walk to correct tile on beds

This commit is contained in:
Alejandro 2019-05-27 12:12:36 +03:00
parent 944115d12c
commit 9554b969c6

View File

@ -2,13 +2,16 @@ package com.eu.habbo.messages.incoming.rooms.users;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.pets.PetTasks; import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
import com.eu.habbo.plugin.events.users.UserIdleEvent; import com.eu.habbo.plugin.events.users.UserIdleEvent;
import gnu.trove.set.hash.THashSet;
public class RoomUserWalkEvent extends MessageHandler { public class RoomUserWalkEvent extends MessageHandler {
@Override @Override
@ -37,6 +40,7 @@ public class RoomUserWalkEvent extends MessageHandler {
} }
roomUnit = habbo.getRoomUnit(); roomUnit = habbo.getRoomUnit();
Room room = habbo.getHabboInfo().getCurrentRoom();
try { try {
if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) { if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) {
@ -47,7 +51,7 @@ public class RoomUserWalkEvent extends MessageHandler {
if (x == roomUnit.getX() && y == roomUnit.getY()) if (x == roomUnit.getX() && y == roomUnit.getY())
return; return;
if (habbo.getHabboInfo().getCurrentRoom() == null || habbo.getHabboInfo().getCurrentRoom().getLayout() == null) if (room == null || room.getLayout() == null)
return; return;
if (roomUnit.isIdle()) { if (roomUnit.isIdle()) {
@ -62,25 +66,47 @@ public class RoomUserWalkEvent extends MessageHandler {
} }
} }
RoomTile tile = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); RoomTile tile = room.getLayout().getTile((short) x, (short) y);
if (tile == null) { if (tile == null) {
return; return;
} }
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
if (habbo.getHabboInfo().getCurrentRoom().getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
return; return;
} }
if (tile.isWalkable() || habbo.getHabboInfo().getCurrentRoom().canSitOrLayAt(tile.x, tile.y)) { if (room.canLayAt(tile.x, tile.y)) {
HabboItem bed = room.getTopItemAt(tile.x, tile.y);
if (bed != null && bed.getBaseItem().allowLay()) {
RoomTile pillow = room.getLayout().getTile(bed.getX(), bed.getY());
switch (bed.getRotation()) {
case 0:
case 4:
pillow = room.getLayout().getTile((short)x, bed.getY());
break;
case 2:
case 8:
pillow = room.getLayout().getTile(bed.getX(), (short)y);
break;
}
if (pillow != null && room.canLayAt(pillow.x, pillow.y)) {
roomUnit.setGoalLocation(pillow);
return;
}
}
}
if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) {
roomUnit.setGoalLocation(tile); roomUnit.setGoalLocation(tile);
} }
} else { } else {
RoomTile t = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); RoomTile t = room.getLayout().getTile((short) x, (short) y);
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, habbo.getHabboInfo().getCurrentRoom()).compose()); room.sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, room).compose());
if (habbo.getHabboInfo().getRiding() != null) { if (habbo.getHabboInfo().getRiding() != null) {
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, habbo.getHabboInfo().getCurrentRoom()).compose()); room.sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, room).compose());
} }
} }
} }