Fixed rotating items goes above height limit. Made height limit variable.

This commit is contained in:
Beny 2020-10-22 02:09:35 +02:00
parent 4f5b6deb77
commit abc1c6905f
2 changed files with 18 additions and 8 deletions

View File

@ -117,6 +117,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public static String PREFIX_FORMAT = "[<font color=\"%color%\">%prefix%</font>] "; public static String PREFIX_FORMAT = "[<font color=\"%color%\">%prefix%</font>] ";
public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1; public static int ROLLERS_MAXIMUM_ROLL_AVATARS = 1;
public static boolean MUTEAREA_CAN_WHISPER = false; public static boolean MUTEAREA_CAN_WHISPER = false;
public static double MAXIMUM_FURNI_HEIGHT = 40d;
static { static {
for (int i = 1; i <= 3; i++) { for (int i = 1; i <= 3; i++) {
@ -4611,9 +4612,9 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
THashSet<RoomTile> oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()); THashSet<RoomTile> oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
int oldRotation = item.getRotation(); int oldRotation = item.getRotation();
item.setRotation(rotation);
if (oldRotation != rotation) { if (oldRotation != rotation) {
item.setRotation(rotation);
if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) { if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true)) {
Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation); Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation);
Emulator.getPluginManager().fireEvent(furnitureRotatedEvent); Emulator.getPluginManager().fireEvent(furnitureRotatedEvent);
@ -4623,6 +4624,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return FurnitureMovementError.CANCEL_PLUGIN_ROTATE; return FurnitureMovementError.CANCEL_PLUGIN_ROTATE;
} }
} }
if((!stackHelper.isPresent() && topItem != null && topItem != item && !topItem.getBaseItem().allowStack())|| (topItem != null && topItem != item && topItem.getZ() + Item.getCurrentHeight(topItem) + Item.getCurrentHeight(item) > MAXIMUM_FURNI_HEIGHT))
{
item.setRotation(oldRotation);
return FurnitureMovementError.CANT_STACK;
}
// )
} }
//Place at new position //Place at new position
@ -4630,7 +4639,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (stackHelper.isPresent()) { if (stackHelper.isPresent()) {
height = stackHelper.get().getExtradata().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtradata()) / 100); height = stackHelper.get().getExtradata().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtradata()) / 100);
} else if (item.equals(topItem)) { } else if (item == topItem) {
height = item.getZ(); height = item.getZ();
} else { } else {
height = this.getStackHeight(tile.x, tile.y, false, item); height = this.getStackHeight(tile.x, tile.y, false, item);
@ -4649,7 +4658,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
if(height > 40d) return FurnitureMovementError.CANT_STACK; if(height > MAXIMUM_FURNI_HEIGHT) return FurnitureMovementError.CANT_STACK;
if(height < this.getLayout().getHeightAtSquare(tile.x, tile.y)) return FurnitureMovementError.CANT_STACK; //prevent furni going under the floor
item.setX(tile.x); item.setX(tile.x);
item.setY(tile.y); item.setY(tile.y);
@ -4658,8 +4668,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
item.setZ(tile.z); item.setZ(tile.z);
item.setExtradata("" + item.getZ() * 100); item.setExtradata("" + item.getZ() * 100);
} }
if (item.getZ() > 40d) { if (item.getZ() > MAXIMUM_FURNI_HEIGHT) {
item.setZ(40); item.setZ(MAXIMUM_FURNI_HEIGHT);
} }
@ -4721,8 +4731,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
item.setZ(tile.z); item.setZ(tile.z);
item.setExtradata("" + item.getZ() * 100); item.setExtradata("" + item.getZ() * 100);
} }
if (item.getZ() > 40d) { if (item.getZ() > MAXIMUM_FURNI_HEIGHT) {
item.setZ(40); item.setZ(MAXIMUM_FURNI_HEIGHT);
} }
double offset = this.getStackHeight(tile.x, tile.y, false, item) - item.getZ(); double offset = this.getStackHeight(tile.x, tile.y, false, item) - item.getZ();
this.sendComposer(new FloorItemOnRollerComposer(item, null, tile, offset, this).compose()); this.sendComposer(new FloorItemOnRollerComposer(item, null, tile, offset, this).compose());

View File

@ -34,7 +34,7 @@ public class SetStackHelperHeightEvent extends MessageHandler {
} }
} }
} else { } else {
stackerHeight = Math.min(Math.max(stackerHeight, itemTile.z * 100), 4000); stackerHeight = Math.min(Math.max(stackerHeight, itemTile.z * 100), Room.MAXIMUM_FURNI_HEIGHT * 100);
} }
double height = 0; double height = 0;