use of com.finderfeed.solarforge.SolarAbilities.SolarStrikeEntity in project SolarCraftRepository by FINDERFEED.
the class SolarStrikeAbility 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())) {
SolarStrikeEntity entityBolt = new SolarStrikeEntity(SolarForge.SOLAR_STRIKE_ENTITY_REG.get(), world);
entityBolt.setPos(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
world.addFreshEntity(entityBolt);
} else {
if (!entity.isCreative()) {
refund(entity);
}
}
}
}
}
Aggregations