diff options
Diffstat (limited to 'src/main/java/com')
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; +import gregtech.nei.GT_NEI_DefaultHandler; +import net.minecraft.item.ItemStack; + +import java.awt.*; + +public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { + + public BW_NEI_BioVatHandler(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_BioVatHandler(this.mRecipeMap); + } + + public void drawExtras(int aRecipeIndex) { + int base = 70; + int[] lines ={ base,base+8,base+16,base+24,base+32,base+40,base+48,base+56,base+64}; + int tEUt = ((GT_NEI_DefaultHandler.CachedDefaultRecipe)this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; + int tDuration = ((GT_NEI_DefaultHandler.CachedDefaultRecipe)this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; + String[] recipeDesc = ((GT_NEI_DefaultHandler.CachedDefaultRecipe)this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); + int tSpecial; + if (recipeDesc == null) { + if (tEUt != 0) { + drawText(10, lines[0], this.trans("152", "Total: ") + (long)tDuration * (long)tEUt + " EU |
