mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-27 08:50:51 +01:00
Ensure bot z position saving & fix bots with multiheight (closes #333)
This commit is contained in:
parent
8570108d98
commit
70bc0f6bcb
@ -1,5 +1,6 @@
|
|||||||
package com.eu.habbo.habbohotel.items.interactions;
|
package com.eu.habbo.habbohotel.items.interactions;
|
||||||
|
|
||||||
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.rooms.*;
|
import com.eu.habbo.habbohotel.rooms.*;
|
||||||
@ -16,6 +17,8 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class InteractionMultiHeight extends HabboItem {
|
public class InteractionMultiHeight extends HabboItem {
|
||||||
public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
public InteractionMultiHeight(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||||
@ -74,26 +77,27 @@ public class InteractionMultiHeight extends HabboItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.isWalkable()) {
|
if (this.isWalkable()) {
|
||||||
THashSet<Habbo> habbos = room.getHabbosOnItem(this);
|
List<RoomUnit> unitsOnItem = new ArrayList<>();
|
||||||
THashSet<RoomUnit> updatedUnits = new THashSet<>();
|
unitsOnItem.addAll(room.getHabbosOnItem(this).stream().map(Habbo::getRoomUnit).filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
for (Habbo habbo : habbos) {
|
unitsOnItem.addAll(room.getBotsOnItem(this).stream().map(Bot::getRoomUnit).filter(Objects::nonNull).collect(Collectors.toList()));
|
||||||
if (habbo.getRoomUnit() == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
|
THashSet<RoomUnit> updatedUnits = new THashSet<>();
|
||||||
|
for (RoomUnit unit : unitsOnItem) {
|
||||||
|
if (unit.hasStatus(RoomUnitStatus.MOVE))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (this.getBaseItem().getMultiHeights().length >= 0) {
|
if (this.getBaseItem().getMultiHeights().length >= 0) {
|
||||||
if (this.getBaseItem().allowSit()) {
|
if (this.getBaseItem().allowSit()) {
|
||||||
habbo.getRoomUnit().setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + "");
|
unit.setStatus(RoomUnitStatus.SIT, this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))] * 1.0D + "");
|
||||||
} else {
|
} else {
|
||||||
habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
|
unit.setZ(unit.getCurrentLocation().getStackHeight());
|
||||||
habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getZ());
|
unit.setPreviousLocationZ(unit.getZ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatedUnits.add(habbo.getRoomUnit());
|
updatedUnits.add(unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
|
room.sendComposer(new RoomUserStatusComposer(updatedUnits, true).compose());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -466,6 +466,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection()));
|
b.getRoomUnit().setRotation(RoomUserRotation.fromValue(this.getLayout().getDoorDirection()));
|
||||||
} else {
|
} else {
|
||||||
b.getRoomUnit().setZ(set.getDouble("z"));
|
b.getRoomUnit().setZ(set.getDouble("z"));
|
||||||
|
b.getRoomUnit().setPreviousLocationZ(set.getDouble("z"));
|
||||||
b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]);
|
b.getRoomUnit().setRotation(RoomUserRotation.values()[set.getInt("rot")]);
|
||||||
}
|
}
|
||||||
b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
|
b.getRoomUnit().setRoomUnitType(RoomUnitType.BOT);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.eu.habbo.habbohotel.rooms;
|
package com.eu.habbo.habbohotel.rooms;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.bots.Bot;
|
||||||
import com.eu.habbo.habbohotel.items.Item;
|
import com.eu.habbo.habbohotel.items.Item;
|
||||||
import com.eu.habbo.habbohotel.items.interactions.*;
|
import com.eu.habbo.habbohotel.items.interactions.*;
|
||||||
import com.eu.habbo.habbohotel.pets.Pet;
|
import com.eu.habbo.habbohotel.pets.Pet;
|
||||||
@ -391,6 +392,13 @@ public class RoomUnit {
|
|||||||
|
|
||||||
public void setZ(double z) {
|
public void setZ(double z) {
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
|
||||||
|
if (this.room != null) {
|
||||||
|
Bot bot = this.room.getBot(this);
|
||||||
|
if (bot != null) {
|
||||||
|
bot.needsUpdate(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInRoom() {
|
public boolean isInRoom() {
|
||||||
|
Loading…
Reference in New Issue
Block a user