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 bf5f5093..928ca2d9 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 @@ -50,6 +50,23 @@ public class InteractionDefault extends HabboItem return true; } + @Override + 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... + + try { + this.onWalkOff(unit, room, new Object[]{}); // the unit walked off! + } catch (Exception ignored) { + + } + } + } + @Override public void onClick(GameClient client, Room room, Object[] objects) throws Exception { diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java index 00f988c4..971e4b61 100644 --- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java +++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWater.java @@ -34,6 +34,8 @@ public class InteractionWater extends InteractionDefault @Override public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) { + super.onMove(room, oldLocation, newLocation); + this.recalculate(room); } 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 3bb46a63..0aa1fd87 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -5702,5 +5702,27 @@ public class Room implements Comparable, ISerialize, Runnable return FurnitureMovementError.NONE; } + public THashSet getRoomUnits() { + THashSet units = new THashSet<>(); + for (Habbo habbo : this.currentHabbos.values()) { + if (habbo != null && habbo.getRoomUnit() != null && habbo.getRoomUnit().getRoom().getId() == this.getId()) { + units.add(habbo.getRoomUnit()); + } + } + + for (Pet pet : this.currentPets.valueCollection()) { + if (pet != null && pet.getRoomUnit() != null && pet.getRoomUnit().getRoom().getId() == this.getId()) { + units.add(pet.getRoomUnit()); + } + } + + for (Bot bot : this.currentBots.valueCollection()) { + if (bot != null && bot.getRoomUnit() != null && bot.getRoomUnit().getRoom().getId() == this.getId()) { + units.add(bot.getRoomUnit()); + } + } + + return units; + } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java index c284d37a..177db674 100644 --- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java +++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTile.java @@ -1,5 +1,7 @@ package com.eu.habbo.habbohotel.rooms; +import com.eu.habbo.habbohotel.items.Item; +import com.eu.habbo.habbohotel.users.HabboItem; import gnu.trove.set.hash.THashSet; import java.util.ArrayList; @@ -233,4 +235,8 @@ public class RoomTile return this.units.size() > 0; } } + + public boolean unitIsOnFurniOnTile(RoomUnit unit, Item item) { + return (unit.getX() >= this.x && unit.getX() < this.x + item.getLength()) && (unit.getY() >= this.y && unit.getY() < this.y + item.getWidth()); + } } \ No newline at end of file