Search in sources :

Example 11 with PotionType

use of net.minecraft.potion.PotionType in project GregTech by GregTechCE.

the class PotionItemFluidHandler method getFluid.

@Override
public FluidStack getFluid() {
    PotionType potionType = PotionUtils.getPotionFromItem(container);
    if (potionType == PotionTypes.EMPTY)
        return null;
    Fluid fluid = PotionFluids.getFluidForPotion(potionType);
    // because some mods are dumb enough to register potion types after block registry event
    if (fluid == null)
        return null;
    return new FluidStack(fluid, capacity);
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) Fluid(net.minecraftforge.fluids.Fluid) PotionType(net.minecraft.potion.PotionType)

Example 12 with PotionType

use of net.minecraft.potion.PotionType in project GregTech by GregTechCE.

the class RecipeMapBrewer method findRecipe.

@Nullable
@Override
public Recipe findRecipe(long voltage, List<ItemStack> inputs, List<FluidStack> fluidInputs, int outputFluidTankCapacity, MatchingMode mode) {
    Recipe recipe = super.findRecipe(voltage, inputs, fluidInputs, outputFluidTankCapacity, mode);
    if (recipe != null || GTUtility.amountOfNonNullElements(fluidInputs) < 1 || GTUtility.amountOfNonEmptyStacks(inputs) < 1) {
        return recipe;
    }
    ItemStack ingredientStack = inputs.get(0);
    FluidStack potionFluid = fluidInputs.get(0);
    PotionType potionType = PotionFluids.getPotionForFluid(potionFluid.getFluid());
    if (potionType == null || potionFluid.amount < POTION_PER_INGREDIENT) {
        // do not return recipes if not enough fluid or fluid doesn't match
        return null;
    }
    ItemStack potionStack = new ItemStack(Items.POTIONITEM);
    PotionUtils.addPotionToItemStack(potionStack, potionType);
    ItemStack resultStack = BrewingRecipeRegistry.getOutput(potionStack, ingredientStack);
    if (resultStack.isEmpty() || resultStack.getItem() != Items.POTIONITEM) {
        // if no recipe matches, or output is not a simple potion, return null
        return null;
    }
    PotionType resultingType = PotionUtils.getPotionFromItem(resultStack);
    if (resultingType == null || resultingType == PotionTypes.EMPTY) {
        // if output is not a simple potion or empty potion, return null
        return null;
    }
    Fluid outputFluid = PotionFluids.getFluidForPotion(resultingType);
    if (outputFluid == null) {
        return null;
    }
    // otherwise, return recipe for fluid potion + ingredient -> new fluid potion
    return recipeBuilder().inputs(// we can reuse recipe only if ingredient fully matches,
    new CountableIngredient(new NBTIngredient(ingredientStack), 1)).fluidInputs(GTUtility.copyAmount(POTION_PER_INGREDIENT, potionFluid)).fluidOutputs(new FluidStack(outputFluid, POTION_PER_INGREDIENT)).build().getResult();
}
Also used : Recipe(gregtech.api.recipes.Recipe) FluidStack(net.minecraftforge.fluids.FluidStack) NBTIngredient(gregtech.api.recipes.ingredients.NBTIngredient) Fluid(net.minecraftforge.fluids.Fluid) PotionType(net.minecraft.potion.PotionType) ItemStack(net.minecraft.item.ItemStack) CountableIngredient(gregtech.api.recipes.CountableIngredient) Nullable(javax.annotation.Nullable)

Example 13 with PotionType

use of net.minecraft.potion.PotionType in project GregTech by GregTechCE.

the class PotionFluids method initPotionFluids.

public static void initPotionFluids() {
    MinecraftForge.EVENT_BUS.register(new PotionFluids());
    for (ResourceLocation registryName : ForgeRegistries.POTION_TYPES.getKeys()) {
        if (registryName.getNamespace().equals("minecraft") && registryName.getPath().equals("empty"))
            continue;
        PotionType potion = ForgeRegistries.POTION_TYPES.getValue(registryName);
        Preconditions.checkNotNull(potion);
        Fluid potionFluid;
        if (potion != PotionTypes.WATER) {
            String fluidName = String.format("potion.%s.%s", registryName.getNamespace(), registryName.getPath());
            potionFluid = new Fluid(fluidName, AUTO_GENERATED_FLUID_TEXTURE, AUTO_GENERATED_FLUID_TEXTURE) {

                @Override
                public String getUnlocalizedName() {
                    return potion.getNamePrefixed("potion.effect.");
                }
            };
            potionFluid.setColor(GTUtility.convertRGBtoOpaqueRGBA_MC(PotionUtils.getPotionColor(potion)));
            FluidRegistry.registerFluid(potionFluid);
            FluidRegistry.addBucketForFluid(potionFluid);
            BlockFluidBase fluidBlock = new BlockPotionFluid(potionFluid, potion);
            fluidBlock.setRegistryName("fluid." + fluidName);
            MetaBlocks.FLUID_BLOCKS.add(fluidBlock);
        } else {
            potionFluid = FluidRegistry.WATER;
        }
        potionFluidMap.put(potion.getRegistryName(), potionFluid);
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) PotionType(net.minecraft.potion.PotionType)

Example 14 with PotionType

use of net.minecraft.potion.PotionType in project GregTech by GregTechCE.

the class GlassBottleFluidHandler method fillImpl.

private int fillImpl(FluidStack resource, boolean doFill) {
    PotionType potionType = PotionFluids.getPotionForFluid(resource.getFluid());
    if (potionType != null && potionType != PotionTypes.EMPTY && resource.amount >= PotionFluids.POTION_ITEM_FLUID_AMOUNT) {
        if (doFill) {
            this.itemStack = new ItemStack(Items.POTIONITEM);
            PotionUtils.addPotionToItemStack(itemStack, potionType);
        }
        return PotionFluids.POTION_ITEM_FLUID_AMOUNT;
    }
    return 0;
}
Also used : PotionType(net.minecraft.potion.PotionType) ItemStack(net.minecraft.item.ItemStack)

Example 15 with PotionType

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

the class EntityStrayCreeper method setEquipmentBasedOnDifficulty.

@Override
protected void setEquipmentBasedOnDifficulty(DifficultyInstance difficulty) {
    super.setEquipmentBasedOnDifficulty(difficulty);
    ItemStack stack = new ItemStack(Items.POTIONITEM);
    PotionType type = null;
    while (type == null || type.hasInstantEffect() || type.getEffects().isEmpty()) {
        type = PotionType.REGISTRY.getRandomObject(this.rand);
    }
    PotionUtils.addPotionToItemStack(stack, type);
    this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, stack);
}
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