Custom stacking setting to stack bigger items on top of smaller ones

This commit is contained in:
ArpyAge 2022-04-17 03:39:55 +02:00
parent 098d6a6684
commit fa0f58b87f
8 changed files with 50 additions and 15 deletions

View File

@ -91,3 +91,6 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.mannequin.name.defa
-- RCON: Change Username
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('rcon.alert.user.change_username', 'You can change your username. Click on yourself to change it.');
-- Custom Stacking Setting
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('custom.stacking.enabled', '0');

View File

@ -3,9 +3,7 @@ package com.eu.habbo.messages.incoming.catalog.recycler;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.InteractionGift;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
@ -58,7 +56,15 @@ public class OpenRecycleBoxEvent extends MessageHandler {
if (item.getRoomId() == 0) {
room.updateTile(room.getLayout().getTile(item.getX(), item.getY()));
room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), room.getStackHeight(item.getX(), item.getY(), true)).compose());
RoomLayout roomLayout = room.getLayout();
short z = (short)room.getStackHeight(item.getX(), item.getY(), true);
if(roomLayout != null) {
RoomTile roomTile = roomLayout.getTile(item.getX(), item.getY());
if(roomTile != null) {
z = roomTile.z;
}
}
room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), z, room.getStackHeight(item.getX(), item.getY(), true)).compose());
}
}
}

View File

@ -40,7 +40,7 @@ public class RedeemClothingEvent extends MessageHandler {
RoomTile tile = this.client.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(item.getX(), item.getY());
this.client.getHabbo().getHabboInfo().getCurrentRoom().removeHabboItem(item);
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTile(tile);
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.relativeHeight()).compose());
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.z, tile.relativeHeight()).compose());
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RemoveFloorItemComposer(item, true).compose());
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));

View File

@ -102,7 +102,7 @@ public class RedeemItemEvent extends MessageHandler {
RoomTile t = room.getLayout().getTile(item.getX(), item.getY());
t.setStackHeight(room.getStackHeight(item.getX(), item.getY(), false));
room.updateTile(t);
room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), t.relativeHeight()).compose());
room.sendComposer(new UpdateStackHeightComposer(item.getX(), item.getY(), t.z, t.relativeHeight()).compose());
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
switch (furniRedeemEvent.currencyID) {

View File

@ -62,7 +62,7 @@ public class PetPackageNameEvent extends MessageHandler {
room.sendComposer(new RemoveFloorItemComposer(item).compose());
RoomTile tile = room.getLayout().getTile(item.getX(), item.getY());
room.updateTile(room.getLayout().getTile(item.getX(), item.getY()));
room.sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.relativeHeight()).compose());
room.sendComposer(new UpdateStackHeightComposer(tile.x, tile.y, tile.z, tile.relativeHeight()).compose());
item.setUserId(0);
} else {
this.client.sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.SERVER_ERROR));

View File

@ -1,5 +1,6 @@
package com.eu.habbo.messages.outgoing.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.messages.ServerMessage;
@ -22,10 +23,17 @@ public class RoomRelativeMapComposer extends MessageComposer {
for (short x = 0; x < this.room.getLayout().getMapSizeX(); x++) {
RoomTile t = this.room.getLayout().getTile(x, y);
if (t != null)
this.response.appendShort(t.relativeHeight());
else
if (t != null) {
if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) {
this.response.appendShort((short) (t.z * 256.0));
}
else {
this.response.appendShort(t.relativeHeight());
}
}
else {
this.response.appendShort(Short.MAX_VALUE);
}
}
}

View File

@ -1,5 +1,6 @@
package com.eu.habbo.messages.outgoing.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.messages.ServerMessage;
@ -10,14 +11,16 @@ import gnu.trove.set.hash.THashSet;
public class UpdateStackHeightComposer extends MessageComposer {
private int x;
private int y;
private short z;
private double height;
private THashSet<RoomTile> updateTiles;
private Room room;
public UpdateStackHeightComposer(int x, int y, double height) {
public UpdateStackHeightComposer(int x, int y, short z, double height) {
this.x = x;
this.y = y;
this.z = z;
this.height = height;
}
@ -40,7 +43,12 @@ public class UpdateStackHeightComposer extends MessageComposer {
updateTiles.remove(t); // remove it from the set
this.response.appendByte((int) t.x);
this.response.appendByte((int) t.y);
this.response.appendShort(t.relativeHeight());
if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) {
this.response.appendShort((short) (t.z * 256.0));
}
else {
this.response.appendShort(t.relativeHeight());
}
}
//send the remaining tiles in a new message
this.room.sendComposer(new UpdateStackHeightComposer(this.room, updateTiles).compose());
@ -51,13 +59,23 @@ public class UpdateStackHeightComposer extends MessageComposer {
for (RoomTile t : this.updateTiles) {
this.response.appendByte((int) t.x);
this.response.appendByte((int) t.y);
this.response.appendShort(t.relativeHeight());
if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) {
this.response.appendShort((short) (t.z * 256.0));
}
else {
this.response.appendShort(t.relativeHeight());
}
}
} else {
this.response.appendByte(1);
this.response.appendByte(this.x);
this.response.appendByte(this.y);
this.response.appendShort((int) (this.height));
if(Emulator.getConfig().getBoolean("custom.stacking.enabled")) {
this.response.appendShort((short) (this.z * 256.0));
}
else {
this.response.appendShort((int) (this.height));
}
}
return this.response;
}

View File

@ -24,6 +24,6 @@ class RemoveFloorItemTask implements Runnable {
this.room.removeHabboItem(this.item);
this.room.updateTile(tile);
this.room.sendComposer(new RemoveFloorItemComposer(this.item, true).compose());
this.room.sendComposer(new UpdateStackHeightComposer(this.item.getX(), this.item.getY(), tile.relativeHeight()).compose());
this.room.sendComposer(new UpdateStackHeightComposer(this.item.getX(), this.item.getY(), tile.z, tile.relativeHeight()).compose());
}
}