aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2019-02-18 23:06:58 +0100
committerbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2019-02-18 23:06:58 +0100
commit799e376a4c422e15dd281765348129313e3dc123 (patch)
treebac63677fe4e5d5a28a5353f2337009b13466a57 /src/main/java
parent145c36f7579ccc4dc479d577f83e83b88b3f2fc1 (diff)
downloadGT5-Unofficial-799e376a4c422e15dd281765348129313e3dc123.tar.gz
GT5-Unofficial-799e376a4c422e15dd281765348129313e3dc123.tar.bz2
GT5-Unofficial-799e376a4c422e15dd281765348129313e3dc123.zip
fixes and API update
-fixed a bug where a circle dependency may exist -fixed a bug where Bacteria might be null -fixed a bug where the fallback might be wrong -fixed NBT issues with BioData -cleaned up NEI -fixed a bug where bacteria fluids might be null -optimised hashcodes to use murmur3 instead of Objects.hash Former-commit-id: a098d67778e16924b2f65e307f1b2be5131b4ce0
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java59
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java13
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java3
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java4
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java10
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LoaderRegistry.java3
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java10
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java18
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java88
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java133
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java47
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java34
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java33
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java10
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java3
18 files changed, 409 insertions, 65 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java
index e0e332fab1..92600b5bfe 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java
@@ -26,7 +26,9 @@ import com.github.bartimaeusnek.bartworks.util.BioCulture;
import com.github.bartimaeusnek.bartworks.util.BioDNA;
import com.github.bartimaeusnek.bartworks.util.BioData;
import com.github.bartimaeusnek.bartworks.util.BioPlasmid;
+import gregtech.api.objects.GT_Fluid;
import net.minecraft.item.EnumRarity;
+import net.minecraftforge.fluids.FluidRegistry;
import java.awt.*;
@@ -47,7 +49,11 @@ public final class BioObjectAdder {
* @return
*/
public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, EnumRarity rarity, boolean breedable) {
- return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, rarity, breedable);
+ if (BioCulture.BIO_CULTURE_ARRAY_LIST.size() > 1)
+ return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, rarity, breedable);
+ else
+ new Exception("Too Early to register a BioCulture! You MUST run this either after:bartworks OR in the init Phase!").printStackTrace();
+ return null;
}
/**
@@ -61,7 +67,11 @@ public final class BioObjectAdder {
* @return
*/
public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, boolean breedable) {
- return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, breedable);
+ if (BioCulture.BIO_CULTURE_ARRAY_LIST.size() > 1)
+ return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, breedable);
+ else
+ new Exception("Too Early to register a BioCulture! You MUST run this either after:bartworks OR in the init Phase!").printStackTrace();
+ return null;
}
/**
@@ -74,7 +84,10 @@ public final class BioObjectAdder {
* @return
*/
public static BioData createAndRegisterBioData(String aName, EnumRarity rarity, int chance, int tier) {
- return BioData.createAndRegisterBioData(aName, rarity, chance, tier);
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1)
+ return BioData.createAndRegisterBioData(aName, rarity, chance, tier);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!").printStackTrace();
+ return null;
}
/**
@@ -85,7 +98,10 @@ public final class BioObjectAdder {
* @return
*/
public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity) {
- return BioDNA.createAndRegisterBioDNA(aName, rarity);
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1)
+ return BioDNA.createAndRegisterBioDNA(aName, rarity);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!").printStackTrace();
+ return null;
}
/**
@@ -96,7 +112,10 @@ public final class BioObjectAdder {
* @return
*/
public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity) {
- return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity);
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1)
+ return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!").printStackTrace();
+ return null;
}
/**
@@ -107,7 +126,10 @@ public final class BioObjectAdder {
* @return
*/
public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity, int chance, int tier) {
- return BioDNA.createAndRegisterBioDNA(aName, rarity, chance, tier);
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1)
+ return BioDNA.createAndRegisterBioDNA(aName, rarity, chance, tier);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!").printStackTrace();
+ return null;
}
/**
@@ -118,8 +140,31 @@ public final class BioObjectAdder {
* @return
*/
public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity, int chance, int tier) {
- return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity, chance, tier);
+ if (BioData.BIO_DATA_ARRAY_LIST.size() > 1)
+ return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity, chance, tier);
+ new Exception("Too Early to register a BioData! You MUST run this either after:bartworks OR in the init Phase!").printStackTrace();
+ return null;
}
+ /**
+ * @param voltageTier (i.e. 6 for LuV, 7 for ZPM, only intresting for LuV+)
+ * @return the propper Bacteria Tier (at least 0)
+ */
+ public static int getBacteriaTierFromVoltageTier(int voltageTier){
+ return voltageTier-6 > 0 ? voltageTier-6 : 0;
+ }
+
+ /**
+ * If you get NPE's related to BioCultures (most likely because of Load Order or creating BioCultures after the postinit Phase) execute this.
+ */
+ public static void regenerateBioFluids(){
+ for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) {
+ if (B.getFluidNotSet()) {
+ B.setFluid(new GT_Fluid(B.getName().replaceAll(" ", "").toLowerCase() + "fluid", "molten.autogenerated", new short[]{(short) B.getColor().getRed(), (short) B.getColor().getBlue(), (short) B.getColor().getGreen()}));
+ if (!FluidRegistry.registerFluid(B.getFluid()))
+ new Exception("FAILED TO REGISTER FLUID FOR: "+B.getName()).printStackTrace();
+ }
+ }
+ }
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java
index feedb79761..0e40363356 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java
@@ -37,7 +37,7 @@ public final class BioRecipeAdder {
public static final int LOWGRAVITY = -100;
public static final int CLEANROOM = -200;
- public static boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
+ public static boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
return BWRecipes.instance.addBioLabRecipe(aInputs, aOutput, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
index f8206768bb..e0384239ba 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
@@ -24,11 +24,14 @@ package com.github.bartimaeusnek.bartworks;
import com.github.bartimaeusnek.bartworks.API.API_REFERENCE;
+import com.github.bartimaeusnek.bartworks.API.BioObjectAdder;
import com.github.bartimaeusnek.bartworks.client.ClientEventHandler.ClientEventHandler;
import com.github.bartimaeusnek.bartworks.client.creativetabs.BioTab;
import com.github.bartimaeusnek.bartworks.client.creativetabs.GT2Tab;
import com.github.bartimaeusnek.bartworks.client.creativetabs.bartworksTab;
import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler;
+import com.github.bartimaeusnek.bartworks.common.loaders.BioCultureLoader;
+import com.github.bartimaeusnek.bartworks.common.loaders.BioLabLoader;
import com.github.bartimaeusnek.bartworks.common.loaders.GTNHBlocks;
import com.github.bartimaeusnek.bartworks.common.loaders.LoaderRegistry;
import com.github.bartimaeusnek.bartworks.common.net.BW_Network;
@@ -52,8 +55,6 @@ import org.apache.logging.log4j.Logger;
dependencies = "required-after:IC2; "
+ "required-after:gregtech; "
+ "after:berriespp;"
- + "after:dreamcraft;"
- + "after:miscutils;"
)
public final class MainMod {
public static final String NAME = "BartWorks";
@@ -86,6 +87,11 @@ public final class MainMod {
CHandler = new ConfigHandler(preinit);
if (GTNH)
LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE.");
+
+ if (ConfigHandler.BioLab) {
+ BioCultureLoader bioCultureLoader = new BioCultureLoader();
+ bioCultureLoader.run();
+ }
}
@Mod.EventHandler
@@ -93,6 +99,8 @@ public final class MainMod {
if (FMLCommonHandler.instance().getSide().isClient() && ConfigHandler.BioLab)
MinecraftForge.EVENT_BUS.register(new ClientEventHandler());
new LoaderRegistry().run();
+ if (ConfigHandler.BioLab)
+ new BioLabLoader().run();
}
@Mod.EventHandler
@@ -100,5 +108,6 @@ public final class MainMod {
NetworkRegistry.INSTANCE.registerGuiHandler(instance, GH);
if (ConfigHandler.BioLab)
new GTNHBlocks().run();
+ BioObjectAdder.regenerateBioFluids();
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java
index f8c228e507..78ff73554f 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java
@@ -34,8 +34,6 @@ import java.awt.*;
public class BioCultureLoader implements Runnable {
public static final BioData BIO_DATA_BETA_LACMATASE = BioData.createAndRegisterBioData("beta-Lactamase", EnumRarity.uncommon, 10000, 0);
- private static final BioDNA NULLLDNA = BioDNA.createAndRegisterBioDNA("", EnumRarity.epic);
- private static final BioPlasmid NULLPLASMID = BioPlasmid.createAndRegisterBioPlasmid("", EnumRarity.epic);
private static final BioData BIO_DATA_YEAST = BioData.createAndRegisterBioData("Saccharomyces cerevisiae", EnumRarity.common);
private static final BioDNA BIO_DNA_WHINE_YEAST = BioDNA.createAndRegisterBioDNA("Saccharomyces cerevisiae var bayanus", EnumRarity.uncommon);
private static final BioDNA BIO_DNA_BEER_YEAST = BioDNA.createAndRegisterBioDNA("Saccharomyces cerevisiae var cerevisiae", EnumRarity.uncommon);
@@ -48,7 +46,6 @@ public class BioCultureLoader implements Runnable {
@Override
public void run() {
- BioCulture.createAndRegisterBioCulture(Color.BLUE, "", NULLPLASMID, NULLLDNA, false); //fallback NULL culture
CommonYeast = BioCulture.createAndRegisterBioCulture(new Color(255, 248, 200), "Saccharomyces cerevisiae", BioPlasmid.convertDataToPlasmid(BIO_DATA_YEAST), BioDNA.convertDataToDNA(BIO_DATA_YEAST), true);
WhineYeast = BioCulture.createAndRegisterBioCulture(new Color(255, 248, 200), "Saccharomyces cerevisiae var bayanus", BioPlasmid.convertDataToPlasmid(BIO_DATA_YEAST), BIO_DNA_WHINE_YEAST, true);
BeerYeast = BioCulture.createAndRegisterBioCulture(new Color(255, 248, 200), "Saccharomyces cerevisiae var cerevisiae", BioPlasmid.convertDataToPlasmid(BIO_DATA_YEAST), BIO_DNA_BEER_YEAST, true);
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java
index 04221196ce..4f862ba6a9 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java
@@ -24,15 +24,13 @@ package com.github.bartimaeusnek.bartworks.common.loaders;
public class BioLabLoader implements Runnable {
- BioCultureLoader bioCultureLoader;
+
FluidLoader fluidLoader;
BioItemList bioItemList;
BioRecipeLoader bioRecipeLoader;
@Override
public void run() {
- bioCultureLoader = new BioCultureLoader();
- bioCultureLoader.run();
fluidLoader = new FluidLoader();
fluidLoader.run();
bioItemList = new BioItemList();
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java
index 0b827b27a0..c0480e2970 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java
@@ -315,7 +315,7 @@ public class BioRecipeLoader extends RecipeLoader {
BWRecipes.instance.addBacterialVatRecipe(
new ItemStack[]{new ItemStack(Items.sugar, 64)},
new FluidStack[]{new FluidStack(fluidStack, 100)},
- BioCulture.BIO_CULTURE_ARRAY_LIST.get(1),
+ BioCultureLoader.CommonYeast,
new FluidStack[]{(Loader.isModLoaded("berriespp") ? FluidRegistry.getFluidStack("potion.ghp", 1) : Materials.Ethanol.getFluid(1L))},
350,
BW_Util.getMachineVoltageFromTier(4)
@@ -324,7 +324,7 @@ public class BioRecipeLoader extends RecipeLoader {
BWRecipes.instance.addBacterialVatRecipe(
new ItemStack[]{ItemList.Crop_Drop_Grapes.get(16)},
new FluidStack[]{new FluidStack(fluidStack, 100)},
- BioCulture.BIO_CULTURE_ARRAY_LIST.get(2),
+ BioCultureLoader.WhineYeast,
new FluidStack[]{FluidRegistry.getFluidStack("potion.wine", 12)},
200,
BW_Util.getMachineVoltageFromTier(2)
@@ -333,7 +333,7 @@ public class BioRecipeLoader extends RecipeLoader {
BWRecipes.instance.addBacterialVatRecipe(
new ItemStack[]{new ItemStack(Items.sugar, 4), ItemList.IC2_Hops.get(16L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wheat, 8L)},
new FluidStack[]{new FluidStack(fluidStack, 100)},
- BioCulture.BIO_CULTURE_ARRAY_LIST.get(3),
+ BioCultureLoader.BeerYeast,
new FluidStack[]{FluidRegistry.getFluidStack("potion.beer", 5)},
600,
BW_Util.getMachineVoltageFromTier(1)
@@ -341,7 +341,7 @@ public class BioRecipeLoader extends RecipeLoader {
BWRecipes.instance.addBacterialVatRecipe(
new ItemStack[]{ItemList.IC2_Hops.get(32L), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Wheat, 16L)},
new FluidStack[]{new FluidStack(fluidStack, 100)},
- BioCulture.BIO_CULTURE_ARRAY_LIST.get(3),
+ BioCultureLoader.BeerYeast,
new FluidStack[]{FluidRegistry.getFluidStack("potion.darkbeer", 10)},
600,
BW_Util.getMachineVoltageFromTier(1)
@@ -352,7 +352,7 @@ public class BioRecipeLoader extends RecipeLoader {
BWRecipes.instance.addBacterialVatRecipe(
null,
new FluidStack[]{FluidRegistry.getFluidStack("potion.grapejuice", 100)},
- BioCulture.BIO_CULTURE_ARRAY_LIST.get(2),
+ BioCultureLoader.WhineYeast,
new FluidStack[]{FluidRegistry.getFluidStack("potion.wine", 12)},
400,
BW_Util.getMachineVoltageFromTier(1)
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java
index 879578d24d..00bd28bde6 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java
@@ -70,7 +70,7 @@ public class FluidLoader implements Runnable {
BioLabFluidCells[i] = ItemFluidCell.getUniversalFluidCell(new FluidStack(BioLabFluidMaterials[i], 1000));
}
- BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).setFluid(new GT_Fluid("_NULL", "molten.autogenerated", BW_Util.splitColortoArray(BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB())));
+// BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).setFluid(new GT_Fluid("_NULL", "molten.autogenerated", BW_Util.splitColortoArray(BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB())));
for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) {
if (B.isBreedable()) {
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LoaderRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LoaderRegistry.java
index 7b21cfaef0..93a4fc75c8 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LoaderRegistry.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/LoaderRegistry.java
@@ -30,9 +30,6 @@ public class LoaderRegistry implements Runnable {
public void run() {
new ItemRegistry().run();
new RecipeLoader().run();
- if (ConfigHandler.BioLab) {
- new BioLabLoader().run();
- }
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java
index 30ff2f4b07..41d8373602 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java
@@ -89,7 +89,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
super(aName);
}
- private static int[] specialValueUnpack(int aSpecialValure) {
+ public static int[] specialValueUnpack(int aSpecialValure) {
int[] ret = new int[4];
ret[0] = aSpecialValure & 0xF; // = glas tier
ret[1] = aSpecialValure >>> 4 & 0b11; // = special valure
@@ -389,7 +389,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ * 2;
staticColorMap.remove(new Coords(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId));
- staticColorMap.put(new Coords(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId), lCulture == null ? BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB() : lCulture.getColorRGB());
+ staticColorMap.put(new Coords(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId), lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB());
if (FMLCommonHandler.instance().getSide().isServer()) {
MainMod.BW_Network_instance.sendPacketToAllPlayersInRange(
@@ -401,7 +401,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
zDir + z + this.getBaseMetaTileEntity().getZCoord(),
this.getBaseMetaTileEntity().getWorld().provider.dimensionId
),
- lCulture == null ? BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB() : lCulture.getColorRGB(),
+ lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB(),
true
),
this.getBaseMetaTileEntity().getXCoord(),
@@ -416,7 +416,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
zDir + z + this.getBaseMetaTileEntity().getZCoord(),
this.getBaseMetaTileEntity().getWorld().provider.dimensionId
),
- lCulture == null ? BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB() : lCulture.getColorRGB(),
+ lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB(),
false
),
this.getBaseMetaTileEntity().getXCoord(),
@@ -571,7 +571,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase {
zDir + z + this.getBaseMetaTileEntity().getZCoord(),
this.getBaseMetaTileEntity().getWorld().provider.dimensionId
),
- mCulture == null ? BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB() : mCulture.getColorRGB(),
+ mCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : mCulture.getColorRGB(),
true
),
this.getBaseMetaTileEntity().getXCoord(),
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java
index 593e9fee7a..2c1218e633 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java
@@ -28,6 +28,7 @@ import com.github.bartimaeusnek.bartworks.common.loaders.BioCultureLoader;
import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList;
import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader;
import com.github.bartimaeusnek.bartworks.util.*;
+import com.sun.istack.internal.NotNull;
import cpw.mods.fml.common.Loader;
import gregtech.api.enums.ItemList;
import gregtech.api.enums.Materials;
@@ -86,7 +87,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine {
FluidStack dnaFluid = Loader.isModLoaded("gendustry") ? FluidRegistry.getFluidStack("liquiddna", 1000) : Materials.Biomass.getFluid(1000L);
if (this.getSpecialSlot() != null && this.getSpecialSlot().getItem() instanceof LabModule) {
- int damage = getSpecialSlot().getItemDamage() + 1;
+ int damage = getSpecialSlot().getItemDamage();
switch (damage) {
case 0:
if (GT_Utility.isStackValid(this.mInventory[4]) && this.mInventory[4].getItem() instanceof LabParts && this.mInventory[4].getItemDamage() == 0 && this.mInventory[4].getTagCompound() != null && //checks if it is a Culture
@@ -197,9 +198,9 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine {
case 3: {
if (
GT_Utility.isStackValid(this.mInventory[4]) && GT_Utility.areStacksEqual(this.mInventory[4], BioItemList.getPetriDish(null), true) && this.mInventory[4].getTagCompound() != null &&
- GT_Utility.isStackValid(this.mInventory[5]) && GT_Utility.areStacksEqual(this.mInventory[5], BioItemList.getPlasmidCell(null), true) && this.mInventory[5].getTagCompound() != null &&
- GT_Utility.isStackValid(this.mInventory[6]) && GT_Utility.areStacksEqual(this.mInventory[6], FluidLoader.BioLabFluidCells[2]) &&
- this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) && this.mFluid.amount >= 1000) {
+ GT_Utility.isStackValid(this.mInventory[5]) && GT_Utility.areStacksEqual(this.mInventory[5], BioItemList.getPlasmidCell(null), true) && this.mInventory[5].getTagCompound() != null &&
+ GT_Utility.isStackValid(this.mInventory[6]) && GT_Utility.areStacksEqual(this.mInventory[6], FluidLoader.BioLabFluidCells[2]) &&
+ this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) && this.mFluid.amount >= 1000) {
BioData cultureDNABioData = BioData.getBioDataFromNBTTag(this.mInventory[5].getTagCompound());
BioCulture bioCulture = BioCulture.getBioCultureFromNBTTag(this.mInventory[4].getTagCompound());
if (cultureDNABioData == null || bioCulture == null)
@@ -213,7 +214,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine {
this.mFluid.amount -= 1000;
bioCulture.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData));
if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) {
- this.mOutputItems[0] = BioItemList.getPetriDish(bioCulture);
+ this.mOutputItems[0] = BioItemList.getPetriDish(checkForExisting(bioCulture));
}
this.mOutputItems[1] = ItemList.Cell_Universal_Fluid.get(1L);
this.calculateOverclockedNess(BW_Util.getMachineVoltageFromTier(3 + rTier + cultureDNABioData.getTier()), 500);
@@ -259,4 +260,11 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine {
}
return super.checkRecipe(skipOC);
}
+
+ private BioCulture checkForExisting(@NotNull BioCulture culture){
+ for (BioCulture bc : BioCulture.BIO_CULTURE_ARRAY_LIST)
+ if (culture.getdDNA().equals(bc.getdDNA()) && culture.getPlasmid().equals(bc.getPlasmid()))
+ return bc;
+ return culture;
+ }
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java
new file mode 100644
index 0000000000..b0b1fe61df
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2019 bartimaeusnek
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.github.bartimaeusnek.bartworks.neiHandler;
+
+import codechicken.nei.recipe.GuiCraftingRecipe;
+import codechicken.nei.recipe.GuiUsageRecipe;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import com.github.bartimaeusnek.bartworks.common.items.LabParts;
+import cpw.mods.fml.common.event.FMLInterModComms;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.util.GT_Recipe;
+import gregtech.nei.GT_NEI_DefaultHandler;
+import net.minecraft.item.ItemStack;
+
+import java.awt.*;
+
+public class BW_NEI_BioLabHandler extends GT_NEI_DefaultHandler {
+ public BW_NEI_BioLabHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) {
+ super(aRecipeMap);
+ this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier()));
+ if (!NEI_BW_Config.sIsAdded) {
+ FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtech@" + getRecipeName() + "@" + getOverlayIdentifier());
+ GuiCraftingRecipe.craftinghandlers.add(this);
+ GuiUsageRecipe.usagehandlers.add(this);
+ }
+ }
+
+ public TemplateRecipeHandler newInstance() {
+ return new BW_NEI_BioLabHandler(this.mRecipeMap);
+ }
+
+ public void loadCraftingRecipes(ItemStack aResult) {
+ if (aResult != null && aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3) {
+ for (GT_Recipe recipe : getSortedRecipes()) {
+ if (aResult.getTagCompound() != null && recipe != null)
+ for (int i = 0; i < recipe.mOutputs.length; i++) {
+ if (recipe.mOutputs[i] != null)
+ if (aResult.getTagCompound().equals(recipe.mOutputs[i].getTagCompound())) {
+ this.arecipes.add(new CachedDefaultRecipe(recipe));
+ break;
+ }
+
+ }
+ }
+ }
+ else
+ super.loadCraftingRecipes(aResult);
+ }
+
+ @Override
+ public void loadUsageRecipes(ItemStack aResult) {
+ if (aResult != null && aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3) {
+ for (GT_Recipe recipe : getSortedRecipes()) {
+ if (aResult.getTagCompound() != null && recipe != null)
+ for (int i = 0; i < recipe.mInputs.length; i++) {
+ if (recipe.mInputs[i] != null)
+ if (aResult.getTagCompound().equals(recipe.mInputs[i].getTagCompound())) {
+ this.arecipes.add(new CachedDefaultRecipe(recipe));
+ break;
+ }
+
+ }
+ }
+ }
+ else
+ super.loadCraftingRecipes(aResult);
+ }
+}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java
new file mode 100644
index 0000000000..ce8aaedd9b
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2019 bartimaeusnek
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.github.bartimaeusnek.bartworks.neiHandler;
+
+import codechicken.nei.recipe.GuiCraftingRecipe;
+import codechicken.nei.recipe.GuiUsageRecipe;
+import codechicken.nei.recipe.TemplateRecipeHandler;
+import com.github.bartimaeusnek.bartworks.common.items.LabParts;
+import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_BioVat;
+import cpw.mods.fml.common.event.FMLInterModComms;
+import gregtech.GT_Mod;
+import gregtech.api.enums.GT_Values;
+import gregtech.api.util.GT_Recipe;
+import gregtech.api.util.GT_Utility;