use of net.minecraft.entity.LightningEntity in project Therrassium by codeman1o1.
the class Smited method onTargetDamaged.
@Override
public void onTargetDamaged(LivingEntity user, Entity target, int level) {
if (!user.world.isClient) {
if (target instanceof LivingEntity) {
LightningEntity lightningEntity = (LightningEntity) EntityType.LIGHTNING_BOLT.create(target.world);
lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(target.getBlockPos()));
target.world.spawnEntity(lightningEntity);
}
}
super.onTargetDamaged(user, target, level);
}
use of net.minecraft.entity.LightningEntity in project bewitchment by MoriyaShiine.
the class SpawnLightningRitualFunction method summonLightning.
private void summonLightning(World world, BlockPos pos) {
LightningEntity entity = EntityType.LIGHTNING_BOLT.create(world);
if (entity != null) {
entity.updatePositionAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, world.random.nextFloat() * 360, 0);
world.spawnEntity(entity);
}
}
use of net.minecraft.entity.LightningEntity in project Biome-Makeover by Lemonszz.
the class LightningBottleEntity method onCollision.
protected void onCollision(HitResult hitResult) {
super.onCollision(hitResult);
NetworkUtil.doLightningSplash(world, true, getBlockPos());
if (!this.world.isClient) {
world.playSound(null, getBlockPos(), BMEffects.BOTTLE_THUNDER, SoundCategory.NEUTRAL, 50F, 0.8F + this.random.nextFloat() * 0.2F);
Box box = this.getBoundingBox().expand(4.0D, 2.0D, 4.0D);
List<LivingEntity> entities = this.world.getEntitiesByClass(LivingEntity.class, box, EntityPredicates.VALID_LIVING_ENTITY);
if (!entities.isEmpty()) {
Iterator<LivingEntity> iterator = entities.iterator();
while (iterator.hasNext()) {
LivingEntity e = iterator.next();
double distance = this.squaredDistanceTo(e);
if (distance < 16.0D) {
int fireTicks = e.getFireTicks();
boolean isInvul = e.isInvulnerable();
LightningEntity dummyLightning = new LightningEntity(EntityType.LIGHTNING_BOLT, world);
dummyLightning.setPos(e.getX(), e.getY(), e.getZ());
e.setInvulnerable(true);
e.onStruckByLightning((ServerWorld) world, dummyLightning);
e.setFireTicks(fireTicks);
e.setInvulnerable(isInvul);
dummyLightning.remove();
}
}
}
// Loop through again to grab transformed entities for damage & effect
entities = this.world.getEntitiesByClass(LivingEntity.class, box, EntityPredicates.VALID_LIVING_ENTITY);
if (!entities.isEmpty()) {
Iterator<LivingEntity> iterator = entities.iterator();
while (iterator.hasNext()) {
LivingEntity e = iterator.next();
double distance = this.squaredDistanceTo(e);
if (distance < 16.0D) {
NetworkUtil.doLightningEntity(world, e, 100);
if (!e.hasStatusEffect(BMPotions.SHOCKED)) {
e.addStatusEffect(new StatusEffectInstance(BMPotions.SHOCKED, 1000, 0));
} else {
e.addStatusEffect(new StatusEffectInstance(BMPotions.SHOCKED, 1000, Math.min(3, e.getStatusEffect(BMPotions.SHOCKED).getAmplifier() + 1)));
}
e.damage(DamageSource.magic(this, this.getOwner()), 0);
if (getOwner() instanceof LivingEntity) {
e.setAttacker((LivingEntity) getOwner());
}
if (e.getHealth() > e.getMaxHealth())
e.setHealth(e.getMaxHealth());
}
}
}
this.remove();
}
}
use of net.minecraft.entity.LightningEntity in project Biome-Makeover by Lemonszz.
the class ConductivityCurseEnchantment method onTick.
@Override
public void onTick(LivingEntity entity, ItemStack stack, int level) {
ServerWorld world = (ServerWorld) entity.world;
Random random = world.random;
if (random.nextInt(11000 - (level * 1000)) == 0 && world.isThundering()) {
BlockPos pos = entity.getBlockPos();
if (world.hasRain(pos)) {
LightningEntity lightningEntity = EntityType.LIGHTNING_BOLT.create(world);
lightningEntity.refreshPositionAfterTeleport(Vec3d.ofBottomCenter(pos));
world.spawnEntity(lightningEntity);
}
}
}
use of net.minecraft.entity.LightningEntity in project Neutrino by FrostWizard4.
the class LightningRodArtifact method summonLightning.
public void summonLightning(PlayerEntity playerEntity, World world) {
for (Entity e : world.getOtherEntities(playerEntity, Box.of(playerEntity.getPos(), 10, 10, 10))) {
if (e instanceof MobEntity && (playerEntity.distanceTo(e) < 10)) {
LightningEntity lightningEntity = new LightningEntity(EntityType.LIGHTNING_BOLT, world);
lightningEntity.setPos(e.getX(), e.getY(), e.getZ());
world.spawnEntity(lightningEntity);
}
}
}
Aggregations