Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static supersymmetry.api.util.SuSyUtility.susyId;

import gregicality.multiblocks.api.unification.material.GCYMMaterialIconTypes;
import gregtech.api.fluids.FluidState;
import gregtech.api.fluids.store.FluidStorageKey;
import supersymmetry.api.unification.material.info.SuSyMaterialIconType;
Expand All @@ -26,5 +27,11 @@ public final class SusyFluidStorageKeys {
m -> "susy.fluid.supercritical",
FluidState.GAS, -1);

public static final FluidStorageKey MOLTEN = new FluidStorageKey(susyId("molten"),
GCYMMaterialIconTypes.molten,
s -> "molten_" + s,
m -> "susy.fluid.molten",
FluidState.LIQUID, -1);

private SusyFluidStorageKeys() {}
}
1 change: 1 addition & 0 deletions src/main/java/supersymmetry/common/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ public static void postRegisterMaterials(@NotNull PostMaterialEvent event) {
MetaItems.addOrePrefix(SusyOrePrefix.dustWet);
MetaItems.addOrePrefix(SusyOrePrefix.electrode);

SusyMaterials.changeProperties();
Materials.Aluminium.addFlags("continuously_cast");
SusyGeneratedFluidHandler.init();

Expand Down
83 changes: 74 additions & 9 deletions src/main/java/supersymmetry/common/materials/SusyMaterials.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@

import gregtech.api.GregTechAPI;
import gregtech.api.fluids.FluidBuilder;
import gregtech.api.fluids.store.FluidStorageImpl;
import gregtech.api.fluids.store.FluidStorageKey;
import gregtech.api.fluids.store.FluidStorageKeys;
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.material.info.MaterialFlag;
import gregtech.api.unification.material.info.MaterialFlags;
import gregtech.api.unification.material.properties.*;
import net.minecraftforge.fluids.Fluid;
import supersymmetry.api.SusyLog;
import supersymmetry.api.fluids.SusyFluidStorageKeys;
import supersymmetry.api.unification.material.info.SuSyMaterialFlags;

public class SusyMaterials {
Expand Down Expand Up @@ -65,7 +69,6 @@ public static void init() {
SuSyOrganicChemistryMaterials.init();
SuSyHighDegreeMaterials.init();
SuSyUnknownCompositionMaterials.init();
changeProperties();
}

public static void removeFlags() {
Expand All @@ -75,7 +78,8 @@ public static void removeFlags() {
}
}

private static void changeProperties() {

public static void changeProperties() {
// removeProperty(PropertyKey.ORE, Materials.Graphite);

removeProperty(PropertyKey.ORE, Materials.Soapstone);
Expand Down Expand Up @@ -131,24 +135,26 @@ private static void changeProperties() {
Materials.Thallium.setProperty(PropertyKey.DUST, new DustProperty());

Materials.CalciumChloride.setProperty(PropertyKey.FLUID,
new FluidProperty(FluidStorageKeys.LIQUID, new FluidBuilder()));
new FluidProperty(SusyFluidStorageKeys.MOLTEN, new FluidBuilder()));

Materials.MagnesiumChloride.setProperty(PropertyKey.FLUID,
new FluidProperty(FluidStorageKeys.LIQUID, new FluidBuilder()));
new FluidProperty(SusyFluidStorageKeys.MOLTEN, new FluidBuilder()));

Materials.RockSalt.setProperty(PropertyKey.FLUID,
new FluidProperty(FluidStorageKeys.LIQUID, new FluidBuilder()));
new FluidProperty(SusyFluidStorageKeys.MOLTEN, new FluidBuilder()));

Materials.Salt.setProperty(PropertyKey.FLUID, new FluidProperty(FluidStorageKeys.LIQUID, new FluidBuilder()));
Materials.Salt.setProperty(PropertyKey.FLUID,
new FluidProperty(SusyFluidStorageKeys.MOLTEN, new FluidBuilder()));

Materials.SodiumHydroxide.setProperty(PropertyKey.FLUID,
new FluidProperty(FluidStorageKeys.LIQUID, new FluidBuilder()));
new FluidProperty(SusyFluidStorageKeys.MOLTEN, new FluidBuilder()));

Materials.Sodium.setProperty(PropertyKey.FLUID, new FluidProperty(FluidStorageKeys.LIQUID, new FluidBuilder()));
Materials.Sodium.setProperty(PropertyKey.FLUID,
new FluidProperty(SusyFluidStorageKeys.MOLTEN, new FluidBuilder()));

Materials.Phosphorus.setProperty(PropertyKey.INGOT, new IngotProperty());
Materials.Phosphorus.setProperty(PropertyKey.FLUID,
new FluidProperty(FluidStorageKeys.LIQUID, new FluidBuilder().temperature(317)));
new FluidProperty(SusyFluidStorageKeys.MOLTEN, new FluidBuilder().temperature(317)));
Materials.Phosphorus.setMaterialRGB(0xfffed6);

Materials.HydrochloricAcid.setFormula("(H2O)(HCl)", true);
Expand Down Expand Up @@ -188,6 +194,65 @@ private static void changeProperties() {
Materials.Electrum.setProperty(PropertyKey.ORE, new OreProperty());

Materials.Hydrogen.addFlags(MaterialFlags.FLAMMABLE);

for (Material material : GregTechAPI.materialManager.getRegisteredMaterials()) {

DustProperty dustProperty = material.getProperty(PropertyKey.DUST);
if (dustProperty != null) {

FluidProperty fluidProperty = material.getProperty(PropertyKey.FLUID);
if (fluidProperty != null) {

FluidStorageKey fluidState = fluidProperty.getPrimaryKey();
if (fluidState == FluidStorageKeys.LIQUID) {

removeFluidKey(FluidStorageKeys.LIQUID, material);
fluidProperty.enqueueRegistration(SusyFluidStorageKeys.MOLTEN, new FluidBuilder());
}
}
}
}

// Exceptions (Could probably condense)
removeFluidKey(SusyFluidStorageKeys.MOLTEN, SusyMaterials.Latex);
SusyMaterials.Latex.getProperty(PropertyKey.FLUID).enqueueRegistration(FluidStorageKeys.LIQUID, new FluidBuilder());
removeFluidKey(SusyFluidStorageKeys.MOLTEN, Materials.Concrete);
Materials.Concrete.getProperty(PropertyKey.FLUID).enqueueRegistration(FluidStorageKeys.LIQUID, new FluidBuilder());
removeFluidKey(SusyFluidStorageKeys.MOLTEN, Materials.Ice);
Materials.Ice.getProperty(PropertyKey.FLUID).enqueueRegistration(FluidStorageKeys.LIQUID, new FluidBuilder());
}

private static void removeFluidKey(FluidStorageKey key, Material material) {
FluidProperty fluidProperty = material.getProperty(PropertyKey.FLUID);
if (fluidProperty == null) return;

try {
Field storageField = FluidProperty.class.getDeclaredField("storage");
storageField.setAccessible(true);
FluidStorageImpl storage = (FluidStorageImpl) storageField.get(fluidProperty);

Field mapField = FluidStorageImpl.class.getDeclaredField("map");
mapField.setAccessible(true);
// noinspection unchecked
Map<FluidStorageKey, Fluid> map = (Map<FluidStorageKey, Fluid>) mapField.get(storage);
map.keySet().removeIf(k -> k == key);

Field toRegField = FluidStorageImpl.class.getDeclaredField("toRegister");
toRegField.setAccessible(true);
// noinspection unchecked
Map<FluidStorageKey, FluidBuilder> toReg = (Map<FluidStorageKey, FluidBuilder>) toRegField.get(storage);

if (toReg != null) {
toReg.keySet().removeIf(k -> k == key);
}

if (key == fluidProperty.getPrimaryKey()) {
fluidProperty.setPrimaryKey(null);
}

} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException("Failed removing FluidStorageKey", e);
}
}

private static void removeProperty(PropertyKey<?> key, Material material) {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/susy/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ item.material.oreprefix.electrode=%s Electrode
susy.fluid.supercritical=Supercritical %s
susy.fluid.impure_slurry=Impure %s Slurry
susy.fluid.slurry=%s Slurry
susy.fluid.molten=Molten %s

# Tooltip Warnings
susy.machine.steam_extractor_cannot_melt_items.warning=Steam Extractors cannot melt items!
Expand Down
Loading