mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 01:50:50 +01:00
New item Tile Walk Magic and stack helper move on top of unstackable furniture fix
This commit is contained in:
parent
1b38a49825
commit
6bf80cdee5
@ -189,6 +189,7 @@ public class ItemManager {
|
||||
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
|
||||
this.interactionsList.add(new ItemInteraction("random_state", InteractionRandomState.class));
|
||||
this.interactionsList.add(new ItemInteraction("vendingmachine_no_sides", InteractionNoSidesVendingMachine.class));
|
||||
this.interactionsList.add(new ItemInteraction("tile_walkmagic", InteractionTileWalkMagic.class));
|
||||
|
||||
this.interactionsList.add(new ItemInteraction("game_timer", InteractionGameTimer.class));
|
||||
|
||||
|
@ -0,0 +1,48 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionTileWalkMagic extends HabboItem {
|
||||
public InteractionTileWalkMagic(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public InteractionTileWalkMagic(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWalkable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serializeExtradata(ServerMessage serverMessage) {
|
||||
serverMessage.appendInt((this.isLimited() ? 256 : 0));
|
||||
serverMessage.appendString(this.getExtradata());
|
||||
|
||||
super.serializeExtradata(serverMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsable() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -640,6 +640,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
result = overriddenState;
|
||||
}
|
||||
|
||||
if (this.getItemsAt(tile).stream().anyMatch(i -> i instanceof InteractionTileWalkMagic)) {
|
||||
result = RoomTileState.OPEN;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -830,6 +834,37 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePetsAt(short x, short y) {
|
||||
HabboItem topItem = this.getTopItemAt(x, y);
|
||||
|
||||
THashSet<RoomUnit> roomUnits = new THashSet<>();
|
||||
|
||||
for (Pet pet : this.getPetsAt(this.layout.getTile(x, y))) {
|
||||
if (topItem != null) {
|
||||
if (topItem.getBaseItem().allowSit()) {
|
||||
pet.getRoomUnit().setZ(topItem.getZ());
|
||||
pet.getRoomUnit().setPreviousLocationZ(topItem.getZ());
|
||||
pet.getRoomUnit().setRotation(RoomUserRotation.fromValue(topItem.getRotation()));
|
||||
} else {
|
||||
pet.getRoomUnit().setZ(topItem.getZ() + Item.getCurrentHeight(topItem));
|
||||
|
||||
if (topItem.getBaseItem().allowLay()) {
|
||||
pet.getRoomUnit().setStatus(RoomUnitStatus.LAY, (topItem.getZ() + topItem.getBaseItem().getHeight()) + "");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pet.getRoomUnit().setZ(pet.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
pet.getRoomUnit().setPreviousLocationZ(pet.getRoomUnit().getCurrentLocation().getStackHeight());
|
||||
}
|
||||
|
||||
roomUnits.add(pet.getRoomUnit());
|
||||
}
|
||||
|
||||
if (!roomUnits.isEmpty()) {
|
||||
this.sendComposer(new RoomUserStatusComposer(roomUnits, true).compose());
|
||||
}
|
||||
}
|
||||
|
||||
public void pickupPetsForHabbo(Habbo habbo) {
|
||||
THashSet<Pet> pets = new THashSet<>();
|
||||
|
||||
@ -2943,6 +2978,27 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return bots;
|
||||
}
|
||||
|
||||
public THashSet<Pet> getPetsAt(RoomTile tile) {
|
||||
THashSet<Pet> pets = new THashSet<>();
|
||||
synchronized (this.currentPets) {
|
||||
TIntObjectIterator<Pet> petIterator = this.currentPets.iterator();
|
||||
|
||||
for (int i = this.currentPets.size(); i-- > 0; ) {
|
||||
try {
|
||||
petIterator.advance();
|
||||
|
||||
if (petIterator.value().getRoomUnit().getCurrentLocation().equals(tile)) {
|
||||
pets.add(petIterator.value());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pets;
|
||||
}
|
||||
|
||||
public THashSet<Habbo> getHabbosAt(short x, short y) {
|
||||
return this.getHabbosAt(this.layout.getTile(x, y));
|
||||
}
|
||||
@ -3653,6 +3709,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
boolean canStack = true;
|
||||
|
||||
THashSet<HabboItem> stackHelpers = this.getItemsAt(InteractionStackHelper.class, x, y);
|
||||
stackHelpers.addAll(this.getItemsAt(InteractionTileWalkMagic.class, x, y));
|
||||
|
||||
if(stackHelpers.size() > 0) {
|
||||
for(HabboItem item : stackHelpers) {
|
||||
@ -4511,7 +4568,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
if (!this.layout.fitsOnMap(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation))
|
||||
return FurnitureMovementError.INVALID_MOVE;
|
||||
|
||||
if (item instanceof InteractionStackHelper) return FurnitureMovementError.NONE;
|
||||
if (item instanceof InteractionStackHelper || item instanceof InteractionTileWalkMagic) return FurnitureMovementError.NONE;
|
||||
|
||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||
for (RoomTile t : occupiedTiles) {
|
||||
@ -4646,7 +4703,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
pluginHelper = event.hasPluginHelper();
|
||||
}
|
||||
|
||||
boolean magicTile = item instanceof InteractionStackHelper;
|
||||
boolean magicTile = item instanceof InteractionStackHelper || item instanceof InteractionTileWalkMagic;
|
||||
|
||||
Optional<HabboItem> stackHelper = this.getItemsAt(tile).stream().filter(i -> i instanceof InteractionStackHelper).findAny();
|
||||
|
||||
@ -4715,6 +4772,19 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
height = stackHelper.get().getExtradata().isEmpty() ? Double.parseDouble("0.0") : (Double.parseDouble(stackHelper.get().getExtradata()) / 100);
|
||||
} else if (item == topItem) {
|
||||
height = item.getZ();
|
||||
} else if(magicTile) {
|
||||
if(topItem == null) {
|
||||
height = this.getStackHeight(tile.x, tile.y, false, item);
|
||||
for(RoomTile til : occupiedTiles) {
|
||||
double sHeight = this.getStackHeight(til.x, til.y, false, item);
|
||||
if(sHeight > height) {
|
||||
height = sHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
height = topItem.getZ() + topItem.getBaseItem().getHeight();
|
||||
}
|
||||
} else {
|
||||
height = this.getStackHeight(tile.x, tile.y, false, item);
|
||||
for(RoomTile til : occupiedTiles) {
|
||||
|
@ -325,6 +325,10 @@ public class RoomUnit {
|
||||
zHeight += room.getLayout().getHeightAtSquare(next.x, next.y);
|
||||
}
|
||||
|
||||
Optional<HabboItem> stackHelper = this.room.getItemsAt(next).stream().filter(i -> i instanceof InteractionTileWalkMagic).findAny();
|
||||
if (stackHelper.isPresent()) {
|
||||
zHeight = stackHelper.get().getZ();
|
||||
}
|
||||
|
||||
this.setPreviousLocation(this.getCurrentLocation());
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.eu.habbo.messages.incoming.rooms.items;
|
||||
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionStackHelper;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionTileWalkMagic;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
@ -20,7 +21,7 @@ public class SetStackHelperHeightEvent extends MessageHandler {
|
||||
if (this.client.getHabbo().getHabboInfo().getId() == this.client.getHabbo().getHabboInfo().getCurrentRoom().getOwnerId() || this.client.getHabbo().getHabboInfo().getCurrentRoom().hasRights(this.client.getHabbo())) {
|
||||
HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId);
|
||||
|
||||
if (item instanceof InteractionStackHelper) {
|
||||
if (item instanceof InteractionStackHelper || item instanceof InteractionTileWalkMagic) {
|
||||
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
|
||||
RoomTile itemTile = room.getLayout().getTile(item.getX(), item.getY());
|
||||
double stackerHeight = this.packet.readInt();
|
||||
@ -49,6 +50,15 @@ public class SetStackHelperHeightEvent extends MessageHandler {
|
||||
item.setZ(height);
|
||||
item.setExtradata((int) (height * 100) + "");
|
||||
item.needsUpdate(true);
|
||||
|
||||
if (item instanceof InteractionTileWalkMagic) {
|
||||
for (RoomTile t : tiles) {
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateHabbosAt(t.x, t.y);
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateBotsAt(t.x, t.y);
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().updatePetsAt(t.x, t.y);
|
||||
}
|
||||
}
|
||||
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateItem(item);
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().updateTiles(tiles);
|
||||
this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new UpdateStackHeightComposer(room, tiles).compose());
|
||||
|
Loading…
Reference in New Issue
Block a user