当前位置: 首页>>代码示例>>Java>>正文


Java PotionTypes类代码示例

本文整理汇总了Java中net.minecraft.init.PotionTypes的典型用法代码示例。如果您正苦于以下问题:Java PotionTypes类的具体用法?Java PotionTypes怎么用?Java PotionTypes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PotionTypes类属于net.minecraft.init包,在下文中一共展示了PotionTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onImpact

import net.minecraft.init.PotionTypes; //导入依赖的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

示例2: addPotionToItemStack

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
public static ItemStack addPotionToItemStack(ItemStack itemIn, PotionType potionIn)
{
    ResourceLocation resourcelocation = (ResourceLocation)PotionType.REGISTRY.getNameForObject(potionIn);

    if (potionIn == PotionTypes.EMPTY)
    {
        if (itemIn.hasTagCompound())
        {
            NBTTagCompound nbttagcompound = itemIn.getTagCompound();
            nbttagcompound.removeTag("Potion");

            if (nbttagcompound.hasNoTags())
            {
                itemIn.setTagCompound((NBTTagCompound)null);
            }
        }
    }
    else
    {
        NBTTagCompound nbttagcompound1 = itemIn.hasTagCompound() ? itemIn.getTagCompound() : new NBTTagCompound();
        nbttagcompound1.setString("Potion", resourcelocation.toString());
        itemIn.setTagCompound(nbttagcompound1);
    }

    return itemIn;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:PotionUtils.java

示例3: setPotionEffect

import net.minecraft.init.PotionTypes; //导入依赖的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

示例4: writeEntityToNBT

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
/**
 * (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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:EntityTippedArrow.java

示例5: readEntityFromNBT

import net.minecraft.init.PotionTypes; //导入依赖的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

示例6: setPotion

import net.minecraft.init.PotionTypes; //导入依赖的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

示例7: onImpact

import net.minecraft.init.PotionTypes; //导入依赖的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

示例8: finishUse

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
@SubscribeEvent
public void finishUse(LivingEntityUseItemEvent.Finish event){
	EntityLivingBase entity = event.getEntityLiving();
	ItemStack stack = event.getItem();
	
	if(entity.isInsideOfMaterial(Material.WATER)){
		if(ItemStackTools.isValid(stack) && stack.getItem() == Items.GLASS_BOTTLE){
			//Restore to full air
			entity.setAir(300);
			ItemStack waterbottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER);
			if(ItemStackTools.getStackSize(stack) > 1){
 			event.setResultStack(ItemUtil.consumeItem(stack));
 			if(entity instanceof EntityPlayer){
 				if(!((EntityPlayer)entity).inventory.addItemStackToInventory(waterbottle)){
 					ItemUtil.spawnItemInWorldWithoutMotion(entity.getEntityWorld(), waterbottle, new BlockPos(entity));
 				}
 			} else {
 				ItemUtil.spawnItemInWorldWithoutMotion(entity.getEntityWorld(), waterbottle, new BlockPos(entity));
 			}
			} else {
				event.setResultStack(waterbottle);
			}
		}
	}
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:26,代码来源:EventHandler.java

示例9: getArrowStack

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
protected ItemStack getArrowStack()
{
    ItemStack dart = new ItemStack(ModItems.dart, 1, getType().getMetadata());
    if(potion !=PotionTypes.EMPTY){
    	PotionUtils.addPotionToItemStack(dart, this.potion);
        PotionUtils.appendEffects(dart, this.customPotionEffects);

        if (this.hasColor)
        {
            NBTTagCompound nbttagcompound = dart.getTagCompound();

            if (nbttagcompound == null)
            {
                nbttagcompound = new NBTTagCompound();
                dart.setTagCompound(nbttagcompound);
            }

            nbttagcompound.setInteger("CustomPotionColor", this.getColor());
        }
    }
    return dart;
}
 
开发者ID:Alec-WAM,项目名称:CrystalMod,代码行数:23,代码来源:EntityDart.java

示例10: handleAttackLogicUpdate

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
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);
	}
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:26,代码来源:EntityMage.java

示例11: attackWithPotion

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
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);
}
 
开发者ID:ToroCraft,项目名称:ToroQuest,代码行数:27,代码来源:EntityMage.java

示例12: registerPotionTypes

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
@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);
}
 
开发者ID:NightKosh,项目名称:Gravestone-mod-Extended,代码行数:23,代码来源:GSPotion.java

示例13: onItemRightClick

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
  switch (type) {
    case WEAK:
      spawnLingeringPotion(player, PotionTypes.WEAKNESS);
    break;
    case SLOW:
      spawnLingeringPotion(player, PotionTypes.SLOWNESS);
    break;
    case ENDER:
      player.addPotionEffect(new PotionEffect(PotionEffectRegistry.ENDER, 200, 0));
      if (!world.isRemote) {
        EntityEnderPearl entityenderpearl = new EntityEnderPearl(world, player);
        entityenderpearl.setHeadingFromThrower(player, player.rotationPitch - 20, player.rotationYaw, 0.0F, 1.6F, 1.0F);
        world.spawnEntity(entityenderpearl);
      }
  }
  UtilSound.playSound(player, SoundEvents.ENTITY_ENDERPEARL_THROW);
  player.getCooldownTracker().setCooldown(this, COOLDOWN);
  return new ActionResult<ItemStack>(EnumActionResult.PASS, player.getHeldItem(hand));
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:22,代码来源:ItemPowerSword.java

示例14: addEquipment

import net.minecraft.init.PotionTypes; //导入依赖的package包/类
@Override
public void addEquipment(World world, Random rand, int level, IEntity mob) {
	
	mob.setMobClass(MobType.STRAY, false);
	
	mob.setSlot(EntityEquipmentSlot.OFFHAND, TippedArrow.get(PotionTypes.STRONG_POISON));
	mob.setSlot(EntityEquipmentSlot.MAINHAND, ItemWeapon.getBow(rand, level, Enchant.canEnchant(world.getDifficulty(), rand, level)));
	
	for(EntityEquipmentSlot slot : new EntityEquipmentSlot[]{
			EntityEquipmentSlot.HEAD,
			EntityEquipmentSlot.CHEST,
			EntityEquipmentSlot.LEGS,
			EntityEquipmentSlot.FEET
			}){
		ItemStack item = ItemArmour.get(rand, Slot.getSlot(slot), Quality.WOOD);
		Enchant.enchantItem(rand, item, 20);
		ItemArmour.dyeArmor(item, 178, 255, 102); //bright lime green
		mob.setSlot(slot, item);
	}
}
 
开发者ID:Greymerk,项目名称:minecraft-roguelike,代码行数:21,代码来源:ProfilePoisonArcher.java

示例15: setPotionEffect

import net.minecraft.init.PotionTypes; //导入依赖的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


注:本文中的net.minecraft.init.PotionTypes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。