Search in sources :

Example 6 with Potion

use of net.minecraft.potion.Potion in project SpongeCommon by SpongePowered.

the class BeaconDataProcessor method set.

@SuppressWarnings("unchecked")
@Override
protected boolean set(TileEntityBeacon dataHolder, Map<Key<?>, Object> keyValues) {
    Potion primary = ((Optional<Potion>) keyValues.get(Keys.BEACON_PRIMARY_EFFECT)).orElse(null);
    Potion secondary = ((Optional<Potion>) keyValues.get(Keys.BEACON_SECONDARY_EFFECT)).orElse(null);
    ((IMixinTileEntityBeacon) dataHolder).forceSetPrimaryEffect(primary);
    ((IMixinTileEntityBeacon) dataHolder).forceSetSecondaryEffect(secondary);
    dataHolder.markDirty();
    return true;
}
Also used : Optional(java.util.Optional) Potion(net.minecraft.potion.Potion) IMixinTileEntityBeacon(org.spongepowered.common.interfaces.IMixinTileEntityBeacon)

Example 7 with Potion

use of net.minecraft.potion.Potion in project SpongeCommon by SpongePowered.

the class PotionEffectTypeRegistryModule method registerDefaults.

@Override
public void registerDefaults() {
    for (Potion potion : Potion.REGISTRY) {
        if (potion != null) {
            PotionEffectType potionEffectType = (PotionEffectType) potion;
            this.potionList.add(potionEffectType);
            this.potionEffectTypeMap.put(Potion.REGISTRY.getNameForObject(potion).toString(), potionEffectType);
        }
    }
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffectType(org.spongepowered.api.effect.potion.PotionEffectType)

Example 8 with Potion

use of net.minecraft.potion.Potion in project Random-Things by lumien231.

the class GuiPotionVaporizer method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    super.drawGuiContainerForegroundLayer(mouseX, mouseY);
    fontRenderer.drawString(I18n.format("tile.potionVaporizer.name", new Object[0]), 8, 6, 4210752);
    // Draw Active Potion
    int guiMouseX = mouseX - guiLeft;
    int guiMouseY = mouseY - guiTop;
    if (guiMouseX > 79 && guiMouseX < 96 && guiMouseY > 16 && guiMouseY < 33) {
        ContainerPotionVaporizer container = (ContainerPotionVaporizer) inventorySlots;
        if (container.duration != 0 && container.potionID >= 0) {
            int i = mouseX - guiLeft, j = mouseY - guiTop;
            Potion potion = Potion.getPotionById(container.potionID);
            if (potion != null) {
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                this.mc.getTextureManager().bindTexture(INVENTORY_BACKGROUND);
                this.drawTexturedModalRect(i, j, 0, 166, 140, 32);
                if (potion.hasStatusIcon()) {
                    int l = potion.getStatusIconIndex();
                    this.drawTexturedModalRect(i + 6, j + 7, 0 + l % 8 * 18, 198 + l / 8 * 18, 18, 18);
                }
                potion.renderInventoryEffect(i, j, new PotionEffect(potion, container.durationLeft), mc);
                String s1 = I18n.format(potion.getName(), new Object[0]);
                int amplifier = container.amplifier;
                if (amplifier == 1) {
                    s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]);
                } else if (amplifier == 2) {
                    s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]);
                } else if (amplifier == 3) {
                    s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]);
                }
                this.fontRenderer.drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215);
                String s = StringUtils.ticksToElapsedTime(container.durationLeft);
                this.fontRenderer.drawStringWithShadow(s, i + 10 + 18, j + 6 + 10, 8355711);
            }
        }
    }
}
Also used : ContainerPotionVaporizer(lumien.randomthings.container.ContainerPotionVaporizer) Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect)

Example 9 with Potion

use of net.minecraft.potion.Potion in project takumicraft by TNTModders.

the class EntitySpiderCreeper method onInitialSpawn.

/**
 * Called only once on an entity when first time spawned, via egg, mob spawner, natural spawning etc, but not called
 * when entity is reloaded from nbt. Mainly used for initializing attributes and inventory
 */
@Override
@Nullable
public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, @Nullable IEntityLivingData livingdata) {
    livingdata = super.onInitialSpawn(difficulty, livingdata);
    if (this.world.rand.nextInt(100) == 0) {
        EntitySkeleton entityskeleton = new EntitySkeleton(this.world);
        entityskeleton.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
        entityskeleton.onInitialSpawn(difficulty, null);
        this.world.spawnEntity(entityskeleton);
        entityskeleton.startRiding(this);
    }
    if (livingdata == null) {
        livingdata = new GroupData();
        if (this.world.getDifficulty() == EnumDifficulty.HARD && this.world.rand.nextFloat() < 0.1F * difficulty.getClampedAdditionalDifficulty()) {
            ((GroupData) livingdata).setRandomEffect(this.world.rand);
        }
    }
    if (livingdata instanceof GroupData) {
        Potion potion = ((GroupData) livingdata).effect;
        if (potion != null) {
            this.addPotionEffect(new PotionEffect(potion, Integer.MAX_VALUE));
        }
    }
    return livingdata;
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect) EntitySkeleton(net.minecraft.entity.monster.EntitySkeleton) Nullable(javax.annotation.Nullable)

Example 10 with Potion

use of net.minecraft.potion.Potion in project KalStuff by TEAMModding.

the class ItemDrink method addEffects.

protected void addEffects(ItemStack stack, World worldIn, EntityPlayer player) {
    if (!worldIn.isRemote && this.potionLength != 0) {
        for (Potion p : this.potions) {
            try {
                player.addPotionEffect(new PotionEffect(p, ((this.potionLength / (this.getMaxDamage(stack) + 1)) + player.getActivePotionEffect(p).getDuration()), 0));
            } catch (NullPointerException e) {
                player.addPotionEffect(new PotionEffect(p, (this.potionLength / (this.getMaxDamage(stack) + 1)), 0));
            }
            if (player.getActivePotionEffect(p).getDuration() > 7200) {
                player.removePotionEffect(p);
                player.addPotionEffect(new PotionEffect(p, 7200, 0));
            }
        }
    }
}
Also used : Potion(net.minecraft.potion.Potion) PotionEffect(net.minecraft.potion.PotionEffect)

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