Wired teleport onWalk works correctly if item moved during wait

This commit is contained in:
Beny 2019-05-23 15:22:14 +01:00
parent b0601b93dd
commit 59613f8900

View File

@ -133,16 +133,13 @@ public class WiredEffectTeleport extends InteractionWiredEffect
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose()); room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY); Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY);
if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) if (tile.state == RoomTileState.INVALID || tile.state == RoomTileState.BLOCKED) {
{
RoomTile alternativeTile = null; RoomTile alternativeTile = null;
List<RoomTile> optionalTiles = room.getLayout().getTilesAround(tile); List<RoomTile> optionalTiles = room.getLayout().getTilesAround(tile);
Collections.reverse(optionalTiles); Collections.reverse(optionalTiles);
for (RoomTile optionalTile : optionalTiles) for (RoomTile optionalTile : optionalTiles) {
{ if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED) {
if (optionalTile.state != RoomTileState.INVALID && optionalTile.state != RoomTileState.BLOCKED)
{
alternativeTile = optionalTile; alternativeTile = optionalTile;
} }
} }
@ -154,14 +151,15 @@ public class WiredEffectTeleport extends InteractionWiredEffect
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY); Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.x, tile.y, tile.getStackHeight() + (tile.state == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
HabboItem topItem = room.getTopItemAt(tile.x, tile.y);
if(topItem != null) {
Emulator.getThreading().run(new Runnable() { Emulator.getThreading().run(new Runnable() {
@Override @Override
public void run() { public void run() {
try { try {
if(roomUnit != null && roomUnit.getRoom() != null) { if(roomUnit == null || roomUnit.getRoom() == null)
return;
HabboItem topItem = room.getTopItemAt(roomUnit.getX(), roomUnit.getY());
if (topItem != null && roomUnit.getCurrentLocation().equals(room.getLayout().getTile(topItem.getX(), topItem.getY()))) {
topItem.onWalkOn(roomUnit, room, new Object[]{}); topItem.onWalkOn(roomUnit, room, new Object[]{});
} }
} catch (Exception e) { } catch (Exception e) {
@ -170,8 +168,6 @@ public class WiredEffectTeleport extends InteractionWiredEffect
}, WiredHandler.TELEPORT_DELAY); }, WiredHandler.TELEPORT_DELAY);
} }
}
@Override @Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{ {