Search in sources :

Example 86 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Potions-HUD-Fabric by Samuel-Martineau.

the class HUD method render.

private void render() {
    final PlayerEntity player = client.player;
    final InGameHud inGameHud = client.inGameHud;
    final TextRenderer textRenderer = client.textRenderer;
    final MatrixStack matrixStack = new MatrixStack();
    if (player == null)
        return;
    Collection<StatusEffectInstance> statusEffects = player.getStatusEffects();
    final GameOptions gameOptions = ((MinecraftClientMixin) MinecraftClient.getInstance()).getGameOptions();
    if (!statusEffects.isEmpty() && !gameOptions.debugEnabled) {
        RenderSystem.enableBlend();
        StatusEffectSpriteManager statusEffectSpriteManager = client.getStatusEffectSpriteManager();
        List<Runnable> statusEffectsRunnables = Lists.newArrayListWithExpectedSize(statusEffects.size());
        final int spriteSize = 18;
        for (StatusEffectInstance statusEffectInstance : Ordering.natural().reverse().sortedCopy(statusEffects)) {
            StatusEffect statusEffect = statusEffectInstance.getEffectType();
            final int duration = statusEffectInstance.getDuration() / 20;
            final long mins = TimeUnit.SECONDS.toMinutes(duration);
            final long secs = duration - TimeUnit.MINUTES.toSeconds(mins);
            String formattedDuration;
            if (statusEffectInstance.isPermanent())
                formattedDuration = "∞";
            else if (mins == 0)
                formattedDuration = secs + " sec";
            else
                formattedDuration = String.format("%d min, %d sec", mins, secs);
            final int x = 3;
            final int y = spriteSize * statusEffectsRunnables.size() + 3;
            System.out.println("\n   \n---\n   ");
            Sprite sprite = statusEffectSpriteManager.getSprite(statusEffect);
            System.out.println(sprite);
            System.out.println(sprite.getAtlas().getId());
            System.out.println(x);
            System.out.println(y);
            System.out.println(inGameHud.getZOffset());
            statusEffectsRunnables.add(() -> {
                client.getTextureManager().bindTexture(sprite.getAtlas().getId());
                DrawableHelper.drawSprite(matrixStack, x, y, inGameHud.getZOffset(), 18, 18, sprite);
                final float textYOffset = spriteSize / 2f - textRenderer.fontHeight / 2.5f;
                int color;
                if (duration <= 5)
                    color = 0xFF5555;
                else if (duration <= 15)
                    color = 0xFFAA00;
                else if (duration <= 25)
                    color = 0xFFFF55;
                else
                    color = 0xFFFFFF;
                textRenderer.draw(matrixStack, formattedDuration, x + spriteSize + 3, y + textYOffset, color);
            });
        }
        statusEffectsRunnables.forEach(Runnable::run);
    }
}
Also used : MinecraftClientMixin(me.smartineau.mixin.MinecraftClientMixin) Sprite(net.minecraft.client.texture.Sprite) MatrixStack(net.minecraft.client.util.math.MatrixStack) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) StatusEffectSpriteManager(net.minecraft.client.texture.StatusEffectSpriteManager) PlayerEntity(net.minecraft.entity.player.PlayerEntity) StatusEffect(net.minecraft.entity.effect.StatusEffect) InGameHud(net.minecraft.client.gui.hud.InGameHud) GameOptions(net.minecraft.client.option.GameOptions) TextRenderer(net.minecraft.client.font.TextRenderer)

Example 87 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Blockus by Brandcraf06.

the class NetherStarBlock method onSteppedOn.

@Override
public void onSteppedOn(World world, BlockPos pos, BlockState state, Entity entity) {
    if (entity.getType() == EntityType.PLAYER) {
        ((LivingEntity) entity).addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 1, 4, true, false, false));
        ((LivingEntity) entity).addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 100, 3, true, false, true));
        ((LivingEntity) entity).addStatusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 1200, 4, true, false, true));
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 88 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project WK by witches-kitchen.

the class CuSithEntity method onStruckByLightning.

@Override
public void onStruckByLightning(ServerWorld world, LightningEntity lightning) {
    this.addStatusEffect(new StatusEffectInstance(StatusEffects.REGENERATION, 4000, 1, true, true), this);
    this.addStatusEffect(new StatusEffectInstance(StatusEffects.ABSORPTION, 4000, 1, true, true), this);
    this.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 4000, 1, true, true), this);
    this.addStatusEffect(new StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 250, 1, true, true), this);
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 89 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project EnvironmentZ by Globox1997.

the class TemperatureAspects method dryOrWett.

public static void dryOrWett(PlayerEntity playerEntity) {
    dryingTimer++;
    if (dryingTimer >= 5 && playerEntity.isTouchingWaterOrRain()) {
        playerEntity.addStatusEffect(new StatusEffectInstance(EffectInit.WET, ConfigInit.CONFIG.wet_effect_time, 0, false, false, true));
        dryingTimer = 0;
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 90 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project Biome-Makeover by Lemonszz.

the class TadpoleEntity method tick.

@Override
public void tick() {
    super.tick();
    if (!world.isClient()) {
        babyTime++;
        if (!isBaby()) {
            ToadEntity toad = BMEntities.TOAD.create(world);
            toad.refreshPositionAndAngles(this.getX(), this.getY(), this.getZ(), bodyYaw, pitch);
            toad.addStatusEffect(new StatusEffectInstance(StatusEffects.WATER_BREATHING, 200, 0));
            ((ServerWorld) world).spawnEntityAndPassengers(toad);
            remove();
        }
    }
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Aggregations

StatusEffectInstance (net.minecraft.entity.effect.StatusEffectInstance)107 PlayerEntity (net.minecraft.entity.player.PlayerEntity)18 LivingEntity (net.minecraft.entity.LivingEntity)17 StatusEffect (net.minecraft.entity.effect.StatusEffect)14 ItemStack (net.minecraft.item.ItemStack)14 Inject (org.spongepowered.asm.mixin.injection.Inject)13 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)9 Sprite (net.minecraft.client.texture.Sprite)4 AreaEffectCloudEntity (net.minecraft.entity.AreaEffectCloudEntity)4 Entity (net.minecraft.entity.Entity)4 Box (net.minecraft.util.math.Box)4 List (java.util.List)3 StatusEffectSpriteManager (net.minecraft.client.texture.StatusEffectSpriteManager)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 EventHandler (mathax.client.eventbus.EventHandler)2 StatusEffectInstanceAccessor (mathax.client.mixin.StatusEffectInstanceAccessor)2 HWGEntity (mod.azure.hwg.entity.HWGEntity)2 ThirstManager (net.dehydration.thirst.ThirstManager)2