From 17bf0dd960c4152d7c4a39d33a801efcd2855558 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=A4=C3=9Fler?= Date: Sat, 29 Apr 2017 17:23:19 +0200 Subject: [PATCH] Fixed a sneaky and game-breaking bug that caused quite a lot of fluids to no longer have recipes for filling cells. The reason for the bug was that the bit flag 256 is already in use to designate something as empty. Since only bit flags up to 128 were documented I had unwittingly used the 256 bit flag for fluid creation. The documentation now informs about the function of 256. Automatic fluid and gas creation are now controlled via booleans. Big thanks to Techlone for helping me debug. --- .../gregtech/api/enums/MaterialBuilder.java | 10 ++++--- .../java/gregtech/api/enums/Materials.java | 27 ++++++++++++++++--- .../GT_Loader_Item_Block_And_Fluid.java | 4 +-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/main/java/gregtech/api/enums/MaterialBuilder.java b/src/main/java/gregtech/api/enums/MaterialBuilder.java index 7fde89d2..cecbe8a7 100644 --- a/src/main/java/gregtech/api/enums/MaterialBuilder.java +++ b/src/main/java/gregtech/api/enums/MaterialBuilder.java @@ -31,6 +31,8 @@ public class MaterialBuilder { private int extraData = 0; private List materialList = new ArrayList(); private List aspects = new ArrayList(); + private boolean hasCorrespondingFluid = false; + private boolean hasCorrespondingGas = false; public MaterialBuilder(int metaItemSubID, TextureSet iconSet, String defaultLocalName) { this.metaItemSubID = metaItemSubID; @@ -41,7 +43,9 @@ public class MaterialBuilder { public Materials constructMaterial() { return new Materials(metaItemSubID, iconSet, toolSpeed, durability, toolQuality, types, r, g, b, a, name, defaultLocalName, fuelType, fuelPower, meltingPoint, blastFurnaceTemp, - blastFurnaceRequired, transparent, oreValue, densityMultiplier, densityDivider, color, extraData, materialList, aspects); + blastFurnaceRequired, transparent, oreValue, densityMultiplier, densityDivider, color, extraData, materialList, aspects) + .setHasCorrespondingFluid(hasCorrespondingFluid) + .setHasCorrespondingGas(hasCorrespondingGas); } public MaterialBuilder setName(String name){ @@ -95,12 +99,12 @@ public class MaterialBuilder { } public MaterialBuilder addFluid(){ - types = types | 256; + this.hasCorrespondingFluid = true; return this; } public MaterialBuilder addGas(){ - types = types | 512; + this.hasCorrespondingGas = true; return this; } diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 67d064c8..eb753907 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -786,6 +786,8 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public boolean mHasParentMod = true, mHasPlasma = false, mHasGas = false, mCustomOre = false; public Fluid mSolid = null, mFluid = null, mGas = null, mPlasma = null; + private boolean hasCorrespondingFluid = false, hasCorrespondingGas = false; + /** * 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. */ @@ -1534,8 +1536,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { * 32 = Plasma Cells * 64 = Tool Heads * 128 = Gears - * 256 = Automatically create a corresponding fluid for this material - * 512 = Automatically create a corresponding gas for this material + * 256 = Designates something as empty (only used for the Empty material) * @param aR, aG, aB Color of the Material 0-255 each. * @param aA transparency of the Material Texture. 0 = fully visible, 255 = Invisible. * @param aName The Name used as Default for localization. @@ -1719,7 +1720,7 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { } return mChemicalFormula; } - + /** * Adds a Class implementing IMaterialRegistrator to the master list */ @@ -1936,4 +1937,24 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { public static Collection getAll(){ return MATERIALS_MAP.values(); } + + + public boolean hasCorrespondingFluid() { + return hasCorrespondingFluid; + } + + + public Materials setHasCorrespondingFluid(boolean hasCorrespondingFluid) { + this.hasCorrespondingFluid = hasCorrespondingFluid; + return this; + } + + public boolean hasCorrespondingGas() { + return hasCorrespondingGas; + } + + public Materials setHasCorrespondingGas(boolean hasCorrespondingGas) { + this.hasCorrespondingGas = hasCorrespondingGas; + return this; + } } \ No newline at end of file diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index e457aadf..c00bf8c2 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -494,10 +494,10 @@ public class GT_Loader_Item_Block_And_Fluid if (tMaterial.mElement != null) { GT_Mod.gregtechproxy.addAutogeneratedPlasmaFluid(tMaterial); } - if ((tMaterial.mTypes & 256) != 0) { + if (tMaterial.hasCorrespondingFluid()) { GT_Mod.gregtechproxy.addAutoGeneratedCorrespondingFluid(tMaterial); } - if ((tMaterial.mTypes & 512) != 0) { + if (tMaterial.hasCorrespondingGas()) { GT_Mod.gregtechproxy.addAutoGeneratedCorrespondingGas(tMaterial); } }