当前位置: 首页>>代码示例>>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;未经允许,请勿转载。