Search in sources :

Example 31 with Potion

use of net.minecraft.potion.Potion in project MorePlanets by SteveKunG.

the class EntityInfectedElderGuardian method updateAITasks.

@Override
protected void updateAITasks() {
    if ((this.ticksExisted + this.getEntityId()) % 1200 == 0) {
        Potion potion = MobEffects.MINING_FATIGUE;
        for (EntityPlayerMP player : this.world.getPlayers(EntityPlayerMP.class, entity -> this.getDistanceSq(entity) < 2500.0D && entity.interactionManager.survivalOrAdventure())) {
            if (!player.isPotionActive(potion) || player.getActivePotionEffect(potion).getAmplifier() < 2 || player.getActivePotionEffect(potion).getDuration() < 1200) {
                MorePlanetsMod.PROXY.spawnParticle(EnumParticleTypesMP.INFECTED_GUARDIAN_APPEARANCE, player.posX, player.posY, player.posZ);
                player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_ELDER_GUARDIAN_CURSE, SoundCategory.HOSTILE, 1.0F, 1.0F);
                player.addPotionEffect(new PotionEffect(potion, 6000, 2));
                if (!player.capabilities.isCreativeMode && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION)) {
                    player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80, 2));
                }
            }
        }
    }
    if (!this.hasHome()) {
        this.setHomePosAndDistance(new BlockPos(this), 16);
    }
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPos(net.minecraft.util.math.BlockPos)

Example 32 with Potion

use of net.minecraft.potion.Potion in project Almura by AlmuraDev.

the class MixinGuiIngame method renderPotionEffects.

/**
 * @author Grinch - Steven Downer
 * @reason Move down where PotionEffects render to not conflict with the far right element of the OriginHUD
 */
@Overwrite
protected void renderPotionEffects(ScaledResolution resolution) {
    Minecraft mc = Minecraft.getMinecraft();
    Collection<PotionEffect> collection = mc.player.getActivePotionEffects();
    if (!collection.isEmpty()) {
        mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
        GlStateManager.enableBlend();
        int i = 0;
        int j = 0;
        for (PotionEffect potioneffect : Ordering.natural().reverse().sortedCopy(collection)) {
            Potion potion = potioneffect.getPotion();
            if (!potion.shouldRenderHUD(potioneffect))
                continue;
            // Rebind in case previous renderHUDEffect changed texture
            mc.getTextureManager().bindTexture(GuiContainer.INVENTORY_BACKGROUND);
            if (potioneffect.doesShowParticles()) {
                int k = resolution.getScaledWidth();
                // TODO Figure out how to do this without overwrite
                // Almura start
                int l = hud.getHUD().map(AbstractHUD::getPotionOffsetY).orElse(1);
                if (mc.isDemo()) {
                    l += 15;
                }
                int i1 = potion.getStatusIconIndex();
                if (potion.isBeneficial()) {
                    ++i;
                    k = k - 25 * i;
                } else {
                    ++j;
                    k = k - 25 * j;
                    l += 26;
                }
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                float f = 1.0F;
                if (potioneffect.getIsAmbient()) {
                    this.drawTexturedModalRect(k, l, 165, 166, 24, 24);
                } else {
                    this.drawTexturedModalRect(k, l, 141, 166, 24, 24);
                    if (potioneffect.getDuration() <= 200) {
                        int j1 = 10 - potioneffect.getDuration() / 20;
                        f = MathHelper.clamp((float) potioneffect.getDuration() / 10.0F / 5.0F * 0.5F, 0.0F, 0.5F) + MathHelper.cos((float) potioneffect.getDuration() * (float) Math.PI / 5.0F) * MathHelper.clamp((float) j1 / 10.0F * 0.25F, 0.0F, 0.25F);
                    }
                }
                GlStateManager.color(1.0F, 1.0F, 1.0F, f);
                // FORGE - Move status icon check down from above so renderHUDEffect will still be called without a status icon
                if (potion.hasStatusIcon())
                    this.drawTexturedModalRect(k + 3, l + 3, i1 % 8 * 18, 198 + i1 / 8 * 18, 18, 18);
                potion.renderHUDEffect(k, l, potioneffect, mc, f);
            }
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) Potion(net.minecraft.potion.Potion) Minecraft(net.minecraft.client.Minecraft) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

Potion (net.minecraft.potion.Potion)32 PotionEffect (net.minecraft.potion.PotionEffect)18 AttributeModifier (net.minecraft.entity.ai.attributes.AttributeModifier)3 IAttribute (net.minecraft.entity.ai.attributes.IAttribute)3 ItemStack (net.minecraft.item.ItemStack)3 Tuple (net.minecraft.util.Tuple)3 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)3 Field (java.lang.reflect.Field)2 Optional (java.util.Optional)2 Minecraft (net.minecraft.client.Minecraft)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 Item (net.minecraft.item.Item)2 PotionType (net.minecraft.potion.PotionType)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 BlockPos (net.minecraft.util.math.BlockPos)2 PotionEffectType (org.spongepowered.api.effect.potion.PotionEffectType)2 AMVector2 (am2.api.math.AMVector2)1 InventoryBaubles (baubles.common.container.InventoryBaubles)1 ChemthrowerEffect_Damage (blusunrize.immersiveengineering.api.tool.ChemthrowerHandler.ChemthrowerEffect_Damage)1