Fix rotating furniture with a stack helper

This commit is contained in:
Alejandro 2020-03-04 18:45:33 +02:00
parent a8f3829216
commit 8d6cd27b85
2 changed files with 31 additions and 18 deletions

View File

@ -4471,8 +4471,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
boolean magicTile = item instanceof InteractionStackHelper;
Optional<HabboItem> stackHelper = this.getItemsAt(tile).stream().filter(i -> i instanceof InteractionStackHelper).findAny();
//Check if can be placed at new position
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
if (!stackHelper.isPresent()) {
if (topItem != item) {
for (RoomTile t : occupiedTiles) {
HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
@ -4492,6 +4496,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (!magicTile && !item.canStackAt(this, tileFurniList)) {
return FurnitureMovementError.CANT_STACK;
}
}
THashSet<RoomTile> oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
@ -4511,8 +4516,16 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
}
//Place at new position
double height = this.getStackHeight(tile.x, tile.y, false, item);
if (item.equals(topItem) && tile.x == item.getX() && tile.y == item.getY()) height = item.getZ();
double height;
if (stackHelper.isPresent()) {
height = stackHelper.get().getExtradata().isEmpty() ? Double.valueOf("0.0") : (Double.valueOf(stackHelper.get().getExtradata()) / 100);
} else if (item.equals(topItem) && tile.x == item.getX() && tile.y == item.getY()) {
height = item.getZ();
} else {
height = this.getStackHeight(tile.x, tile.y, false, item);
}
if(height > 40d) return FurnitureMovementError.CANT_STACK;
item.setX(tile.x);

View File

@ -8,7 +8,7 @@ import java.util.Collection;
public class HabboAddedToRoomEvent extends UserEvent {
public final Room room;
public final Collection<Habbo> habbosToSendEnter;
public Collection<Habbo> habbosToSendEnter;
public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection<Habbo> habbosToSendEnter) {