Java 类net.minecraft.init.PotionTypes 实例源码

项目:Backmemed    文件:EntityExpBottle.java   
/**
 * 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();
    }
}
项目:Backmemed    文件:PotionUtils.java   
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;
}
项目:CustomWorldGen    文件:EntityTippedArrow.java   
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));
    }
}
项目: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    文件:EntityTippedArrow.java   
/**
 * (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))));
    }
}
项目: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))));
        }
    }
}
项目:BetterWithAddons    文件:EntityAncestryBottle.java   
@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();
    }
}
项目:CrystalMod    文件:EventHandler.java   
@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);
            }
        }
    }
}
项目:CrystalMod    文件:EntityDart.java   
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;
}
项目: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);
}
项目:ARKCraft    文件:EntityArkArrow.java   
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));
    }
}
项目: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);
    }
}
项目:ARKCraft    文件:EntityArkArrow.java   
/**
 * (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))));
    }
}
项目:Cyclic    文件:ItemPowerSword.java   
@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));
}
项目:ExpandedRailsMod    文件:EntityTippedArrow.java   
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));
    }
}
项目: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    文件:EntityTippedArrow.java   
/**
 * (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))));
    }
}
项目: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))));
        }
    }
}
项目:minecraft-roguelike    文件:ProfilePoisonArcher.java   
@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);
    }
}
项目:Backmemed    文件:EntityTippedArrow.java   
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));
    }
}
项目:Backmemed    文件:EntityTippedArrow.java   
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    super.onUpdate();

    if (this.world.isRemote)
    {
        if (this.inGround)
        {
            if (this.timeInGround % 5 == 0)
            {
                this.spawnPotionParticles(1);
            }
        }
        else
        {
            this.spawnPotionParticles(2);
        }
    }
    else if (this.inGround && this.timeInGround != 0 && !this.customPotionEffects.isEmpty() && this.timeInGround >= 600)
    {
        this.world.setEntityState(this, (byte)0);
        this.potion = PotionTypes.EMPTY;
        this.customPotionEffects.clear();
        this.dataManager.set(COLOR, Integer.valueOf(-1));
    }
}
项目: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 EntityAreaEffectCloud(World worldIn)
{
    super(worldIn);
    this.potion = PotionTypes.EMPTY;
    this.effects = Lists.<PotionEffect>newArrayList();
    this.reapplicationDelayMap = Maps.<Entity, Integer>newHashMap();
    this.duration = 600;
    this.waitTime = 20;
    this.reapplicationDelay = 20;
    this.noClip = true;
    this.isImmuneToFire = true;
    this.setRadius(3.0F);
}
项目:Backmemed    文件:EntityAreaEffectCloud.java   
private void func_190618_C()
{
    if (this.potion == PotionTypes.EMPTY && this.effects.isEmpty())
    {
        this.getDataManager().set(COLOR, Integer.valueOf(0));
    }
    else
    {
        this.getDataManager().set(COLOR, Integer.valueOf(PotionUtils.getPotionColorFromEffectList(PotionUtils.mergeEffects(this.potion, this.effects))));
    }
}
项目: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    文件: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    文件:EntityTippedArrow.java   
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    super.onUpdate();

    if (this.worldObj.isRemote)
    {
        if (this.inGround)
        {
            if (this.timeInGround % 5 == 0)
            {
                this.spawnPotionParticles(1);
            }
        }
        else
        {
            this.spawnPotionParticles(2);
        }
    }
    else if (this.inGround && this.timeInGround != 0 && !this.customPotionEffects.isEmpty() && this.timeInGround >= 600)
    {
        this.worldObj.setEntityState(this, (byte)0);
        this.potion = PotionTypes.EMPTY;
        this.customPotionEffects.clear();
        this.dataManager.set(COLOR, Integer.valueOf(0));
    }
}
项目:CustomWorldGen    文件:EntityTippedArrow.java   
protected ItemStack getArrowStack()
{
    if (this.customPotionEffects.isEmpty() && this.potion == PotionTypes.EMPTY)
    {
        return new ItemStack(Items.ARROW);
    }
    else
    {
        ItemStack itemstack = new ItemStack(Items.TIPPED_ARROW);
        PotionUtils.addPotionToItemStack(itemstack, this.potion);
        PotionUtils.appendEffects(itemstack, this.customPotionEffects);
        return itemstack;
    }
}
项目: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    文件:EntityAreaEffectCloud.java   
public EntityAreaEffectCloud(World worldIn)
{
    super(worldIn);
    this.potion = PotionTypes.EMPTY;
    this.effects = Lists.<PotionEffect>newArrayList();
    this.reapplicationDelayMap = Maps.<Entity, Integer>newHashMap();
    this.duration = 600;
    this.waitTime = 20;
    this.reapplicationDelay = 20;
    this.noClip = true;
    this.isImmuneToFire = true;
    this.setRadius(3.0F);
}
项目:CustomWorldGen    文件:ContainerBrewingStand.java   
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);
}
项目: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    文件:EntityDart.java   
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));
    }
}
项目:CrystalMod    文件:EntityDart.java   
/**
 * Called to update the entity's position/logic.
 */
@Override
public void onUpdate()
{
    super.onUpdate();

    if (this.world.isRemote)
    {
        if (this.inGround)
        {
            if (this.timeInGround % 5 == 0)
            {
                this.spawnPotionParticles(1);
            }
        }
        else
        {
            this.spawnPotionParticles(2);
        }
    }
    else if (this.inGround && this.timeInGround != 0 && !this.customPotionEffects.isEmpty() && this.timeInGround >= 600)
    {
        this.world.setEntityState(this, (byte)0);
        this.potion = PotionTypes.EMPTY;
        this.customPotionEffects.clear();
        this.dataManager.set(COLOR, Integer.valueOf(-1));
    }
}
项目:CrystalMod    文件:TileJar.java   
@Override
public void writeCustomNBT(NBTTagCompound nbt){
    super.writeCustomNBT(nbt);
    if(potion != PotionTypes.EMPTY){
        nbt.setString("Potion", potion.getRegistryName().toString());
    }
    nbt.setInteger("Count", potionCount);
    nbt.setBoolean("IsShulker", isShulkerLamp());
    for(EnumFacing facing : EnumFacing.HORIZONTALS){
        nbt.setBoolean("Label."+facing.getName().toUpperCase(), labelMap.getOrDefault(facing, false));
    }
}
项目:CrystalMod    文件:TileJar.java   
@Override
public void writeToStack(NBTTagCompound nbt){
    if(potion != PotionTypes.EMPTY){
        nbt.setString("Potion", potion.getRegistryName().toString());
    }
    if(potionCount > 0)nbt.setInteger("Count", potionCount);
    if(isShulkerLamp())nbt.setBoolean("IsShulker", isShulkerLamp());
    for(EnumFacing facing : EnumFacing.HORIZONTALS){
        if(labelMap.getOrDefault(facing, false))nbt.setBoolean("Label."+facing.getName().toUpperCase(), true);
    }
}
项目:ToroQuest    文件:Potions.java   
public static void initRecipes() {
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromItem(Items.EMERALD), TQPotionTypes.ROYALTY);
    PotionHelper.addMix(TQPotionTypes.ROYALTY, Ingredient.fromItem(Items.REDSTONE), TQPotionTypes.ROYALTY_LONG);
    PotionHelper.addMix(TQPotionTypes.ROYALTY, Ingredient.fromItem(Items.GLOWSTONE_DUST), TQPotionTypes.ROYALTY_STRONG);

    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromItem(Items.DIAMOND), TQPotionTypes.LOYALTY);
    PotionHelper.addMix(TQPotionTypes.LOYALTY, Ingredient.fromItem(Items.REDSTONE), TQPotionTypes.LOYALTY_LONG);
    PotionHelper.addMix(TQPotionTypes.LOYALTY, Ingredient.fromItem(Items.GLOWSTONE_DUST), TQPotionTypes.LOYALTY_STRONG);
}