Search in sources :

Example 6 with MaterialStack

use of gregtech.api.unification.stack.MaterialStack in project GregTech by GregTechCE.

the class OreDictUnifier method getByProducts.

@Nullable
public static ImmutableList<MaterialStack> getByProducts(ItemStack itemStack) {
    if (itemStack.isEmpty())
        return null;
    SimpleItemStack simpleItemStack = new SimpleItemStack(itemStack);
    UnificationEntry entry = stackUnificationInfo.get(simpleItemStack);
    if (entry != null && entry.material != null)
        return ImmutableList.of(new MaterialStack(entry.material, entry.orePrefix.materialAmount), entry.orePrefix.secondaryMaterial);
    ItemMaterialInfo info = materialUnificationInfo.get(simpleItemStack);
    return info == null ? null : info.byProducts;
}
Also used : ItemMaterialInfo(gregtech.api.unification.stack.ItemMaterialInfo) MaterialStack(gregtech.api.unification.stack.MaterialStack) UnificationEntry(gregtech.api.unification.stack.UnificationEntry) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack) Nullable(javax.annotation.Nullable)

Example 7 with MaterialStack

use of gregtech.api.unification.stack.MaterialStack in project GregTech by GregTechCE.

the class OreDictUnifier method getMaterial.

@Nullable
public static MaterialStack getMaterial(ItemStack itemStack) {
    if (itemStack.isEmpty())
        return null;
    SimpleItemStack simpleItemStack = new SimpleItemStack(itemStack);
    UnificationEntry entry = stackUnificationInfo.get(simpleItemStack);
    if (entry != null && entry.material != null)
        return new MaterialStack(entry.material, entry.orePrefix.materialAmount);
    ItemMaterialInfo info = materialUnificationInfo.get(simpleItemStack);
    return info == null ? null : info.material.copy();
}
Also used : ItemMaterialInfo(gregtech.api.unification.stack.ItemMaterialInfo) MaterialStack(gregtech.api.unification.stack.MaterialStack) UnificationEntry(gregtech.api.unification.stack.UnificationEntry) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack) Nullable(javax.annotation.Nullable)

Example 8 with MaterialStack

use of gregtech.api.unification.stack.MaterialStack in project GregTech by GregTechCE.

the class Material method getMass.

public long getMass() {
    if (element != null)
        return element.getMass();
    if (materialComponents.size() <= 0)
        return Element.Tc.getMass();
    long totalProtons = 0, totalAmount = 0;
    for (MaterialStack material : materialComponents) {
        totalAmount += material.amount;
        totalProtons += material.amount * material.material.getMass();
    }
    return (getDensity() * totalProtons) / (totalAmount * M);
}
Also used : MaterialStack(gregtech.api.unification.stack.MaterialStack)

Example 9 with MaterialStack

use of gregtech.api.unification.stack.MaterialStack in project GregTech by GregTechCE.

the class Material method getNeutrons.

public long getNeutrons() {
    if (element != null)
        return element.getNeutrons();
    if (materialComponents.size() <= 0)
        return Element.Tc.getNeutrons();
    long totalProtons = 0, totalAmount = 0;
    for (MaterialStack material : materialComponents) {
        totalAmount += material.amount;
        totalProtons += material.amount * material.material.getNeutrons();
    }
    return (getDensity() * totalProtons) / (totalAmount * M);
}
Also used : MaterialStack(gregtech.api.unification.stack.MaterialStack)

Aggregations

MaterialStack (gregtech.api.unification.stack.MaterialStack)9 ItemMaterialInfo (gregtech.api.unification.stack.ItemMaterialInfo)4 SimpleItemStack (gregtech.api.unification.stack.SimpleItemStack)3 ItemStack (net.minecraft.item.ItemStack)3 UnificationEntry (gregtech.api.unification.stack.UnificationEntry)2 Nullable (javax.annotation.Nullable)2 ElectricStats (gregtech.api.items.metaitem.ElectricStats)1 FluidStats (gregtech.api.items.metaitem.FluidStats)1 FoodStats (gregtech.api.items.metaitem.FoodStats)1 RecipeBuilder (gregtech.api.recipes.RecipeBuilder)1 DustMaterial (gregtech.api.unification.material.type.DustMaterial)1 FluidMaterial (gregtech.api.unification.material.type.FluidMaterial)1 RandomPotionEffect (gregtech.api.util.RandomPotionEffect)1 ArrayList (java.util.ArrayList)1 FluidStack (net.minecraftforge.fluids.FluidStack)1