Search in sources :

Example 36 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance 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 37 with StatusEffectInstance

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

the class WItemWithLabel method getStringToAppend.

private String getStringToAppend() {
    String str = "";
    if (itemStack.getItem() == Items.POTION) {
        List<StatusEffectInstance> effects = PotionUtil.getPotion(itemStack).getEffects();
        if (effects.size() > 0) {
            str += " ";
            StatusEffectInstance effect = effects.get(0);
            if (effect.getAmplifier() > 0)
                str += effect.getAmplifier() + 1 + " ";
            str += "(" + StatusEffectUtil.durationToString(effect, 1) + ")";
        }
    }
    return str;
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 38 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project KiwiClient by TangyKiwi.

the class Tooltips method appendTooltip.

@Subscribe
@AllowConcurrentEvents
public void appendTooltip(ItemStackTooltipEvent event) {
    // Stew
    if (getSetting(0).asToggle().state) {
        if (event.itemStack.getItem() == Items.SUSPICIOUS_STEW) {
            NbtCompound tag = event.itemStack.getNbt();
            if (tag != null) {
                NbtList effects = tag.getList("Effects", 10);
                if (effects != null) {
                    for (int i = 0; i < effects.size(); i++) {
                        NbtCompound effectTag = effects.getCompound(i);
                        byte effectId = effectTag.getByte("EffectId");
                        int effectDuration = effectTag.contains("EffectDuration") ? effectTag.getInt("EffectDuration") : 160;
                        StatusEffectInstance effect = new StatusEffectInstance(StatusEffect.byRawId(effectId), effectDuration, 0);
                        event.list.add(1, getStatusText(effect));
                    }
                }
            }
        } else if (event.itemStack.getItem().isFood()) {
            FoodComponent food = event.itemStack.getItem().getFoodComponent();
            if (food != null) {
                food.getStatusEffects().forEach((e) -> {
                    StatusEffectInstance effect = e.getFirst();
                    event.list.add(1, getStatusText(effect));
                });
            }
        }
    }
    // Bees
    if (getSetting(1).asToggle().state) {
        if (event.itemStack.getItem() == Items.BEEHIVE || event.itemStack.getItem() == Items.BEE_NEST) {
            NbtCompound tag = event.itemStack.getNbt();
            if (tag != null) {
                NbtCompound blockStateTag = tag.getCompound("BlockStateTag");
                if (blockStateTag != null) {
                    int level = blockStateTag.getInt("honey_level");
                    event.list.add(1, new LiteralText(String.format("%sHoney Level: %s%d%s", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY)));
                }
                NbtCompound blockEntityTag = tag.getCompound("BlockEntityTag");
                if (blockEntityTag != null) {
                    NbtList beesTag = blockEntityTag.getList("Bees", 10);
                    event.list.add(1, new LiteralText(String.format("%sBees: %s%d%s", Formatting.GRAY, Formatting.YELLOW, beesTag.size(), Formatting.GRAY)));
                }
            }
        }
    }
// Fish handled in EntityBucketItemMixin
}
Also used : LiteralText(net.minecraft.text.LiteralText) NbtList(net.minecraft.nbt.NbtList) EChestMemory(com.tangykiwi.kiwiclient.util.tooltip.EChestMemory) TranslatableText(net.minecraft.text.TranslatableText) Module(com.tangykiwi.kiwiclient.modules.Module) DefaultedList(net.minecraft.util.collection.DefaultedList) Block(net.minecraft.block.Block) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Inventories(net.minecraft.inventory.Inventories) MutableText(net.minecraft.text.MutableText) ToggleSetting(com.tangykiwi.kiwiclient.modules.settings.ToggleSetting) Subscribe(com.google.common.eventbus.Subscribe) Object2IntOpenHashMap(it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap) ItemStackTooltipEvent(com.tangykiwi.kiwiclient.event.ItemStackTooltipEvent) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) Category(com.tangykiwi.kiwiclient.modules.Category) ContainerTooltipComponent(com.tangykiwi.kiwiclient.util.tooltip.ContainerTooltipComponent) net.minecraft.item(net.minecraft.item) Blocks(net.minecraft.block.Blocks) java.awt(java.awt) TooltipDataEvent(com.tangykiwi.kiwiclient.event.TooltipDataEvent) NbtCompound(net.minecraft.nbt.NbtCompound) StatusEffect(net.minecraft.entity.effect.StatusEffect) Formatting(net.minecraft.util.Formatting) List(java.util.List) StatusEffectUtil(net.minecraft.entity.effect.StatusEffectUtil) Object2IntMap(it.unimi.dsi.fastutil.objects.Object2IntMap) ShulkerBoxBlock(net.minecraft.block.ShulkerBoxBlock) DyeColor(net.minecraft.util.DyeColor) Text(net.minecraft.text.Text) Comparator(java.util.Comparator) NbtCompound(net.minecraft.nbt.NbtCompound) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) NbtList(net.minecraft.nbt.NbtList) LiteralText(net.minecraft.text.LiteralText) AllowConcurrentEvents(com.google.common.eventbus.AllowConcurrentEvents) Subscribe(com.google.common.eventbus.Subscribe)

Example 39 with StatusEffectInstance

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

the class WhiteSwetEntity method onPlayerCollision.

public void onPlayerCollision(PlayerEntity player) {
    Collection<StatusEffectInstance> effects = player.getStatusEffects();
    for (StatusEffectInstance effect : effects) {
        this.applyStatusEffect(effect);
        player.removeStatusEffect(effect.getEffectType());
    }
    super.onPlayerCollision(player);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 40 with StatusEffectInstance

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

the class EndGatewayBlockEntityMixin method serverTick.

@Inject(at = @At("HEAD"), method = "serverTick")
private static void serverTick(World world, BlockPos pos, BlockState state, EndGatewayBlockEntity blockEntity, CallbackInfo ci) {
    if (world instanceof ServerWorld) {
        if (world.getTime() % 100L == 0L) {
            for (MobEntity e : world.getEntitiesByClass(MobEntity.class, Box.of(Vec3d.ofCenter(pos), 1000, 1000, 1000), EndGatewayBlockEntity::canTeleport)) {
                e.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 1200, 1));
                e.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 1200, 1));
                e.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 1200, 2));
                e.addStatusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 1200, 1));
            }
        }
    }
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) EndGatewayBlockEntity(net.minecraft.block.entity.EndGatewayBlockEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) MobEntity(net.minecraft.entity.mob.MobEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

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