Fix vending machines without sides

This commit is contained in:
Alejandro 2020-02-27 23:16:36 +02:00
parent 8c9faa56e6
commit 706577f220
3 changed files with 20 additions and 13 deletions

View File

@ -83,11 +83,10 @@ public class InteractionVendingMachine extends HabboItem {
}
}
List<Runnable> onSuccess = new ArrayList<>();
List<Runnable> onFail = new ArrayList<>();
RoomTile finalTile = tile;
onSuccess.add(() -> {
client.getHabbo().getRoomUnit().setGoalLocation(tile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, () -> {
this.setExtradata("1");
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
@ -98,7 +97,7 @@ public class InteractionVendingMachine extends HabboItem {
}
Emulator.getThreading().run(() -> {
Runnable procedure = () -> {
client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(() -> {
if (client.getHabbo().getRoomUnit().getCurrentLocation().equals(finalTile)) {
this.rotateToMachine(client.getHabbo().getRoomUnit());
room.sendComposer(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
@ -117,14 +116,9 @@ public class InteractionVendingMachine extends HabboItem {
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
};
client.getHabbo().getRoomUnit().setMoveBlockingTask(Emulator.getThreading().run(procedure, 300));
}, 300));
}, 250);
});
client.getHabbo().getRoomUnit().setGoalLocation(tile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), tile, room, onSuccess, onFail));
}, null));
}
}
}

View File

@ -781,7 +781,7 @@ public class RoomUnit {
return this.getClosestTile(
rotations.stream()
.map(rotation -> room.getLayout().getTileInFront(baseTile, rotation))
.filter(t -> t != null && t.isWalkable() && !room.hasHabbosAt(t.x, t.y))
.filter(t -> t != null && t.isWalkable() && (this.getCurrentLocation().equals(t) || !room.hasHabbosAt(t.x, t.y)))
.collect(Collectors.toList())
);
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import java.util.ArrayList;
import java.util.List;
public class RoomUnitWalkToLocation implements Runnable {
@ -14,6 +15,18 @@ public class RoomUnitWalkToLocation implements Runnable {
private List<Runnable> targetReached;
private List<Runnable> failedReached;
public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, Runnable targetReached, Runnable failedReached) {
this.walker = walker;
this.goalTile = goalTile;
this.room = room;
this.targetReached = new ArrayList<>();
if (targetReached != null) this.targetReached.add(targetReached);
this.failedReached = new ArrayList<>();
if (failedReached != null) this.targetReached.add(failedReached);
}
public RoomUnitWalkToLocation(RoomUnit walker, RoomTile goalTile, Room room, List<Runnable> targetReached, List<Runnable> failedReached) {
this.walker = walker;
this.goalTile = goalTile;