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


Java PotionUtils類代碼示例

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


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

示例1: tryFireMinigun

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
public boolean tryFireMinigun(EntityLivingBase target) {
    boolean lastShotOfAmmo = false;
    if (!ammo.isEmpty() && (pressurizable == null || pressurizable.getPressure(stack) > 0)) {
        setMinigunTriggerTimeOut(Math.max(10, getMinigunSoundCounter()));
        if (getMinigunSpeed() == MAX_GUN_SPEED && (!requiresTarget || gunAimedAtTarget)) {
            if (!requiresTarget) target = raytraceTarget();
            lastShotOfAmmo = ammo.attemptDamageItem(1, rand, player instanceof EntityPlayerMP ? (EntityPlayerMP) player : null);
            if (pressurizable != null) pressurizable.addAir(stack, -airUsage);
            if (target != null) {
                ItemStack potion = ItemGunAmmo.getPotion(ammo);
                if (!potion.isEmpty()) {
                    if (rand.nextInt(20) == 0) {
                        List<PotionEffect> effects = PotionUtils.getEffectsFromStack(potion);
                        for (PotionEffect effect : effects) {
                            target.addPotionEffect(new PotionEffect(effect));
                        }
                    }
                } else {
                    target.attackEntityFrom(DamageSource.causePlayerDamage(player), ConfigHandler.general.configMinigunDamage);
                }
            }
        }
    }
    return lastShotOfAmmo;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:26,代碼來源:Minigun.java

示例2: deSerialize

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
public static Tuple<List<BrewEffect>, List<PotionEffect>> deSerialize(NBTTagCompound compound) {
	List<PotionEffect> potionEffects = PotionUtils.getEffectsFromTag(compound);
	List<BrewEffect> brewEffects = new ArrayList<>();
	Tuple<List<BrewEffect>, List<PotionEffect>> tuple = new Tuple<>(brewEffects, potionEffects);

	NBTTagList list = (NBTTagList) compound.getTag(BREW_DATA);
	for (int i = 0, size = list.tagCount(); i < size; i++) {
		NBTTagCompound tag = list.getCompoundTagAt(i);
		IBrew brew = BrewRegistry.getRegisteredBrew(tag.getString(BREW_ID));
		int duration = tag.getInteger(BREW_DURATION);
		int amplifier = tag.getInteger(BREW_AMPLIFIER);
		brewEffects.add(new BrewEffect(brew, duration, amplifier));
	}

	return tuple;
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:17,代碼來源:BrewUtils.java

示例3: onItemUseFinish

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
@Override
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase entity) {
	EntityPlayer entityplayer = entity instanceof EntityPlayer ? (EntityPlayer) entity : null;
	if (!world.isRemote) {
		for (BrewEffect effect : BrewUtils.getBrewsFromStack(stack)) {
			BrewStorageHandler.addEntityBrewEffect(entity, effect);
		}

		for (PotionEffect potioneffect : PotionUtils.getEffectsFromStack(stack)) {
			entity.addPotionEffect(new PotionEffect(potioneffect));
		}
	}

	if (entityplayer == null || !entityplayer.capabilities.isCreativeMode) {
		stack.shrink(1);
		if (stack.getCount() <= 0) {
			return new ItemStack(Items.GLASS_BOTTLE);
		}

		if (entityplayer != null) {
			entityplayer.inventory.addItemStackToInventory(new ItemStack(Items.GLASS_BOTTLE));
		}
	}
	return stack;
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:26,代碼來源:ItemBrewDrink.java

示例4: apply

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
/**
 * Applies all effects in the bottle to the entity; if the bottle has both a potion and a spirit, both are applied.
 */
public void apply(ItemStack bottle, EntityLivingBase entity) {
	if (entity.world.isRemote) return;
	Spirit spirit = getSpirit(bottle);
	if (spirit!=null) {
		
		if (spirit.isAlcoholic()) {
			PotionEffect effect = entity.getActivePotionEffect(Thermionics.POTION_TIPSY);
			int curStrength = 0;
			if (effect!=null) {
				curStrength = effect.getAmplifier();
			}
			
			entity.removeActivePotionEffect(Thermionics.POTION_TIPSY);
			entity.addPotionEffect( new PotionEffect(Thermionics.POTION_TIPSY, 20*30, curStrength+1));
		}
	}
	
	for (PotionEffect potion : PotionUtils.getEffectsFromStack(bottle)) {
		if (potion.getPotion().isInstant()) {
               potion.getPotion().affectEntity(entity, entity, entity, potion.getAmplifier(), 1.0D);
           } else {
               entity.addPotionEffect(new PotionEffect(potion));
           }
	}
}
 
開發者ID:elytra,項目名稱:Thermionics,代碼行數:29,代碼來源:ItemSpiritBottle.java

示例5: 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)
    {
        this.world.playEvent(2002, new BlockPos(this), PotionUtils.getPotionColor(PotionTypes.WATER));
        int i = 3 + this.world.rand.nextInt(5) + this.world.rand.nextInt(5);

        while (i > 0)
        {
            int j = EntityXPOrb.getXPSplit(i);
            i -= j;
            this.world.spawnEntityInWorld(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, j));
        }

        this.setDead();
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:21,代碼來源:EntityExpBottle.java

示例6: updatePotionMetadata

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
/**
 * Clears potion metadata values if the entity has no potion effects. Otherwise, updates potion effect color,
 * ambience, and invisibility metadata values
 */
protected void updatePotionMetadata()
{
    if (this.activePotionsMap.isEmpty())
    {
        this.resetPotionEffectMetadata();
        this.setInvisible(false);
    }
    else
    {
        Collection<PotionEffect> collection = this.activePotionsMap.values();
        this.dataManager.set(HIDE_PARTICLES, Boolean.valueOf(areAllPotionsAmbient(collection)));
        this.dataManager.set(POTION_EFFECTS, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(collection)));
        this.setInvisible(this.isPotionActive(MobEffects.INVISIBILITY));
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:20,代碼來源:EntityLivingBase.java

示例7: func_190542_a

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

示例8: readEntityFromNBT

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);

    if (compound.hasKey("Potion", 8))
    {
        this.potion = PotionUtils.getPotionTypeFromNBT(compound);
    }

    for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromTag(compound))
    {
        this.addEffect(potioneffect);
    }

    if (compound.hasKey("Color", 99))
    {
        this.func_191507_d(compound.getInteger("Color"));
    }
    else
    {
        this.func_190548_o();
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:27,代碼來源:EntityTippedArrow.java

示例9: getCraftingResult

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = inv.getStackInRowAndColumn(1, 1);

    if (itemstack.getItem() != Items.LINGERING_POTION)
    {
        return ItemStack.field_190927_a;
    }
    else
    {
        ItemStack itemstack1 = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.addPotionToItemStack(itemstack1, PotionUtils.getPotionFromItem(itemstack));
        PotionUtils.appendEffects(itemstack1, PotionUtils.getFullEffectsFromItem(itemstack));
        return itemstack1;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:20,代碼來源:RecipeTippedArrow.java

示例10: getCraftingResult

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
@Override
public ItemStack getCraftingResult(InventoryCrafting inv)
{
	ItemStack outputStack = ItemStack.EMPTY;
	if (countSlotsNotEmpty(inv) <= 1) return outputStack;

	Collection<PotionEffect> effects = new ArrayList<PotionEffect>();

	for (int i = 0; i < inv.getSizeInventory(); i++)
	{
		ItemStack stack = inv.getStackInSlot(i);
		if (!stack.isEmpty())
		{
			if (outputStack.isEmpty()) outputStack = getOutputStack(stack);
			if (outputStack.isEmpty()) return outputStack;

			effects.addAll(getEffectsFromStack(stack));
		}
	}

	outputStack = PotionUtils.appendEffects(outputStack, effects);
	outputStack.setStackDisplayName(I18n.translateToLocal("item.combined_" + outputStack.getItem().getUnlocalizedName().substring(5) + ".name"));

	return outputStack;
}
 
開發者ID:crazysnailboy,項目名稱:CombinedPotions,代碼行數:26,代碼來源:RecipeCombinedPotions2.java

示例11: setPotionEffect

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

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

        this.dataManager.set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, collection))));
    }
    else if (stack.getItem() == Items.ARROW)
    {
        this.potion = PotionTypes.EMPTY;
        this.customPotionEffects.clear();
        this.dataManager.set(COLOR, Integer.valueOf(0));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:EntityTippedArrow.java

示例12: readEntityFromNBT

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
public void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);

    if (compound.hasKey("Potion", 8))
    {
        this.potion = PotionUtils.getPotionTypeFromNBT(compound);
    }

    for (PotionEffect potioneffect : PotionUtils.getFullEffectsFromTag(compound))
    {
        this.addEffect(potioneffect);
    }

    if (this.potion != PotionTypes.EMPTY || !this.customPotionEffects.isEmpty())
    {
        this.dataManager.set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, this.customPotionEffects))));
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:EntityTippedArrow.java

示例13: setPotion

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
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))));
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:EntityAreaEffectCloud.java

示例14: getCraftingResult

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
/**
 * Returns an Item that is the result of this recipe
 */
@Nullable
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = inv.getStackInRowAndColumn(1, 1);

    if (itemstack != null && itemstack.getItem() == Items.LINGERING_POTION)
    {
        ItemStack itemstack1 = new ItemStack(Items.TIPPED_ARROW, 8);
        PotionUtils.addPotionToItemStack(itemstack1, PotionUtils.getPotionFromItem(itemstack));
        PotionUtils.appendEffects(itemstack1, PotionUtils.getFullEffectsFromItem(itemstack));
        return itemstack1;
    }
    else
    {
        return null;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:RecipeTippedArrow.java

示例15: onImpact

import net.minecraft.potion.PotionUtils; //導入依賴的package包/類
@Override
protected void onImpact(RayTraceResult result)
{
    if (!this.world.isRemote)
    {
        this.world.playEvent(2002, new BlockPos(this), PotionUtils.getPotionColor(PotionTypes.HEALING));
        int i = InteractionEriottoMod.SPIRIT_PER_BOTTLE;

        while (i > 0)
        {
            int j = EntitySpirit.getSpiritSplit(i);
            i -= j;
            this.world.spawnEntity(new EntitySpirit(this.world, this.posX, this.posY, this.posZ, j));
        }

        this.setDead();
    }
}
 
開發者ID:DaedalusGame,項目名稱:BetterWithAddons,代碼行數:19,代碼來源:EntityAncestryBottle.java


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