From 90918309b759e14e9f294386caba56d8de2771f9 Mon Sep 17 00:00:00 2001 From: Beny Date: Fri, 16 Oct 2020 05:50:57 +0200 Subject: [PATCH] Rollers and teleporting to seats fixed --- .../interactions/InteractionDefault.java | 16 ++--- .../com/eu/habbo/habbohotel/rooms/Room.java | 6 +- .../rooms/users/RoomUserLookAtPoint.java | 3 +- .../items/FloorItemOnRollerComposer.java | 2 +- .../rooms/users/RoomUnitOnRollerComposer.java | 59 ++++++++++++++----- .../threading/runnables/RoomUnitTeleport.java | 4 +- 6 files changed, 61 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java index c4898d0d..4860d0ff 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java @@ -48,15 +48,17 @@ public class InteractionDefault extends HabboItem { public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { super.onMove(room, oldLocation, newLocation); - for (RoomUnit unit : room.getRoomUnits()) { - if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) - continue; // If the unit was previously on the furni... - if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // but is not anymore... + if(room.getItemsAt(oldLocation).stream().noneMatch(item -> item.getClass().isAssignableFrom(InteractionRoller.class))) { + for (RoomUnit unit : room.getRoomUnits()) { + if (!oldLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) + continue; // If the unit was previously on the furni... + if (newLocation.unitIsOnFurniOnTile(unit, this.getBaseItem())) continue; // but is not anymore... - try { - this.onWalkOff(unit, room, new Object[]{ oldLocation, newLocation }); // the unit walked off! - } catch (Exception ignored) { + try { + this.onWalkOff(unit, room, new Object[]{oldLocation, newLocation}); // the unit walked off! + } catch (Exception ignored) { + } } } } 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 4ce65199..59b63195 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1462,7 +1462,7 @@ public class Room implements Comparable, ISerialize, Runnable { tile.setStackHeight(ridingUnit.getZ() + zOffset); rolledUnitIds.add(ridingUnit.getId()); updatedUnit.remove(ridingUnit); - messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentLocation(), ridingUnit.getZ(), tile, tile.getStackHeight() + (nextTileChair != null ? -1 : 0), room)); + messages.add(new RoomUnitOnRollerComposer(ridingUnit, roller, ridingUnit.getCurrentLocation(), ridingUnit.getZ(), tile, tile.getStackHeight(), room)); isRiding = true; } } @@ -1471,7 +1471,7 @@ public class Room implements Comparable, ISerialize, Runnable { usersRolledThisTile.add(unit.getId()); rolledUnitIds.add(unit.getId()); updatedUnit.remove(unit); - messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentLocation(), unit.getZ() + (isRiding ? 1 : 0), tile, tile.getStackHeight() + (isRiding ? 1 : 0) + (nextTileChair != null ? -1 : 0), room)); + messages.add(new RoomUnitOnRollerComposer(unit, roller, unit.getCurrentLocation(), unit.getZ() + (isRiding ? 1 : 0), tile, tile.getStackHeight() + (isRiding ? 1 : 0), room)); if (itemsOnRoller.isEmpty()) { HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y); @@ -3613,7 +3613,7 @@ public class Room implements Comparable, ISerialize, Runnable { HabboItem item = this.getTopItemAt(x, y, exclude); if (item != null) { canStack = item.getBaseItem().allowStack(); - height = item.getZ() + Item.getCurrentHeight(item); + height = item.getZ() + (item.getBaseItem().allowSit() ? 0 : Item.getCurrentHeight(item)); } /*HabboItem lowestChair = this.getLowestChair(x, y); diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java index 24e8004c..f4f7c005 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java +++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java @@ -51,7 +51,8 @@ public class RoomUserLookAtPoint extends MessageHandler { if (tile != null) { roomUnit.lookAtPoint(tile); - room.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); + roomUnit.statusUpdate(true); + //room.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); } } } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java index 3a10e281..878b9490 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/items/FloorItemOnRollerComposer.java @@ -70,7 +70,7 @@ public class FloorItemOnRollerComposer extends MessageComposer { THashSet tiles = this.room.getLayout().getTilesAt(this.room.getLayout().getTile(oldX, oldY), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation()); tiles.addAll(this.room.getLayout().getTilesAt(this.room.getLayout().getTile(this.item.getX(), this.item.getY()), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())); this.room.updateTiles(tiles); - this.room.sendComposer(new UpdateStackHeightComposer(oldX, oldY, this.room.getStackHeight(oldX, oldY, true)).compose()); + //this.room.sendComposer(new UpdateStackHeightComposer(oldX, oldY, this.room.getStackHeight(oldX, oldY, true)).compose()); // //this.room.updateHabbosAt(RoomLayout.getRectangle(this.item.getX(), this.item.getY(), this.item.getBaseItem().getWidth(), this.item.getBaseItem().getLength(), this.item.getRotation())); } diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java index c86de7ef..70df0b1c 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java @@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionRoller; import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomUnit; +import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.outgoing.MessageComposer; @@ -66,25 +67,53 @@ public class RoomUnitOnRollerComposer extends MessageComposer { this.response.appendString(this.newZ + ""); if (this.roller != null && room.getLayout() != null) { - RoomTile rollerTile = room.getLayout().getTile(this.roller.getX(), this.roller.getY()); - HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y); - if (topItem != null && (topItem == roller || oldTopItem != topItem)) { - try { - topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); - } catch (Exception e) { - LOGGER.error("Caught exception", e); - } - } Emulator.getThreading().run(() -> { - if (RoomUnitOnRollerComposer.this.oldLocation == rollerTile && RoomUnitOnRollerComposer.this.roomUnit.getGoal() == rollerTile) { - RoomUnitOnRollerComposer.this.roomUnit.setLocation(room.getLayout().getTile(newLocation.x, newLocation.y)); - RoomUnitOnRollerComposer.this.roomUnit.setPreviousLocationZ(RoomUnitOnRollerComposer.this.newLocation.getStackHeight()); - RoomUnitOnRollerComposer.this.roomUnit.setZ(RoomUnitOnRollerComposer.this.newLocation.getStackHeight()); - RoomUnitOnRollerComposer.this.roomUnit.sitUpdate = true; + if(!this.roomUnit.isWalking() && this.roomUnit.getCurrentLocation() == this.oldLocation) { + HabboItem topItem = this.room.getTopItemAt(this.oldLocation.x, this.oldLocation.y); + HabboItem topItemNewLocation = this.room.getTopItemAt(this.newLocation.x, this.newLocation.y); + if (topItem != null && (oldTopItem == null || oldTopItem != topItemNewLocation)) { + try { + topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + } + + 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}); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + } } - }, this.room.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); + /* + RoomTile rollerTile = room.getLayout().getTile(this.roller.getX(), this.roller.getY()); + Emulator.getThreading().run(() -> { + if (this.oldLocation == rollerTile && this.roomUnit.getGoal() == rollerTile) { + this.roomUnit.setLocation(newLocation); + this.roomUnit.setGoalLocation(newLocation); + this.roomUnit.setPreviousLocationZ(newLocation.getStackHeight()); + this.roomUnit.setZ(newLocation.getStackHeight()); + this.roomUnit.sitUpdate = true; + + HabboItem topItem = this.room.getTopItemAt(this.roomUnit.getCurrentLocation().x, this.roomUnit.getCurrentLocation().y); + if (topItem != null && topItem != roller && oldTopItem != topItem) { + try { + topItem.onWalkOff(this.roomUnit, this.room, new Object[]{this}); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + } + } + }, this.room.getRollerSpeed() == 0 ? 250 : InteractionRoller.DELAY); + */ } else { this.roomUnit.setLocation(this.newLocation); this.roomUnit.setZ(this.newZ); diff --git a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java index 755005c8..3251e090 100644 --- a/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java +++ b/src/main/java/com/eu/habbo/threading/runnables/RoomUnitTeleport.java @@ -54,9 +54,9 @@ public class RoomUnitTeleport implements Runnable { this.roomUnit.setZ(this.z); this.roomUnit.setPreviousLocationZ(this.z); this.roomUnit.removeStatus(RoomUnitStatus.MOVE); - ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose(); + //ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, newLocation, this.room).compose(); this.roomUnit.setLocation(newLocation); - this.room.sendComposer(teleportMessage); + //this.room.sendComposer(teleportMessage); roomUnit.isWiredTeleporting = false; this.room.updateHabbosAt(newLocation.x, newLocation.y);