Originally Posted by
Lumiere
If you have Ground Items written OO, just have it when the player drops the item, the ground item is saved as a ground item for the player.
Code:
private GroundItem personalGatestone;
public final GroundItem getPersonalGatestone() {
return personalGatestone;
}
public final Player setPersonalGatestone(final GroundItem gatestone) {
this.personalGatestone = gatestone;
return this;
}
Then you can call "player.getPersonalGatestone().getPosition()"
Seems a bit pointless to save the grounditem like that, when all he needs is the position
If you have a Position or location system you could do it like this:
Code:
private Optional<Position> gatestonePosition = Optional.empty();
public Optional<Position> getGatestonePosition() {
return gatestonePosition;
}
public void setGatestonePosition(Optional<Position> gatestonePosition) {
this.gatestonePosition = gatestonePosition;
}
And in Drop packet or where you create ground items:
Code:
if(item.getId() == GATESTONE_ITEM_ID) {
player.setGatestonePosition(Optional.of(player.getPosition().copy()));
}
And in pick up:
Code:
if(item.getId() == GATESTONE_ITEM_ID) {
player.setGatestonePosition(Optional.empty());
}
When teleporting, have a check similar ot this:
Code:
if(player.getGatestonePosition().isPresent()) {
teleportPosition = player.getGatestonePosition().get();
}
If you don't have a position/location system you'll have to use ints for x, y, z, which I don't recommend