Search in sources :

Example 81 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.

the class DoomWallBlock method checkIconSpawn.

public static void checkIconSpawn(World world, BlockPos pos, IconBlockEntity blockEntity) {
    if (!world.isClient()) {
        BlockState block = blockEntity.getCachedState();
        boolean flag = block.isOf(DoomBlocks.ICON_WALL1) || block.isOf(DoomBlocks.ICON_WALL2) || block.isOf(DoomBlocks.ICON_WALL3) || block.isOf(DoomBlocks.ICON_WALL4) || block.isOf(DoomBlocks.ICON_WALL5) || block.isOf(DoomBlocks.ICON_WALL6) || block.isOf(DoomBlocks.ICON_WALL7) || block.isOf(DoomBlocks.ICON_WALL8) || block.isOf(DoomBlocks.ICON_WALL9) || block.isOf(DoomBlocks.ICON_WALL10) || block.isOf(DoomBlocks.ICON_WALL11) || block.isOf(DoomBlocks.ICON_WALL12) || block.isOf(DoomBlocks.ICON_WALL13) || block.isOf(DoomBlocks.ICON_WALL14) || block.isOf(DoomBlocks.ICON_WALL15) || block.isOf(DoomBlocks.ICON_WALL16);
        if (flag && pos.getY() >= 3 && world.getDifficulty() != Difficulty.PEACEFUL) {
            BlockPattern blockPattern = getOrCreateIconFull();
            BlockPattern.Result result = blockPattern.searchAround(world, pos);
            if (result != null) {
                for (int i = 0; i < blockPattern.getWidth(); ++i) {
                    for (int j = 0; j < blockPattern.getHeight(); ++j) {
                        CachedBlockPosition cachedBlockPosition = result.translate(i, j, 0);
                        world.setBlockState(cachedBlockPosition.getBlockPos(), Blocks.AIR.getDefaultState(), 2);
                        world.syncWorldEvent(2001, cachedBlockPosition.getBlockPos(), Block.getRawIdFromState(cachedBlockPosition.getBlockState()));
                    }
                }
                IconofsinEntity witherentity = ModEntityTypes.ICONOFSIN.create(world);
                BlockPos blockPos = result.translate(1, 2, 0).getBlockPos();
                witherentity.refreshPositionAndAngles((double) blockPos.getX() + 0.5D, (double) blockPos.getY() + 0.55D, (double) blockPos.getZ() + 0.5D, result.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F, 0.0F);
                witherentity.bodyYaw = result.getForwards().getAxis() == Direction.Axis.X ? 0.0F : 90.0F;
                witherentity.addStatusEffect(new StatusEffectInstance(StatusEffects.SLOWNESS, 200, 4));
                witherentity.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 200, 4));
                world.spawnEntity(witherentity);
                Iterator<ServerPlayerEntity> var13 = world.getNonSpectatingEntities(ServerPlayerEntity.class, witherentity.getBoundingBox().expand(50.0D)).iterator();
                while (var13.hasNext()) {
                    ServerPlayerEntity serverPlayerEntity = (ServerPlayerEntity) var13.next();
                    Criteria.SUMMONED_ENTITY.trigger(serverPlayerEntity, witherentity);
                }
                for (int k = 0; k < blockPattern.getWidth(); ++k) {
                    for (int l = 0; l < blockPattern.getHeight(); ++l) {
                        world.updateNeighbors(result.translate(k, l, 0).getBlockPos(), Blocks.AIR);
                    }
                }
            }
        }
    }
}
Also used : CachedBlockPosition(net.minecraft.block.pattern.CachedBlockPosition) BlockState(net.minecraft.block.BlockState) BlockPattern(net.minecraft.block.pattern.BlockPattern) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) IconofsinEntity(mod.azure.doom.entity.tierboss.IconofsinEntity) BlockPos(net.minecraft.util.math.BlockPos) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity)

Example 82 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.

the class DoomHunterEntity method tick.

@Override
public void tick() {
    super.tick();
    flameTimer = (flameTimer + 1) % 8;
    if (this.getHealth() < (this.getMaxHealth() * 0.50)) {
        if (!this.world.isClient) {
            this.addStatusEffect(new StatusEffectInstance(StatusEffects.SPEED, 10000000, 2));
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance)

Example 83 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.

the class InmortalSphereItem method usageTick.

@Override
public void usageTick(World worldIn, LivingEntity livingEntityIn, ItemStack stack, int count) {
    if (livingEntityIn instanceof PlayerEntity) {
        PlayerEntity playerentity = (PlayerEntity) livingEntityIn;
        if (!worldIn.isClient) {
            livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 600, 4));
            livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 600, 4));
            if (!playerentity.getAbilities().creativeMode) {
                stack.decrement(1);
                if (stack.isEmpty()) {
                    playerentity.getInventory().removeOne(stack);
                }
            }
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 84 with StatusEffectInstance

use of net.minecraft.entity.effect.StatusEffectInstance in project MCDoom by AzureDoom.

the class MegaSphereItem method usageTick.

@Override
public void usageTick(World worldIn, LivingEntity livingEntityIn, ItemStack stack, int count) {
    if (livingEntityIn instanceof PlayerEntity) {
        PlayerEntity playerentity = (PlayerEntity) livingEntityIn;
        if (!worldIn.isClient) {
            livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 600, 4));
            livingEntityIn.heal(40);
            livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.RESISTANCE, 600, 4));
            livingEntityIn.addStatusEffect(new StatusEffectInstance(StatusEffects.FIRE_RESISTANCE, 600, 4));
            if (!playerentity.getAbilities().creativeMode) {
                stack.decrement(1);
                if (stack.isEmpty()) {
                    playerentity.getInventory().removeOne(stack);
                }
            }
        }
    }
}
Also used : StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 85 with StatusEffectInstance

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

the class InGameHudMixin method renderStatusEffectOverlay.

/**
 * @author Samuel-Martineau
 * @reason Prevents the default status effects overlay from being rendered
 */
@Overwrite()
public void renderStatusEffectOverlay(MatrixStack matrices) {
    MinecraftClient client = MinecraftClient.getInstance();
    InGameHud inGameHud = client.inGameHud;
    TextRenderer textRenderer = inGameHud.getTextRenderer();
    int spriteSize = 18;
    assert client.player != null;
    Collection<StatusEffectInstance> statusEffectsCollection = client.player.getStatusEffects();
    if (!statusEffectsCollection.isEmpty()) {
        RenderSystem.enableBlend();
        StatusEffectSpriteManager statusEffectSpriteManager = client.getStatusEffectSpriteManager();
        List<Runnable> statusEffectsRunnableList = Lists.newArrayListWithExpectedSize(statusEffectsCollection.size());
        RenderSystem.setShaderTexture(0, HandledScreen.BACKGROUND_TEXTURE);
        Iterator<StatusEffectInstance> statusEffectsIterator = Ordering.natural().reverse().sortedCopy(statusEffectsCollection).iterator();
        int i = 0;
        while (statusEffectsIterator.hasNext()) {
            int x = PotionsHUDMod.CONFIG_MANAGER.X_OFFSET;
            int y = spriteSize * i + PotionsHUDMod.CONFIG_MANAGER.Y_OFFSET;
            StatusEffectInstance statusEffectInstance = statusEffectsIterator.next();
            StatusEffect statusEffect = statusEffectInstance.getEffectType();
            if (statusEffectInstance.shouldShowIcon()) {
                Sprite statusEffectSprite = statusEffectSpriteManager.getSprite(statusEffect);
                statusEffectsRunnableList.add(() -> {
                    RenderSystem.setShaderTexture(0, statusEffectSprite.getAtlas().getId());
                    DrawableHelper.drawSprite(matrices, x, y, inGameHud.getZOffset(), spriteSize, spriteSize, statusEffectSprite);
                    int duration = statusEffectInstance.getDuration() / 20;
                    long mins = TimeUnit.SECONDS.toMinutes(duration);
                    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);
                    float textX = x + spriteSize + 3;
                    float textY = y + (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(matrices, formattedDuration, textX, textY, color);
                });
            }
            i++;
        }
        statusEffectsRunnableList.forEach(Runnable::run);
    }
}
Also used : Sprite(net.minecraft.client.texture.Sprite) StatusEffectInstance(net.minecraft.entity.effect.StatusEffectInstance) StatusEffectSpriteManager(net.minecraft.client.texture.StatusEffectSpriteManager) StatusEffect(net.minecraft.entity.effect.StatusEffect) InGameHud(net.minecraft.client.gui.hud.InGameHud) MinecraftClient(net.minecraft.client.MinecraftClient) TextRenderer(net.minecraft.client.font.TextRenderer) Overwrite(org.spongepowered.asm.mixin.Overwrite)

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