Untitled

mail@pastecode.io avatar
unknown
java
a year ago
893 B
6
Indexable
Never
    private void markersActivate(MarkerEntity marker, World world, int chargeLevel, ServerPlayerEntity player) {
        // Detect entities in range of markers
        List<LivingEntity> nearbySlamTargetEntities = world.getTargets(LivingEntity.class, TargetPredicate.createAttackable(), player,
                marker.getBoundingBox().expand(chargeLevel + 1));
        // Create damage multiplier
        float damageMultiplier;
        if (chargeLevel == 2) {
            damageMultiplier = 1.5F;
        } else {
            damageMultiplier = 1;
        }
        // Damage targets
        nearbySlamTargetEntities.forEach(m -> m.damage(m.getDamageSources().explosion(player, player), 10 * damageMultiplier));
        nearbySlamTargetEntities.forEach(m -> m.addVelocity(0, chargeLevel, 0));
        // Remove markers
        marker.remove(Entity.RemovalReason.KILLED);
    }