Search in sources :

Example 41 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Neutrino by FrostWizard4.

the class DeathCapArtifact method finishUsing.

@Override
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
    for (int i = 0; i < 50; i++) {
        rndDeath = (int) (Math.random() * (100 - 1 + 1) + 1);
    }
    if (rndDeath > 15 && rndDeath < 30) {
        user.kill();
    }
    // Play Sound
    user.playSound(EAT_DEATH_CAP_MUSHROOM, 1.0F, 1.0F);
    // Apply Effects
    world.getClosestPlayer(user, 15).addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 400, 2));
    world.getClosestPlayer(user, 15).addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 400, 1));
    // Set 30 second Cooldown
    return this.isFood() ? user.eatFood(world, stack) : stack;
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 42 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Neutrino by FrostWizard4.

the class EnchantersTomeArtifact method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
    // Play Sound
    playerEntity.playSound(ENCHANTERS_TOME_ACTIVATE, 1.0F, 1.0F);
    // Apply Effects to the Closest Players
    world.getClosestPlayer(playerEntity, 15).addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 400, 2));
    world.getClosestPlayer(playerEntity, 15).addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 400, 1));
    world.getClosestPlayer(playerEntity, 15).addStatusEffect(new StatusEffectInstance(StatusEffects.HASTE, 400, 2));
    // Add 25 second Cooldown
    playerEntity.getItemCooldownManager().set(ItemRegistry.ENCHANTERS_TOME, 500);
    return TypedActionResult.success(playerEntity.getStackInHand(hand));
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 43 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Neutrino by FrostWizard4.

the class SoulHealerArtifact method use.

@Override
public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) {
    if (((PlayerEntityAccess) playerEntity).neutrino$getPowerCount() >= 150) {
        // Play Healer Sound
        playerEntity.playSound(SoundRegister.SOUL_HEALER_ACTIVATE, 1.0F, 1.0F);
        // Heal
        world.getClosestPlayer(playerEntity, 15).addStatusEffect(new StatusEffectInstance(StatusEffects.INSTANT_HEALTH, 200, 2));
        ((PlayerEntityAccess) playerEntity).neutrino$setPowerCount(0);
    } else {
        if (world.isClient()) {
            MinecraftClient.getInstance().inGameHud.addChatMessage(MessageType.GAME_INFO, Text.of("Not enough souls!"), UUID.randomUUID());
        }
    }
    return TypedActionResult.success(playerEntity.getStackInHand(hand));
}
Also used : PlayerEntityAccess(com.frostwizard4.Neutrino.PlayerEntityAccess) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 44 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Neutrino by FrostWizard4.

the class DaturaFlower method onBreak.

public void onBreak(World world, BlockPos pos, BlockState state, PlayerEntity player) {
    this.spawnBreakParticles(world, player, pos, state);
    if (state.isIn(BlockTags.GUARDED_BY_PIGLINS)) {
        PiglinBrain.onGuardedBlockInteracted(player, false);
    }
    AreaEffectCloudEntity areaEffectCloudEntity = new AreaEffectCloudEntity(world, pos.getX(), pos.getY(), pos.getZ());
    areaEffectCloudEntity.setRadius(3.0F);
    areaEffectCloudEntity.setRadiusOnUse(-0.5F);
    areaEffectCloudEntity.setWaitTime(10);
    areaEffectCloudEntity.setRadiusGrowth(-areaEffectCloudEntity.getRadius() / (float) areaEffectCloudEntity.getDuration());
    areaEffectCloudEntity.setPotion(Potions.POISON);
    areaEffectCloudEntity.addEffect(new StatusEffectInstance(StatusEffects.POISON));
    if (world.isDay()) {
        world.spawnEntity(areaEffectCloudEntity);
    }
    world.emitGameEvent(player, GameEvent.BLOCK_DESTROY, pos);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) AreaEffectCloudEntity(net.minecraft.entity.AreaEffectCloudEntity)

Example 45 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance 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();
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) LightningEntity(net.minecraft.entity.LightningEntity) Box(net.minecraft.util.math.Box)

Aggregations

StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)128 LivingEntity (net.minecraft.entity.LivingEntity)25 PlayerEntity (net.minecraft.entity.player.PlayerEntity)20 StatusEffect (net.minecraft.entity.effect.StatusEffect)16 ItemStack (net.minecraft.item.ItemStack)15 Inject (org.spongepowered.asm.mixin.injection.Inject)13 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)10 TypedActionResult (net.minecraft.util.TypedActionResult)7 Sprite (net.minecraft.client.texture.Sprite)4 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)4 Entity (net.minecraft.entity.Entity)4 MobEntity (net.minecraft.entity.mob.MobEntity)4 Box (net.minecraft.util.math.Box)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 List (java.util.List)3 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 HWGEntity (mod.azure.hwg.entity.HWGEntity)2 ThirstManager (net.dehydration.thirst.ThirstManager)2