Search in sources :

Example 1 with StatusEffect

use of net.minecraft.entity.effect.StatusEffect in project Rug by RubixDev.

the class MaxEffectCommand method register.

public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
    LiteralArgumentBuilder<ServerCommandSource> command = literal("maxeffect").requires((player) -> SettingsManager.canUseCommand(player, RugSettings.commandMaxEffect)).then(argument("effect", StatusEffectArgumentType.statusEffect()).executes(context -> {
        ServerCommandSource source = context.getSource();
        ServerPlayerEntity player = source.getPlayer();
        StatusEffect effect = StatusEffectArgumentType.getStatusEffect(context, "effect");
        boolean success = false;
        if (player instanceof LivingEntity) {
            StatusEffectInstance statusEffectInstance = new StatusEffectInstance(effect, effect.isInstant() ? 999999 : (999999 * 20), 255, false, false);
            success = (player).addStatusEffect(statusEffectInstance, source.getEntity());
        }
        if (!success) {
            throw new SimpleCommandExceptionType(new TranslatableText("commands.effect.give.failed")).create();
        }
        source.sendFeedback(new TranslatableText("commands.effect.give.success.single", effect.getName(), player.getDisplayName(), 999999), true);
        return 1;
    }));
    dispatcher.register(command);
}
Also used : StatusEffectArgumentType(net.minecraft.command.argument.StatusEffectArgumentType) CommandDispatcher(com.mojang.brigadier.CommandDispatcher) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerCommandSource(net.minecraft.server.command.ServerCommandSource) LivingEntity(net.minecraft.entity.LivingEntity) SettingsManager(carpet.settings.SettingsManager) TranslatableText(net.minecraft.text.TranslatableText) RugSettings(de.rubixdev.rug.RugSettings) CommandManager.literal(net.minecraft.server.command.CommandManager.literal) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) CommandManager.argument(net.minecraft.server.command.CommandManager.argument) StatusEffect(net.minecraft.entity.effect.StatusEffect) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) TranslatableText(net.minecraft.text.TranslatableText) StatusEffect(net.minecraft.entity.effect.StatusEffect) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) SimpleCommandExceptionType(com.mojang.brigadier.exceptions.SimpleCommandExceptionType) ServerCommandSource(net.minecraft.server.command.ServerCommandSource)

Example 2 with StatusEffect

use of net.minecraft.entity.effect.StatusEffect in project bewitchment by MoriyaShiine.

the class TheftStatusEffect method applyUpdateEffect.

@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
    if (!entity.world.isClient && entity.age % 20 == 0) {
        entity.world.getEntitiesByClass(LivingEntity.class, entity.getBoundingBox().expand(3 * (amplifier + 1)), foundEntity -> foundEntity != entity).forEach(livingEntity -> {
            List<StatusEffectInstance> statusEffects = livingEntity.getStatusEffects().stream().filter(instance -> instance.getEffectType().getCategory() == StatusEffectCategory.BENEFICIAL && !instance.isAmbient()).toList();
            for (StatusEffectInstance statusEffect : statusEffects) {
                entity.addStatusEffect(new StatusEffectInstance(statusEffect.getEffectType(), statusEffect.getDuration() / 2, statusEffect.getAmplifier()));
                livingEntity.removeStatusEffect(statusEffect.getEffectType());
            }
        });
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectCategory(net.minecraft.entity.effect.StatusEffectCategory) StatusEffect(net.minecraft.entity.effect.StatusEffect) List(java.util.List) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) BWStatusEffects(moriyashiine.bewitchment.common.registry.BWStatusEffects) LivingEntity(net.minecraft.entity.LivingEntity) AttributeContainer(net.minecraft.entity.attribute.AttributeContainer) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 3 with StatusEffect

use of net.minecraft.entity.effect.StatusEffect in project bewitchment by MoriyaShiine.

the class CorruptionStatusEffect method applyUpdateEffect.

@Override
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
    if (!entity.world.isClient) {
        Registry.STATUS_EFFECT.stream().forEach(effect -> {
            if (effect.getCategory() == StatusEffectCategory.BENEFICIAL && entity.hasStatusEffect(effect) && !entity.getStatusEffect(effect).isAmbient()) {
                StatusEffect inverse = INVERSE_EFFECTS.get(effect);
                StatusEffectInstance inverseEffect = null;
                if (inverse != null) {
                    StatusEffectInstance goodEffect = entity.getStatusEffect(effect);
                    inverseEffect = new StatusEffectInstance(inverse, goodEffect.getDuration(), goodEffect.getAmplifier(), goodEffect.isAmbient(), goodEffect.shouldShowParticles(), goodEffect.shouldShowIcon());
                }
                entity.removeStatusEffect(effect);
                if (inverseEffect != null) {
                    entity.addStatusEffect(inverseEffect);
                }
            }
        });
    }
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 4 with StatusEffect

use of net.minecraft.entity.effect.StatusEffect in project meteor-client by MeteorDevelopment.

the class PotionSpoof method onTick.

@EventHandler
private void onTick(TickEvent.Post event) {
    for (StatusEffect statusEffect : potions.get().keySet()) {
        int level = potions.get().getInt(statusEffect);
        if (level <= 0)
            continue;
        if (mc.player.hasStatusEffect(statusEffect)) {
            StatusEffectInstance instance = mc.player.getStatusEffect(statusEffect);
            ((StatusEffectInstanceAccessor) instance).setAmplifier(level - 1);
            if (instance.getDuration() < 20)
                ((StatusEffectInstanceAccessor) instance).setDuration(20);
        } else {
            mc.player.addStatusEffect(new StatusEffectInstance(statusEffect, 20, level - 1));
        }
    }
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) StatusEffectInstanceAccessor(meteordevelopment.meteorclient.mixin.StatusEffectInstanceAccessor) EventHandler(meteordevelopment.orbit.EventHandler)

Example 5 with StatusEffect

use of net.minecraft.entity.effect.StatusEffect in project meteor-client by MeteorDevelopment.

the class StatusEffectAmplifierMapSetting method parseImpl.

@Override
protected Object2IntMap<StatusEffect> parseImpl(String str) {
    String[] values = str.split(",");
    Object2IntMap<StatusEffect> effects = Utils.createStatusEffectMap();
    try {
        for (String value : values) {
            String[] split = value.split(" ");
            StatusEffect effect = parseId(Registry.STATUS_EFFECT, split[0]);
            int level = Integer.parseInt(split[1]);
            effects.put(effect, level);
        }
    } catch (Exception ignored) {
    }
    return effects;
}
Also used : StatusEffect(net.minecraft.entity.effect.StatusEffect)

Aggregations

StatusEffect (net.minecraft.entity.effect.StatusEffect)27 StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)13 Identifier (net.minecraft.util.Identifier)8 ArrayList (java.util.ArrayList)6 NbtCompound (net.minecraft.nbt.NbtCompound)4 NbtList (net.minecraft.nbt.NbtList)4 Sprite (net.minecraft.client.texture.Sprite)3 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)3 TextRenderer (net.minecraft.client.font.TextRenderer)2 InGameHud (net.minecraft.client.gui.hud.InGameHud)2 LivingEntity (net.minecraft.entity.LivingEntity)2 ItemStack (net.minecraft.item.ItemStack)2 NbtElement (net.minecraft.nbt.NbtElement)2 NbtString (net.minecraft.nbt.NbtString)2 SettingsManager (carpet.settings.SettingsManager)1 CommandDispatcher (com.mojang.brigadier.CommandDispatcher)1 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)1 SimpleCommandExceptionType (com.mojang.brigadier.exceptions.SimpleCommandExceptionType)1 RugSettings (de.rubixdev.rug.RugSettings)1 List (java.util.List)1