use of net.minecraft.server.v1_13_R2.Vec3D in project BigDoors by PimvanderLoos.
the class CustomCraftFallingBlock_V1_15_R1 method setVelocity.
@Override
public void setVelocity(Vector3Dd vector) {
entity.setMot(new Vec3D(vector.x(), vector.y(), vector.z()));
entity.velocityChanged = true;
}
use of net.minecraft.server.v1_13_R2.Vec3D in project custom-items-gradle by knokko.
the class EntityLineIntersection method distanceToStart.
public static double distanceToStart(Entity entity, Location lineStartLocation, Vector direction, double safeUpperBound) {
net.minecraft.server.v1_12_R1.Entity nmsEntity = ((CraftEntity) entity).getHandle();
Vec3D lineStart = new Vec3D(lineStartLocation.getX(), lineStartLocation.getY(), lineStartLocation.getZ());
Vec3D lineEnd = new Vec3D(lineStartLocation.getX() + safeUpperBound * direction.getX(), lineStartLocation.getY() + safeUpperBound * direction.getY(), lineStartLocation.getZ() + safeUpperBound * direction.getZ());
MovingObjectPosition intersection = nmsEntity.getBoundingBox().b(lineStart, lineEnd);
if (intersection != null) {
return Math.sqrt(intersection.pos.distanceSquared(lineStart));
} else {
return Double.POSITIVE_INFINITY;
}
}
use of net.minecraft.server.v1_13_R2.Vec3D in project RoseStacker by Rosewood-Development.
the class NMSHandlerImpl method hasLineOfSight.
@Override
public boolean hasLineOfSight(LivingEntity entity1, org.bukkit.entity.Entity entity2) {
EntityLiving nmsEntity1 = ((CraftLivingEntity) entity1).getHandle();
Entity nmsEntity2 = ((CraftEntity) entity2).getHandle();
Vec3D vec3d = new Vec3D(nmsEntity1.locX(), nmsEntity1.getHeadY(), nmsEntity1.locZ());
Vec3D vec3d1 = new Vec3D(nmsEntity2.locX(), nmsEntity2.getHeadY(), nmsEntity2.locZ());
return nmsEntity1.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.VISUAL, RayTrace.FluidCollisionOption.NONE, nmsEntity1)).getType() == MovingObjectPosition.EnumMovingObjectType.MISS;
}
use of net.minecraft.server.v1_13_R2.Vec3D in project RoseStacker by Rosewood-Development.
the class NMSHandlerImpl method hasLineOfSight.
@Override
public boolean hasLineOfSight(LivingEntity entity1, org.bukkit.entity.Entity entity2) {
EntityLiving nmsEntity1 = ((CraftLivingEntity) entity1).getHandle();
Entity nmsEntity2 = ((CraftEntity) entity2).getHandle();
Vec3D vec3d = new Vec3D(nmsEntity1.locX(), nmsEntity1.getHeadY(), nmsEntity1.locZ());
Vec3D vec3d1 = new Vec3D(nmsEntity2.locX(), nmsEntity2.getHeadY(), nmsEntity2.locZ());
return nmsEntity1.world.rayTrace(new RayTrace(vec3d, vec3d1, RayTrace.BlockCollisionOption.VISUAL, RayTrace.FluidCollisionOption.NONE, nmsEntity1)).getType() == MovingObjectPosition.EnumMovingObjectType.MISS;
}
use of net.minecraft.server.v1_13_R2.Vec3D in project UltraCosmetics by iSach.
the class CustomEntities method ride.
public static void ride(float sideMot, float forMot, EntityHuman passenger, EntityInsentient entity) {
if (!(entity instanceof EntityBase)) {
throw new IllegalArgumentException("The entity field should implements EntityBase");
}
EntityBase entityBase = (EntityBase) entity;
EntityWrapper wEntity = new EntityWrapper(entity);
EntityWrapper wPassenger = new EntityWrapper(passenger);
if (passenger != null) {
entity.lastYaw = entity.yaw = passenger.yaw % 360f;
entity.pitch = (passenger.pitch * 0.5F) % 360f;
wEntity.setRenderYawOffset(entity.yaw);
wEntity.setRotationYawHead(entity.yaw);
sideMot = wPassenger.getMoveStrafing() * 0.25f;
forMot = wPassenger.getMoveForward() * 0.5f;
if (forMot <= 0.0F) {
forMot *= 0.25F;
}
wEntity.setJumping(wPassenger.isJumping());
if (wPassenger.isJumping() && entity.isOnGround()) {
Vec3D v = entity.getMot();
Vec3D v2 = new Vec3D(v.getX(), 0.4D, v.getZ());
entity.setMot(v2);
}
wEntity.setStepHeight(1.0f);
wEntity.setJumpMovementFactor(wEntity.getMoveSpeed() * 0.1f);
wEntity.setRotationYawHead(entity.yaw);
entityBase.g_(sideMot, forMot);
wEntity.setPrevLimbSwingAmount(wEntity.getLimbSwingAmount());
double dx = entity.locX() - entity.lastX;
double dz = entity.locZ() - entity.lastZ;
float f4 = MathHelper.sqrt(dx * dx + dz * dz) * 4;
if (f4 > 1)
f4 = 1;
wEntity.setLimbSwingAmount(wEntity.getLimbSwingAmount() + (f4 - wEntity.getLimbSwingAmount()) * 0.4f);
wEntity.setLimbSwing(wEntity.getLimbSwing() + wEntity.getLimbSwingAmount());
} else {
wEntity.setStepHeight(0.5f);
wEntity.setJumpMovementFactor(0.02f);
entityBase.g_(sideMot, forMot);
}
}
Aggregations