diff options
author | â€huajijam <strhuaji@gmail.com> | 2019-02-20 17:38:04 +0800 |
---|---|---|
committer | â€huajijam <strhuaji@gmail.com> | 2019-02-20 17:38:04 +0800 |
commit | e7dca95d5389b94798865649e2829b650bfb1da3 (patch) | |
tree | 902664f09c9662b9d640ada0060933da4b6bea5a /src/main | |
parent | 795e3c58afa8b6a794155439904ef26a6fbc963b (diff) | |
parent | 0edb18ca00f94e4930eb4b854f99b2affd5999e6 (diff) | |
download | GT5-Unofficial-e7dca95d5389b94798865649e2829b650bfb1da3.tar.gz GT5-Unofficial-e7dca95d5389b94798865649e2829b650bfb1da3.tar.bz2 GT5-Unofficial-e7dca95d5389b94798865649e2829b650bfb1da3.zip |
Automatic synchronization
Former-commit-id: e8bd8ce82c09b98183a40265b1c90a92d4ab7cff
Diffstat (limited to 'src/main')
18 files changed, 410 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..b2e34902c0 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 @@ -86,7 +86,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 +197,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 +213,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 +259,13 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { } return super.checkRecipe(skipOC); } + + private BioCulture checkForExisting(BioCulture culture){ + if (culture == null) + return null; + 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", -16777216); + drawText(10, lines[1], this.trans("153", "Usage: ") + tEUt + " EU/t", -16777216); + if (this.mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10,lines[2], this.trans("154", "Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); + drawText(10, lines[3], this.trans("155", "Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + } else { + drawText(10, lines[2], this.trans("156", "Voltage: unspecified"), -16777216); + drawText(10, lines[3], this.trans("157", "Amperage: unspecified"), -16777216); + } + } + + + + if (tDuration > 0) { + drawText(10, lines[4], this.trans("158", "Time: ") + String.format("%.2f " + this.trans("161", " secs"), 0.05F * (float)tDuration), -16777216); + } + + tSpecial = ((GT_NEI_DefaultHandler.CachedDefaultRecipe)this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + + int[] tSpecialA = GT_TileEntity_BioVat.specialValueUnpack(tSpecial); + + drawText(10, lines[5], "Needs Glas Tier: "+ tSpecialA[0],-16777216); + + if (tSpecialA[1] == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { + drawText(10, lines[7], this.trans("159", "Needs Low Gravity"), -16777216); + } else if (tSpecialA[1] == -200 && GT_Mod.gregtechproxy.mEnableCleanroom) { + drawText(10, lines[7], this.trans("160", "Needs Cleanroom"), -16777216); + } else if (tSpecialA[1] == -300 && GT_Mod.gregtechproxy.mEnableCleanroom) { + drawText(10, lines[7], this.trans("160", "Needs Cleanroom & LowGrav"), -16777216); + } else if (tSpecialA[1] == -400) { + drawText(10, lines[7], this.trans("216", "Deprecated Recipe"), -16777216); + } else if (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre) || GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost)) { + drawText(10, lines[6],(tSpecialA[2] == 1 ? "Need exactly": "Need minimum") + this.mRecipeMap.mNEISpecialValuePre + tSpecialA[3] * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + } + } else { + tSpecial = 0; + String[] var6 = recipeDesc; + int var7 = recipeDesc.length; + + for(int var8 = 0; var8 < var7; ++var8) { + String descLine = var6[var8]; + drawText(10, 73 + 10 * tSpecial, descLine, -16777216); + ++tSpecial; + } + } + + } + + @Override + public void loadUsageRecipes(ItemStack aResult) { + if (aResult != null && aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3) + for (GT_Recipe recipe : this.getSortedRecipes()) { + if (aResult.getTagCompound() != null && recipe != null) + if (recipe.mSpecialItems instanceof ItemStack && ((ItemStack) recipe.mSpecialItems).getItem() instanceof LabParts) + if (aResult.getTagCompound().equals(((ItemStack) recipe.mSpecialItems).getTagCompound())) { + this.arecipes.add(new CachedDefaultRecipe(recipe)); + } + } + else + super.loadCraftingRecipes(aResult); + } + + @Override + public void loadCraftingRecipes(ItemStack aResult) { + if (aResult == null || !(aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3 )) { + super.loadCraftingRecipes(aResult); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java new file mode 100644 index 0000000000..3614f608b1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java @@ -0,0 +1,47 @@ +/* + * 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.api.IConfigureNEI; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; + +public class NEI_BW_Config implements IConfigureNEI { + + public static boolean sIsAdded = true; + + public void loadConfig() { + sIsAdded = false; + new BW_NEI_BioVatHandler(BWRecipes.instance.getMappingsFor(BWRecipes.BACTERIALVATBYTE)); + new BW_NEI_BioLabHandler(BWRecipes.instance.getMappingsFor(BWRecipes.BIOLABBYTE)); + sIsAdded = true; + } + + public String getName() { + return "BartWorks NEI Plugin"; + } + + public String getVersion() { + return MainMod.APIVERSION; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java index cba13261d0..33b699a87b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -66,7 +66,8 @@ public class BWRecipes { null, "gregtech:textures/gui/basicmachines/BW.GUI.BioLab", 6, 2, 1, 1, 1, - "", 1, "", true, true); + "", 1, "", true, false //special handler + ); private final BacteriaVatRecipeMap sBacteriaVat = new BacteriaVatRecipeMap( new HashSet<GT_Recipe>(50), "bw.recipe.BacteriaVat", @@ -74,7 +75,8 @@ public class BWRecipes { null, "gregtech:textures/gui/basicmachines/Default", 6, 2, 0, 1, 1, - "Need Sievert: ", 1, " Sv", true, true); + " Sievert: ", 1, " Sv", true, false //special handler + ); private final BW_Recipe_Map_LiquidFuel sAcidGenFuels = new BW_Recipe_Map_LiquidFuel( new HashSet<GT_Recipe>(10), "bw.fuels.acidgens", @@ -317,7 +319,7 @@ public class BWRecipes { } - public boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + public boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) return true; return false; @@ -370,13 +372,14 @@ public class BWRecipes { return false; } + @Deprecated public boolean addBacterialVatRecipe(ItemStack[] aInputs, ItemStack[] aOutputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, Materials material, @Nonnegative byte glasTier) { int aSievert = 0; if (material.getProtons() >= 83 || material.getProtons() == 61 || material.getProtons() == 43) aSievert += calculateSv(material); aSievert = aSievert << 6; aSievert = aSievert | glasTier; - if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, aOutputs, new ItemStack[]{GT_Values.NI}, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) + if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, aOutputs, null, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) return true; return false; } @@ -392,7 +395,7 @@ public class BWRecipes { aSievert = aSievert | specialToByte(aSpecialValue); aSievert = aSievert << 4; aSievert = aSievert | gTier; - if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, new ItemStack[]{BioItemList.getPetriDish(aCulture)}, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) + if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, BioItemList.getPetriDish(aCulture), new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) return true; return false; } @@ -408,11 +411,12 @@ public class BWRecipes { aSievert = aSievert | specialToByte(aSpecialValue); aSievert = aSievert << 4; aSievert = aSievert | gTier; - if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, new ItemStack[]{BioItemList.getPetriDish(aCulture)}, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) + if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, BioItemList.getPetriDish(aCulture), new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) return true; return false; } + @Deprecated public boolean addBacterialVatRecipe(ItemStack[] aInputs, ItemStack[] aOutputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, Materials material, boolean exactSv) { int aSievert = 0; if (material.getProtons() >= 83 || material.getProtons() == 61 || material.getProtons() == 43) @@ -420,7 +424,7 @@ public class BWRecipes { aSievert = aSievert << 1; aSievert = aSievert | (exactSv ? 1 : 0); aSievert = aSievert << 6; - if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, aOutputs, new ItemStack[]{GT_Values.NI}, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) + if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, aOutputs, null, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) return true; return false; } @@ -434,7 +438,7 @@ public class BWRecipes { aSievert = aSievert << 2; aSievert = aSievert | specialToByte(aSpecialValue); aSievert = aSievert << 4; - if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, new ItemStack[]{BioItemList.getPetriDish(culture)}, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) + if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, BioItemList.getPetriDish(culture), new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) return true; return false; } @@ -446,7 +450,7 @@ public class BWRecipes { int aSievert = 0; aSievert = aSievert << 7; aSievert = aSievert | glasTier; - if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, new ItemStack[]{BioItemList.getPetriDish(culture)}, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) + if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, BioItemList.getPetriDish(culture), new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) return true; return false; } @@ -455,7 +459,7 @@ public class BWRecipes { * Adds a Vat recipe without Rad or Glas requirements */ public boolean addBacterialVatRecipe(ItemStack[] aInputs, FluidStack[] aFluidInputs, BioCulture culture, FluidStack[] aFluidOutputs, int aDuration, int aEUt) { - if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, new ItemStack[]{BioItemList.getPetriDish(culture)}, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, 0)) != null) + if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(false, aInputs, null, BioItemList.getPetriDish(culture), new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, 0)) != null) return true; return false; } @@ -472,7 +476,7 @@ public class BWRecipes { aSievert = aSievert | specialToByte(aSpecialValue); aSievert = aSievert << 4; aSievert = aSievert | gTier; - if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(true, aInputs, null, new ItemStack[]{BioItemList.getPetriDish(aCulture)}, new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) + if (sBacteriaVat.addRecipe(new BacteriaVatRecipe(true, aInputs, null, BioItemList.getPetriDish(aCulture), new int[]{}, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert)) != null) return true; return false; } @@ -498,19 +502,19 @@ public class BWRecipes { } class BioLabRecipe extends GT_Recipe { - protected BioLabRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + protected BioLabRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); } } - class BacteriaVatRecipe extends GT_Recipe { - protected BacteriaVatRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + public static class BacteriaVatRecipe extends GT_Recipe { + protected BacteriaVatRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); } } - class BacteriaVatRecipeMap extends GT_Recipe.GT_Recipe_Map { + public static class BacteriaVatRecipeMap extends GT_Recipe.GT_Recipe_Map { public BacteriaVatRecipeMap(Collection<GT_Recipe> aRecipeList, String aUnlocalizedName, String aLocalName, String aNEIName, String aNEIGUIPath, int aUsualInputCount, int aUsualOutputCount, int aMinimalInputItems, int aMinimalInputFluids, int aAmperage, String aNEISpecialValuePre, int aNEISpecialValueMultiplier, String aNEISpecialValuePost, boolean aShowVoltageAmperageInNEI, boolean aNEIAllowed) { super(aRecipeList, aUnlocalizedName, aLocalName, aNEIName, aNEIGUIPath, aUsualInputCount, aUsualOutputCount, aMinimalInputItems, aMinimalInputFluids, aAmperage, aNEISpecialValuePre, aNEISpecialValueMultiplier, aNEISpecialValuePost, aShowVoltageAmperageInNEI, aNEIAllowed); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java index 15f432aab3..98601e568c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java @@ -30,12 +30,15 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import java.awt.*; +import java.nio.ByteBuffer; import java.util.ArrayList; +import java.util.Arrays; import java.util.Objects; public class BioCulture extends BioData { public static final ArrayList<BioCulture> BIO_CULTURE_ARRAY_LIST = new ArrayList<BioCulture>(); + public static final BioCulture NULLCULTURE = BioCulture.createAndRegisterBioCulture(Color.BLUE, "", BioPlasmid.NULLPLASMID,BioDNA.NULLDNA, false); //fallback NULL culture, also Blue =) Color color; BioPlasmid plasmid; @@ -75,7 +78,7 @@ public class BioCulture extends BioData { return new NBTTagCompound(); NBTTagCompound ret = new NBTTagCompound(); ret.setString("Name", bioCulture.name); - ret.setInteger("ID", bioCulture.ID); + //ret.setInteger("ID", bioCulture.ID); ret.setIntArray("Color", new int[]{bioCulture.color.getRed(), bioCulture.color.getGreen(), bioCulture.color.getBlue()}); ret.setTag("Plasmid", BioData.getNBTTagFromBioData(BioData.convertBioPlasmidToBioData(bioCulture.plasmid))); ret.setTag("DNA", BioData.getNBTTagFromBioData(BioData.convertBioDNAToBioData(bioCulture.dDNA))); @@ -89,17 +92,21 @@ public class BioCulture extends BioData { public static BioCulture getBioCultureFromNBTTag(NBTTagCompound tag) { if (tag == null || tag.getIntArray("Color").length == 0) return null; - BioCulture ret = new BioCulture( - new Color(tag.getIntArray("Color")[0], tag.getIntArray("Color")[1], tag.getIntArray("Color")[2]), - tag.getString("Name"), - tag.getInteger("ID"), - BioPlasmid.convertDataToPlasmid(getBioDataFromNBTTag(tag.getCompoundTag("Plasmid"))), - BioDNA.convertDataToDNA(getBioDataFromNBTTag(tag.getCompoundTag("DNA"))), - BW_Util.getRarityFromByte(tag.getByte("Rarety")), - tag.getBoolean("Breedable") - ); + BioCulture ret = getBioCulture(tag.getString("Name")); + + if (ret == null) + ret = createAndRegisterBioCulture( + new Color(tag.getIntArray("Color")[0], tag.getIntArray("Color")[1], tag.getIntArray("Color")[2]), + tag.getString("Name"), + BioPlasmid.convertDataToPlasmid(getBioDataFromNBTTag(tag.getCompoundTag("Plasmid"))), + BioDNA.convertDataToDNA(getBioDataFromNBTTag(tag.getCompoundTag("DNA"))), + BW_Util.getRarityFromByte(tag.getByte("Rarety")), + tag.getBoolean("Breedable") + ); if (ret.bBreedable) ret.setFluid(FluidRegistry.getFluid(tag.getString("Fluid"))); + if (ret.getFluidNotSet()) //should never happen, but better safe than sorry + ret.setbBreedable(false); return ret; } @@ -123,6 +130,10 @@ public class BioCulture extends BioData { return this.mFluid; } + public boolean getFluidNotSet(){ + return this.mFluid == null && this.isBreedable(); + } + public void setFluid(Fluid mFluid) { this.mFluid = mFluid; } @@ -184,6 +195,6 @@ public class BioCulture extends BioData { @Override public int hashCode() { - return Objects.hash(super.hashCode(), this.getColor(), this.getPlasmid(), this.getdDNA(), this.isBreedable(), this.mFluid); + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(17).putInt(MurmurHash3.murmurhash3_x86_32(this.getName(),0,this.getName().length(),31)).putInt(this.getColorRGB()).putInt(this.getPlasmid().ID).putInt(this.getdDNA().ID).put((byte) (isBreedable() ? 1 : 0)).array(),0,17,31); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java index 65a7de4ab0..4cdbf1a143 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java @@ -26,6 +26,8 @@ import net.minecraft.item.EnumRarity; public class BioDNA extends BioData { + public static final BioDNA NULLDNA = createAndRegisterBioDNA("", EnumRarity.epic); + protected BioDNA(String name, int ID, EnumRarity rarity) { super(name, ID, rarity); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java index ac9c7d2083..f4e8917e67 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java @@ -25,11 +25,13 @@ package com.github.bartimaeusnek.bartworks.util; import net.minecraft.item.EnumRarity; import net.minecraft.nbt.NBTTagCompound; +import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Objects; public class BioData { public static final ArrayList<BioData> BIO_DATA_ARRAY_LIST = new ArrayList<BioData>(); + protected String name; protected int ID; protected EnumRarity rarity; @@ -83,7 +85,7 @@ public class BioData { NBTTagCompound ret = new NBTTagCompound(); ret.setByte("Rarity", BW_Util.getByteFromRarity(bioData.rarity)); ret.setString("Name", bioData.name); - ret.setInteger("ID", bioData.ID); + //ret.setInteger("ID", bioData.ID); buggy when load Order changes ret.setInteger("Chance", bioData.chance); ret.setInteger("Tier", bioData.tier); return ret; @@ -107,16 +109,16 @@ public class BioData { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; BioData bioData = (BioData) o; - return this.getID() == bioData.getID() && + return this.getID() == bioData.getID() || ( this.getChance() == bioData.getChance() && this.getTier() == bioData.getTier() && Objects.equals(this.getName(), bioData.getName()) && - this.getRarity() == bioData.getRarity(); + this.getRarity() == bioData.getRarity()); } @Override public int hashCode() { - return Objects.hash(this.getName(), this.getID(), this.getRarity(), this.getChance(), this.getTier()); + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(13).putInt(MurmurHash3.murmurhash3_x86_32(this.getName(),0,this.getName().length(),31)).put(BW_Util.getByteFromRarity(this.getRarity())).putInt(this.getChance()).putInt(this.getTier()).array(),0,13,31); } public int getTier() { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java index 7b034f8c43..1d59edb5ea 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java @@ -25,6 +25,9 @@ package com.github.bartimaeusnek.bartworks.util; import net.minecraft.item.EnumRarity; public class BioPlasmid extends BioData { + + public static final BioPlasmid NULLPLASMID = convertDataToPlasmid(BioData.convertBioDNAToBioData(BioDNA.NULLDNA)); + private BioPlasmid(String name, int ID, EnumRarity rarity) { super(name, ID, rarity); } |