use of org.valkyrienskies.mod.common.ships.ship_transform.CoordinateSpaceType in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class TileEntityPassengerChair method tryToMountPlayerToChair.
public void tryToMountPlayerToChair(EntityPlayer player, Vec3d mountPos) {
if (getWorld().isRemote) {
throw new IllegalStateException("tryToMountPlayerToChair is not designed to be called on client side!");
}
boolean isChairEmpty;
if (chairEntityUUID != null) {
Entity chairEntity = ((WorldServer) getWorld()).getEntityFromUuid(chairEntityUUID);
if (chairEntity != null) {
if (chairEntity.isDead || chairEntity.isBeingRidden()) {
// Dead entity, chair is empty.
this.chairEntityUUID = null;
markDirty();
isChairEmpty = true;
} else {
// Everything checks out, this chair is not empty.
isChairEmpty = false;
}
} else {
// Either null or not a chair entity (somehow?). Just consider this chair as empty
this.chairEntityUUID = null;
markDirty();
isChairEmpty = true;
}
} else {
// No UUID for a chair entity, so this chair must be empty.
isChairEmpty = true;
}
if (isChairEmpty) {
// Chair is guaranteed empty.
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(getWorld(), getPos());
CoordinateSpaceType mountCoordType = physicsObject.isPresent() ? CoordinateSpaceType.SUBSPACE_COORDINATES : CoordinateSpaceType.GLOBAL_COORDINATES;
EntityMountableChair entityMountable = new EntityMountableChair(getWorld(), mountPos, mountCoordType, getPos());
chairEntityUUID = entityMountable.getPersistentID();
markDirty();
getWorld().spawnEntity(entityMountable);
player.startRiding(entityMountable);
}
}
Aggregations