use of com.finderfeed.solarforge.SolarAbilities.meteorite.MeteoriteProjectile in project SolarCraftRepository by FINDERFEED.
the class MeteoriteAbility method cast.
@Override
public void cast(ServerPlayer entity, ServerLevel world) {
super.cast(entity, world);
if (allowed) {
Vec3 vec = entity.getLookAngle().multiply(200, 200, 200);
ClipContext ctx = new ClipContext(entity.position().add(0, 1.5, 0), entity.position().add(0, 1.5, 0).add(vec), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity);
BlockHitResult result = world.clip(ctx);
if (result.getType() == HitResult.Type.BLOCK) {
BlockPos pos = result.getBlockPos();
if (world.canSeeSky(pos.above())) {
MeteoriteProjectile proj = new MeteoriteProjectile(entity, world);
Vector3f posVect = new Vector3f((float) entity.position().x - (float) entity.getLookAngle().x * 20, (float) entity.position().y + 64, (float) entity.position().z - (float) entity.getLookAngle().z * 20);
proj.setPos(posVect.x(), posVect.y(), posVect.z());
Vec3 velocity = new Vec3(pos.offset(0.5, 0, 0.5).getX() - posVect.x(), pos.offset(0.5, 0, 0.5).getY() - posVect.y(), pos.offset(0.5, 0, 0.5).getZ() - posVect.z());
proj.setDeltaMovement(velocity.normalize());
world.addFreshEntity(proj);
} else {
if (!entity.isCreative()) {
refund(entity);
}
}
}
}
}
use of com.finderfeed.solarforge.SolarAbilities.meteorite.MeteoriteProjectile in project SolarCraftRepository by FINDERFEED.
the class SolarAbilities method meteorStrike.
// 5
public static void meteorStrike(ServerLevel world, Player entity) {
if (entity.getPersistentData().getBoolean("solar_forge_can_player_use_meteorite")) {
if (!entity.isCreative()) {
double mana = CapabilitySolarMana.getSolarMana(entity).orElseThrow(RuntimeException::new).getMana();
CapabilitySolarMana.getSolarMana(entity).orElseThrow(RuntimeException::new).setMana(mana - 500);
}
Vec3 vec = entity.getLookAngle().multiply(200, 200, 200);
ClipContext ctx = new ClipContext(entity.position().add(0, 1.5, 0), entity.position().add(0, 1.5, 0).add(vec), ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity);
BlockHitResult result = world.clip(ctx);
if (result.getType() == HitResult.Type.BLOCK) {
BlockPos pos = result.getBlockPos();
if (world.canSeeSky(pos.above())) {
MeteoriteProjectile proj = new MeteoriteProjectile(entity, world);
Vector3f posVect = new Vector3f((float) entity.position().x - (float) entity.getLookAngle().x * 20, (float) entity.position().y + 64, (float) entity.position().z - (float) entity.getLookAngle().z * 20);
proj.setPos(posVect.x(), posVect.y(), posVect.z());
Vec3 velocity = new Vec3(pos.offset(0.5, 0, 0.5).getX() - posVect.x(), pos.offset(0.5, 0, 0.5).getY() - posVect.y(), pos.offset(0.5, 0, 0.5).getZ() - posVect.z());
proj.setDeltaMovement(velocity.normalize());
world.addFreshEntity(proj);
}
}
}
}
Aggregations