use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class OreDictUnifier method onItemRegistration.
@SubscribeEvent
public static void onItemRegistration(OreDictionary.OreRegisterEvent event) {
SimpleItemStack simpleItemStack = new SimpleItemStack(event.getOre());
String oreName = event.getName();
// cache this registration by name
stackOreDictName.computeIfAbsent(simpleItemStack, k -> new HashSet<>()).add(oreName);
// and try to transform registration name into OrePrefix + Material pair
OrePrefix orePrefix = OrePrefix.getPrefix(oreName);
Material material = null;
if (orePrefix == null) {
// split ore dict name to parts
// oreBasalticMineralSand -> ore, Basaltic, Mineral, Sand
ArrayList<String> splits = new ArrayList<>();
StringBuilder builder = new StringBuilder();
for (char character : oreName.toCharArray()) {
if (Character.isUpperCase(character)) {
if (builder.length() > 0) {
splits.add(builder.toString());
builder = new StringBuilder().append(character);
} else
splits.add(Character.toString(character));
} else
builder.append(character);
}
if (builder.length() > 0) {
splits.add(builder.toString());
}
// try to combine in different manners
// oreBasaltic MineralSand , ore BasalticMineralSand
StringBuilder buffer = new StringBuilder();
for (int i = 0; i < splits.size(); i++) {
buffer.append(splits.get(i));
// ore -> OrePrefix.ore
OrePrefix maybePrefix = OrePrefix.getPrefix(buffer.toString());
// BasalticMineralSand
String possibleMaterialName = Joiner.on("").join(splits.subList(i + 1, splits.size()));
// basaltic_mineral_sand
String underscoreName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, possibleMaterialName);
// Materials.BasalticSand
Material possibleMaterial = Material.MATERIAL_REGISTRY.getObject(underscoreName);
if (maybePrefix != null && possibleMaterial != null) {
orePrefix = maybePrefix;
material = possibleMaterial;
break;
}
}
}
// finally register item
if (orePrefix != null && (material != null || orePrefix.isSelfReferencing)) {
UnificationEntry unificationEntry = new UnificationEntry(orePrefix, material);
stackUnificationInfo.put(simpleItemStack, unificationEntry);
stackUnificationItems.computeIfAbsent(unificationEntry, p -> new ArrayList<>()).add(simpleItemStack);
orePrefix.processOreRegistration(material);
}
}
use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class OreDictUnifier method get.
public static ItemStack get(OrePrefix orePrefix, Material material, int stackSize) {
UnificationEntry unificationEntry = new UnificationEntry(orePrefix, material);
if (!stackUnificationItems.containsKey(unificationEntry) || !unificationEntry.orePrefix.isUnificationEnabled)
return ItemStack.EMPTY;
ArrayList<SimpleItemStack> keys = stackUnificationItems.get(unificationEntry);
keys.sort(Comparator.comparing(a -> a.item.delegate.name().getResourceDomain()));
return keys.size() > 0 ? keys.get(0).asItemStack(stackSize) : ItemStack.EMPTY;
}
use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class MetaFluids method init.
public static void init() {
Materials.Water.setMaterialFluid(FluidRegistry.WATER);
Materials.Ice.setMaterialFluid(FluidRegistry.WATER);
Materials.Lava.setMaterialFluid(FluidRegistry.LAVA);
FluidRegistry.registerFluid(DISTILLED_WATER);
Materials.DistilledWater.setMaterialFluid(DISTILLED_WATER);
FluidRegistry.addBucketForFluid(DISTILLED_WATER);
fluidSprites.add(AUTO_GENERATED_FLUID_TEXTURE);
// TODO TWEAK VALUES
registerFluid(Materials.Air, FluidType.GAS, 295, true);
registerFluid(Materials.Oxygen, FluidType.LIQUID, 295, true);
registerFluid(Materials.Hydrogen, FluidType.LIQUID, 295, true);
registerFluid(Materials.Deuterium, FluidType.LIQUID, 295, true);
registerFluid(Materials.Tritium, FluidType.LIQUID, 295, true);
registerFluid(Materials.Helium, FluidType.LIQUID, 295, true);
registerFluid(Materials.Argon, FluidType.LIQUID, 295, true);
registerFluid(Materials.Radon, FluidType.LIQUID, 295, true);
registerFluid(Materials.Fluorine, FluidType.LIQUID, 53, true);
registerFluid(Materials.Titaniumtetrachloride, FluidType.LIQUID, 2200, true);
registerFluid(Materials.Helium3, FluidType.LIQUID, 295, true);
registerFluid(Materials.Methane, FluidType.LIQUID, 295, true);
registerFluid(Materials.Nitrogen, FluidType.LIQUID, 295, true);
registerFluid(Materials.NitrogenDioxide, FluidType.LIQUID, 295, true);
registerFluid(Materials.Steam, FluidType.GAS, 295, true);
registerFluid(Materials.OilHeavy, FluidType.LIQUID, 295, true);
registerFluid(Materials.OilMedium, FluidType.LIQUID, 295, true);
registerFluid(Materials.OilLight, FluidType.LIQUID, 295, true);
registerFluid(Materials.HydrogenSulfide, FluidType.GAS, 295, true);
registerFluid(Materials.SulfuricGas, FluidType.GAS, 295, true);
registerFluid(Materials.Gas, FluidType.GAS, 295, true);
registerFluid(Materials.SulfuricNaphtha, FluidType.LIQUID, 295, true);
registerFluid(Materials.SulfuricLightFuel, FluidType.LIQUID, 295, true);
registerFluid(Materials.SulfuricHeavyFuel, FluidType.LIQUID, 295, true);
registerFluid(Materials.Naphtha, FluidType.LIQUID, 295, true);
registerFluid(Materials.LightFuel, FluidType.LIQUID, 295, true);
registerFluid(Materials.HeavyFuel, FluidType.LIQUID, 295, true);
registerFluid(Materials.LPG, FluidType.LIQUID, 295, true);
registerFluid(Materials.CrackedLightFuel, FluidType.LIQUID, 295, true);
registerFluid(Materials.CrackedHeavyFuel, FluidType.LIQUID, 295, true);
registerFluid(Materials.UUAmplifier, FluidType.LIQUID, 295, true);
registerFluid(Materials.Chlorine, FluidType.GAS, 295, true);
registerFluid(Materials.Mercury, FluidType.LIQUID, 295, true);
registerFluid(Materials.NitroFuel, FluidType.LIQUID, 295, true);
registerFluid(Materials.SodiumPersulfate, FluidType.LIQUID, 295, true);
registerFluid(Materials.Glyceryl, FluidType.LIQUID, 295, true);
registerFluid(Materials.Lubricant, FluidType.LIQUID, 295, true);
registerFluid(Materials.Creosote, FluidType.LIQUID, 295, true);
registerFluid(Materials.SeedOil, FluidType.LIQUID, 295, true);
registerFluid(Materials.FishOil, FluidType.LIQUID, 295, true);
registerFluid(Materials.Oil, FluidType.LIQUID, 295, true);
registerFluid(Materials.Fuel, FluidType.LIQUID, 295, true);
registerFluid(Materials.Honey, FluidType.LIQUID, 295, true);
registerFluid(Materials.Biomass, FluidType.LIQUID, 295, true);
registerFluid(Materials.Ethanol, FluidType.LIQUID, 295, true);
registerFluid(Materials.SulfuricAcid, FluidType.LIQUID, 295, true);
registerFluid(Materials.Milk, FluidType.LIQUID, 290, true);
registerFluid(Materials.McGuffium239, FluidType.LIQUID, 295, true);
registerFluid(Materials.Glue, FluidType.LIQUID, 295, true);
registerFluid(Materials.FryingOilHot, FluidType.LIQUID, 400, true);
for (Material material : Material.MATERIAL_REGISTRY) {
if (!(material instanceof FluidMaterial))
continue;
FluidMaterial fluidMaterial = (FluidMaterial) material;
if (fluidMaterial.shouldGenerateFluid() && fluidMaterial.getMaterialFluid() == null) {
int temperature = fluidMaterial.getFluidTemperature();
FluidType fluidType = fluidMaterial.hasFlag(MatFlags.STATE_GAS) ? FluidType.GAS : FluidType.LIQUID;
registerFluid(fluidMaterial, fluidType, temperature, false);
}
if (fluidMaterial.shouldGeneratePlasma() && fluidMaterial.getMaterialPlasma() == null) {
registerFluid(fluidMaterial, FluidType.PLASMA, 30000, false);
}
}
}
use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class MetaBlocks method createOreBlock.
private static void createOreBlock(DustMaterial material, StoneType[] stoneTypes, int index) {
BlockOre block = new BlockOre(material, stoneTypes);
block.setRegistryName("ore_" + material + "_" + index);
for (StoneType stoneType : stoneTypes) {
GregTechAPI.oreBlockTable.computeIfAbsent(material, m -> new HashMap<>()).put(stoneType, block);
}
ORES.add(block);
}
use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class MetaBlocks method createCompressedBlock.
private static void createCompressedBlock(Material[] materials, int index) {
BlockCompressed block = new BlockCompressed(materials);
block.setRegistryName("compressed_" + index);
for (Material material : materials) {
if (material instanceof DustMaterial)
COMPRESSED.put((DustMaterial) material, block);
}
}
Aggregations