Search in sources :

Example 6 with LightningEntity

use of net.minecraft.entity.LightningEntity in project MobOrigins by UltrusBot.

the class TridentEntityMixin method onEntityHit$MobOrigins.

@Inject(method = "onEntityHit", at = @At("TAIL"))
public void onEntityHit$MobOrigins(EntityHitResult entityHitResult, CallbackInfo ci) {
    Entity tridentThrower = this.getOwner();
    if (this.world instanceof ServerWorld && MobOriginsPowers.SEAS_STORM.isActive(tridentThrower) && !this.world.isThundering() && EnchantmentHelper.hasChanneling(this.tridentStack)) {
        Entity entity = entityHitResult.getEntity();
        BlockPos blockPos = entity.getBlockPos();
        if (this.world.isSkyVisible(blockPos)) {
            LightningEntity lightningEntity = (LightningEntity) EntityType.LIGHTNING_BOLT.create(this.world);
            lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(blockPos));
            lightningEntity.setChanneler(tridentThrower instanceof ServerPlayerEntity ? (ServerPlayerEntity) tridentThrower : null);
            this.world.spawnEntity(lightningEntity);
        }
    }
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) Entity(net.minecraft.entity.Entity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) TridentEntity(net.minecraft.entity.projectile.TridentEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LightningEntity(net.minecraft.entity.LightningEntity) LightningEntity(net.minecraft.entity.LightningEntity) BlockPos(net.minecraft.util.math.BlockPos) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 7 with LightningEntity

use of net.minecraft.entity.LightningEntity in project MCDungeonsArtifacts by chronosacaria.

the class AOEHelper method summonLightningBoltOnEntity.

public static void summonLightningBoltOnEntity(Entity target) {
    World world = target.getEntityWorld();
    LightningEntity lightningEntity = EntityType.LIGHTNING_BOLT.create(world);
    if (lightningEntity != null) {
        lightningEntity.refreshPositionAfterTeleport(target.getX(), target.getY(), target.getZ());
        lightningEntity.setCosmetic(true);
        world.spawnEntity(lightningEntity);
    }
}
Also used : LightningEntity(net.minecraft.entity.LightningEntity) World(net.minecraft.world.World) ServerWorld(net.minecraft.server.world.ServerWorld)

Example 8 with LightningEntity

use of net.minecraft.entity.LightningEntity in project bewitchment by MoriyaShiine.

the class ThunderboltFortune method finish.

@Override
public boolean finish(ServerWorld world, PlayerEntity target) {
    LightningEntity entity = EntityType.LIGHTNING_BOLT.create(world);
    if (entity != null) {
        entity.updatePositionAndAngles(target.getX(), target.getY(), target.getZ(), world.random.nextFloat() * 360, 0);
        world.spawnEntity(entity);
    }
    return super.finish(world, target);
}
Also used : LightningEntity(net.minecraft.entity.LightningEntity)

Example 9 with LightningEntity

use of net.minecraft.entity.LightningEntity in project Paradise-Lost by devs-immortal.

the class ElementalSword method postHit.

@Override
public boolean postHit(ItemStack stack, LivingEntity victim, LivingEntity attacker) {
    if (this == AetherItems.FLAMING_SWORD) {
        victim.setOnFireFor(30);
    } else if (this == AetherItems.LIGHTNING_SWORD) {
        LightningEntity lightning = new LightningEntity(EntityType.LIGHTNING_BOLT, attacker.world);
        if (attacker instanceof ServerPlayerEntity)
            lightning.setChanneler((ServerPlayerEntity) attacker);
    } else if (this == AetherItems.HOLY_SWORD && victim.isUndead()) {
        victim.damage(DamageSource.mob(attacker), 20);
        stack.damage(10, attacker, null);
    }
    return super.postHit(stack, victim, attacker);
}
Also used : LightningEntity(net.minecraft.entity.LightningEntity) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Aggregations

LightningEntity (net.minecraft.entity.LightningEntity)9 ServerWorld (net.minecraft.server.world.ServerWorld)3 Entity (net.minecraft.entity.Entity)2 LivingEntity (net.minecraft.entity.LivingEntity)2 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 Random (java.util.Random)1 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)1 MobEntity (net.minecraft.entity.mob.MobEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)1 TridentEntity (net.minecraft.entity.projectile.TridentEntity)1 Box (net.minecraft.util.math.Box)1 World (net.minecraft.world.World)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1