Fixes & work on #266

This commit is contained in:
Muramasa 2016-08-23 16:39:20 +01:00
parent ccfc536501
commit c66db54eab
7 changed files with 61 additions and 3 deletions

View file

@ -123,6 +123,7 @@ public class GT_Mod
GregTech_API.sMachineFile = new GT_Config(new Configuration(new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "MachineStats.cfg")));
GregTech_API.sWorldgenFile = new GT_Config(new Configuration(new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "WorldGeneration.cfg")));
GregTech_API.sMaterialProperties = new GT_Config(new Configuration(new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "MaterialProperties.cfg")));
GregTech_API.sMaterialComponents = new GT_Config(new Configuration(new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "MaterialComponents.cfg")));
GregTech_API.sUnification = new GT_Config(new Configuration(new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "Unification.cfg")));
GregTech_API.sSpecialFile = new GT_Config(new Configuration(new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "Other.cfg")));
GregTech_API.sOPStuff = new GT_Config(new Configuration(new File(new File(aEvent.getModConfigurationDirectory(), "GregTech"), "OverpoweredStuff.cfg")));

View file

@ -169,7 +169,7 @@ public class GregTech_API {
/**
* The Configuration Objects
*/
public static GT_Config sRecipeFile = null, sMachineFile = null, sWorldgenFile = null, sMaterialProperties = null, sUnification = null, sSpecialFile = null, sClientDataFile, sOPStuff = null, sMaterialsFile = null;
public static GT_Config sRecipeFile = null, sMachineFile = null, sWorldgenFile = null, sMaterialProperties = null, sMaterialComponents = null, sUnification = null, sSpecialFile = null, sClientDataFile, sOPStuff = null;
public static int TICKS_FOR_LAG_AVERAGING = 25, MILLISECOND_THRESHOLD_UNTIL_LAG_WARNING = 100;
/**
* Initialized by the Block creation.

View file

@ -6,6 +6,7 @@ import gregtech.api.enums.TC_Aspects.TC_AspectStack;
import gregtech.api.interfaces.IColorModulationContainer;
import gregtech.api.interfaces.IMaterialRegistrator;
import gregtech.api.interfaces.ISubTagContainer;
import gregtech.api.interfaces.IComponentRegistrator;
import gregtech.api.objects.GT_FluidStack;
import gregtech.api.objects.MaterialStack;
import gregtech.api.util.GT_Utility;
@ -22,6 +23,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
private static Materials[] MATERIALS_ARRAY = new Materials[]{};
private static final Map<String, Materials> MATERIALS_MAP = new HashMap<String, Materials>();
private static final List<IMaterialRegistrator> mMaterialRegistrators = new ArrayList<IMaterialRegistrator>();
private static final List<IComponentRegistrator> mComponentRegistrators = new ArrayList<IComponentRegistrator>();
/**
* This is the Default Material returned in case no Material has been found or a NullPointer has been inserted at a location where it shouldn't happen.
@ -731,6 +733,8 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
public byte mToolQuality = 0;
public boolean mHasPlasma = false, mHasGas = false, mCustomOre = false;
public Fluid mSolid = null, mFluid = null, mGas = null, mPlasma = null;
public List<OrePrefixes> mComponents = new LinkedList<>(Arrays.asList(OrePrefixes.dustTiny, OrePrefixes.dustSmall, OrePrefixes.dust, OrePrefixes.dustImpure, OrePrefixes.dustPure, OrePrefixes.crushed, OrePrefixes.crushedPurified, OrePrefixes.crushedCentrifuged, OrePrefixes.gem, OrePrefixes.nugget, OrePrefixes.ingot, OrePrefixes.ingotHot, OrePrefixes.ingotDouble, OrePrefixes.ingotTriple, OrePrefixes.ingotQuadruple, OrePrefixes.ingotQuintuple, OrePrefixes.plate, OrePrefixes.plateDouble, OrePrefixes.plateTriple, OrePrefixes.plateQuadruple, OrePrefixes.plateQuintuple, OrePrefixes.plateDense, OrePrefixes.stick, OrePrefixes.lens, OrePrefixes.round, OrePrefixes.bolt, OrePrefixes.screw, OrePrefixes.ring, OrePrefixes.foil, OrePrefixes.cell, OrePrefixes.cellPlasma, OrePrefixes.toolHeadSword, OrePrefixes.toolHeadPickaxe, OrePrefixes.toolHeadShovel, OrePrefixes.toolHeadAxe, OrePrefixes.toolHeadHoe, OrePrefixes.toolHeadHammer, OrePrefixes.toolHeadFile, OrePrefixes.toolHeadSaw, OrePrefixes.toolHeadDrill, OrePrefixes.toolHeadChainsaw, OrePrefixes.toolHeadWrench, OrePrefixes.toolHeadUniversalSpade, OrePrefixes.toolHeadSense, OrePrefixes.toolHeadPlow, OrePrefixes.toolHeadArrow, OrePrefixes.toolHeadBuzzSaw, OrePrefixes.turbineBlade, OrePrefixes.wireFine, OrePrefixes.gearGtSmall, OrePrefixes.rotor, OrePrefixes.stickLong, OrePrefixes.springSmall, OrePrefixes.spring, OrePrefixes.arrowGtWood, OrePrefixes.arrowGtPlastic, OrePrefixes.gemChipped, OrePrefixes.gemFlawed, OrePrefixes.gemFlawless, OrePrefixes.gemExquisite, OrePrefixes.gearGt, OrePrefixes.crateGtDust, OrePrefixes.crateGtIngot, OrePrefixes.crateGtGem, OrePrefixes.crateGtPlate));
public static List<OrePrefixes> mDefaultComponents = new LinkedList<>(Arrays.asList(OrePrefixes.dustTiny, OrePrefixes.dustSmall, OrePrefixes.dust, OrePrefixes.dustImpure, OrePrefixes.dustPure, OrePrefixes.crushed, OrePrefixes.crushedPurified, OrePrefixes.crushedCentrifuged, OrePrefixes.gem, OrePrefixes.nugget, OrePrefixes.ingot, OrePrefixes.ingotHot, OrePrefixes.ingotDouble, OrePrefixes.ingotTriple, OrePrefixes.ingotQuadruple, OrePrefixes.ingotQuintuple, OrePrefixes.plate, OrePrefixes.plateDouble, OrePrefixes.plateTriple, OrePrefixes.plateQuadruple, OrePrefixes.plateQuintuple, OrePrefixes.plateDense, OrePrefixes.stick, OrePrefixes.lens, OrePrefixes.round, OrePrefixes.bolt, OrePrefixes.screw, OrePrefixes.ring, OrePrefixes.foil, OrePrefixes.cell, OrePrefixes.cellPlasma, OrePrefixes.toolHeadSword, OrePrefixes.toolHeadPickaxe, OrePrefixes.toolHeadShovel, OrePrefixes.toolHeadAxe, OrePrefixes.toolHeadHoe, OrePrefixes.toolHeadHammer, OrePrefixes.toolHeadFile, OrePrefixes.toolHeadSaw, OrePrefixes.toolHeadDrill, OrePrefixes.toolHeadChainsaw, OrePrefixes.toolHeadWrench, OrePrefixes.toolHeadUniversalSpade, OrePrefixes.toolHeadSense, OrePrefixes.toolHeadPlow, OrePrefixes.toolHeadArrow, OrePrefixes.toolHeadBuzzSaw, OrePrefixes.turbineBlade, OrePrefixes.wireFine, OrePrefixes.gearGtSmall, OrePrefixes.rotor, OrePrefixes.stickLong, OrePrefixes.springSmall, OrePrefixes.spring, OrePrefixes.arrowGtWood, OrePrefixes.arrowGtPlastic, OrePrefixes.gemChipped, OrePrefixes.gemFlawed, OrePrefixes.gemFlawless, OrePrefixes.gemExquisite, OrePrefixes.gearGt, OrePrefixes.crateGtDust, OrePrefixes.crateGtIngot, OrePrefixes.crateGtGem, OrePrefixes.crateGtPlate));
/**
* This Fluid is used as standard Unit for Molten Materials. 1296 is a Molten Block, that means 144 is one Material Unit worth of fluid.
@ -1413,6 +1417,16 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
if (GT_Mod.gregtechproxy.mChangeHarvestLevels && aMaterial.mToolQuality > 0 && aMaterial.mMetaItemSubID < GT_Mod.gregtechproxy.mHarvestLevel.length && aMaterial.mMetaItemSubID >= 0) {
GT_Mod.gregtechproxy.mHarvestLevel[aMaterial.mMetaItemSubID] = GregTech_API.sMaterialProperties.get(aConfigPath, "HarvestLevel", aMaterial.mToolQuality);
}
if (aMaterial.mMetaItemSubID >= 0) {
for (IComponentRegistrator aRegistrator : mComponentRegistrators) {
aRegistrator.registerComponents(aMaterial);
}
aConfigPath = aConfigPath.replace("materials", "components");
for (OrePrefixes aPrefix : mDefaultComponents) {
boolean aComponent = GregTech_API.sMaterialComponents.get(aConfigPath, aPrefix.toString(), aMaterial.mComponents.contains(aPrefix));
if (!aComponent) aMaterial.mComponents.remove(aPrefix);
}
}
}
aConfigPathSB.setLength(0);
}
@ -1422,10 +1436,20 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
this(aMetaItemSubID, aIconSet, aToolSpeed, aDurability, aToolQuality, aUnificatable, aDefaultLocalName, "ore", false, "null");
}
public static String getFixedName(String aDefaultLocalName) {
if (aDefaultLocalName.contains(" ")) aDefaultLocalName = aDefaultLocalName.replaceAll(" ", "");
switch (aDefaultLocalName) {
case "Uranium": return "Uranium238";
case "Plutonium": return "Plutonium244";
case "Ash": return "Ashes";
default: return aDefaultLocalName;
}
}
public Materials(int aMetaItemSubID, TextureSet aIconSet, float aToolSpeed, int aDurability, int aToolQuality, boolean aUnificatable, String aDefaultLocalName, String aConfigSection, boolean aCustomOre, String aCustomID) {
mMetaItemSubID = aMetaItemSubID;
mDefaultLocalName = aDefaultLocalName;
mName = aDefaultLocalName.contains(" ") ? aDefaultLocalName.replaceAll(" ", "") : aDefaultLocalName;
mName = getFixedName(aDefaultLocalName);
MATERIALS_MAP.put(mName, this);
mCustomOre = aCustomOre;
mCustomID = aCustomID;
@ -1549,6 +1573,8 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
}
public static Materials get(String aMaterialName) {
//System.out.println("S:" + aMaterialName + " - M:" + getMaterialsMap().get(aMaterialName));
if (aMaterialName.equals("")) return Materials._NULL;
return getMaterialsMap().get(aMaterialName);
}
@ -1627,6 +1653,14 @@ public class Materials implements IColorModulationContainer, ISubTagContainer {
return mMaterialRegistrators.add(aRegistrator);
}
/**
* Adds a Class implementing IComponentRegistrator to the master list
*/
public static boolean add(IComponentRegistrator aRegistrator) {
if (aRegistrator == null) return false;
return mComponentRegistrators.add(aRegistrator);
}
/**
* Adds an ItemStack to this Material.
*/

View file

@ -0,0 +1,7 @@
package gregtech.api.interfaces;
import gregtech.api.enums.Materials;
public interface IComponentRegistrator {
void registerComponents(Materials aMaterial);
}

View file

@ -49,7 +49,7 @@ public abstract class GT_MetaGenerated_Item_X32 extends GT_MetaGenerated_Item {
OrePrefixes tPrefix = mGeneratedPrefixList[i / 1000];
if (tPrefix == null) continue;
Materials tMaterial = GregTech_API.sGeneratedMaterials[i % 1000];
if (tMaterial == null) continue;
if (tMaterial == null || !tMaterial.mComponents.contains(tPrefix)) continue;
if (doesMaterialAllowGeneration(tPrefix, tMaterial)) {
ItemStack tStack = new ItemStack(this, 1, i);
GT_LanguageManager.addStringLocalization(getUnlocalizedName(tStack) + ".name", getDefaultLocalization(tPrefix, tMaterial, i));

View file

@ -0,0 +1,14 @@
package gregtech.loaders.materialprocessing;
import gregtech.api.enums.Materials;
public class ProcessingComponents implements gregtech.api.interfaces.IComponentRegistrator {
public ProcessingComponents() {
Materials.add(this);
}
@Override
public void registerComponents(Materials aMaterial) {
//Disable components by default
}
}

View file

@ -1,11 +1,13 @@
package gregtech.loaders.preload;
import gregtech.api.util.GT_Log;
import gregtech.loaders.materialprocessing.ProcessingComponents;
import gregtech.loaders.materialprocessing.ProcessingConfig;
public class GT_Loader_MaterialProcessing implements Runnable {
public void run() {
GT_Log.out.println("GT_Mod: Register Material processing.");
new ProcessingConfig();
new ProcessingComponents();
}
}