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;
}
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();
}
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);
}
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);
}
Aggregations