Search in sources :

Example 16 with PotionType

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

the class EntityWitchCreeper method onLivingUpdate.

/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
@Override
public void onLivingUpdate() {
    if (!this.world.isRemote) {
        if (this.isDrinkingPotion()) {
            if (this.witchAttackTimer-- <= 0) {
                this.setAggressive(false);
                ItemStack itemstack = this.getHeldItemMainhand();
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
                if (itemstack.getItem() == Items.POTIONITEM) {
                    List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);
                    if (list != null) {
                        for (PotionEffect potioneffect : list) {
                            this.addPotionEffect(new PotionEffect(potioneffect));
                        }
                    }
                }
                this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
            }
        } else {
            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.getLastDamageSource() != null && this.getLastDamageSource().isFireDamage()) && !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.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
                this.witchAttackTimer = this.getHeldItemMainhand().getMaxItemUseDuration();
                this.setAggressive(true);
                this.world.playSound(null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
                IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
                iattributeinstance.removeModifier(MODIFIER);
                iattributeinstance.applyModifier(MODIFIER);
            }
        }
        if (this.rand.nextFloat() < 7.5E-4F) {
            this.world.setEntityState(this, (byte) 15);
        }
    }
    super.onLivingUpdate();
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) IAttributeInstance(net.minecraft.entity.ai.attributes.IAttributeInstance) PotionType(net.minecraft.potion.PotionType) ItemStack(net.minecraft.item.ItemStack)

Example 17 with PotionType

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

the class TakumiPotionCore method registerPotionType.

public static void registerPotionType(IForgeRegistry<PotionType> event) {
    PotionType type = new PotionType(SUBSIDENCE.getRegistryName().getResourcePath(), new PotionEffect(SUBSIDENCE, 400)).setRegistryName(SUBSIDENCE.getRegistryName());
    event.register(type);
    type = new PotionType(INVERSION.getRegistryName().getResourcePath(), new PotionEffect(INVERSION, 400)).setRegistryName(INVERSION.getRegistryName());
    event.register(type);
    type = new PotionType(CREEPERED.getRegistryName().getResourcePath(), new PotionEffect(CREEPERED, 30)).setRegistryName(CREEPERED.getRegistryName());
    event.register(type);
    type = new PotionType(EXP_JUMP.getRegistryName().getResourcePath(), new PotionEffect(EXP_JUMP, 400)).setRegistryName(EXP_JUMP.getRegistryName());
    event.register(type);
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) PotionType(net.minecraft.potion.PotionType)

Example 18 with PotionType

use of net.minecraft.potion.PotionType in project ImmersiveEngineering by BluSunrize.

the class InspirationsHelper method registerRecipes.

@Override
public void registerRecipes() {
    if (ITEM_MATERIAL != null) {
        CreativeTabs[] tabs = ITEM_MATERIAL.getCreativeTabs();
        // Check if Potion bottles are enabled by checking if they have a creative tab
        if (tabs.length > 2 && tabs[2] == CreativeTabs.BREWING) {
            ItemStack splashBottle = new ItemStack(ITEM_MATERIAL, 1, 2);
            ItemStack lingeringBottle = new ItemStack(ITEM_MATERIAL, 1, 3);
            for (PotionType potionType : PotionType.REGISTRY) if (!MixerPotionHelper.BLACKLIST.contains(potionType.getRegistryName().toString())) {
                BottlingMachineRecipe.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potionType), splashBottle, MixerPotionHelper.getFluidStackForType(potionType, 250));
                BottlingMachineRecipe.addRecipe(PotionUtils.addPotionToItemStack(new ItemStack(Items.LINGERING_POTION), potionType), lingeringBottle, MixerPotionHelper.getFluidStackForType(potionType, 250));
            }
        }
    }
}
Also used : CreativeTabs(net.minecraft.creativetab.CreativeTabs) 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