Search in sources :

Example 6 with PotionType

use of net.minecraft.potion.PotionType in project takumicraft by TNTModders.

the class EntityWitchCreeper method attackEntityWithRangedAttack.

/**
 * Attack the specified entity using a ranged attack.
 */
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor) {
    if (!this.isDrinkingPotion()) {
        double d0 = target.posY + 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 EntityTakumiPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        entitypotion.rotationPitch -= -15.0F;
        entitypotion.setThrowableHeading(d1, d2 + f * 0.2F, d3, 0.75F, 8.0F);
        this.world.playSound(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);
    }
}
Also used : EntityPotion(net.minecraft.entity.projectile.EntityPotion) EntityTakumiPotion(com.tntmodders.takumi.entity.item.EntityTakumiPotion) PotionType(net.minecraft.potion.PotionType) ItemStack(net.minecraft.item.ItemStack)

Example 7 with PotionType

use of net.minecraft.potion.PotionType in project takumicraft by TNTModders.

the class EntityWitchCreeper method takumiExplode.

@Override
public void takumiExplode() {
    PotionType type = PotionTypes.HARMING;
    switch(this.rand.nextInt(4)) {
        case 0:
            break;
        case 1:
            type = PotionTypes.POISON;
            break;
        case 2:
            type = PotionTypes.SLOWNESS;
            break;
        case 3:
            type = PotionTypes.WEAKNESS;
            break;
    }
    EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
    entityareaeffectcloud.setRadius(5F);
    entityareaeffectcloud.setRadiusOnUse(-0.5F);
    entityareaeffectcloud.setWaitTime(10);
    entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration());
    entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / entityareaeffectcloud.getDuration());
    entityareaeffectcloud.addEffect(type.getEffects().get(0));
    this.world.spawnEntity(entityareaeffectcloud);
}
Also used : EntityAreaEffectCloud(net.minecraft.entity.EntityAreaEffectCloud) PotionType(net.minecraft.potion.PotionType)

Example 8 with PotionType

use of net.minecraft.potion.PotionType in project Random-Things by lumien231.

the class ModRecipes method addGlowingMushroomRecipes.

public static void addGlowingMushroomRecipes() {
    try {
        Field listField = PotionHelper.class.getDeclaredField(MCPNames.field("field_185213_a"));
        ReflectionUtil.makeModifiable(listField);
        Field inputField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185198_a"));
        ReflectionUtil.makeModifiable(inputField);
        Field reagentField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185199_b"));
        ReflectionUtil.makeModifiable(reagentField);
        Field outputField = MixPredicate.class.getDeclaredField(MCPNames.field("field_185200_c"));
        ReflectionUtil.makeModifiable(outputField);
        List<PotionHelper.MixPredicate<PotionType>> conversionList = (List<MixPredicate<PotionType>>) listField.get(null);
        List<MixPredicate<PotionType>> toAdd = new ArrayList<MixPredicate<PotionType>>();
        for (MixPredicate<PotionType> p : conversionList) {
            Ingredient reagent = (Ingredient) reagentField.get(p);
            if (reagent.test(new ItemStack(Items.GLOWSTONE_DUST))) {
                PotionType input = (PotionType) inputField.get(p);
                PotionType output = (PotionType) outputField.get(p);
                toAdd.add(new MixPredicate<PotionType>(input, Ingredient.fromItem(Item.getItemFromBlock(ModBlocks.glowingMushroom)), output));
            }
        }
        RandomThings.instance.logger.log(Level.DEBUG, "Added " + toAdd.size() + " Glowing Mushroom Recipes");
        conversionList.addAll(toAdd);
    } catch (Exception e) {
        RandomThings.instance.logger.log(Level.ERROR, "Couldn't add glowing mushroom potion recipes, please report this as a bug");
        e.printStackTrace();
    }
}
Also used : Field(java.lang.reflect.Field) Ingredient(net.minecraft.item.crafting.Ingredient) ItemIngredient(lumien.randomthings.item.ItemIngredient) ArrayList(java.util.ArrayList) MixPredicate(net.minecraft.potion.PotionHelper.MixPredicate) ArrayList(java.util.ArrayList) NonNullList(net.minecraft.util.NonNullList) List(java.util.List) PotionType(net.minecraft.potion.PotionType) ItemStack(net.minecraft.item.ItemStack)

Example 9 with PotionType

use of net.minecraft.potion.PotionType in project Random-Things by lumien231.

the class ModPotions method preInit.

public static void preInit(FMLPreInitializationEvent event) {
    imbueFire = new ImbueFire();
    imbuePoison = new ImbuePoison();
    imbueExperience = new ImbueExperience();
    imbueWither = new ImbueWither();
    imbueCollapse = new ImbueCollapse();
    collapse = new EffectCollapse();
    collapseType = new PotionType("rtcollapse", new PotionEffect(collapse, 450));
    collapseTypeLong = new PotionType("rtcollapse", new PotionEffect(collapse, 900));
    collapseTypeStrong = new PotionType("rtcollapse", new PotionEffect(collapse, 300, 1));
    collapseType.setRegistryName(new ResourceLocation("randomthings", "collapse"));
    collapseTypeLong.setRegistryName(new ResourceLocation("randomthings", "long_collapse"));
    collapseTypeStrong.setRegistryName(new ResourceLocation("randomthings", "strong_collapse"));
    ForgeRegistries.POTION_TYPES.register(collapseType);
    ForgeRegistries.POTION_TYPES.register(collapseTypeLong);
    ForgeRegistries.POTION_TYPES.register(collapseTypeStrong);
    // Brewing
    PotionHelper.addMix(PotionTypes.AWKWARD, Ingredient.fromStacks(new ItemStack(ModItems.ingredients, 1, 0)), collapseType);
    PotionHelper.addMix(collapseType, Items.REDSTONE, collapseTypeLong);
    PotionHelper.addMix(collapseType, Items.GLOWSTONE_DUST, collapseTypeStrong);
}
Also used : ImbueWither(lumien.randomthings.potion.imbues.ImbueWither) ImbueCollapse(lumien.randomthings.potion.imbues.ImbueCollapse) ImbueExperience(lumien.randomthings.potion.imbues.ImbueExperience) PotionEffect(net.minecraft.potion.PotionEffect) ResourceLocation(net.minecraft.util.ResourceLocation) ImbuePoison(lumien.randomthings.potion.imbues.ImbuePoison) ImbueFire(lumien.randomthings.potion.imbues.ImbueFire) EffectCollapse(lumien.randomthings.potion.effects.EffectCollapse) PotionType(net.minecraft.potion.PotionType) ItemStack(net.minecraft.item.ItemStack)

Example 10 with PotionType

use of net.minecraft.potion.PotionType in project Railcraft by Railcraft.

the class PotionPlugin method init.

private static void init() {
    POTIONS.clear();
    POTIONS_SPLASH.clear();
    POTIONS_LINGERING.clear();
    for (PotionType potiontype : ForgeRegistries.POTION_TYPES) {
        POTIONS.add(PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
        POTIONS_SPLASH.add(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
        POTIONS_LINGERING.add(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), potiontype));
    }
    hasInit = true;
}
Also used : PotionType(net.minecraft.potion.PotionType) ItemStack(net.minecraft.item.ItemStack)

Aggregations

PotionType (net.minecraft.potion.PotionType)18 ItemStack (net.minecraft.item.ItemStack)12 PotionEffect (net.minecraft.potion.PotionEffect)5 IBlockState (net.minecraft.block.state.IBlockState)2 EntityPotion (net.minecraft.entity.projectile.EntityPotion)2 Item (net.minecraft.item.Item)2 Potion (net.minecraft.potion.Potion)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Fluid (net.minecraftforge.fluids.Fluid)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 Vector3d (com.flowpowered.math.vector.Vector3d)1 Vector3f (com.flowpowered.math.vector.Vector3f)1 ITakumiEntity (com.tntmodders.takumi.entity.ITakumiEntity)1 EntityTakumiPotion (com.tntmodders.takumi.entity.item.EntityTakumiPotion)1 TakumiExplosion (com.tntmodders.takumi.world.TakumiExplosion)1 CountableIngredient (gregtech.api.recipes.CountableIngredient)1 Recipe (gregtech.api.recipes.Recipe)1 NBTIngredient (gregtech.api.recipes.ingredients.NBTIngredient)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1