當前位置: 首頁>>代碼示例>>Java>>正文


Java PotionUtils.getPotionFromItem方法代碼示例

本文整理匯總了Java中net.minecraft.potion.PotionUtils.getPotionFromItem方法的典型用法代碼示例。如果您正苦於以下問題:Java PotionUtils.getPotionFromItem方法的具體用法?Java PotionUtils.getPotionFromItem怎麽用?Java PotionUtils.getPotionFromItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.potion.PotionUtils的用法示例。


在下文中一共展示了PotionUtils.getPotionFromItem方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: colorCoke

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
@SubscribeEvent
public void colorCoke(PotionBrewEvent.Post event){
	for(int i=0;i<event.getLength();i++){
		if(PotionUtils.getPotionFromItem(event.getItem(i))==COKE_COLA||
				PotionUtils.getPotionFromItem(event.getItem(i))==COKE_COLA_LONG||
				PotionUtils.getPotionFromItem(event.getItem(i))==COKE_COLA_STRONG){
			ItemStack brew=event.getItem(i).copy();
			brew.getTagCompound().setInteger("CustomPotionColor", 4738376);
			event.setItem(i, brew);
		}
	}
}
 
開發者ID:EnderiumSmith,項目名稱:CharcoalPit,代碼行數:13,代碼來源:PotionRegistry.java

示例2: setPotionEffect

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
public void setPotionEffect(ItemStack stack)
{
    if (stack.getItem() == Items.TIPPED_ARROW)
    {
        this.potion = PotionUtils.getPotionFromItem(stack);
        Collection<PotionEffect> collection = PotionUtils.getFullEffectsFromItem(stack);

        if (!collection.isEmpty())
        {
            for (PotionEffect potioneffect : collection)
            {
                this.customPotionEffects.add(new PotionEffect(potioneffect));
            }
        }

        int i = func_191508_b(stack);

        if (i == -1)
        {
            this.func_190548_o();
        }
        else
        {
            this.func_191507_d(i);
        }
    }
    else if (stack.getItem() == Items.ARROW)
    {
        this.potion = PotionTypes.EMPTY;
        this.customPotionEffects.clear();
        this.dataManager.set(COLOR, Integer.valueOf(-1));
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:34,代碼來源:EntityTippedArrow.java

示例3: func_190901_a

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
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_;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:13,代碼來源:ContainerBrewingStand.java

示例4: onPickupFromSlot

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
{
    if (PotionUtils.getPotionFromItem(stack) != PotionTypes.WATER)
    {
        net.minecraftforge.event.ForgeEventFactory.onPlayerBrewedPotion(playerIn, stack);
        this.player.addStat(AchievementList.POTION);
    }

    super.onPickupFromSlot(playerIn, stack);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:11,代碼來源:ContainerBrewingStand.java

示例5: setPotionEffect

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
public void setPotionEffect(ItemStack stack)
{
    if (stack.hasTagCompound() && ItemNBTHelper.verifyExistance(stack, "Potion"))
    {
        this.potion = PotionUtils.getPotionFromItem(stack);
        Collection<PotionEffect> collection = PotionUtils.getFullEffectsFromItem(stack);

        if (!collection.isEmpty())
        {
            for (PotionEffect potioneffect : collection)
            {
                this.customPotionEffects.add(new PotionEffect(potioneffect));
            }
        }

        int i = getCustomColor(stack);

        if (i == -1)
        {
            this.refreshColor();
        }
        else
        {
            this.setCustomColor(i);
        }
    }
    else
    {
        this.potion = PotionTypes.EMPTY;
        this.customPotionEffects.clear();
        this.dataManager.set(COLOR, Integer.valueOf(-1));
    }
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:34,代碼來源:EntityDart.java

示例6: onProjectileImpact

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
@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);
            }
        }
    }
}
 
開發者ID:NightKosh,項目名稱:Gravestone-mod-Extended,代碼行數:14,代碼來源:GSEventsHandler.java

示例7: getNewPotions

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
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;
}
 
開發者ID:Creysys,項目名稱:GuideBook,代碼行數:35,代碼來源:RecipeHandlerBrewing.java

示例8: onPickupFromSlot

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack)
{
    if (PotionUtils.getPotionFromItem(stack) != PotionTypes.WATER)
    {
        this.player.addStat(AchievementList.POTION);
    }

    super.onPickupFromSlot(playerIn, stack);
}
 
開發者ID:BlazeAxtrius,項目名稱:ExpandedRailsMod,代碼行數:10,代碼來源:ContainerBrewingStand.java

示例9: onImpact

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
/**
 * Called when this EntityThrowable hits a block or entity.
 */
protected void onImpact(RayTraceResult result)
{
    if (!this.world.isRemote)
    {
        ItemStack itemstack = this.getPotion();
        PotionType potiontype = PotionUtils.getPotionFromItem(itemstack);
        List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);
        boolean flag = potiontype == PotionTypes.WATER && list.isEmpty();

        if (result.typeOfHit == RayTraceResult.Type.BLOCK && flag)
        {
            BlockPos blockpos = result.getBlockPos().offset(result.sideHit);
            this.extinguishFires(blockpos);

            for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL)
            {
                this.extinguishFires(blockpos.offset(enumfacing));
            }
        }

        if (flag)
        {
            this.func_190545_n();
        }
        else if (!list.isEmpty())
        {
            if (this.isLingering())
            {
                this.func_190542_a(itemstack, potiontype);
            }
            else
            {
                this.func_190543_a(result, list);
            }
        }

        int i = potiontype.hasInstantEffect() ? 2007 : 2002;
        this.world.playEvent(i, new BlockPos(this), PotionUtils.func_190932_c(itemstack));
        this.setDead();
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:45,代碼來源:EntityPotion.java

示例10: onBlockActivated

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
   {
	TileEntity tile = world.getTileEntity(pos);
	if(tile == null || !(tile instanceof TileJar)) return false;
	TileJar jar = (TileJar)tile;
	ItemStack held = player.getHeldItem(hand);
	if(ItemStackTools.isValid(held)){
		if(held.getItem() == Items.SHULKER_SHELL && !jar.isShulkerLamp()){
			jar.setShulkerLamp(true);
			world.checkLightFor(EnumSkyBlock.BLOCK, pos);
			BlockUtil.markBlockForUpdate(world, pos);
			return true;
		}
		else if(held.getItem() == Items.ITEM_FRAME && facing.getAxis().isHorizontal()){
			if(!jar.hasLabel(facing)){
				jar.setHasLabel(facing, true);
				if(!player.capabilities.isCreativeMode){
					player.setHeldItem(hand, ItemUtil.consumeItem(held));
				}
				BlockUtil.markBlockForUpdate(world, pos);
				return true;
			}
		}
		else if(held.getItem() == Items.POTIONITEM){
			PotionType type = PotionUtils.getPotionFromItem(held);
			if(type.getEffects().size() > 0 && (jar.getPotion() == type || jar.getPotion() == PotionTypes.EMPTY)){
				if(jar.getPotionCount() < 3){
					if(jar.getPotion() == PotionTypes.EMPTY){
						jar.setPotionType(type);
					}
					jar.setPotionCount(jar.getPotionCount()+1);
					player.setHeldItem(hand, new ItemStack(Items.GLASS_BOTTLE));
					BlockUtil.markBlockForUpdate(world, pos);
					return true;
				}
			}
		} else if(held.getItem() == Items.GLASS_BOTTLE){
			if(jar.getPotion() !=PotionTypes.EMPTY && jar.getPotionCount() > 0){
				player.setHeldItem(hand, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), jar.getPotion()));
				jar.setPotionCount(jar.getPotionCount()-1);
				if(jar.getPotionCount() <= 0){
					jar.setPotionType(PotionTypes.EMPTY);
				}
				BlockUtil.markBlockForUpdate(world, pos);
				return true;
			}
		}
		
	}
       return false;
   }
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:53,代碼來源:BlockJar.java

示例11: isInput

import net.minecraft.potion.PotionUtils; //導入方法依賴的package包/類
@Override
default boolean isInput(ItemStack input) {
	return input.getItem() == Items.POTIONITEM && PotionUtils.getPotionFromItem(input) == PotionTypes.AWKWARD;
}
 
開發者ID:NekoCaffeine,項目名稱:Alchemy,代碼行數:5,代碼來源:IAlchemyBrewingRecipe.java


注:本文中的net.minecraft.potion.PotionUtils.getPotionFromItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。