use of net.minecraft.util.math.RayTraceResult in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class EntityCannonBall method processMovementForTick.
private void processMovementForTick() {
Vec3d origin = new Vec3d(posX, posY, posZ);
Vec3d traceEnd = origin.addVector(motionX, motionY, motionZ);
RayTraceResult traceResult = CallRunner.onRayTraceBlocks(worldObj, origin, traceEnd, false, true, false);
if (traceResult == null || traceResult.typeOfHit == Type.MISS) {
posX += motionX;
posY += motionY;
posZ += motionZ;
// double drag = .98D;
// motionX*=drag;
// motionY*=drag;
// motionZ*=drag;
motionY -= .01;
} else {
if (traceResult.hitVec != null && !worldObj.isRemote) {
processCollision(traceResult);
kill();
}
}
}
use of net.minecraft.util.math.RayTraceResult in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class ClientPilotingManager method rayTraceExcludingWrapper.
//Used to make Pilot 3rd person the 20 block range it is, without stopping on the ship the player is piloting
public static final RayTraceResult rayTraceExcludingWrapper(World world, Vec3d vec31, Vec3d vec32, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock, PhysicsWrapperEntity toExclude) {
RayTraceResult vanillaTrace = world.rayTraceBlocks(vec31, vec32, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock);
WorldPhysObjectManager physManager = ValkyrienWarfareMod.physicsManager.getManagerForWorld(world);
AxisAlignedBB playerRangeBB = new AxisAlignedBB(vec31.xCoord - 1D, vec31.yCoord - 1D, vec31.zCoord - 1D, vec31.xCoord + 1D, vec31.yCoord + 1D, vec31.zCoord + 1D);
List<PhysicsWrapperEntity> nearbyShips = physManager.getNearbyPhysObjects(playerRangeBB);
boolean changed = false;
Vec3d playerEyesPos = vec31;
Vec3d playerReachVector = vec32.subtract(vec31);
double reachDistance = playerReachVector.lengthVector();
double worldResultDistFromPlayer = 420D;
if (vanillaTrace != null && vanillaTrace.hitVec != null) {
worldResultDistFromPlayer = vanillaTrace.hitVec.distanceTo(vec31);
}
for (PhysicsWrapperEntity wrapper : nearbyShips) {
if (ClientPilotingManager.getPilotedWrapperEntity() != null && wrapper.getEntityId() != ClientPilotingManager.getPilotedWrapperEntity().getEntityId()) {
playerEyesPos = vec31;
playerReachVector = vec32.subtract(vec31);
// Transform the coordinate system for the player eye pos
playerEyesPos = RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RwToLTransform, playerEyesPos);
playerReachVector = RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RwToLRotation, playerReachVector);
Vec3d playerEyesReachAdded = playerEyesPos.addVector(playerReachVector.xCoord * reachDistance, playerReachVector.yCoord * reachDistance, playerReachVector.zCoord * reachDistance);
RayTraceResult resultInShip = world.rayTraceBlocks(playerEyesPos, playerEyesReachAdded, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock);
if (resultInShip != null && resultInShip.hitVec != null && resultInShip.typeOfHit == Type.BLOCK) {
double shipResultDistFromPlayer = resultInShip.hitVec.distanceTo(playerEyesPos);
if (shipResultDistFromPlayer < worldResultDistFromPlayer) {
worldResultDistFromPlayer = shipResultDistFromPlayer;
resultInShip.hitVec = RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RlToWTransform, resultInShip.hitVec);
vanillaTrace = resultInShip;
}
}
} else {
if (ClientPilotingManager.getMountedWrapperEntity() != null) {
// System.out.println("test");
}
}
}
return vanillaTrace;
}
Aggregations