use of org.valkyrienskies.mod.common.tileentity.TileEntityBoatChair in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class BlockBoatChair method getTorqueInGlobal.
@Nullable
@Override
public Vector3dc getTorqueInGlobal(PhysicsCalculations physicsCalculations, BlockPos pos) {
final World world = physicsCalculations.getParent().getWorld();
final TileEntity tileEntity = world.getTileEntity(pos);
if (tileEntity instanceof TileEntityBoatChair) {
return ((TileEntityBoatChair) tileEntity).getTorqueInGlobal(physicsCalculations);
}
return null;
}
use of org.valkyrienskies.mod.common.tileentity.TileEntityBoatChair in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class BlockBoatChair method onBlockActivated.
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote) {
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(worldIn, pos);
if (physicsObject.isPresent()) {
TileEntity tileEntity = worldIn.getTileEntity(pos);
if (tileEntity instanceof TileEntityBoatChair) {
Vector3d playerPos = new Vector3d(playerIn.posX, playerIn.posY, playerIn.posZ);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(playerPos, TransformType.SUBSPACE_TO_GLOBAL);
playerIn.posX = playerPos.x;
playerIn.posY = playerPos.y;
playerIn.posZ = playerPos.z;
// Only mount the player if they're standing on the ship.
final EntityShipMovementData entityShipMovementData = ValkyrienUtils.getEntityShipMovementDataFor(playerIn);
if (entityShipMovementData.getTicksSinceTouchedShip() == 0 && (entityShipMovementData.getLastTouchedShip() == physicsObject.get().getShipData())) {
Vector3dc localMountPos = getPlayerMountOffset(state, pos);
ValkyrienUtils.fixEntityToShip(playerIn, localMountPos, physicsObject.get());
}
((TileEntityBoatChair) tileEntity).setPilotEntity(playerIn);
physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(playerPos, TransformType.GLOBAL_TO_SUBSPACE);
playerIn.posX = playerPos.x;
playerIn.posY = playerPos.y;
playerIn.posZ = playerPos.z;
}
}
}
return true;
}
Aggregations