Java 类net.minecraft.potion.PotionType 实例源码

项目:Backmemed    文件:EntityPotion.java   
private void func_190542_a(ItemStack p_190542_1_, PotionType p_190542_2_)
{
    EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
    entityareaeffectcloud.setOwner(this.getThrower());
    entityareaeffectcloud.setRadius(3.0F);
    entityareaeffectcloud.setRadiusOnUse(-0.5F);
    entityareaeffectcloud.setWaitTime(10);
    entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float)entityareaeffectcloud.getDuration());
    entityareaeffectcloud.setPotion(p_190542_2_);

    for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromItem(p_190542_1_))
    {
        entityareaeffectcloud.addEffect(new PotionEffect(potioneffect));
    }

    NBTTagCompound nbttagcompound = p_190542_1_.getTagCompound();

    if (nbttagcompound != null && nbttagcompound.hasKey("CustomPotionColor", 99))
    {
        entityareaeffectcloud.setColor(nbttagcompound.getInteger("CustomPotionColor"));
    }

    this.world.spawnEntityInWorld(entityareaeffectcloud);
}
项目:Backmemed    文件:Bootstrap.java   
/**
 * Registers blocks, items, stats, etc.
 */
public static void register()
{
    if (!alreadyRegistered)
    {
        alreadyRegistered = true;
        redirectOutputToLog();
        SoundEvent.registerSounds();
        Block.registerBlocks();
        BlockFire.init();
        Potion.registerPotions();
        Enchantment.registerEnchantments();
        Item.registerItems();
        PotionType.registerPotionTypes();
        PotionHelper.init();
        EntityList.init();
        StatList.init();
        Biome.registerBiomes();
        registerDispenserBehaviors();
    }
}
项目:CustomWorldGen    文件:GameData.java   
public GameData()
{
    iBlockRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BLOCKS, Block.class, new ResourceLocation("minecraft:air"), MIN_BLOCK_ID, MAX_BLOCK_ID, true, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE, BlockCallbacks.INSTANCE);
    iItemRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ITEMS, Item.class, null, MIN_ITEM_ID, MAX_ITEM_ID, true, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE, ItemCallbacks.INSTANCE);
    iPotionRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONS, Potion.class, null, MIN_POTION_ID, MAX_POTION_ID, false, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, PotionCallbacks.INSTANCE, null);
    iBiomeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.BIOMES, Biome.class, null, MIN_BIOME_ID, MAX_BIOME_ID, false, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, BiomeCallbacks.INSTANCE, null);
    iSoundEventRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.SOUNDEVENTS, SoundEvent.class, null, MIN_SOUND_ID, MAX_SOUND_ID, false, null, null, null, null);
    ResourceLocation WATER = new ResourceLocation("water");
    iPotionTypeRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.POTIONTYPES, PotionType.class, WATER, MIN_POTIONTYPE_ID, MAX_POTIONTYPE_ID, false, null, null, null, null);
    iEnchantmentRegistry = PersistentRegistryManager.createRegistry(PersistentRegistryManager.ENCHANTMENTS, Enchantment.class, null, MIN_ENCHANTMENT_ID, MAX_ENCHANTMENT_ID, false, null, null, null, null);

    try
    {
        blockField = FinalFieldHelper.makeWritable(ReflectionHelper.findField(ItemBlock.class, "block", "field_150939" + "_a"));
    }
    catch (Exception e)
    {
        FMLLog.log(Level.FATAL, e, "Cannot access the 'block' field from ItemBlock, this is fatal!");
        throw Throwables.propagate(e);
    }
}
项目:CustomWorldGen    文件:EntityTippedArrow.java   
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);

    if (this.potion != PotionTypes.EMPTY && this.potion != null)
    {
        compound.setString("Potion", ((ResourceLocation)PotionType.REGISTRY.getNameForObject(this.potion)).toString());
    }

    if (!this.customPotionEffects.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (PotionEffect potioneffect : this.customPotionEffects)
        {
            nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
        }

        compound.setTag("CustomPotionEffects", nbttaglist);
    }
}
项目:CustomWorldGen    文件:EntityAreaEffectCloud.java   
public void setPotion(PotionType potionIn)
{
    this.potion = potionIn;

    if (!this.colorSet)
    {
        if (potionIn == PotionTypes.EMPTY && this.effects.isEmpty())
        {
            this.getDataManager().set(COLOR, Integer.valueOf(0));
        }
        else
        {
            this.getDataManager().set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(potionIn, this.effects))));
        }
    }
}
项目:CustomWorldGen    文件:Bootstrap.java   
/**
 * Registers blocks, items, stats, etc.
 */
public static void register()
{
    if (!alreadyRegistered)
    {
        alreadyRegistered = true;

        if (LOGGER.isDebugEnabled())
        {
            redirectOutputToLog();
        }

        SoundEvent.registerSounds();
        Block.registerBlocks();
        BlockFire.init();
        Potion.registerPotions();
        Enchantment.registerEnchantments();
        Item.registerItems();
        PotionType.registerPotionTypes();
        PotionHelper.init();
        StatList.init();
        Biome.registerBiomes();
        registerDispenserBehaviors();
        net.minecraftforge.fml.common.registry.GameData.vanillaSnapshot();
    }
}
项目:ToroQuest    文件:EntityMage.java   
protected void handleAttackLogicUpdate() {
    PotionType potiontype = null;

    if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.WATER) && !this.isPotionActive(MobEffects.WATER_BREATHING)) {
        potiontype = PotionTypes.WATER_BREATHING;
    } else if (this.rand.nextFloat() < 0.15F && this.isBurning() && !this.isPotionActive(MobEffects.FIRE_RESISTANCE)) {
        potiontype = PotionTypes.FIRE_RESISTANCE;
    } else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth()) {
        potiontype = PotionTypes.HEALING;
    } else if (this.rand.nextFloat() < 0.5F && this.getAttackTarget() != null && !this.isPotionActive(MobEffects.SPEED)
            && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D) {
        potiontype = PotionTypes.SWIFTNESS;
    }

    if (potiontype != null) {
        this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F,
                0.8F + this.rand.nextFloat() * 0.4F);
        this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
        this.attackTimer = 10;
        this.setAggressive(true);
        IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
        iattributeinstance.removeModifier(MODIFIER);
        iattributeinstance.applyModifier(MODIFIER);
    }
}
项目:ToroQuest    文件:EntityMage.java   
protected void attackWithPotion(EntityLivingBase target) {
    double targetY = target.posY + (double) target.getEyeHeight() - 1.100000023841858D;
    double targetX = target.posX + target.motionX - this.posX;
    double d2 = targetY - this.posY;
    double targetZ = target.posZ + target.motionZ - this.posZ;

    float f = MathHelper.sqrt(targetX * targetX + targetZ * targetZ);
    PotionType potiontype = PotionTypes.HARMING;

    if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS)) {
        potiontype = PotionTypes.SLOWNESS;
    } else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON)) {
        potiontype = PotionTypes.POISON;
    } else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F) {
        potiontype = PotionTypes.WEAKNESS;
    }

    EntityPotion entitypotion = new EntityPotion(this.world, this,
            PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
    entitypotion.rotationPitch -= -20.0F;
    entitypotion.setThrowableHeading(targetX, d2 + (double) (f * 0.2F), targetZ, 0.75F, 8.0F);

    this.world.playSound((EntityPlayer) null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F,
            0.8F + this.rand.nextFloat() * 0.4F);
    this.world.spawnEntity(entitypotion);
}
项目:Gravestone-mod-Extended    文件:GSPotion.java   
@SubscribeEvent
public static void registerPotionTypes(final RegistryEvent.Register<PotionType> event) {
    event.getRegistry().registerAll(PURIFICATION_TYPE, RUST_TYPE, BONE_SKIN_TYPE, RECALL_TYPE, BURNING_TYPE, BLEEDING_TYPE,
            INFERNO_TYPE);
    event.getRegistry().registerAll(HUNGER_TYPE, BLINDNESS_TYPE, NAUSEA_TYPE, RESISTANCE_TYPE, LEVITATION_TYPE);

    PotionHelper.addMix(PotionTypes.AWKWARD, GSItem.TOXIC_SLIME, RUST_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.GOLDEN_KOI.ordinal())), PURIFICATION_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BONE_FISH.ordinal())), BONE_SKIN_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.SPECULAR_FISH.ordinal())), RECALL_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.MAGMA_JELLYFISH.ordinal())), BURNING_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.PIRANHA.ordinal())), BLEEDING_TYPE);
    PotionHelper.addMix(BURNING_TYPE, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.FLAREFIN_KOI.ordinal())), INFERNO_TYPE);

    // vanilla potions
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(Items.FISH, 1, 2)), PotionType.getPotionTypeForName("luck"));
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(Items.ROTTEN_FLESH, 1)), HUNGER_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.BLUE_JELLYFISH.ordinal())), NAUSEA_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.SPOOKYFIN.ordinal())), BLINDNESS_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.CAVEFISH.ordinal())), RESISTANCE_TYPE);
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(GSItem.FISH, 1, ItemFish.EnumFishType.CHORUS_KOI.ordinal())), LEVITATION_TYPE);
}
项目:SeasonsAPI    文件:SeasonPotion.java   
private static void registerUpgrades(PotionType normal, PotionType extended, PotionType strong) {
    BrewingRecipeRegistry.addRecipe(createBrewingRecipe(normal, new ItemStack(Items.REDSTONE), extended));
    BrewingRecipeRegistry.addRecipe(createBrewingRecipe(strong, new ItemStack(Items.REDSTONE), extended));
    BrewingRecipeRegistry.addRecipe(createBrewingRecipe(normal, new ItemStack(Items.GLOWSTONE_DUST), strong));      
    BrewingRecipeRegistry.addRecipe(createBrewingRecipe(extended, new ItemStack(Items.GLOWSTONE_DUST), strong));    
    BrewingRecipeRegistry.addRecipe(createSplashBrewingRecipe(normal, new ItemStack(Items.REDSTONE), extended));
    BrewingRecipeRegistry.addRecipe(createSplashBrewingRecipe(strong, new ItemStack(Items.REDSTONE), extended));
    BrewingRecipeRegistry.addRecipe(createSplashBrewingRecipe(normal, new ItemStack(Items.GLOWSTONE_DUST), strong));        
    BrewingRecipeRegistry.addRecipe(createSplashBrewingRecipe(extended, new ItemStack(Items.GLOWSTONE_DUST), strong));  
    BrewingRecipeRegistry.addRecipe(createLingeringBrewingRecipe(normal, new ItemStack(Items.REDSTONE), extended));
    BrewingRecipeRegistry.addRecipe(createLingeringBrewingRecipe(strong, new ItemStack(Items.REDSTONE), extended));
    BrewingRecipeRegistry.addRecipe(createLingeringBrewingRecipe(normal, new ItemStack(Items.GLOWSTONE_DUST), strong)); 
    BrewingRecipeRegistry.addRecipe(createLingeringBrewingRecipe(extended, new ItemStack(Items.GLOWSTONE_DUST), strong));   
    BrewingRecipeRegistry.addRecipe(new BrewingRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), normal), new ItemStack(Items.GUNPOWDER), (PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), normal))));
    BrewingRecipeRegistry.addRecipe(new BrewingRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), normal), new ItemStack(Items.DRAGON_BREATH), (PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), normal))));
}
项目:ARKCraft    文件:EntityArkArrow.java   
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);

    if (this.potion != PotionTypes.EMPTY && this.potion != null)
    {
        compound.setString("Potion", ((ResourceLocation)PotionType.REGISTRY.getNameForObject(this.potion)).toString());
    }

    if (!this.customPotionEffects.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (PotionEffect potioneffect : this.customPotionEffects)
        {
            nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
        }

        compound.setTag("CustomPotionEffects", nbttaglist);
    }
}
项目:Cyclic    文件:PotionTypeRegistry.java   
@SubscribeEvent
public static void onRegistryEvent(RegistryEvent.Register<PotionType> event) {
  PotionTypeRegistry.register();
  for (PotionTypeCyclic pt : potions) {
    event.getRegistry().register(pt);
    pt.addMix();
  }
  //    //    PotionHelper.addMix(PotionTypes.AWKWARD, Items.APPLE,PotionTypes.THICK);
  //    PotionHelper.addMix(PotionTypes.AWKWARD, Items.APPLE, potionTypeSlowfall);
  //    RecipeRegistry.addShapedOreRecipe(
  //
  //        BrewingRecipeRegistry.addRecipe(
  //            PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.AWKWARD), 
  //            new ItemStack(Items.APPLE), 
  //            PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypeRegistry.potionTypeSlowfall))
  //        
  //        );
}
项目:ExpandedRailsMod    文件:EntityTippedArrow.java   
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);

    if (this.potion != PotionTypes.EMPTY && this.potion != null)
    {
        compound.setString("Potion", ((ResourceLocation)PotionType.REGISTRY.getNameForObject(this.potion)).toString());
    }

    if (!this.customPotionEffects.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (PotionEffect potioneffect : this.customPotionEffects)
        {
            nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
        }

        compound.setTag("CustomPotionEffects", nbttaglist);
    }
}
项目:ExpandedRailsMod    文件:EntityAreaEffectCloud.java   
public void setPotion(PotionType potionIn)
{
    this.potion = potionIn;

    if (!this.colorSet)
    {
        if (potionIn == PotionTypes.EMPTY && this.effects.isEmpty())
        {
            this.getDataManager().set(COLOR, Integer.valueOf(0));
        }
        else
        {
            this.getDataManager().set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(potionIn, this.effects))));
        }
    }
}
项目:ExpandedRailsMod    文件:Bootstrap.java   
/**
 * Registers blocks, items, stats, etc.
 */
public static void register()
{
    if (!alreadyRegistered)
    {
        alreadyRegistered = true;

        if (LOGGER.isDebugEnabled())
        {
            redirectOutputToLog();
        }

        SoundEvent.registerSounds();
        Block.registerBlocks();
        BlockFire.init();
        Potion.registerPotions();
        Enchantment.registerEnchantments();
        Item.registerItems();
        PotionType.registerPotionTypes();
        PotionHelper.init();
        StatList.init();
        Biome.registerBiomes();
        registerDispenserBehaviors();
        net.minecraftforge.fml.common.registry.GameData.vanillaSnapshot();
    }
}
项目:genera    文件:BlockAltar.java   
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
                                EnumFacing side, float hitX, float hitY, float hitZ) {
    ItemStack handStack = player.getHeldItem(hand);
    if (handStack.getItem() == GeneraItems.ItemGlassJar &&
            handStack.getMetadata() == 1) {
        NBTTagCompound nbt = handStack.getTagCompound();
        if (nbt == null) return false;
        PotionType potion;
        player.getEntityData().setInteger("genera.sacrifices_made", player.getEntityData().getInteger("genera.sacrifices_made") + 1);
        switch (nbt.getInteger("type")) {
            case 0:
                potion = PotionType.getPotionTypeForName("regeneration");
                if (potion == null) return false;
                player.setHeldItem(hand, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potion));
                return false;
            case 1:
                potion = PotionType.getPotionTypeForName("night_vision");
                if (potion == null) return false;
                player.setHeldItem(hand, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potion));
                return false;
            case 2:
                potion = PotionType.getPotionTypeForName("leaping");
                if (potion == null) return false;
                player.setHeldItem(hand, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potion));
                return false;
        }
    }
    return false;
}
项目:Backmemed    文件:EntityTippedArrow.java   
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);

    if (this.potion != PotionTypes.EMPTY && this.potion != null)
    {
        compound.setString("Potion", ((ResourceLocation)PotionType.REGISTRY.getNameForObject(this.potion)).toString());
    }

    if (this.field_191509_at)
    {
        compound.setInteger("Color", this.getColor());
    }

    if (!this.customPotionEffects.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (PotionEffect potioneffect : this.customPotionEffects)
        {
            nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
        }

        compound.setTag("CustomPotionEffects", nbttaglist);
    }
}
项目:Backmemed    文件:EntityWitch.java   
/**
 * Attack the specified entity using a ranged attack.
 *  
 * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
    if (!this.isDrinkingPotion())
    {
        double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
        double d1 = target.posX + target.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = target.posZ + target.motionZ - this.posZ;
        float f = MathHelper.sqrt(d1 * d1 + d3 * d3);
        PotionType potiontype = PotionTypes.HARMING;

        if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
        {
            potiontype = PotionTypes.SLOWNESS;
        }
        else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
        {
            potiontype = PotionTypes.POISON;
        }
        else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
        {
            potiontype = PotionTypes.WEAKNESS;
        }

        EntityPotion entitypotion = new EntityPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        entitypotion.rotationPitch -= -20.0F;
        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
        this.world.spawnEntityInWorld(entitypotion);
    }
}
项目:Backmemed    文件:EntityAreaEffectCloud.java   
public void setPotion(PotionType potionIn)
{
    this.potion = potionIn;

    if (!this.colorSet)
    {
        this.func_190618_C();
    }
}
项目:Backmemed    文件:PotionTypes.java   
private static PotionType getRegisteredPotionType(String id)
{
    PotionType potiontype = (PotionType)PotionType.REGISTRY.getObject(new ResourceLocation(id));

    if (!CACHE.add(potiontype))
    {
        throw new IllegalStateException("Invalid Potion requested: " + id);
    }
    else
    {
        return potiontype;
    }
}
项目:Backmemed    文件:ItemPotion.java   
/**
 * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
 */
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems)
{
    for (PotionType potiontype : PotionType.REGISTRY)
    {
        if (potiontype != PotionTypes.EMPTY)
        {
            subItems.add(PotionUtils.addPotionToItemStack(new ItemStack(itemIn), potiontype));
        }
    }
}
项目:Backmemed    文件:ItemTippedArrow.java   
/**
 * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
 */
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems)
{
    for (PotionType potiontype : PotionType.REGISTRY)
    {
        if (!potiontype.getEffects().isEmpty())
        {
            subItems.add(PotionUtils.addPotionToItemStack(new ItemStack(itemIn), potiontype));
        }
    }
}
项目:Backmemed    文件:ContainerBrewingStand.java   
public ItemStack func_190901_a(EntityPlayer p_190901_1_, ItemStack p_190901_2_)
{
    PotionType potiontype = PotionUtils.getPotionFromItem(p_190901_2_);

    if (potiontype != PotionTypes.WATER && potiontype != PotionTypes.EMPTY)
    {
        this.player.addStat(AchievementList.POTION);
    }

    super.func_190901_a(p_190901_1_, p_190901_2_);
    return p_190901_2_;
}
项目:CustomWorldGen    文件:EntityWitch.java   
/**
 * Attack the specified entity using a ranged attack.
 *  
 * @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
    if (!this.isDrinkingPotion())
    {
        double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
        double d1 = target.posX + target.motionX - this.posX;
        double d2 = d0 - this.posY;
        double d3 = target.posZ + target.motionZ - this.posZ;
        float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);
        PotionType potiontype = PotionTypes.HARMING;

        if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
        {
            potiontype = PotionTypes.SLOWNESS;
        }
        else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
        {
            potiontype = PotionTypes.POISON;
        }
        else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
        {
            potiontype = PotionTypes.WEAKNESS;
        }

        EntityPotion entitypotion = new EntityPotion(this.worldObj, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        entitypotion.rotationPitch -= -20.0F;
        entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
        this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
        this.worldObj.spawnEntityInWorld(entitypotion);
    }
}
项目:CustomWorldGen    文件:PotionTypes.java   
private static PotionType getRegisteredPotionType(String id)
{
    PotionType potiontype = (PotionType)PotionType.REGISTRY.getObject(new ResourceLocation(id));

    if (!CACHE.add(potiontype))
    {
        throw new IllegalStateException("Invalid Potion requested: " + id);
    }
    else
    {
        return potiontype;
    }
}
项目:CustomWorldGen    文件:ItemPotion.java   
/**
 * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
 */
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems)
{
    for (PotionType potiontype : PotionType.REGISTRY)
    {
        subItems.add(PotionUtils.addPotionToItemStack(new ItemStack(itemIn), potiontype));
    }
}
项目:CustomWorldGen    文件:ItemTippedArrow.java   
/**
 * returns a list of items with the same ID, but different meta (eg: dye returns 16 items)
 */
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems)
{
    for (PotionType potiontype : PotionType.REGISTRY)
    {
        subItems.add(PotionUtils.addPotionToItemStack(new ItemStack(itemIn), potiontype));
    }
}
项目:CrystalMod    文件:EntityDart.java   
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
@Override
public void writeEntityToNBT(NBTTagCompound compound)
{
    super.writeEntityToNBT(compound);
    compound.setInteger("Type", getType().getMetadata());

    if (this.potion != PotionTypes.EMPTY && this.potion != null)
    {
        compound.setString("Potion", ((ResourceLocation)PotionType.REGISTRY.getNameForObject(this.potion)).toString());
        if (this.hasColor)
        {
            compound.setInteger("Color", this.getColor());
        }

        if (!this.customPotionEffects.isEmpty())
        {
            NBTTagList nbttaglist = new NBTTagList();

            for (PotionEffect potioneffect : this.customPotionEffects)
            {
                nbttaglist.appendTag(potioneffect.writeCustomPotionEffectToNBT(new NBTTagCompound()));
            }

            compound.setTag("CustomPotionEffects", nbttaglist);
        }
    }
}
项目:CrystalMod    文件:RenderTileJar.java   
public static Vector3f getColorFromPotion(PotionType type){
    if (type.getEffects().isEmpty())
    {
        return null;
    }
    else
    {
        float f = 0.0F;
        float f1 = 0.0F;
        float f2 = 0.0F;
        int j = 0;

        for (PotionEffect potioneffect : type.getEffects())
        {
            if (potioneffect.doesShowParticles())
            {
                int k = potioneffect.getPotion().getLiquidColor();
                int l = potioneffect.getAmplifier() + 1;
                f += l * (k >> 16 & 255) / 255.0F;
                f1 += l * (k >> 8 & 255) / 255.0F;
                f2 += l * (k >> 0 & 255) / 255.0F;
                j += l;
            }
        }

        if (j == 0)
        {
            return new Vector3f(0, 0, 0);
        }
        else
        {
            f = f / j * 255.0F;
            f1 = f1 / j * 255.0F;
            f2 = f2 / j * 255.0F;
            return new Vector3f(f, f1, f2);
        }
    }
}
项目:ToroQuest    文件:TQPotionTypes.java   
private static PotionType createPotionType(PotionEffect potionEffect, @Nullable String namePrefix) {
    final ResourceLocation potionName = potionEffect.getPotion().getRegistryName();

    final ResourceLocation potionTypeName;
    if (namePrefix != null) {
        potionTypeName = new ResourceLocation(potionName.getResourceDomain(), namePrefix + potionName.getResourcePath());
    } else {
        potionTypeName = potionName;
    }

    return new PotionType(potionName.toString(), potionEffect).setRegistryName(potionTypeName);
}
项目:AquaRegia    文件:ModPotionTypes.java   
/**
 * Create a {@link PotionType} from the specified {@link PotionEffect}
 * <p>
 * Uses the {@link Potion}'s registry name as the {@link PotionType}'s registry name (with an optional prefix) and name (with no prefix).
 *
 * @param potionEffect The PotionEffect
 * @param namePrefix   The name prefix, if any
 * @return The PotionType
 */
private static PotionType createPotionType(PotionEffect potionEffect, @Nullable String namePrefix) {
    final ResourceLocation potionName = potionEffect.getPotion().getRegistryName();

    final ResourceLocation potionTypeName;
    if (namePrefix != null) {
        potionTypeName = new ResourceLocation(potionName.getResourceDomain(), namePrefix + potionName.getResourcePath());
    } else {
        potionTypeName = potionName;
    }

    return GameRegistry.register(new PotionType(potionName.toString(), potionEffect).setRegistryName(potionTypeName));
}
项目:Gravestone-mod-Extended    文件:GSEventsHandler.java   
@SubscribeEvent(priority = EventPriority.HIGH)
public void onProjectileImpact(ProjectileImpactEvent.Throwable event) {
    if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
        if (event.getThrowable() instanceof EntityPotion) {
            EntityPotion entityPotion = (EntityPotion) event.getThrowable();
            PotionType potionType = PotionUtils.getPotionFromItem(entityPotion.getPotion());

            if (potionType == GSPotion.PURIFICATION_TYPE) {
                PotionPurification.applyPotionOnBlocks(entityPotion);
            }
        }
    }
}
项目:GuideBook    文件:RecipeHandlerCrafting.java   
public void addTippedArrowRecipes(ArrayList<DrawableRecipe> list) {
    ItemStack arrow = new ItemStack(Items.ARROW);

    for (PotionType type : PotionType.REGISTRY) {
        ItemStack input = new ItemStack(Items.LINGERING_POTION);
        PotionUtils.addPotionToItemStack(input, type);

        ItemStack output = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.addPotionToItemStack(output, type);

        list.add(new DrawableRecipeCrafting(output, new ItemStack[]{arrow, arrow, arrow, arrow, input, arrow, arrow, arrow, arrow}, 3));
    }
}
项目:GuideBook    文件:RecipeHandlerBrewing.java   
private List<ItemStack> getNewPotions(ArrayList<ItemStack> knownPotions, ArrayList<ItemStack> potionIngredients, ArrayList<DrawableRecipe> recipes) {
    List<ItemStack> newPotions = new ArrayList<ItemStack>();
    for (ItemStack potionInput : knownPotions) {
        for (ItemStack potionIngredient : potionIngredients) {
            ItemStack potionOutput = PotionHelper.doReaction(potionIngredient, potionInput.copy());
            if (potionOutput == null) {
                continue;
            }

            if (potionInput.getItem() == potionOutput.getItem()) {
                PotionType potionOutputType = PotionUtils.getPotionFromItem(potionOutput);
                if (potionOutputType == PotionTypes.WATER)
                {
                    continue;
                }

                PotionType potionInputType = PotionUtils.getPotionFromItem(potionInput);
                int inputId = PotionType.REGISTRY.getIDForObject(potionInputType);
                int outputId = PotionType.REGISTRY.getIDForObject(potionOutputType);
                if (inputId == outputId)
                {
                    continue;
                }
            }

            DrawableRecipeBrewing recipe = new DrawableRecipeBrewing(potionInput, potionIngredient, potionOutput);
            if (!containsRecipe(recipe, recipes)) {
                recipes.add(recipe);
                newPotions.add(potionOutput);
            }
        }
    }
    return newPotions;
}
项目:Alchemy    文件:Dump.java   
public static void init() throws IOException {
    if (!dump_dir.isDirectory())
        dump_dir.mkdirs();
    dumpFile(Item.REGISTRY, "item");
    dumpFile(Block.REGISTRY, "block");
    dumpFile(Potion.REGISTRY, "potion");
    dumpFile(Biome.REGISTRY, "biome");
    dumpFile(Enchantment.REGISTRY, "enchantment");
    dumpFile(PotionType.REGISTRY, "potiontype");
    dumpFile(SoundEvent.REGISTRY, "soundevent");
}
项目:Alchemy    文件:DLang.java   
public static void init(PotionType potion) {
    String name = getName(potion.getNamePrefixed("."));
    potionMap.put(potion.getNamePrefixed("potion.effect."), name);
    potionMap.put(potion.getNamePrefixed("splash_potion.effect."), name);
    potionMap.put(potion.getNamePrefixed("lingering_potion.effect."), name);
    potionMap.put(potion.getNamePrefixed("tipped_arrow.effect."), name);
}
项目:LightningCraft    文件:LCPotions.java   
/** Register custom potions */
private static void registerPotions() {

    // register the demon friend potion with two types
    demonFriend = new PotionCustom("demonFriend", false, new Color(255,255,0).getRGB()).setPotionName("potion.demonFriend");
    GameRegistry.register(demonFriend);
    demonFriendNormal = new PotionType(new PotionEffect(demonFriend, demonFriendTicks));
    demonFriendExtended = new PotionType(new PotionEffect(demonFriend, demonFriendExtTicks));
    GameRegistry.register(demonFriendNormal.setRegistryName("demonFriendNormal"));
    GameRegistry.register(demonFriendExtended.setRegistryName("demonFriendExtended"));
}
项目:NotEnoughItems    文件:NEIInitialization.java   
public static void loadPotionSubsets() {
    ArrayList<ItemStack> allPotions = new ArrayList<>();
    for (IPotionRecipe recipe : PotionRecipeHelper.getRecipes()) {
        allPotions.add(recipe.getRecipeOutput());
    }

    ItemStackSet positiveEffects = new ItemStackSet();
    ItemStackSet negativeEffects = new ItemStackSet();
    ItemStackSet neutralEffects = new ItemStackSet();
    for (ItemStack potionStack : allPotions) {
        PotionType potionType = PotionRecipeHelper.getPotionTypeFromStack(potionStack);
        if (potionType == null) {
            continue;
        }
        List<PotionEffect> stackEffects = potionType.getEffects();
        if (stackEffects.isEmpty()) {
            neutralEffects.add(potionStack);
            continue;
        }
        for (PotionEffect effect : stackEffects) {
            //If for some reason a vanilla potion has positive and negative effects, make sure we don't add it to the list more than once.
            if (effect.getPotion().isBadEffect()) {
                if (!negativeEffects.contains(potionStack)) {
                    negativeEffects.add(potionStack);
                }
            } else {
                if (!positiveEffects.contains(potionStack)) {
                    positiveEffects.add(potionStack);
                }
            }
        }
    }

    API.addSubset("Items.Potions", new ItemStackSet().with(Items.POTIONITEM).with(Items.SPLASH_POTION).with(Items.LINGERING_POTION));
    API.addSubset("Items.Potions.Splash", new ItemStackSet().with(Items.SPLASH_POTION));
    API.addSubset("Items.Potions.Lingering", new ItemStackSet().with(Items.LINGERING_POTION));
    API.addSubset("Items.Potions.Positive", positiveEffects);
    API.addSubset("Items.Potions.Negative", negativeEffects);
    API.addSubset("Items.Potions.Neutral", neutralEffects);
}
项目:NotEnoughItems    文件:PotionRecipeHelper.java   
public static PotionType getPotionTypeFromStack(ItemStack itemStack) {
    if (itemStack.hasTagCompound()) {
        NBTTagCompound tagCompound = itemStack.getTagCompound();
        if (tagCompound.hasKey("Potion")) {
            String potion = tagCompound.getString("Potion");
            PotionType type = PotionType.getPotionTypeForName(potion);
            if (type != null) {
                return type;
            }
        }
    }
    return null;
}
项目:UniversalCoins    文件:UCItemPricer.java   
private void updatePotions() {
    for (PotionType potiontype : PotionType.REGISTRY) {
        String potionName = potiontype.getRegistryName().toString();
        if (!ucPriceMap.containsKey(potionName)) {
            ucPriceMap.put(potionName, -1);
        }
    }
}