diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-01-09 19:17:23 +0100 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-01-09 19:17:23 +0100 |
commit | 82bd52008b663bd38e96472c5d12a3db8bca63b3 (patch) | |
tree | 0fdffcfce6e9d3e163d0bcdf9cbc681153860986 /src | |
parent | b1e249a5d28a0fcc72943042866580147b6efb40 (diff) | |
download | GT5-Unofficial-82bd52008b663bd38e96472c5d12a3db8bca63b3.tar.gz GT5-Unofficial-82bd52008b663bd38e96472c5d12a3db8bca63b3.tar.bz2 GT5-Unofficial-82bd52008b663bd38e96472c5d12a3db8bca63b3.zip |
Bio Cultre System!
-Added the Bio Cultre System
-Added the Bio Vat, Bio Lab and custom Glas types
-Updated Copyright on the Files
-Added a shitton of ressources
-Added an API to for the Bio Cultre System
-Added a Phyton Script for the ease of adding Glas Types to the Bio Vat
-Fixed Spawning on custom blocks
-Fixed Nuggets giving out boni in the windmill
-Fixed tooltip again for the Windmill
-Added dimensionsIDs to the BlockCoord class
-Added apiJar, sourceJar, devJar to the grandlew output
Diffstat (limited to 'src')
95 files changed, 6891 insertions, 631 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/API_REFERENCE.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/API_REFERENCE.java new file mode 100644 index 0000000000..2767d56168 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/API_REFERENCE.java @@ -0,0 +1,27 @@ +/* + * 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.API; + +public final class API_REFERENCE { + public static final String VERSION = "@version@"; +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java new file mode 100644 index 0000000000..e0e332fab1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectAdder.java @@ -0,0 +1,125 @@ +/* + * 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.API; + +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 net.minecraft.item.EnumRarity; + +import java.awt.*; + +public final class BioObjectAdder { + +// @Deprecated +// public static BioCulture createAndRegisterBioCulture(Color color, String name, long ID, BioPlasmid plasmid, BioDNA dna, EnumRarity rarity){ +// return BioCulture.createAndRegisterBioCulture(color,name,ID,plasmid,dna,rarity); +// } + + /** + * @param color the color of the Culture + * @param name the name of the Culture + * @param plasmid the cultures plasmid, get it from createAndRegisterBioPlasmid + * @param dna the cultures dna, get it from createAndRegisterBioDNA + * @param breedable if the culture can be inserted into the BacterialVat + * @param rarity visual + * @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); + } + + /** + * rarity inherits from dna + * + * @param color the color of the Culture + * @param name the name of the Culture + * @param plasmid the cultures plasmid, get it from createAndRegisterBioPlasmid + * @param dna the cultures dna, get it from createAndRegisterBioDNA + * @param breedable if the culture can be inserted into the BacterialVat + * @return + */ + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, boolean breedable) { + return BioCulture.createAndRegisterBioCulture(color, name, plasmid, dna, breedable); + } + + /** + * unspecific Biodata that can be converted into DNA and Plasmid with the propper methodes + * + * @param aName the name of the Biodata + * @param rarity visual only + * @param chance the chanche to extract this BioData + * @param tier the tier of this BioData 0=HV, 1=EV etc. + * @return + */ + public static BioData createAndRegisterBioData(String aName, EnumRarity rarity, int chance, int tier) { + return BioData.createAndRegisterBioData(aName, rarity, chance, tier); + } + + /** + * Default Constructor for HV Tier DNA with 75% extraction rate + * + * @param aName Name of the DNA String + * @param rarity visual + * @return + */ + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity) { + return BioDNA.createAndRegisterBioDNA(aName, rarity); + } + + /** + * Default Constructor for HV Tier Plasmid with 75% extraction rate + * + * @param aName Name of the Plasmid + * @param rarity visual + * @return + */ + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity) { + return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity); + } + + /** + * @param aName Name of the DNA String + * @param rarity visual + * @param chance chanche of extracting + * @param tier tier needed to extract 0=HV, 1=EV etc. + * @return + */ + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity, int chance, int tier) { + return BioDNA.createAndRegisterBioDNA(aName, rarity, chance, tier); + } + + /** + * @param aName Name of the Plasmid + * @param rarity visual + * @param chance chanche of extracting + * @param tier tier needed to extract 0=HV, 1=EV etc. + * @return + */ + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity, int chance, int tier) { + return BioPlasmid.createAndRegisterBioPlasmid(aName, rarity, chance, tier); + } + + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java new file mode 100644 index 0000000000..86ec61c138 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioObjectGetter.java @@ -0,0 +1,122 @@ +/* + * 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.API; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +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 net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.util.Collection; + +public final class BioObjectGetter { + + public static BioCulture getBioCulture(String aName) { + return BioCulture.getBioCulture(aName); + } + + public static NBTTagCompound getNBTTagFromCulture(BioCulture bioCulture) { + return BioCulture.getNBTTagFromCulture(bioCulture); + } + + public static NBTTagCompound getNBTTagFromBioPlasmid(BioPlasmid bioPlasmid) { + return getNBTTagFromBioData(convertBioPlasmidToData(bioPlasmid)); + } + + public static NBTTagCompound getNBTTagFromBioDNA(BioDNA bioDNA) { + return getNBTTagFromBioData(convertBioDNAtoData(bioDNA)); + } + + public static NBTTagCompound getNBTTagFromBioData(BioData bioData) { + return BioData.getNBTTagFromBioData(bioData); + } + + public static BioDNA convertDataToDNA(BioData bioData) { + return BioDNA.convertDataToDNA(bioData); + } + + public static BioPlasmid convertDataToPlasmid(BioData bioData) { + return BioPlasmid.convertDataToPlasmid(bioData); + } + + public static BioData convertBioPlasmidToData(BioPlasmid bioPlasmid) { + return BioData.convertBioPlasmidToBioData(bioPlasmid); + } + + public static BioData convertDataToDNA(BioDNA bioData) { + return BioData.convertBioDNAToBioData(bioData); + } + + public static BioData convertBioDNAtoData(BioDNA bioDNA) { + return BioData.convertBioDNAToBioData(bioDNA); + } + + public static BioPlasmid convertBioDNAtoBioPlasmid(BioDNA bioDNA) { + return convertDataToPlasmid(convertBioDNAtoData(bioDNA)); + } + + public static BioDNA convertBioPlasmidtoBioDNA(BioPlasmid bioPlasmid) { + return convertDataToDNA(convertBioPlasmidToData(bioPlasmid)); + } + + public static Collection<ItemStack> getAllPetriDishes() { + return BioItemList.getAllPetriDishes(); + } + + public static Collection<ItemStack> getAllDNASampleFlasks() { + return BioItemList.getAllDNASampleFlasks(); + } + + public static Collection<ItemStack> getAllPlasmidCells() { + return BioItemList.getAllPlasmidCells(); + } + + public static ItemStack getDNASampleFlask(BioDNA dna) { + return BioItemList.getDNASampleFlask(dna); + } + + public static ItemStack getPetriDish(BioCulture culture) { + return BioItemList.getPetriDish(culture); + } + + public static ItemStack getPlasmidCell(BioPlasmid plasmid) { + return BioItemList.getPlasmidCell(plasmid); + } + + /** + * 1 - DetergentPowder + * 2 - Agarose + * 3 - IncubationModule + * 4 - Plasma Membrane + * + * @param selection + * @return the selected Item + */ + public static ItemStack getOther(int selection) { + return BioItemList.getOther(selection); + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java new file mode 100644 index 0000000000..0f81d266f0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioRecipeAdder.java @@ -0,0 +1,124 @@ +/* + * 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.API; + +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import gregtech.api.enums.Materials; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; + +public final class BioRecipeAdder { + + public static final int STANDART = 0; + 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) { + return BWRecipes.instance.addBioLabRecipe(aInputs, aOutput, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); + } + + /** + * Adds a Incubation Recipe for the BioLab. + * + * @param aInput any item that will be added with a petri dish + * @param aOutput must be a BioCulture + * @param aChances + * @param aFluidInputs + * @param aDuration + * @param aEUt use BW_Util.getMachineVoltageFromTier(tier) to get optimal EU/t + * @param aSpecialValue 0 = STANDART, -100 = LowGravity, -200 = Cleanroom + * @return if the recipe was added. + */ + public static boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { + return BWRecipes.instance.addBioLabRecipeIncubation(aInput, aOutput, aChances, aFluidInputs, aDuration, aEUt, aSpecialValue); + } + + /** + * @param aInputs Item Inputs, DO NOT PUT INTEGRATED CIRCUITS IN HERE! THEY WILL GET ADDED AUTOMATICALLY!, can be null + * @param aCulture the bio culture + * @param aFluidInputs may not be null + * @param aFluidOutputs may not be null + * @param aDuration + * @param aEUt + * @param Sv Manual Sv entry i.e. for custom items + * @param glasTier the glass tier + * @param aSpecialValue Space or Cleanroom, Not yet implemented + * @param exactSv if the recipe needs EXACTLY the Sv or can use less... + * @return + */ + public static boolean addBacterialVatRecipe(ItemStack[] aInputs, @Nonnull BioCulture aCulture, @Nonnull FluidStack[] aFluidInputs, @Nonnull FluidStack[] aFluidOutputs, @Nonnegative int aDuration, @Nonnegative int aEUt, int Sv, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { + return BWRecipes.instance.addBacterialVatRecipe(aInputs, aCulture, aFluidInputs, aFluidOutputs, aDuration, aEUt, Sv, glasTier, aSpecialValue, exactSv); + } + + /** + * @param aInputs Item Inputs, DO NOT PUT INTEGRATED CIRCUITS IN HERE! THEY WILL GET ADDED AUTOMATICALLY!, can be null + * @param aCulture the bio culture + * @param aFluidInputs may not be null + * @param aFluidOutputs may not be null + * @param aDuration + * @param aEUt + * @param material may be null. used for auto Sv calculation + * @param glasTier the glass tier + * @param aSpecialValue Space or Cleanroom, Not yet implemented + * @param exactSv if the recipe needs EXACTLY the Sv or can use less... + * @return + */ + public static boolean addBacterialVatRecipe(ItemStack[] aInputs, @Nonnull BioCulture aCulture, @Nonnull FluidStack[] aFluidInputs, @Nonnull FluidStack[] aFluidOutputs, @Nonnegative int aDuration, @Nonnegative int aEUt, Materials material, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { + return BWRecipes.instance.addBacterialVatRecipe(aInputs, aCulture, aFluidInputs, aFluidOutputs, aDuration, aEUt, material, glasTier, aSpecialValue, exactSv); + } + +// public static boolean addBacterialVatRecipe(ItemStack[] aInputs, ItemStack[] aOutputs, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSievert) { +// return BWRecipes.instance.addBacterialVatRecipe(aInputs, aOutputs, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSievert); +// } + +// @Deprecated +// public static boolean addBioLabRecipeDNAExtraction(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue){ +// return BWRecipes.instance.addBioLabRecipeDNAExtraction(aInputs, aOutput, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); +// } +// +// @Deprecated +// public static boolean addBioLabRecipePCRThermoclycling(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue){ +// return BWRecipes.instance.addBioLabRecipePCRThermoclycling(aInputs, aOutput, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); +// } +// +// @Deprecated +// public static boolean addBioLabRecipePlasmidSynthesis(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue){ +// return BWRecipes.instance.addBioLabRecipePlasmidSynthesis(aInputs, aOutput, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); +// } +// +// @Deprecated +// public static boolean addBioLabRecipeTransformation(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue){ +// return BWRecipes.instance.addBioLabRecipeTransformation(aInputs, aOutput, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); +// } +// +// @Deprecated +// public static boolean addBioLabRecipeClonalCellularSynthesis(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue){ +// return BWRecipes.instance.addBioLabRecipeClonalCellularSynthesis(aInputs, aOutput, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); +// } + + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java new file mode 100644 index 0000000000..483b4a67e2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/BioVatLogicAdder.java @@ -0,0 +1,197 @@ +/* + * 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.API; + +import com.github.bartimaeusnek.bartworks.MainMod; +import gregtech.api.enums.Materials; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; + +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Objects; + +import static cpw.mods.fml.common.registry.GameRegistry.findBlock; + +public final class BioVatLogicAdder { + + + public static class RadioHatch { + + private static final HashSet<BioVatLogicAdder.MaterialSvPair> MaSv = new HashSet<>(); + private static final HashMap<ItemStack, Integer> IsSv = new HashMap<>(); + + public static HashSet<BioVatLogicAdder.MaterialSvPair> getMaSv() { + return RadioHatch.MaSv; + } + + public static HashMap<ItemStack, Integer> getIsSv() { + return RadioHatch.IsSv; + } + + public static void setOverrideSvForMaterial(Materials m, Integer sv) { + MaSv.add(new BioVatLogicAdder.MaterialSvPair(m, sv)); + } + + public static void giveItemStackRadioHatchAbilites(ItemStack stack, Integer sv) { + IsSv.put(stack, sv); + } + + public static int getMaxSv() { + int ret = 150; + Iterator it = BioVatLogicAdder.RadioHatch.getMaSv().iterator(); + while (it.hasNext()) { + BioVatLogicAdder.MaterialSvPair pair = (BioVatLogicAdder.MaterialSvPair) it.next(); + if (pair.getSievert() > ret) + ret = pair.getSievert(); + } + for (ItemStack is : RadioHatch.IsSv.keySet()) { + if (RadioHatch.IsSv.get(is) > ret) + ret = RadioHatch.IsSv.get(is); + } + return ret; + } + + } + + public static class BioVatGlass { + + private static final HashMap<BlockMetaPair, Byte> glasses = new HashMap<>(); + + /** + * @param sModname The modid owning the block + * @param sUnlocBlockName The name of the block itself + * @param meta The meta of the block + * @param tier the glasses Tier = Voltage tier (MIN 3) + * @return if the block was found in the Block registry + */ + public static boolean addCustomGlass(String sModname, String sUnlocBlockName, int meta, int tier) { + Block block = findBlock(sModname, sUnlocBlockName); + boolean ret = block != null; + if (ret) + BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) meta), (byte) tier); + else + MainMod.logger.warn("Block: " + sUnlocBlockName + " of the Mod: " + sModname + " was NOT found!"); + block = null; + return ret; + } + + /** + * @param block the block to add + * @param meta the meta of the block (0-15) + * @param tier the glasses Tier = Voltage tier (MIN 3) + */ + public static void addCustomGlass(@Nonnull Block block, @Nonnegative int meta, @Nonnegative int tier) { + BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) meta), (byte) tier); + } + + /** + * @param block the block to add + * @param tier the glasses Tier = Voltage tier (MIN 3) + */ + public static void addCustomGlass(@Nonnull Block block, @Nonnegative int tier) { + BioVatGlass.glasses.put(new BlockMetaPair(block, (byte) 0), (byte) tier); + } + + /** + * @param blockBytePair the block to add and its meta as a javafx.util Pair + * @param tier the glasses Tier = Voltage tier (MIN 3) + */ + public static void addCustomGlass(@Nonnull BlockMetaPair blockBytePair, @Nonnegative byte tier) { + BioVatGlass.glasses.put(blockBytePair, tier); + } + + public static HashMap<BlockMetaPair, Byte> getGlassMap() { + return BioVatGlass.glasses; + } + } + + public static class MaterialSvPair { + final Materials materials; + final Integer sievert; + + public MaterialSvPair(Materials materials, Integer sievert) { + this.materials = materials; + this.sievert = sievert; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + BioVatLogicAdder.MaterialSvPair that = (BioVatLogicAdder.MaterialSvPair) o; + return Objects.equals(this.getMaterials(), that.getMaterials()) && + Objects.equals(this.getSievert(), that.getSievert()); + } + + @Override + public int hashCode() { + return Objects.hash(this.getMaterials(), this.getSievert()); + } + + public Materials getMaterials() { + return this.materials; + } + + public Integer getSievert() { + return this.sievert; + } + + + } + + public static class BlockMetaPair { + final Block block; + final Byte aByte; + + public BlockMetaPair(Block block, Byte aByte) { + this.block = block; + this.aByte = aByte; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + BioVatLogicAdder.BlockMetaPair that = (BioVatLogicAdder.BlockMetaPair) o; + return Objects.equals(this.getBlock(), that.getBlock()) && + Objects.equals(this.getaByte(), that.getaByte()); + } + + @Override + public int hashCode() { + return Objects.hash(this.getBlock(), this.getaByte()); + } + + public Block getBlock() { + return this.block; + } + + public Byte getaByte() { + return this.aByte; + } + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java index 7d2f2d4628..f45ac86579 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/GuiHandler.java @@ -1,10 +1,35 @@ +/* + * 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; +import com.github.bartimaeusnek.bartworks.client.gui.BW_GUIContainer_RadLevel; import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_CircuitProgrammer; import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_Destructopack; +import com.github.bartimaeusnek.bartworks.server.container.BW_Container_RadioHatch; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_CircuitProgrammer; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_Item_Destructopack; import cpw.mods.fml.common.network.IGuiHandler; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; @@ -12,18 +37,34 @@ public class GuiHandler implements IGuiHandler { @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID){ - case 0: return new GT_Container_Item_Destructopack(player.inventory); - case 1: return new GT_Container_CircuitProgrammer(player.inventory); + switch (ID) { + case 0: + return new GT_Container_Item_Destructopack(player.inventory); + case 1: + return new GT_Container_CircuitProgrammer(player.inventory); + case 2: { + if (world.getTileEntity(x, y, z) instanceof IGregTechTileEntity) { + IGregTechTileEntity te = (IGregTechTileEntity) world.getTileEntity(x, y, z); + return new BW_Container_RadioHatch(player.inventory, te.getMetaTileEntity()); + } + } } return null; } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { - switch (ID){ - case 0: return new GT_GUIContainer_Destructopack(player.inventory); - case 1: return new GT_GUIContainer_CircuitProgrammer(player.inventory); + switch (ID) { + case 0: + return new GT_GUIContainer_Destructopack(player.inventory); + case 1: + return new GT_GUIContainer_CircuitProgrammer(player.inventory); + case 2: { + if (world.getTileEntity(x, y, z) instanceof IGregTechTileEntity) { + IGregTechTileEntity te = (IGregTechTileEntity) world.getTileEntity(x, y, z); + return new BW_GUIContainer_RadLevel(new BW_Container_RadioHatch(player.inventory, te.getMetaTileEntity())); + } + } } return null; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 0219ef93bd..c2a42579df 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -1,13 +1,35 @@ +/* + * 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; +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.ConfigHandler; -import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.loaders.GTNHBlocks; import com.github.bartimaeusnek.bartworks.common.loaders.LoaderRegistry; -import com.github.bartimaeusnek.bartworks.common.tileentities.BW_RotorBlock; -import com.github.bartimaeusnek.bartworks.common.tileentities.GT_TileEntity_Windmill; +import com.github.bartimaeusnek.bartworks.common.net.BW_Network; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLInitializationEvent; @@ -15,51 +37,59 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import static com.github.bartimaeusnek.bartworks.API.API_REFERENCE.VERSION; + @Mod( modid = MainMod.modID, name = MainMod.name, version = MainMod.version, - dependencies = "required-after:IC2; " - + "required-after:gregtech; " - ) + dependencies = "required-after:IC2; " + + "required-after:gregtech; " +) public final class MainMod { public static final String name = "BartWorks"; public static final String version = "@version@"; public static final String modID = "bartworks"; public static final Logger logger = LogManager.getLogger(name); - public static boolean GTNH = false; public static final CreativeTabs GT2 = new GT2Tab("GT2C"); + public static final CreativeTabs BioTab = new BioTab("BioTab"); public static final CreativeTabs BWT = new bartworksTab("bartworks"); public static final IGuiHandler GH = new GuiHandler(); + public static boolean GTNH = false; @Mod.Instance(modID) public static MainMod instance; public static ConfigHandler CHandler; - + public static BW_Network BW_Network_instance = new BW_Network(); @Mod.EventHandler public void preInit(FMLPreInitializationEvent preinit) { - if(Loader.isModLoaded("dreamcraft")) { + if (!(VERSION.equals(version))) { + logger.error("Something has loaded an old API. Please contact the Mod authors to update!"); + } + + if (Loader.isModLoaded("dreamcraft")) { GTNH = true; } - CHandler= new ConfigHandler(preinit); + CHandler = new ConfigHandler(preinit); if (GTNH) logger.info("GTNH-Detected . . . ACTIVATE HARDMODE."); + } + @Mod.EventHandler public void init(FMLInitializationEvent init) { - new LoaderRegistry().run(); + new LoaderRegistry().run(); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent postinit) { - NetworkRegistry.INSTANCE.registerGuiHandler(instance,GH); + NetworkRegistry.INSTANCE.registerGuiHandler(instance, GH); + if (ConfigHandler.BioLab) + new GTNHBlocks().run(); } - } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/BioTab.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/BioTab.java new file mode 100644 index 0000000000..2057052be3 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/BioTab.java @@ -0,0 +1,39 @@ +/* + * 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.client.creativetabs; + +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; + +public class BioTab extends CreativeTabs { + + public BioTab(String lable) { + super(lable); + } + + @Override + public Item getTabIconItem() { + return BioItemList.getPetriDish(null).getItem(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/GT2Tab.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/GT2Tab.java index 82188db9c5..1d403a93d9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/GT2Tab.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/GT2Tab.java @@ -1,3 +1,25 @@ +/* + * 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.client.creativetabs; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; @@ -6,7 +28,7 @@ import net.minecraft.item.Item; public class GT2Tab extends CreativeTabs { - public GT2Tab (String lable) { + public GT2Tab(String lable) { super(lable); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/bartworksTab.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/bartworksTab.java index 30449b88de..f3e5e15882 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/bartworksTab.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/creativetabs/bartworksTab.java @@ -1,3 +1,25 @@ +/* + * 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.client.creativetabs; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; @@ -6,7 +28,7 @@ import net.minecraft.item.Item; public class bartworksTab extends CreativeTabs { - public bartworksTab (String lable) { + public bartworksTab(String lable) { super(lable); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RadLevel.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RadLevel.java new file mode 100644 index 0000000000..91dfa14c28 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RadLevel.java @@ -0,0 +1,60 @@ +/* + * 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.client.gui; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.server.container.BW_Container_RadioHatch; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Container; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class BW_GUIContainer_RadLevel extends GuiContainer { + final BW_Container_RadioHatch container; + + public BW_GUIContainer_RadLevel(Container p_i1072_1_) { + super(p_i1072_1_); + container = (BW_Container_RadioHatch) p_i1072_1_; + } + + + @Override + protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { + GL11.glColor3f(1, 1, 1); + this.mc.getTextureManager().bindTexture(new ResourceLocation(MainMod.modID, "textures/GUI/GUI_RSC.png")); + drawTexturedModalRect(guiLeft - 79, guiTop, 0, 0, 256, 165); + } + + @Override + protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) { + int y = 51 + (container.coverage / 2 - 3); + int x = -63; + if (container.coverage != 100 && container.coverage != 0) + drawRect(x, y, x + 51, y + 1, 0xFF60D82E); + drawRect(x, 48, x + 51, y, 0xFF8B8B8B); + this.fontRendererObj.drawString(Byte.toString(container.coverage), 88 - 79, 50, 16448255); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java index 1311c291ac..61b87019e3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_RotorBlock.java @@ -1,3 +1,25 @@ +/* + * 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.client.gui; import com.github.bartimaeusnek.bartworks.MainMod; @@ -11,8 +33,7 @@ import net.minecraft.util.StatCollector; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class BW_GUIContainer_RotorBlock extends GuiWindKineticGenerator -{ +public class BW_GUIContainer_RotorBlock extends GuiWindKineticGenerator { public ContainerWindKineticGenerator container; public String name; @@ -42,7 +63,7 @@ public class BW_GUIContainer_RotorBlock extends GuiWindKineticGenerator } protected void drawGuiContainerBackgroundLayer(float f, int x, int y) { - GL11.glColor3f(0.5f,0.25f,0.07f); + GL11.glColor3f(0.5f, 0.25f, 0.07f); this.mc.getTextureManager().bindTexture(new ResourceLocation(MainMod.modID, "textures/GUI/GUIPrimitiveKUBox.png")); int j = (this.width - this.xSize) / 2; int k = (this.height - this.ySize) / 2; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_Windmill.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_Windmill.java index 76cd7d2998..09dec26e2b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_Windmill.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/BW_GUIContainer_Windmill.java @@ -1,3 +1,25 @@ +/* + * 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.client.gui; import com.github.bartimaeusnek.bartworks.MainMod; @@ -13,30 +35,31 @@ public class BW_GUIContainer_Windmill extends GT_GUIContainer_MultiMachine { public BW_GUIContainer_Windmill(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(aInventoryPlayer, aTileEntity, aName, null); } + protected void drawGuiContainerForegroundLayer(int par1, int par2) { if (!(this.mContainer instanceof GT_Container_MultiMachine)) return; - if ((((GT_Container_MultiMachine)this.mContainer).mDisplayErrorCode & 64) != 0) + if ((((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode & 64) != 0) this.fontRendererObj.drawString(this.trans("138", "Incomplete Structure."), 92, 22, 16448255); } protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - GL11.glColor3f(0.5f,0.25f,0.07f); + GL11.glColor3f(0.5f, 0.25f, 0.07f); this.mc.getTextureManager().bindTexture(new ResourceLocation(MainMod.modID, "textures/GUI/GUI_Windmill.png")); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer.mMaxProgressTime > 0){ - this.drawTexturedModalRect(x+152, y+5,176,0,16,15); - this.drawTexturedModalRect(x+53, y+63,176,16,13,17); + if (this.mContainer.mMaxProgressTime > 0) { + this.drawTexturedModalRect(x + 152, y + 5, 176, 0, 16, 15); + this.drawTexturedModalRect(x + 53, y + 63, 176, 16, 13, 17); } - if (((GT_Container_MultiMachine)this.mContainer).mDisplayErrorCode == 0) { + if (((GT_Container_MultiMachine) this.mContainer).mDisplayErrorCode == 0) { if (((GT_Container_MultiMachine) this.mContainer).mActive == 0) { - GL11.glColor3f(1f,1f,1f); - this.drawTexturedModalRect(x+66, y+66,176,33,15,15); + GL11.glColor3f(1f, 1f, 1f); + this.drawTexturedModalRect(x + 66, y + 66, 176, 33, 15, 15); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_CircuitProgrammer.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_CircuitProgrammer.java index d511369435..2a699035f4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_CircuitProgrammer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_CircuitProgrammer.java @@ -1,3 +1,25 @@ +/* + * 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.client.gui; import com.github.bartimaeusnek.bartworks.MainMod; @@ -10,14 +32,16 @@ import org.lwjgl.opengl.GL11; public class GT_GUIContainer_CircuitProgrammer extends GuiContainer { + public static final ResourceLocation texture = new ResourceLocation(MainMod.modID, "textures/GUI/GUI_CircuitP.png"); + public GT_GUIContainer_CircuitProgrammer(InventoryPlayer p_i1072_1_) { super(new GT_Container_CircuitProgrammer(p_i1072_1_)); } - public static final ResourceLocation texture = new ResourceLocation(MainMod.modID, "textures/GUI/GUI_CircuitP.png"); + @Override protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1F, 1F, 1F, 1F); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - drawTexturedModalRect(guiLeft-79, guiTop, 0, 0, 256, 165); + drawTexturedModalRect(guiLeft - 79, guiTop, 0, 0, 256, 165); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_Destructopack.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_Destructopack.java index 68e2516979..feaf22fcc1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_Destructopack.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_Destructopack.java @@ -1,3 +1,25 @@ +/* + * 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.client.gui; import com.github.bartimaeusnek.bartworks.MainMod; @@ -8,12 +30,12 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; -public class GT_GUIContainer_Destructopack extends GuiContainer -{ +public class GT_GUIContainer_Destructopack extends GuiContainer { + public static final ResourceLocation texture = new ResourceLocation(MainMod.modID, "textures/GT2/gui/Destructopack.png"); + public GT_GUIContainer_Destructopack(InventoryPlayer inventory) { super(new GT_Container_Item_Destructopack(inventory)); } - public static final ResourceLocation texture = new ResourceLocation(MainMod.modID, "textures/GT2/gui/Destructopack.png"); @Override public void drawGuiContainerBackgroundLayer(float f, int j, int i) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_LESU.java index 4a0b1ada5b..1378d9e943 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_LESU.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_LESU.java @@ -1,7 +1,29 @@ +/* + * 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.client.gui; import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.common.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.tileentities.GT_TileEntity_LESU; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_LESU; import gregtech.api.gui.GT_GUIContainer; @@ -15,32 +37,31 @@ import java.awt.*; public class GT_GUIContainer_LESU extends GT_GUIContainer { - protected GT_Container_LESU mContainer; - public static final ResourceLocation texture = new ResourceLocation(MainMod.modID, "textures/GT2/gui/LESU.png"); + protected GT_Container_LESU mContainer; private GT_TileEntity_LESU c; public GT_GUIContainer_LESU(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(new GT_Container_LESU(aInventoryPlayer, aTileEntity), texture.getResourceDomain()); - mContainer = ((GT_Container_LESU)this.inventorySlots); - c = ((GT_TileEntity_LESU)(this.mContainer.mTileEntity.getMetaTileEntity())); + mContainer = ((GT_Container_LESU) this.inventorySlots); + c = ((GT_TileEntity_LESU) (this.mContainer.mTileEntity.getMetaTileEntity())); } @Override protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { - this.drawString(this.fontRendererObj,"L.E.S.U.", 11, 8, 16448255); + this.drawString(this.fontRendererObj, "L.E.S.U.", 11, 8, 16448255); if (this.mContainer != null) { String percell = String.valueOf(ConfigHandler.energyPerCell).substring(1); - this.drawString(this.fontRendererObj,"EU: " + String.valueOf(this.mContainer.mEnergy), 11, 16, 16448255); - this.drawString(this.fontRendererObj,"MAX: " + (this.c.getBaseMetaTileEntity().isActive() ? String.valueOf(this.mContainer.mOutput)+ percell : Integer.toString(0)), 11, 24, 16448255); - this.drawString(this.fontRendererObj,"MAX EU/t IN: " + String.valueOf(this.mContainer.mInput), 11, 32, 16448255); - this.drawString(this.fontRendererObj,"EU/t OUT: " + String.valueOf(this.mContainer.mOutput), 11, 40, 16448255); - this.drawString(this.fontRendererObj,"AMP/t IN/OUT: " + String.valueOf(c.getBaseMetaTileEntity().getInputAmperage()), 11, 48, 16448255); - if (c.maxEUStore() >= Long.MAX_VALUE-1) { + this.drawString(this.fontRendererObj, "EU: " + String.valueOf(this.mContainer.mEnergy), 11, 16, 16448255); + this.drawString(this.fontRendererObj, "MAX: " + (this.c.getBaseMetaTileEntity().isActive() ? String.valueOf(this.mContainer.mOutput) + percell : Integer.toString(0)), 11, 24, 16448255); + this.drawString(this.fontRendererObj, "MAX EU/t IN: " + String.valueOf(this.mContainer.mInput), 11, 32, 16448255); + this.drawString(this.fontRendererObj, "EU/t OUT: " + String.valueOf(this.mContainer.mOutput), 11, 40, 16448255); + this.drawString(this.fontRendererObj, "AMP/t IN/OUT: " + String.valueOf(c.getBaseMetaTileEntity().getInputAmperage()), 11, 48, 16448255); + if (c.maxEUStore() >= Long.MAX_VALUE - 1) { this.drawString(this.fontRendererObj, "Maximum Capacity!", 11, 56, Color.YELLOW.getRGB()); } if (!this.c.getBaseMetaTileEntity().isActive()) { - this.drawString(this.fontRendererObj,"Multiple Controllers!", 11, 56, Color.RED.getRGB()); + this.drawString(this.fontRendererObj, "Multiple Controllers!", 11, 56, Color.RED.getRGB()); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java new file mode 100644 index 0000000000..220d88d7a9 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/gui/GT_GUIContainer_RadioHatch.java @@ -0,0 +1,77 @@ +/* + * 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.client.gui; + +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_MetaTileEntity_RadioHatch; +import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.util.ResourceLocation; +import org.lwjgl.opengl.GL11; + +import java.nio.ByteBuffer; + +public class GT_GUIContainer_RadioHatch extends GT_GUIContainerMetaTile_Machine { + private static int maxSv; + private final String mName; + + public GT_GUIContainer_RadioHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { + super(new GT_Container_RadioHatch(aInventoryPlayer, aTileEntity), MainMod.modID + ":textures/GUI/RadHatch.png"); + this.mName = "Radio Hatch"; + this.mContainer.detectAndSendChanges(); + maxSv = BioVatLogicAdder.RadioHatch.getMaxSv(); + } + + protected void drawGuiContainerForegroundLayer(int par1, int par2) { + long timer = ByteBuffer.wrap(((GT_Container_RadioHatch) mContainer).teTimer).getLong(); + double maxT = ((GT_Container_RadioHatch) mContainer).mass * (GT_MetaTileEntity_RadioHatch.calcDecayTicks(((GT_Container_RadioHatch) mContainer).sievert)); + double rem = maxT - timer % maxT; + + this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); + this.mc.getTextureManager().bindTexture(new ResourceLocation(MainMod.modID + ":textures/GUI/RadHatch.png")); + if (((GT_Container_RadioHatch) mContainer).mass > 0) { + GL11.glColor3f(((GT_Container_RadioHatch) mContainer).r / 255f, ((GT_Container_RadioHatch) mContainer).g / 255f, ((GT_Container_RadioHatch) mContainer).b / 255f); + this.drawTexturedModalRect(124, 18, 124, 18, 16, 48); + } + GL11.glColor3f(1f, 1f, 1f); + this.drawTexturedModalRect(124, 18, 176, 0, 16, 48 - (int) Math.ceil(48 * (rem / maxT))); + this.drawTexturedModalRect(65, 13, 192, 0, (48 * (((GT_Container_RadioHatch) mContainer).sv)) / (maxSv), 16); + + this.fontRendererObj.drawString("Sv: " + ((GT_Container_RadioHatch) mContainer).sievert, 8, 50, BW_Util.getColorFromArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); + this.fontRendererObj.drawString("Kg: " + ((GT_Container_RadioHatch) mContainer).mass, 8, 68, BW_Util.getColorFromArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); + this.fontRendererObj.drawString("Time: " + timer, 8, 76, BW_Util.getColorFromArray(new short[]{((GT_Container_RadioHatch) mContainer).r, ((GT_Container_RadioHatch) mContainer).g, ((GT_Container_RadioHatch) mContainer).b})); + + } + + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { + super.drawGuiContainerBackgroundLayer(par1, par2, par3); + int x = (this.width - this.xSize) / 2; + int y = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java new file mode 100644 index 0000000000..15523b68f6 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java @@ -0,0 +1,298 @@ +/* + * 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.client.renderer; + +import com.github.bartimaeusnek.bartworks.common.blocks.BioFluidBlock; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_TileEntity_BioVat; +import com.github.bartimaeusnek.bartworks.util.Coords; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.IFluidBlock; + + +public class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler { + private static final float LIGHT_Y_NEG = 0.5f; + private static final float LIGHT_Y_POS = 1f; + private static final float LIGHT_XZ_NEG = 0.8f; + private static final float LIGHT_XZ_POS = 0.6f; + private static final float THREE_QUARTERS_FILLED = 0.875f; + private static final double RENDER_OFFSET = 0.0010000000474974513; + + public static RendererSwitchingColorFluid instance = new RendererSwitchingColorFluid(); + + private float getFluidHeightAverage(float[] flow) { + float total = 0.0f; + int count = 0; + float end = 0.0f; + for (float aFlow : flow) { + if (aFlow >= RendererSwitchingColorFluid.THREE_QUARTERS_FILLED && end != RendererSwitchingColorFluid.LIGHT_Y_POS) { + end = aFlow; + } + if (aFlow >= 0.0f) { + total += aFlow; + ++count; + } + } + if (end == 0.0f) { + end = total / count; + } + return end; + } + + private float getFluidHeightForRender(IBlockAccess world, int x, int y, int z, BlockFluidBase block) { + + if (world.getBlock(x, y, z) == block) { + Block vOrigin = world.getBlock(x, y + 1, z); + if (vOrigin.getMaterial().isLiquid() || vOrigin instanceof IFluidBlock) { + return RendererSwitchingColorFluid.LIGHT_Y_POS; + } + if (world.getBlockMetadata(x, y, z) == block.getMaxRenderHeightMeta()) { + return RendererSwitchingColorFluid.THREE_QUARTERS_FILLED; + } + } + return (!world.getBlock(x, y, z).getMaterial().isSolid() && world.getBlock(x, y + 1, z) == block) ? RendererSwitchingColorFluid.LIGHT_Y_POS : (block.getQuantaPercentage(world, x, y, z) * RendererSwitchingColorFluid.THREE_QUARTERS_FILLED); + } + + public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + } + + + @SideOnly(Side.CLIENT) + public boolean renderWorldBlock(IBlockAccess iBlockAccess, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { + if ((!(block instanceof BioFluidBlock))) + return false; + Tessellator tessellator = Tessellator.instance; + Coords blockat = new Coords(x, y, z, iBlockAccess.getTileEntity(x, y, z).getWorldObj().provider.dimensionId); + Integer rgb = GT_TileEntity_BioVat.staticColorMap.get(blockat); + + int r, g, b; + + if (rgb != null) { + r = (rgb >> 16) & 0xFF; + g = (rgb >> 8) & 0xFF; + b = rgb & 0xFF; + } else { + r = 0; + g = 0; + b = 255; + } + float red = ((float) r) / 255f, green = ((float) g) / 255f, blue = ((float) b) / 255f; + + BlockFluidBase blockFluidBase = (BlockFluidBase) block; + boolean renderTop = iBlockAccess.getBlock(x, y + 1, z) != blockFluidBase; + boolean renderBottom = + block.shouldSideBeRendered(iBlockAccess, x, y - 1, z, 0) + && iBlockAccess.getBlock(x, y - 1, z) != blockFluidBase; + boolean[] renderSides = { + block.shouldSideBeRendered(iBlockAccess, x, y, z - 1, 2), + block.shouldSideBeRendered(iBlockAccess, x, y, z + 1, 3), + block.shouldSideBeRendered(iBlockAccess, x - 1, y, z, 4), + block.shouldSideBeRendered(iBlockAccess, x + 1, y, z, 5) + }; + if (!renderTop && !renderBottom && !renderSides[0] && !renderSides[1] && !renderSides[2] && !renderSides[3]) { + return false; + } + boolean rendered = false; + float fluidHeightForRender = this.getFluidHeightForRender(iBlockAccess, x, y, z, blockFluidBase); + double heightNW, heightSW, heightSE, heightNE; + + if (fluidHeightForRender != RendererSwitchingColorFluid.LIGHT_Y_POS) { + float fluidHeightForRender1 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z - 1, blockFluidBase); + float fluidHeightForRender2 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z, blockFluidBase); + float fluidHeightForRender3 = this.getFluidHeightForRender(iBlockAccess, x - 1, y, z + 1, blockFluidBase); + float fluidHeightForRender4 = this.getFluidHeightForRender(iBlockAccess, x, y, z - 1, blockFluidBase); + float fluidHeightForRender5 = this.getFluidHeightForRender(iBlockAccess, x, y, z + 1, blockFluidBase); + float fluidHeightForRender6 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z - 1, blockFluidBase); + float fluidHeightForRender7 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z, blockFluidBase); + float fluidHeightForRender8 = this.getFluidHeightForRender(iBlockAccess, x + 1, y, z + 1, blockFluidBase); + heightNW = this.getFluidHeightAverage(new float[]{fluidHeightForRender1, fluidHeightForRender2, fluidHeightForRender4, fluidHeightForRender}); + heightSW = this.getFluidHeightAverage(new float[]{fluidHeightForRender2, fluidHeightForRender3, fluidHeightForRender5, fluidHeightForRender}); + heightSE = this.getFluidHeightAverage(new float[]{fluidHeightForRender5, fluidHeightForRender7, fluidHeightForRender8, fluidHeightForRender}); + heightNE = this.getFluidHeightAverage(new float[]{fluidHeightForRender4, fluidHeightForRender6, fluidHeightForRender7, fluidHeightForRender}); + } else { + heightNW = fluidHeightForRender; + heightSW = fluidHeightForRender; + heightSE = fluidHeightForRender; + heightNE = fluidHeightForRender; + } + + if (renderer.renderAllFaces || renderTop) { + rendered = true; + IIcon iconStill = this.getNullCheckedIiconOrFallbackTexture(); + float flowDir = (float) BlockFluidBase.getFlowDirection(iBlockAccess, x, y, z); + + heightNW -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightSW -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightSE -= RendererSwitchingColorFluid.RENDER_OFFSET; + heightNE -= RendererSwitchingColorFluid.RENDER_OFFSET; + + double dInterpolatedU, dInterpolatedV, dInterpolatedU2, dInterpolatedV2, dInterpolatedU3, dInterpolatedV3, dInterpolatedU4, dInterpolatedV4; + + if (flowDir < -999.0f) { + dInterpolatedU = iconStill.getInterpolatedU(0.0); + dInterpolatedV = iconStill.getInterpolatedV(0.0); + dInterpolatedU2 = dInterpolatedU; + dInterpolatedV2 = iconStill.getInterpolatedV(16.0); + dInterpolatedU3 = iconStill.getInterpolatedU(16.0); + dInterpolatedV3 = dInterpolatedV2; + dInterpolatedU4 = dInterpolatedU3; + dInterpolatedV4 = dInterpolatedV; + } else { + float xFlow = MathHelper.sin(flowDir) * 0.25f, zFlow = MathHelper.cos(flowDir) * 0.25f; + dInterpolatedU = iconStill.getInterpolatedU((double) (8.0f + (-zFlow - xFlow) * 16.0f)); + dInterpolatedV = iconStill.getInterpolatedV((double) (8.0f + (-zFlow + xFlow) * 16.0f)); + dInterpolatedU2 = iconStill.getInterpolatedU((double) (8.0f + (-zFlow + xFlow) * 16.0f)); + dInterpolatedV2 = iconStill.getInterpolatedV((double) (8.0f + (zFlow + xFlow) * 16.0f)); + dInterpolatedU3 = iconStill.getInterpolatedU((double) (8.0f + (zFlow + xFlow) * 16.0f)); + dInterpolatedV3 = iconStill.getInterpolatedV((double) (8.0f + (zFlow - xFlow) * 16.0f)); + dInterpolatedU4 = iconStill.getInterpolatedU((double) (8.0f + (zFlow - xFlow) * 16.0f)); + dInterpolatedV4 = iconStill.getInterpolatedV((double) (8.0f + (-zFlow - xFlow) * 16.0f)); + } + + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x, y, z)); + tessellator.setColorOpaque_F(RendererSwitchingColorFluid.LIGHT_Y_POS * red, RendererSwitchingColorFluid.LIGHT_Y_POS * green, RendererSwitchingColorFluid.LIGHT_Y_POS * blue); + + tessellator.addVertexWithUV((double) x, y + heightNW, (double) z, dInterpolatedU, dInterpolatedV); + tessellator.addVertexWithUV((double) x, y + heightSW, (double) (z + 1), dInterpolatedU2, dInterpolatedV2); + tessellator.addVertexWithUV((double) (x + 1), y + heightSE, (double) (z + 1), dInterpolatedU3, dInterpolatedV3); + tessellator.addVertexWithUV((double) (x + 1), y + heightNE, (double) z, dInterpolatedU4, dInterpolatedV4); + tessellator.addVertexWithUV((double) x, y + heightNW, (double) z, dInterpolatedU, dInterpolatedV); + tessellator.addVertexWithUV((double) (x + 1), y + heightNE, (double) z, dInterpolatedU4, dInterpolatedV4); + tessellator.addVertexWithUV((double) (x + 1), y + heightSE, (double) (z + 1), dInterpolatedU3, dInterpolatedV3); + tessellator.addVertexWithUV((double) x, y + heightSW, (double) (z + 1), dInterpolatedU2, dInterpolatedV2); + + } + + if (renderer.renderAllFaces || renderBottom) { + rendered = true; + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x, y - 1, z)); + tessellator.setColorOpaque_F(RendererSwitchingColorFluid.LIGHT_Y_NEG * red, RendererSwitchingColorFluid.LIGHT_Y_NEG * green, RendererSwitchingColorFluid.LIGHT_Y_NEG * blue); + renderer.renderFaceYNeg(block, (double) x, y + RendererSwitchingColorFluid.RENDER_OFFSET, (double) z, this.getNullCheckedIiconOrFallbackTexture()); + } + + for (int side = 0; side < 4; ++side) { + int x2 = x, z2 = z; + + switch (side) { + case 0: + --z2; + break; + case 1: + ++z2; + break; + case 2: + --x2; + break; + case 3: + ++x2; + break; + default: + break; + } + + IIcon iconFlow = this.getNullCheckedIiconOrFallbackTexture(); + + if (renderer.renderAllFaces || renderSides[side]) { + rendered = true; + double dHeight1, dHeight2, dXcoord1, dXcoord2, dZcoord1, dZcoord2; + if (side == 0) { + dHeight1 = heightNW; + dHeight2 = heightNE; + dXcoord1 = x; + dXcoord2 = x + 1; + dZcoord1 = z + RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord2 = z + RendererSwitchingColorFluid.RENDER_OFFSET; + } else if (side == 1) { + dHeight1 = heightSE; + dHeight2 = heightSW; + dXcoord1 = x + 1; + dXcoord2 = x; + dZcoord1 = z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord2 = z + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + } else if (side == 2) { + dHeight1 = heightSW; + dHeight2 = heightNW; + dXcoord1 = x + RendererSwitchingColorFluid.RENDER_OFFSET; + dXcoord2 = x + RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord1 = z + 1; + dZcoord2 = z; + } else { + dHeight1 = heightNE; + dHeight2 = heightSE; + dXcoord1 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dXcoord2 = x + 1 - RendererSwitchingColorFluid.RENDER_OFFSET; + dZcoord1 = z; + dZcoord2 = z + 1; + } + float u1Flow = iconFlow.getInterpolatedU(0.0); + float u2Flow = iconFlow.getInterpolatedU(8.0); + float v1Flow = iconFlow.getInterpolatedV((1.0 - dHeight1) * 16.0 * 0.5); + float v2Flow = iconFlow.getInterpolatedV((1.0 - dHeight2) * 16.0 * 0.5); + float v3Flow = iconFlow.getInterpolatedV(8.0); + tessellator.setBrightness(block.getMixedBrightnessForBlock(iBlockAccess, x2, y, z2)); + float sideLighting; + if (side < 2) { + sideLighting = RendererSwitchingColorFluid.LIGHT_XZ_NEG; + } else { + sideLighting = RendererSwitchingColorFluid.LIGHT_XZ_POS; + } + tessellator.setColorOpaque_F(RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * red, RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * green, RendererSwitchingColorFluid.LIGHT_Y_POS * sideLighting * blue); + + tessellator.addVertexWithUV(dXcoord1, y + dHeight1, dZcoord1, (double) u1Flow, (double) v1Flow); + tessellator.addVertexWithUV(dXcoord2, y + dHeight2, dZcoord2, (double) u2Flow, (double) v2Flow); + tessellator.addVertexWithUV(dXcoord2, (double) y, dZcoord2, (double) u2Flow, (double) v3Flow); + tessellator.addVertexWithUV(dXcoord1, (double) y, dZcoord1, (double) u1Flow, (double) v3Flow); + tessellator.addVertexWithUV(dXcoord1, y + dHeight1, dZcoord1, (double) u1Flow, (double) v1Flow); + tessellator.addVertexWithUV(dXcoord1, (double) y, dZcoord1, (double) u1Flow, (double) v3Flow); + tessellator.addVertexWithUV(dXcoord2, (double) y, dZcoord2, (double) u2Flow, (double) v3Flow); + tessellator.addVertexWithUV(dXcoord2, y + dHeight2, dZcoord2, (double) u2Flow, (double) v2Flow); + } + } + renderer.renderMinY = 0.0; + renderer.renderMaxY = 1.0; + return rendered; + } + + public boolean shouldRender3DInInventory(int modelId) { + return false; + } + + public int getRenderId() { + return FluidLoader.renderID; + } + + private IIcon getNullCheckedIiconOrFallbackTexture() { + return FluidLoader.autogenIIcon != null ? FluidLoader.autogenIIcon : ((TextureMap) Minecraft.getMinecraft().getTextureManager().getTexture(TextureMap.locationBlocksTexture)).getAtlasSprite("missingno"); + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/ConfigHandler.java deleted file mode 100644 index 33999f71d4..0000000000 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/ConfigHandler.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.github.bartimaeusnek.bartworks.common; - - -import com.github.bartimaeusnek.bartworks.MainMod; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import gregtech.api.enums.GT_Values; -import net.minecraftforge.common.config.Configuration; - -import java.io.File; - -public class ConfigHandler { - public static int IDOffset = 12600; - public static final int IDU=1+ GT_Values.VN.length; - public static boolean ezmode = false; - public static boolean teslastaff = false; - public static long energyPerCell = 100000L; - public static boolean newStuff = true; - public final Configuration c; - public ConfigHandler(FMLPreInitializationEvent e){ - c = new Configuration(new File(e.getModConfigurationDirectory().toString()+"/"+MainMod.modID+".cfg")); - - IDOffset=c.get("System","ID Offset",12600,"ID Offset for this mod. This Mod uses "+IDU+" IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS").getInt(12600); - energyPerCell=c.get("Multiblocks","energyPerLESUCell",1000000,"This will set Up the Energy per LESU Cell",1000000,Integer.MAX_VALUE).getInt(1000000); - ezmode=c.get("System","Mode switch",false,"If GTNH is Loaded, this will enable easy recipes, if not, it will enable harder recipes.").getBoolean(false); - MainMod.GTNH = ezmode ? !MainMod.GTNH : MainMod.GTNH; - teslastaff=c.get("System","Enable Teslastaff",false,"Enables the Teslastaff, an Item used to destroy Electric Armors").getBoolean(false); - newStuff=!c.get("System","Disable non-original-GT-stuff",false,"This switch disables my new content, that is not part of the GT2 compat").getBoolean(false); - - if (c.hasChanged()) - c.save(); - - } - -} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java index a838e52125..ea7869c982 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_Blocks.java @@ -1,3 +1,25 @@ +/* + * 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.common.blocks; import com.github.bartimaeusnek.bartworks.MainMod; @@ -7,35 +29,48 @@ import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; import java.util.List; public class BW_Blocks extends Block { + @SideOnly(Side.CLIENT) + private IIcon[] texture; + private String[] textureNames; + private String name; + public BW_Blocks(String name, String[] texture) { super(Material.anvil); this.setHardness(15.0F); this.setResistance(30.0F); this.name = name; - this.textureNames=texture; + this.textureNames = texture; this.setCreativeTab(MainMod.GT2); } + public BW_Blocks(String name, String[] texture, CreativeTabs tabs) { super(Material.anvil); this.setHardness(15.0F); this.setResistance(30.0F); this.name = name; - this.textureNames=texture; + this.textureNames = texture; this.setCreativeTab(tabs); } - @SideOnly(Side.CLIENT) - private IIcon[] texture; - private String[] textureNames; - private String name; + public BW_Blocks(String name, String[] texture, CreativeTabs tabs, Material material) { + super(material); + this.setHardness(15.0F); + this.setResistance(30.0F); + this.name = name; + this.textureNames = texture; + this.setCreativeTab(tabs); + } @Override public int damageDropped(final int meta) { @@ -44,7 +79,7 @@ public class BW_Blocks extends Block { @Override public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { - for (int i = 0; i < textureNames.length; i ++) { + for (int i = 0; i < textureNames.length; i++) { list.add(new ItemStack(item, 1, i)); } } @@ -57,7 +92,7 @@ public class BW_Blocks extends Block { @Override @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister par1IconRegister){ + public void registerBlockIcons(IIconRegister par1IconRegister) { texture = new IIcon[textureNames.length]; for (int i = 0; i < textureNames.length; i++) { texture[i] = par1IconRegister.registerIcon(textureNames[i]); @@ -65,7 +100,22 @@ public class BW_Blocks extends Block { } @Override - public String getUnlocalizedName(){ + public String getUnlocalizedName() { return name; } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) { + return false; + } + + @Override + public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + return false; + } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java new file mode 100644 index 0000000000..db93c1cfe6 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java @@ -0,0 +1,65 @@ +/* + * 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.common.blocks; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.material.Material; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.world.IBlockAccess; + +public class BW_GlasBlocks extends BW_Blocks { + + public BW_GlasBlocks(String name, String[] texture, CreativeTabs tabs) { + super(name, texture, tabs, Material.glass); + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { + if (worldClient.getBlock(xCoord, yCoord, zCoord) instanceof BW_GlasBlocks) + return false; + return super.shouldSideBeRendered(worldClient, xCoord, yCoord, zCoord, aSide); + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + protected boolean canSilkHarvest() { + return false; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java index b90bfeeec9..b0be51a5c0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer.java @@ -1,3 +1,25 @@ +/* + * 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.common.blocks; import com.github.bartimaeusnek.bartworks.MainMod; @@ -17,15 +39,14 @@ public class BW_TileEntityContainer extends BlockContainer { Class<? extends TileEntity> tileEntity = null; - public BW_TileEntityContainer(Material p_i45386_1_,Class<? extends TileEntity> tileEntity, String blockName) { + public BW_TileEntityContainer(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName) { super(p_i45386_1_); - this.tileEntity=tileEntity; + this.tileEntity = tileEntity; this.setCreativeTab(MainMod.BWT); this.setBlockName(blockName); - this.setBlockTextureName(MainMod.modID+":"+blockName); + this.setBlockTextureName(MainMod.modID + ":" + blockName); } - @Override public boolean onBlockActivated(World worldObj, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (worldObj.isRemote) { @@ -34,7 +55,7 @@ public class BW_TileEntityContainer extends BlockContainer { if (!player.isSneaking()) { final TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof IHasGui) { - return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui)tile); + return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); } } @@ -45,23 +66,23 @@ public class BW_TileEntityContainer extends BlockContainer { public void onBlockPlacedBy(final World world, final int x, final int y, final int z, final EntityLivingBase entity, final ItemStack itemStack) { final TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof IWrenchable && itemStack != null) { - final IWrenchable tile2 = (IWrenchable)tile; + final IWrenchable tile2 = (IWrenchable) tile; int meta = itemStack.getItemDamage(); world.setBlockMetadataWithNotify(x, y, z, meta, 2); if (entity != null) { final int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; switch (face) { case 0: - tile2.setFacing((short)2); + tile2.setFacing((short) 2); break; case 1: - tile2.setFacing((short)5); + tile2.setFacing((short) 5); break; case 2: - tile2.setFacing((short)3); + tile2.setFacing((short) 3); break; case 3: - tile2.setFacing((short)4); + tile2.setFacing((short) 4); break; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java new file mode 100644 index 0000000000..3a17a3759b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BioFluidBlock.java @@ -0,0 +1,98 @@ +/* + * 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.common.blocks; + +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.tileentities.BWTileEntityDimIDBridge; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +import net.minecraft.world.World; +import net.minecraftforge.fluids.BlockFluidBase; +import net.minecraftforge.fluids.FluidStack; + +public class BioFluidBlock extends BlockFluidBase implements ITileEntityProvider { + + public BioFluidBlock() { + super(FluidLoader.ff, Material.water); + this.setBlockName("BioFluidBlock"); + //this.setCreativeTab(MainMod.BioTab); + this.textureName = "gregtech:fluids/fluid.molten.autogenerated"; + } + + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister p_149651_1_) { + FluidLoader.autogenIIcon = this.blockIcon = p_149651_1_.registerIcon(this.getTextureName()); + } + + @Override + public int getQuantaValue(IBlockAccess world, int x, int y, int z) { + return 0; + } + + @Override + public boolean canCollideCheck(int meta, boolean fullHit) { + return false; + } + + @Override + public int getMaxRenderHeightMeta() { + return 0; + } + + public int getRenderType() { + return FluidLoader.renderID; + } + + @Override + public FluidStack drain(World world, int x, int y, int z, boolean doDrain) { + return null; + } + + @Override + public boolean canDrain(World world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_) { + return FluidLoader.autogenIIcon; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int p_149691_1_, int p_149691_2_) { + return FluidLoader.autogenIIcon; + } + + @Override + public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) { + return new BWTileEntityDimIDBridge(); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java new file mode 100644 index 0000000000..69621bc1b5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java @@ -0,0 +1,65 @@ +/* + * 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.common.configs; + + +import com.github.bartimaeusnek.bartworks.MainMod; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gregtech.api.enums.GT_Values; +import net.minecraftforge.common.config.Configuration; + +import javax.annotation.Nonnull; +import java.io.File; + +public class ConfigHandler { + private static final int IDU = GT_Values.VN.length * 8 - 3; + public static int IDOffset = 12600; + public static boolean teslastaff = false; + public static long energyPerCell = 100000L; + public static boolean newStuff = true; + public static boolean BioLab = true; + public static Configuration c; + private static boolean ezmode = false; + + public ConfigHandler(@Nonnull FMLPreInitializationEvent e) { + c = new Configuration(new File(e.getModConfigurationDirectory().toString() + "/" + MainMod.modID + ".cfg")); + + IDOffset = c.get("System", "ID Offset", 12600, "ID Offset for this mod. This Mod uses " + IDU + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS").getInt(12600); + energyPerCell = c.get("Multiblocks", "energyPerLESUCell", 1000000, "This will set Up the Energy per LESU Cell", 1000000, Integer.MAX_VALUE).getInt(1000000); + ezmode = c.get("System", "Mode switch", false, "If GTNH is Loaded, this will enable easy recipes, if not, it will enable harder recipes.").getBoolean(false); + MainMod.GTNH = ezmode ? !MainMod.GTNH : MainMod.GTNH; + teslastaff = c.get("System", "Enable Teslastaff", false, "Enables the Teslastaff, an Item used to destroy Electric Armors").getBoolean(false); + newStuff = !c.get("System", "Disable non-original-GT-stuff", false, "This switch disables my new content, that is not part of the GT2 compat").getBoolean(false); + BioLab = !c.get("System", "Disable BioLab", false, "This switch disables the BioLab, BioVat etc. If you use GT5.08 or equivalent, this needs to be turned off!").getBoolean(false); + + if (ConfigHandler.IDOffset == 0) { + ConfigHandler.IDOffset = 12600; + c.get("System", "ID Offset", 12600, "ID Offset for this mod. This Mod uses " + IDU + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS").set(12600); + } + + if (c.hasChanged()) + c.save(); + + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java index 959a67014e..2066ac3b8e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_ItemBlocks.java @@ -1,6 +1,29 @@ +/* + * 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.common.items; import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.util.GT_LanguageManager; @@ -14,16 +37,16 @@ import java.util.List; public class BW_ItemBlocks extends ItemBlock { - public BW_ItemBlocks(final Block par1){ + protected final String mNoMobsToolTip = GT_LanguageManager.addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + protected final String mNoTileEntityToolTip = GT_LanguageManager.addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); + + public BW_ItemBlocks(final Block par1) { super(par1); this.setMaxDamage(0); this.setHasSubtypes(true); this.setCreativeTab(MainMod.GT2); } - protected final String mNoMobsToolTip = GT_LanguageManager.addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); - protected final String mNoTileEntityToolTip = GT_LanguageManager.addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); - @Override public int getMetadata(final int aMeta) { return aMeta; @@ -38,12 +61,13 @@ public class BW_ItemBlocks extends ItemBlock { public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { aList.add(this.mNoMobsToolTip); aList.add(this.mNoTileEntityToolTip); + aList.add("Added by" + ChatColorHelper.DARKGREEN + " BartWorks"); } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(ItemStack stack, int pass) { - return this.field_150939_a.getIcon(0,stack.getItemDamage()); + return this.field_150939_a.getIcon(0, stack.getItemDamage()); } @Override @@ -55,6 +79,6 @@ public class BW_ItemBlocks extends ItemBlock { @Override @SideOnly(Side.CLIENT) public IIcon getIconFromDamageForRenderPass(int p_77618_1_, int p_77618_2_) { - return this.field_150939_a.getIcon(0,p_77618_2_); + return this.field_150939_a.getIcon(0, p_77618_2_); } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java index 3fb86d4963..edb2f32e77 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/BW_Stonage_Rotors.java @@ -1,6 +1,29 @@ +/* + * 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.common.items; import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import ic2.api.item.IKineticRotor; @@ -27,22 +50,22 @@ public class BW_Stonage_Rotors extends Item implements IKineticRotor { private ResourceLocation tex; private String itemTex; - public BW_Stonage_Rotors(int diameter, float eff, int min, int max,int durability, GearboxType type,ResourceLocation tex, String Name, String itemTex){ - this.DiaMinMax[0]=diameter; - this.DiaMinMax[1]=min; - this.DiaMinMax[2]=max; - this.eff=eff; - this.type=type; - this.tex=tex; + public BW_Stonage_Rotors(int diameter, float eff, int min, int max, int durability, GearboxType type, ResourceLocation tex, String Name, String itemTex) { + this.DiaMinMax[0] = diameter; + this.DiaMinMax[1] = min; + this.DiaMinMax[2] = max; + this.eff = eff; + this.type = type; + this.tex = tex; this.setMaxDamage(durability); this.setUnlocalizedName(Name); this.setCreativeTab(MainMod.BWT); - this.itemTex=itemTex; + this.itemTex = itemTex; } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon(MainMod.modID+":"+itemTex); + this.itemIcon = iconRegister.registerIcon(MainMod.modID + ":" + itemTex); } public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) { @@ -56,6 +79,7 @@ public class BW_Stonage_Rotors extends Item implements IKineticRotor { if (type != null) { info.add(StatCollector.translateToLocal(("ic2.itemrotor.fitsin." + this.isAcceptedType(itemStack, type)))); } + info.add("Added by" + ChatColorHelper.DARKGREEN + " BartWorks"); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java index a8df28c5aa..6f8fe09229 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/Circuit_Programmer.java @@ -1,3 +1,25 @@ +/* + * 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.common.items; import com.github.bartimaeusnek.bartworks.MainMod; @@ -20,23 +42,24 @@ import java.util.List; public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem { public Circuit_Programmer() { - super("BWCircuitProgrammer","Circuit Programmer","Programs Integrated Circuits"); + super("BWCircuitProgrammer", "Circuit Programmer", "Programs Integrated Circuits"); this.setMaxStackSize(1); this.setNoRepair(); this.setHasSubtypes(false); this.setCreativeTab(MainMod.BWT); } + @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - super.addInformation(aStack,aPlayer,aList,aF3_H); + super.addInformation(aStack, aPlayer, aList, aF3_H); if (aStack != null && aStack.getTagCompound() != null) - aList.add("Has Circuit inside? "+ (aStack.getTagCompound().getBoolean("HasChip") ? "Yes" : "No")); - aList.add("Added by"+ ChatColorHelper.DARKGREEN +" BartWorks"); + aList.add("Has Circuit inside? " + (aStack.getTagCompound().getBoolean("HasChip") ? "Yes" : "No")); + aList.add("Added by" + ChatColorHelper.DARKGREEN + " BartWorks"); } @Override public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { - if (ElectricItem.manager.use(aStack,100,aPlayer)) { + if (ElectricItem.manager.use(aStack, 100, aPlayer)) { aPlayer.openGui(MainMod.instance, 1, aWorld, 0, 0, 0); } return aStack; @@ -59,7 +82,8 @@ public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem public void registerIcons(IIconRegister aIconRegister) { this.mIcon = aIconRegister.registerIcon("bartworks:CircuitProgrammer"); } - public int getTier(ItemStack var1){ + + public int getTier(ItemStack var1) { return 1; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java index 88883a039c..04fa57efdd 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Destructopack_Item.java @@ -1,3 +1,25 @@ +/* + * 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.common.items; import com.github.bartimaeusnek.bartworks.MainMod; @@ -12,11 +34,10 @@ import net.minecraft.world.World; import java.util.List; -public class GT_Destructopack_Item extends GT_Generic_Item -{ +public class GT_Destructopack_Item extends GT_Generic_Item { public GT_Destructopack_Item() { - super("GT2Destructopack","Destructopack","Mobile Trash Bin"); + super("GT2Destructopack", "Destructopack", "Mobile Trash Bin"); this.setMaxStackSize(1); this.setNoRepair(); this.setHasSubtypes(false); @@ -25,8 +46,8 @@ public class GT_Destructopack_Item extends GT_Generic_Item @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - super.addInformation(aStack,aPlayer,aList,aF3_H); - aList.add("Added by"+ ChatColorHelper.DARKGREEN +" BartWorks"); + super.addInformation(aStack, aPlayer, aList, aF3_H); + aList.add("Added by" + ChatColorHelper.DARKGREEN + " BartWorks"); } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java index 3148281c38..38873cd04a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Rockcutter_Item.java @@ -1,3 +1,25 @@ +/* + * 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.common.items; import com.github.bartimaeusnek.bartworks.MainMod; @@ -27,67 +49,63 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -public class GT_Rockcutter_Item extends ItemTool implements IElectricItem -{ - @SideOnly(Side.CLIENT) - private IIcon icon; - +public class GT_Rockcutter_Item extends ItemTool implements IElectricItem { + public static Set mineableBlocks = Sets.newHashSet(Blocks.stone, Blocks.cobblestone, Blocks.sand, Blocks.clay); public int mCharge; public int mTransfer; public int mTier; - public static Set mineableBlocks = Sets.newHashSet(Blocks.stone, Blocks.cobblestone, Blocks.sand, Blocks.clay); + @SideOnly(Side.CLIENT) + private IIcon icon; private int multi; + public GT_Rockcutter_Item(int aTier) { - super(2*aTier, ToolMaterial.EMERALD, mineableBlocks); + super(2 * aTier, ToolMaterial.EMERALD, mineableBlocks); this.mTier = aTier; - multi = (int) Math.pow(10,(mTier-1)); + multi = (int) Math.pow(10, (mTier - 1)); this.mineableBlocks = new HashSet(); - this.maxStackSize=1; + this.maxStackSize = 1; this.mCharge = 10000 * multi; this.mTransfer = (int) GT_Values.V[mTier]; - this.efficiencyOnProperMaterial = 2.0f*mTier; + this.efficiencyOnProperMaterial = 2.0f * mTier; this.setCreativeTab(MainMod.GT2); - this.setMaxDamage(27+ 10*multi); + this.setMaxDamage(27 + 10 * multi); this.setNoRepair(); - this.setUnlocalizedName("GT_Rockcutter_Item_"+ GT_Values.VN[mTier]); + this.setUnlocalizedName("GT_Rockcutter_Item_" + GT_Values.VN[mTier]); } public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { aList.add("Tier: " + GT_Values.VN[this.mTier]); - aList.add("Added by"+ ChatColorHelper.DARKGREEN +" BartWorks"); + aList.add("Added by" + ChatColorHelper.DARKGREEN + " BartWorks"); } public void onUpdate(ItemStack aStack, World p_77663_2_, Entity p_77663_3_, int p_77663_4_, boolean p_77663_5_) { - if (!ElectricItem.manager.canUse(aStack, 500*multi)) { + if (!ElectricItem.manager.canUse(aStack, 500 * multi)) { if (aStack.isItemEnchanted()) { aStack.getTagCompound().removeTag("ench"); } - } - else if (!aStack.isItemEnchanted()) { - aStack.addEnchantment(Enchantment.silkTouch,3); + } else if (!aStack.isItemEnchanted()) { + aStack.addEnchantment(Enchantment.silkTouch, 3); } } - public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) - { + public boolean onItemUse(ItemStack aStack, EntityPlayer aPlayer, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { ElectricItem.manager.use(aStack, 0, aPlayer); return false; } - + public boolean onBlockDestroyed(final ItemStack var1, final World var2, final Block var3, final int var4, final int var5, final int var6, final EntityLivingBase var7) { ElectricItem.manager.use(var1, 0, var7); - if (ElectricItem.manager.canUse(var1, 500*multi)) { - ElectricItem.manager.use(var1, 500*multi, var7); - } - else{ - ElectricItem.manager.discharge(var1, Integer.MAX_VALUE, Integer.MAX_VALUE, true,true, false); + if (ElectricItem.manager.canUse(var1, 500 * multi)) { + ElectricItem.manager.use(var1, 500 * multi, var7); + } else { + ElectricItem.manager.discharge(var1, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false); } return true; } @Override public boolean canHarvestBlock(Block par1Block, ItemStack itemStack) { - return par1Block.getMaterial().equals(Material.glass) || par1Block.getMaterial().equals(Material.clay) || par1Block.getMaterial().equals(Material.packedIce) || par1Block.getMaterial().equals(Material.ice) || par1Block.getMaterial().equals(Material.sand) || par1Block.getMaterial().equals(Material.ground) || par1Block.getMaterial().equals(Material.rock) || this.mineableBlocks.contains(par1Block); + return par1Block.getMaterial().equals(Material.glass) || par1Block.getMaterial().equals(Material.clay) || par1Block.getMaterial().equals(Material.packedIce) || par1Block.getMaterial().equals(Material.ice) || par1Block.getMaterial().equals(Material.sand) || par1Block.getMaterial().equals(Material.ground) || par1Block.getMaterial().equals(Material.rock) || this.mineableBlocks.contains(par1Block); } @SideOnly(Side.CLIENT) @@ -102,7 +120,7 @@ public class GT_Rockcutter_Item extends ItemTool implements IElectricItem itemList.add(new ItemStack(this, 1, getMaxDamage())); } } - + @Override public boolean canProvideEnergy(ItemStack itemStack) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java index 59f8ac5835..de59f9cec0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/GT_Teslastaff_Item.java @@ -1,3 +1,25 @@ +/* + * 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.common.items; import com.github.bartimaeusnek.bartworks.MainMod; @@ -21,16 +43,14 @@ import net.minecraft.util.IIcon; import java.util.List; import java.util.Set; -public class GT_Teslastaff_Item extends ItemTool implements IElectricItem -{ +public class GT_Teslastaff_Item extends ItemTool implements IElectricItem { + private static Set effective = Sets.newHashSet(Blocks.web); public double mCharge; public double mTransfer; public int mTier; - private static Set effective = Sets.newHashSet(Blocks.web); - @SideOnly(Side.CLIENT) private IIcon icon; - + public GT_Teslastaff_Item() { super(0, ToolMaterial.GOLD, effective); this.setCreativeTab(MainMod.GT2); @@ -46,17 +66,17 @@ public class GT_Teslastaff_Item extends ItemTool implements IElectricItem @Override public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { aList.add("No warranty!"); - aList.add("Added by"+ ChatColorHelper.DARKGREEN +" BartWorks"); + aList.add("Added by" + ChatColorHelper.DARKGREEN + " BartWorks"); } public boolean hitEntity(ItemStack aStack, EntityLivingBase aTarget, EntityLivingBase aPlayer) { if (aTarget instanceof EntityLiving && ElectricItem.manager.canUse(aStack, 9000000)) { - final EntityLiving tTarget = (EntityLiving)aTarget; - final EntityLivingBase tPlayer = (EntityLivingBase)aPlayer; + final EntityLiving tTarget = (EntityLiving) aTarget; + final EntityLivingBase tPlayer = (EntityLivingBase) aPlayer; ElectricItem.manager.use(aStack, 9000000, tPlayer); for (int i = 1; i < 5; ++i) { if (tTarget.getEquipmentInSlot(i) != null && tTarget.getEquipmentInSlot(i).getItem() instanceof IElectricItem) { - tTarget.setCurrentItemOrArmor(i,null); + tTarget.setCurrentItemOrArmor(i, null); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java new file mode 100644 index 0000000000..f434fd5d5f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabModule.java @@ -0,0 +1,46 @@ +/* + * 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.common.items; + +import com.github.bartimaeusnek.bartworks.MainMod; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import java.util.List; + +public class LabModule extends SimpleSubItemClass { + public LabModule(String[] tex) { + super(tex); + this.setCreativeTab(MainMod.BioTab); + } + + public String getUnlocalizedName(ItemStack p_77667_1_) { + return "labModule." + super.getUnlocalizedName(p_77667_1_); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + aList.add("A Module used to change the BioLab's working Mode"); + super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java new file mode 100644 index 0000000000..5fa2064026 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/LabParts.java @@ -0,0 +1,135 @@ +/* + * 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.common.items; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.List; + +import static com.github.bartimaeusnek.bartworks.common.loaders.BioItemList.*; + +public class LabParts extends SimpleSubItemClass { + + public LabParts(String[] tex) { + super(tex); + this.setCreativeTab(MainMod.BioTab); + } + + @Override + public EnumRarity getRarity(ItemStack itemStack) { + + if (itemStack == null || itemStack.getTagCompound() == null) + return EnumRarity.common; + + switch (itemStack.getItemDamage()) { + case 0: + return BW_Util.getRarityFromByte(itemStack.getTagCompound().getCompoundTag("DNA").getByte("Rarity")); + case 1: + case 2: + return BW_Util.getRarityFromByte(itemStack.getTagCompound().getByte("Rarity")); + default: + return EnumRarity.common; + } + } + + @Override + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int p_82790_2_) { + if (stack.getItemDamage() == 0 && stack.getTagCompound() != null && stack.getTagCompound().getIntArray("Color") != null && stack.getTagCompound().getIntArray("Color").length > 0) { + int[] rgb = stack.getTagCompound().getIntArray("Color"); + return BW_Util.getColorFromArray(rgb); + } + return super.getColorFromItemStack(stack, p_82790_2_); + } + + @Override + public void addInformation(ItemStack itemStack, EntityPlayer entityPlayer, List list, boolean b) { + if (itemStack == null || itemStack.getTagCompound() == null) { + switch (itemStack.getItemDamage()) { + case 0: + list.add("An empty Sterilized Petri Dish."); + break; + case 1: + list.add("An empty DNA Flask."); + break; + case 2: + list.add("An empty Plasmid Cell."); + break; + case 3: + list.add("A special washing power for Bio Engineering."); + break; + case 4: + list.add("A powder for the separation of DNA by electrophoresis."); + break; + default: + break; + } + super.addInformation(itemStack, entityPlayer, list, b); + return; + } + + + switch (itemStack.getItemDamage()) { + case 0: + list.add("A Petri Dish containing: " + itemStack.getTagCompound().getString("Name")); + if (!itemStack.getTagCompound().getBoolean("Breedable")) { + list.add("This is a weak culture, it can not be bred in the Bacterial Vat"); + } + break; + case 1: + list.add("A DNA Flask containing: " + itemStack.getTagCompound().getString("Name")); + break; + case 2: + list.add("A Plasmid Cell containing: " + itemStack.getTagCompound().getString("Name")); + break; + default: + break; + } + super.addInformation(itemStack, entityPlayer, list, b); + } + + @Override + public void getSubItems(Item item, CreativeTabs creativeTabs, List list) { + for (ItemStack stack : getAllPetriDishes()) + list.add(stack); + for (ItemStack stack : getAllDNASampleFlasks()) + list.add(stack); + for (ItemStack stack : getAllPlasmidCells()) + list.add(stack); + super.getSubItems(item, creativeTabs, list); + } + + public String getUnlocalizedName(ItemStack itemStack) { + if (itemStack.getItemDamage() == 0 && itemStack.getTagCompound() != null) + return "filled.item." + this.tex[itemStack.getItemDamage()].replaceAll("/", "."); + return super.getUnlocalizedName(itemStack); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java index 41b72f6369..c38be6c6c0 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleIconItem.java @@ -1,3 +1,25 @@ +/* + * 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.common.items; import cpw.mods.fml.relauncher.Side; @@ -9,13 +31,13 @@ public class SimpleIconItem extends Item { String tex; - public SimpleIconItem(String tex){ + public SimpleIconItem(String tex) { super(); - this.tex=tex; + this.tex = tex; } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - itemIcon=iconRegister.registerIcon("bartworks:"+tex); + itemIcon = iconRegister.registerIcon("bartworks:" + tex); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java index 76b0d79b78..365efb5c81 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/items/SimpleSubItemClass.java @@ -1,10 +1,34 @@ +/* + * 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.common.items; import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; @@ -12,13 +36,13 @@ import net.minecraft.util.IIcon; import java.util.List; public class SimpleSubItemClass extends Item { - String[] tex; @SideOnly(Side.CLIENT) protected IIcon[] itemIcon; + String[] tex; - public SimpleSubItemClass(String[] tex){ - this.tex=tex; - this.hasSubtypes=true; + public SimpleSubItemClass(String[] tex) { + this.tex = tex; + this.hasSubtypes = true; this.setCreativeTab(MainMod.BWT); } @@ -26,12 +50,18 @@ public class SimpleSubItemClass extends Item { public void registerIcons(IIconRegister iconRegister) { itemIcon = new IIcon[tex.length]; for (int i = 0; i < tex.length; i++) { - itemIcon[i]=iconRegister.registerIcon(MainMod.modID+":"+tex[i]); + itemIcon[i] = iconRegister.registerIcon(MainMod.modID + ":" + tex[i]); } } @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List aList, boolean p_77624_4_) { + super.addInformation(p_77624_1_, p_77624_2_, aList, p_77624_4_); + aList.add("Added by" + ChatColorHelper.DARKGREEN + " BartWorks"); + } + + @Override public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { for (int i = 0; i < tex.length; i++) { p_150895_3_.add(new ItemStack(p_150895_1_, 1, i)); @@ -39,18 +69,16 @@ public class SimpleSubItemClass extends Item { } @SideOnly(Side.CLIENT) - public IIcon getIconFromDamage(int p_77617_1_) - { - if (p_77617_1_<tex.length) + public IIcon getIconFromDamage(int p_77617_1_) { + if (p_77617_1_ < tex.length) return this.itemIcon[p_77617_1_]; else return this.itemIcon[0]; } - public String getUnlocalizedName(ItemStack p_77667_1_) - { - if (p_77667_1_.getItemDamage()<tex.length) - return "item."+this.tex[p_77667_1_.getItemDamage()].replaceAll("/","."); + public String getUnlocalizedName(ItemStack p_77667_1_) { + if (p_77667_1_.getItemDamage() < tex.length) + return "item." + this.tex[p_77667_1_.getItemDamage()].replaceAll("/", "."); else return "WrongDamageItemDestroyIt"; } 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 new file mode 100644 index 0000000000..f8c228e507 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java @@ -0,0 +1,60 @@ +/* + * 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.common.loaders; + +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 net.minecraft.item.EnumRarity; + +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); + private static final BioData eColiData = BioData.createAndRegisterBioData("Escherichia koli", EnumRarity.uncommon, 10000, 0); + public static BioCulture CommonYeast; + public static BioCulture WhineYeast; + public static BioCulture BeerYeast; + public static BioCulture rottenFleshBacteria; + public static BioCulture eColi; + + @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); + rottenFleshBacteria = BioCulture.createAndRegisterBioCulture(new Color(110, 40, 25), "Escherichia cadaver", BioPlasmid.convertDataToPlasmid(BIO_DATA_BETA_LACMATASE), BioDNA.convertDataToDNA(BIO_DATA_BETA_LACMATASE), false); + eColi = BioCulture.createAndRegisterBioCulture(new Color(149, 132, 75), "Escherichia koli", BioPlasmid.convertDataToPlasmid(eColiData), BioDNA.convertDataToDNA(eColiData), true); + + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java new file mode 100644 index 0000000000..088736025e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java @@ -0,0 +1,140 @@ +/* + * 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.common.loaders; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks; +import com.github.bartimaeusnek.bartworks.common.items.BW_ItemBlocks; +import com.github.bartimaeusnek.bartworks.common.items.LabModule; +import com.github.bartimaeusnek.bartworks.common.items.LabParts; +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 cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import java.util.Collection; +import java.util.HashSet; + + +public class BioItemList { + + + public static final Block[] bw_glasses = { + new BW_GlasBlocks("BW_GlasBlocks", new String[]{ + MainMod.modID + ":BoronSilicateGlassBlock", + MainMod.modID + ":NickelReinforcedBoronSilicateGlassBlock", + MainMod.modID + ":TungstenReinforcedBoronSilicateGlassBlock", + MainMod.modID + ":ChromeReinforcedBoronSilicateGlassBlock", + MainMod.modID + ":IridiumReinforcedBoronSilicateGlassBlock", + MainMod.modID + ":OsmiumReinforcedBoronSilicateGlassBlock", + }, MainMod.BioTab + ) + }; + + private static final Item mItemBioLabParts = new LabModule(new String[]{"DNAExtractionModule", "PCRThermoclyclingModule", "PlasmidSynthesisModule", "TransformationModule", "ClonalCellularSynthesisModule"}); + public static final ItemStack[] mBioLabParts = {new ItemStack(mItemBioLabParts), new ItemStack(mItemBioLabParts, 1, 1), new ItemStack(mItemBioLabParts, 1, 2), new ItemStack(mItemBioLabParts, 1, 3), new ItemStack(mItemBioLabParts, 1, 4)}; + private static final Item vanillaBioLabParts = new LabParts(new String[]{"petriDish", "DNASampleFlask", "PlasmidCell", "DetergentPowder", "Agarose", "IncubationModule", "PlasmaMembrane"}); + + public BioItemList() { + GameRegistry.registerItem(mItemBioLabParts, "BioLabModules"); + GameRegistry.registerItem(vanillaBioLabParts, "BioLabParts"); + GameRegistry.registerBlock(bw_glasses[0], BW_ItemBlocks.class, "BW_GlasBlocks"); + //fixing BorosilicateGlass... -_-' + Materials.BorosilicateGlass.add(SubTag.CRYSTAL, SubTag.NO_SMASHING, SubTag.NO_RECYCLING, SubTag.SMELTING_TO_FLUID); + GT_OreDictUnificator.add(OrePrefixes.block, Materials.BorosilicateGlass, new ItemStack(bw_glasses[0], 1, 0)); + } + + public static Collection<ItemStack> getAllPetriDishes() { + HashSet<ItemStack> ret = new HashSet<>(); + for (BioCulture Culture : BioCulture.BIO_CULTURE_ARRAY_LIST) { + ret.add(getPetriDish(Culture)); + } + return ret; + } + + public static Collection<ItemStack> getAllDNASampleFlasks() { + HashSet<ItemStack> ret = new HashSet<>(); + for (BioData dna : BioData.BIO_DATA_ARRAY_LIST) { + ret.add(getDNASampleFlask(BioDNA.convertDataToDNA(dna))); + } + return ret; + } + + public static Collection<ItemStack> getAllPlasmidCells() { + HashSet<ItemStack> ret = new HashSet<>(); + for (BioData dna : BioData.BIO_DATA_ARRAY_LIST) { + ret.add(getPlasmidCell(BioPlasmid.convertDataToPlasmid(dna))); + } + return ret; + } + + public static ItemStack getPetriDish(BioCulture Culture) { + if (Culture == null) + return new ItemStack(vanillaBioLabParts); + ItemStack ret = new ItemStack(vanillaBioLabParts); + ret.setTagCompound(BioCulture.getNBTTagFromCulture(Culture)); + return ret; + } + + public static ItemStack getDNASampleFlask(BioDNA dna) { + if (dna == null) + return new ItemStack(vanillaBioLabParts, 1, 1); + + ItemStack ret = new ItemStack(vanillaBioLabParts, 1, 1); + ret.setTagCompound(BioData.getNBTTagFromBioData(dna)); + return ret; + } + + public static ItemStack getPlasmidCell(BioPlasmid plasmid) { + if (plasmid == null) + return new ItemStack(vanillaBioLabParts, 1, 2); + ItemStack ret = new ItemStack(vanillaBioLabParts, 1, 2); + ret.setTagCompound(BioData.getNBTTagFromBioData(plasmid)); + return ret; + } + + /** + * 1 - Detergent Powder + * 2 - Agarose + * 3 - Incubation Module + * 4 - Plasma Membrane + * others are null + * + * @param selection see above + * @return the selected Item + */ + public static ItemStack getOther(int selection) { + if (selection < 1 || selection > 4) + return null; + + return new ItemStack(vanillaBioLabParts, 1, 2 + selection); + } +} 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 new file mode 100644 index 0000000000..04221196ce --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java @@ -0,0 +1,42 @@ +/* + * 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.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(); + bioRecipeLoader = new BioRecipeLoader(); + bioRecipeLoader.run(); + } +} 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 new file mode 100644 index 0000000000..5fc32bcfc8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java @@ -0,0 +1,375 @@ +/* + * 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.common.loaders; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_MetaTileEntity_BioLab; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_MetaTileEntity_RadioHatch; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_TileEntity_BioVat; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import cpw.mods.fml.common.Loader; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +public class BioRecipeLoader extends RecipeLoader { + + @Override + public void run() { + + //DNAExtractionModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[0], + RecipeLoader.BITSD, + new Object[]{ + "TET", + "CFC", + "TST", + 'T', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 1L), + 'E', ItemList.Emitter_EV.get(1L), + 'C', GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Aluminium, 1L), + 'S', ItemList.Sensor_EV.get(1L), + 'F', ItemList.Field_Generator_EV.get(1L) + } + ); + + //PCRThermoclyclingModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[1], + RecipeLoader.BITSD, + new Object[]{ + "NEN", + "CFC", + "NSN", + 'N', GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Nichrome, 1L), + 'E', ItemList.Emitter_EV.get(1L), + 'C', GT_OreDictUnificator.get(OrePrefixes.cableGt04, Materials.Aluminium, 1L), + 'S', ItemList.Sensor_EV.get(1L), + 'F', ItemList.Field_Generator_EV.get(1L) + } + ); + + //PlasmidSynthesisModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[2], + RecipeLoader.BITSD, + new Object[]{ + "SFE", + "CPC", + "NFN", + 'N', GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Nichrome, 1L), + 'C', "circuit" + Materials.Data, + 'F', ItemList.Field_Generator_EV.get(1L), + 'E', ItemList.Emitter_EV.get(1L), + 'S', ItemList.Sensor_EV.get(1L), + 'P', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Titanium, 1L), + } + ); + //TransformationModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[3], + RecipeLoader.BITSD, + new Object[]{ + "SFE", + "CPC", + "NFN", + 'N', GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 1L), + 'C', "circuit" + Materials.Master, + 'F', ItemList.Field_Generator_LuV.get(1L), + 'E', ItemList.Emitter_LuV.get(1L), + 'S', ItemList.Sensor_LuV.get(1L), + 'P', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Chrome, 1L), + } + ); + + //ClonalCellularSynthesisModule + GT_ModHandler.addCraftingRecipe( + BioItemList.mBioLabParts[4], + RecipeLoader.BITSD, + new Object[]{ + "FEF", + "CPC", + "FSF", + 'N', GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 1L), + 'C', "circuit" + Materials.Master, + 'F', ItemList.Field_Generator_LuV.get(1L), + 'E', ItemList.Emitter_LuV.get(1L), + 'S', ItemList.Sensor_LuV.get(1L), + 'P', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Chrome, 1L), + } + ); + + if (Loader.isModLoaded("croploadcore")) + for (int i = 0; i < OreDictionary.getOres("cropVine").size(); i++) { + GT_Values.RA.addExtractorRecipe(OreDictionary.getOres("cropVine").get(i).splitStack(12), BioItemList.getOther(1), 500, BW_Util.getMachineVoltageFromTier(3)); + } + else + GT_Values.RA.addExtractorRecipe(new ItemStack(Blocks.vine, 12), BioItemList.getOther(1), 500, BW_Util.getMachineVoltageFromTier(3)); + + GT_Values.RA.addExtractorRecipe(ItemList.Circuit_Chip_Stemcell.get(1L), BioItemList.getOther(4), 500, BW_Util.getMachineVoltageFromTier(6)); + + FluidStack dnaFluid = Loader.isModLoaded("gendustry") ? FluidRegistry.getFluidStack("liquiddna", 1000) : Materials.Biomass.getFluid(1000L); + GT_Values.RA.addMixerRecipe(GT_Utility.getIntegratedCircuit(17), GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Radon, 1L), null, null, dnaFluid, new FluidStack(FluidLoader.BioLabFluidMaterials[0], 2000), Materials.Empty.getCells(1), 500, BW_Util.getMachineVoltageFromTier(3)); + + GT_Values.RA.addCentrifugeRecipe(GT_Utility.getIntegratedCircuit(17), null, new FluidStack(BioCultureLoader.eColi.getFluid(), 1000), new FluidStack(FluidLoader.BioLabFluidMaterials[1], 10), BioItemList.getOther(4), null, null, null, null, null, new int[]{1000}, 60 * 20, BW_Util.getMachineVoltageFromTier(3)); + GT_Values.RA.addCentrifugeRecipe(GT_Utility.getIntegratedCircuit(17), null, new FluidStack(FluidLoader.BioLabFluidMaterials[1], 1000), new FluidStack(FluidLoader.BioLabFluidMaterials[3], 250), null, null, null, null, null, null, null, 60 * 20, BW_Util.getMachineVoltageFromTier(3)); + GT_Values.RA.addCentrifugeRecipe(GT_Utility.getIntegratedCircuit(17), null, new FluidStack(BioCultureLoader.CommonYeast.getFluid(), 1000), new FluidStack(FluidLoader.BioLabFluidMaterials[2], 10), null, null, null, null, null, null, null, 60 * 20, BW_Util.getMachineVoltageFromTier(3)); + + + ItemStack[] Pistons = {ItemList.Electric_Piston_HV.get(1L), ItemList.Electric_Piston_EV.get(1L), ItemList.Electric_Piston_IV.get(1L), ItemList.Electric_Piston_LuV.get(1L), ItemList.Electric_Piston_ZPM.get(1L), ItemList.Electric_Piston_UV.get(1L)}; + ItemStack[] BioLab = new ItemStack[GT_Values.VN.length - 3]; + ItemStack[] RadioHatch = new ItemStack[GT_Values.VN.length - 3]; + Materials[] cables = {Materials.Gold, Materials.Aluminium, Materials.Tungsten, Materials.VanadiumGallium, Materials.Naquadah, Materials.NaquadahAlloy, Materials.Superconductor}; + Materials[] hulls = {Materials.StainlessSteel, Materials.Titanium, Materials.TungstenSteel, Materials.Chrome, Materials.Iridium, Materials.Osmium, Materials.Naquadah}; + Materials[] wireMat = {Materials.Kanthal, Materials.Nichrome, Materials.TungstenSteel, Materials.Naquadah, Materials.NaquadahAlloy, Materials.Superconductor}; + Materials[] circuits = {Materials.Advanced, Materials.Data, Materials.Elite, Materials.Master, Materials.Ultimate, Materials.Superconductor}; + for (int i = 3; i < GT_Values.VN.length; i++) { + //12625 + BioLab[(i - 3)] = new GT_MetaTileEntity_BioLab(ConfigHandler.IDOffset + GT_Values.VN.length * 6 + i, GT_Values.VN[i] + " Bio Lab", GT_Values.VN[i] + " Bio Lab", i, "The BioLab, a Multi-Use Bioengineering Station").getStackForm(1L); + RadioHatch[(i - 3)] = new GT_MetaTileEntity_RadioHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 7 - 2 + i, GT_Values.VN[i] + " Radio Hatch", GT_Values.VN[i] + " Radio Hatch", i).getStackForm(1L); + try { + ItemStack machinehull = ItemList.MACHINE_HULLS[i].get(1L); + GT_ModHandler.addCraftingRecipe( + BioLab[(i - 3)], + RecipeLoader.BITSD, + new Object[]{ + "PFP", + "WCW", + "OGO", + 'F', GT_OreDictUnificator.get(OrePrefixes.frameGt, hulls[(i - 3)], 1L), + 'W', GT_OreDictUnificator.get(OrePrefixes.wireGt01, wireMat[(i - 3)], 1L), + 'P', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Polytetrafluoroethylene, 1L), + 'O', GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Polystyrene, 1L), + 'G', "circuit" + circuits[(i - 3)], + 'C', machinehull + } + ); + GT_ModHandler.addCraftingRecipe( + RadioHatch[(i - 3)], + RecipeLoader.BITSD, + new Object[]{ + "DPD", + "DCD", + "DKD", + 'D', GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Lead, 1L), + 'C', machinehull, + 'K', GT_OreDictUnificator.get(OrePrefixes.cableGt08, cables[(i - 3)], 1L), + 'P', Pistons[(i - 3)] + } + ); + } catch (ArrayIndexOutOfBoundsException e) { + //e.printStackTrace(); + } + } + GT_ModHandler.addCraftingRecipe( + new GT_TileEntity_BioVat(ConfigHandler.IDOffset + GT_Values.VN.length * 7, "BioVat", "BioVat").getStackForm(1L), + RecipeLoader.BITSD, + new Object[]{ + "GCG", + "KHK", + "GCG", + 'G', new ItemStack(BioItemList.bw_glasses[0], 1, 1), + 'C', "circuit" + Materials.Data, + 'K', GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Silver, 1L), + 'H', ItemList.MACHINE_HULLS[3].get(1L) + } + ); + + + Materials[] sterilizers = {Materials.Ammonia, Materials.Chlorine, Materials.Ethanol, Materials.Methanol}; + for (Materials used : sterilizers) { + GT_Values.RA.addAutoclaveRecipe( + ItemList.Circuit_Parts_PetriDish.get(1L), + used.getGas(10L) != null ? used.getGas(8L) : used.getFluid(16L), + BioItemList.getPetriDish(null), + 10000, + 100, + BW_Util.getMachineVoltageFromTier(1) + ); + + GT_Values.RA.addAutoclaveRecipe( + new ItemStack(Items.glass_bottle), + used.getGas(10L) != null ? used.getGas(8L) : used.getFluid(16L), + BioItemList.getDNASampleFlask(null), + 10000, + 100, + BW_Util.getMachineVoltageFromTier(1) + ); + } + + GT_Values.RA.addLaserEngraverRecipe( + new ItemStack(Items.emerald), + GT_Utility.getIntegratedCircuit(17), + BioItemList.getPlasmidCell(null), + 100, + BW_Util.getMachineVoltageFromTier(1) + + ); + + + FluidStack[] easyFluids = {Materials.Water.getFluid(1000L), FluidRegistry.getFluidStack("ic2distilledwater", 1000)}; + for (FluidStack fluidStack : easyFluids) { + + BWRecipes.instance.addBioLabRecipeIncubation( + new ItemStack(Items.rotten_flesh), + BioCultureLoader.rottenFleshBacteria, + new int[]{3300}, + new FluidStack[]{fluidStack}, + 500, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + ); + + BWRecipes.instance.addBioLabRecipeIncubation( + new ItemStack(Items.fermented_spider_eye), + BioCultureLoader.eColi, + new int[]{4500}, + new FluidStack[]{fluidStack}, + 500, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + ); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Food_Dough.get(1L), + BioCultureLoader.CommonYeast, + new int[]{7500}, + new FluidStack[]{fluidStack}, + 500, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + ); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Food_Dough_Sugar.get(1L), + BioCultureLoader.WhineYeast, + new int[]{2500}, + new FluidStack[]{fluidStack}, + 500, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + ); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Bottle_Wine.get(1L), + BioCultureLoader.WhineYeast, + new int[]{3300}, + new FluidStack[]{fluidStack}, + 500, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + ); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Bottle_Beer.get(1L), + BioCultureLoader.BeerYeast, + new int[]{2500}, + new FluidStack[]{fluidStack}, + 500, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + ); + + BWRecipes.instance.addBioLabRecipeIncubation( + ItemList.Bottle_Dark_Beer.get(1L), + BioCultureLoader.BeerYeast, + new int[]{3300}, + new FluidStack[]{fluidStack}, + 500, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + ); + + BWRecipes.instance.addBacterialVatRecipe( + new ItemStack[]{new ItemStack(Items.sugar, 64)}, + new FluidStack[]{new FluidStack(fluidStack, 100)}, + BioCulture.BIO_CULTURE_ARRAY_LIST.get(1), + new FluidStack[]{(Loader.isModLoaded("berriespp") ? FluidRegistry.getFluidStack("potion.GHP", 1) : Materials.Ethanol.getFluid(1L))}, + 350, + BW_Util.getMachineVoltageFromTier(4) + ); + + BWRecipes.instance.addBacterialVatRecipe( + new ItemStack[]{ItemList.Crop_Drop_Grapes.get(16)}, + new FluidStack[]{new FluidStack(fluidStack, 100)}, + BioCulture.BIO_CULTURE_ARRAY_LIST.get(2), + new FluidStack[]{FluidRegistry.getFluidStack("potion.wine", 12)}, + 200, + BW_Util.getMachineVoltageFromTier(2) + ); + + 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), + new FluidStack[]{FluidRegistry.getFluidStack("potion.beer", 5)}, + 600, + BW_Util.getMachineVoltageFromTier(1) + ); + 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), + new FluidStack[]{FluidRegistry.getFluidStack("potion.darkbeer", 10)}, + 600, + BW_Util.getMachineVoltageFromTier(1) + ); + + } + + BWRecipes.instance.addBacterialVatRecipe( + null, + new FluidStack[]{FluidRegistry.getFluidStack("potion.grapejuice", 100)}, + BioCulture.BIO_CULTURE_ARRAY_LIST.get(2), + new FluidStack[]{FluidRegistry.getFluidStack("potion.wine", 12)}, + 400, + BW_Util.getMachineVoltageFromTier(1) + ); + + GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 0), Materials.Nickel.getMolten(5184), new ItemStack(BioItemList.bw_glasses[0], 1, 1), 800, BW_Util.getMachineVoltageFromTier(3)); + GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 1), Materials.Tungsten.getMolten(1296), new ItemStack(BioItemList.bw_glasses[0], 1, 2), 800, BW_Util.getMachineVoltageFromTier(5)); + GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 2), Materials.Chrome.getMolten(1296), new ItemStack(BioItemList.bw_glasses[0], 1, 3), 800, BW_Util.getMachineVoltageFromTier(6)); + GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 3), Materials.Iridium.getMolten(3888), new ItemStack(BioItemList.bw_glasses[0], 1, 4), 800, BW_Util.getMachineVoltageFromTier(7)); + GT_Values.RA.addFluidSolidifierRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 4), Materials.Osmium.getMolten(1296), new ItemStack(BioItemList.bw_glasses[0], 1, 5), 800, BW_Util.getMachineVoltageFromTier(8)); + + //and reverse recipes... cause im nice :P + GT_Values.RA.addPulveriserRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 1), new ItemStack[]{Materials.BorosilicateGlass.getDust(9), Materials.Nickel.getDust(36)}, null, 800, BW_Util.getMachineVoltageFromTier(3)); + GT_Values.RA.addPulveriserRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 2), new ItemStack[]{Materials.BorosilicateGlass.getDust(9), Materials.Nickel.getDust(36), Materials.Tungsten.getDust(9)}, null, 800, BW_Util.getMachineVoltageFromTier(5)); + GT_Values.RA.addPulveriserRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 3), new ItemStack[]{Materials.BorosilicateGlass.getDust(9), Materials.Nichrome.getDust(45), Materials.Tungsten.getDust(9)}, null, 800, BW_Util.getMachineVoltageFromTier(6)); + GT_Values.RA.addPulveriserRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 4), new ItemStack[]{Materials.BorosilicateGlass.getDust(9), Materials.Nichrome.getDust(45), Materials.Tungsten.getDust(9), Materials.Iridium.getDust(27)}, null, 800, BW_Util.getMachineVoltageFromTier(7)); + GT_Values.RA.addPulveriserRecipe(new ItemStack(BioItemList.bw_glasses[0], 1, 5), new ItemStack[]{Materials.BorosilicateGlass.getDust(9), Materials.Nichrome.getDust(45), Materials.Tungsten.getDust(9), Materials.Osmiridium.getDust(36)}, null, 800, BW_Util.getMachineVoltageFromTier(8)); + + } +} 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 new file mode 100644 index 0000000000..b060002b38 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java @@ -0,0 +1,85 @@ +/* + * 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.common.loaders; + +import com.github.bartimaeusnek.bartworks.client.renderer.RendererSwitchingColorFluid; +import com.github.bartimaeusnek.bartworks.common.blocks.BioFluidBlock; +import com.github.bartimaeusnek.bartworks.common.tileentities.BWTileEntityDimIDBridge; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.BioCulture; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.objects.GT_Fluid; +import ic2.core.item.ItemFluidCell; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import java.util.Arrays; + +public class FluidLoader implements Runnable { + + public static IIcon autogenIIcon; + public static Fluid ff; + public static int renderID; + public static Block bioFluidBlock; + public static Fluid[] BioLabFluidMaterials; + public static ItemStack[] BioLabFluidCells; + + @Override + public void run() { + FluidLoader.renderID = RenderingRegistry.getNextAvailableRenderId(); + short[] rgb = new short[3]; + Arrays.fill(rgb, (short) 255); + FluidLoader.ff = new GT_Fluid("BWfakeFluid", "molten.autogenerated", rgb); + BioLabFluidMaterials = new Fluid[]{ + new GT_Fluid("FluorecentdDNA", "molten.autogenerated", new short[]{125, 50, 170, 0}), + new GT_Fluid("EnzymesSollution", "molten.autogenerated", new short[]{240, 200, 125, 0}), + new GT_Fluid("Penicillin", "molten.autogenerated", new short[]{255, 255, 255, 0}), + new GT_Fluid("Polymerase", "molten.autogenerated", new short[]{110, 180, 110, 0}), + }; + + BioLabFluidCells = new ItemStack[BioLabFluidMaterials.length]; + for (int i = 0; i < BioLabFluidMaterials.length; i++) { + FluidRegistry.registerFluid(BioLabFluidMaterials[i]); + 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()))); + + for (BioCulture B : BioCulture.BIO_CULTURE_ARRAY_LIST) { + if (B.isBreedable()) { + 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()})); + FluidRegistry.registerFluid(B.getFluid()); + } + } + + bioFluidBlock = new BioFluidBlock(); + GameRegistry.registerBlock(bioFluidBlock, "coloredFluidBlock"); + GameRegistry.registerTileEntity(BWTileEntityDimIDBridge.class, "bwTEDimIDBridge"); + RenderingRegistry.registerBlockHandler(RendererSwitchingColorFluid.instance); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/GTNHBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/GTNHBlocks.java new file mode 100644 index 0000000000..8d54f44d8a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/GTNHBlocks.java @@ -0,0 +1,96 @@ +/* + * 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.common.loaders; + +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import cpw.mods.fml.common.Loader; + +/** + * Autogenerated run file, script Created on Wed Jan 2 19:11:07 2019 by boubou_19 and bartimaeusnek + * Executed on 2019-01-03 02:08:43 + * modified by bartimaeusnek to only add blocks that mods are loaded + */ +public class GTNHBlocks implements Runnable { + + @Override + public void run() { + BioVatLogicAdder.BioVatGlass.addCustomGlass("minecraft", "glass", 0, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass("IC2", "blockAlloyGlass", 0, 4); + + if (Loader.isModLoaded("BloodArsenal")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("BloodArsenal", "blood_stained_glass", 0, 3); + if (Loader.isModLoaded("Botany")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("Botany", "stained", 0, 3); + if (Loader.isModLoaded("EnderIO")) + for (int i = 0; i <= 5; ++i) + BioVatLogicAdder.BioVatGlass.addCustomGlass("EnderIO", "blockFusedQuartz", i, 3); + + if (Loader.isModLoaded("ExtraUtilities")) { + BioVatLogicAdder.BioVatGlass.addCustomGlass("ExtraUtilities", "decorativeBlock1", 9, 3); + for (int i = 0; i <= 11; ++i) + BioVatLogicAdder.BioVatGlass.addCustomGlass("ExtraUtilities", "decorativeBlock2", i, 3); + for (int i = 0; i <= 5; ++i) + BioVatLogicAdder.BioVatGlass.addCustomGlass("ExtraUtilities", "etherealglass", i, 3); + } + if (Loader.isModLoaded("GalaxySpace")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("GalaxySpace", "futureglass", 0, 3); + if (Loader.isModLoaded("HardcoreEnderExpension")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("HardcoreEnderExpension", "laboratory_glass", 0, 3); + + if (Loader.isModLoaded("Natura")) + for (int i = 0; i <= 1; ++i) + BioVatLogicAdder.BioVatGlass.addCustomGlass("Natura", "NetherGlass", i, 3); + + if (Loader.isModLoaded("RandomThings")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("RandomThings", "spectreGlass", 0, 3); + if (Loader.isModLoaded("TConstruct")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("TConstruct", "GlassBlock", 0, 3); + if (Loader.isModLoaded("tectech")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("tectech", "tile.quantumGlass", 0, 5); + + if (Loader.isModLoaded("chisel")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("chisel", "glass2", 0, 3); + + for (int i = 0; i <= 15; ++i) { + BioVatLogicAdder.BioVatGlass.addCustomGlass("minecraft", "stained_glass", i, 3); + if (Loader.isModLoaded("GalaxySpace")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("GalaxySpace", "futureglasses", i, 3); + if (Loader.isModLoaded("Railcraft")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("Railcraft", "glass", i, 3); + if (Loader.isModLoaded("TConstruct")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("TConstruct", "GlassBlock.StainedClear", i, 3); + if (Loader.isModLoaded("Ztones")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("Ztones", "tile.glaxx", i, 3); + if (Loader.isModLoaded("chisel")) { + BioVatLogicAdder.BioVatGlass.addCustomGlass("chisel", "glass", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass("chisel", "stained_glass_white", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass("chisel", "stained_glass_yellow", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass("chisel", "stained_glass_lightgray", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass("chisel", "stained_glass_brown", i, 3); + BioVatLogicAdder.BioVatGlass.addCustomGlass("chisel", "stained_glass_forestry", i, 3); + } + if (Loader.isModLoaded("witchery")) + BioVatLogicAdder.BioVatGlass.addCustomGlass("witchery", "shadedglass", i, 3); + } + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java index 161f6111bb..fffcf974de 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/ItemRegistry.java @@ -1,11 +1,35 @@ +/* + * 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.common.loaders; import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.common.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.blocks.BW_Blocks; import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.items.*; import com.github.bartimaeusnek.bartworks.common.tileentities.BW_RotorBlock; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_MetaTileEntity_Diode; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_MetaTileEntity_EnergyDistributor; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; @@ -20,7 +44,7 @@ import net.minecraft.util.ResourceLocation; import static com.github.bartimaeusnek.bartworks.MainMod.BWT; import static com.github.bartimaeusnek.bartworks.MainMod.GT2; -import static com.github.bartimaeusnek.bartworks.common.ConfigHandler.newStuff; +import static com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler.newStuff; public class ItemRegistry implements Runnable { @@ -30,40 +54,38 @@ public class ItemRegistry implements Runnable { public static final Item RockcutterMV = new GT_Rockcutter_Item(2); public static final Item RockcutterHV = new GT_Rockcutter_Item(3); public static final Item CircuitProgrammer = new Circuit_Programmer(); - public static ItemStack[] Diode2A= new ItemStack[GT_Values.VN.length]; - public static ItemStack[] Diode4A= new ItemStack[GT_Values.VN.length]; - public static ItemStack[] Diode8A= new ItemStack[GT_Values.VN.length]; - public static ItemStack[] Diode12A= new ItemStack[GT_Values.VN.length]; - public static ItemStack[] Diode16A= new ItemStack[GT_Values.VN.length]; - public static final Block ROTORBLOCK = new BW_TileEntityContainer(Material.wood, BW_RotorBlock.class,"BWRotorBlock"); - - public static final Item LeatherRotor = new BW_Stonage_Rotors(5, 0.15f, 15, 30,2400, IKineticRotor.GearboxType.WIND,new ResourceLocation(MainMod.modID, "textures/items/rotors/rotorLeather.png"),"BW_LeatherRotor","rotors/itemRotorLeather"); - public static final Item WoolRotor = new BW_Stonage_Rotors(7, 0.18f, 10, 20,1600, IKineticRotor.GearboxType.WIND,new ResourceLocation(MainMod.modID, "textures/items/rotors/rotorWool.png"),"BW_WoolRotor","rotors/itemRotorWool"); - public static final Item PaperRotor = new BW_Stonage_Rotors(9, 0.2f, 1, 10,800, IKineticRotor.GearboxType.WIND,new ResourceLocation(MainMod.modID, "textures/items/rotors/rotorPaper.png"),"BW_PaperRotor","rotors/itemRotorPaper"); - public static final Item CombinedRotor = new BW_Stonage_Rotors(11, 0.22f, 1, 50,5800, IKineticRotor.GearboxType.WIND,new ResourceLocation(MainMod.modID, "textures/items/rotors/rotorCombined.png"),"BW_CombinedRotor","rotors/itemRotorCombined"); - public static final Item craftingParts = new SimpleSubItemClass(new String[]{"grindstone_top","grindstone_bottom","completed_grindstone","rotors/leatherParts","rotors/woolParts","rotors/paperParts","rotors/combinedParts"}); - - + public static final Block ROTORBLOCK = new BW_TileEntityContainer(Material.wood, BW_RotorBlock.class, "BWRotorBlock"); + public static final Item LeatherRotor = new BW_Stonage_Rotors(5, 0.15f, 15, 30, 2400, IKineticRotor.GearboxType.WIND, new ResourceLocation(MainMod.modID, "textures/items/rotors/rotorLeather.png"), "BW_LeatherRotor", "rotors/itemRotorLeather"); + public static final Item WoolRotor = new BW_Stonage_Rotors(7, 0.18f, 10, 20, 1600, IKineticRotor.GearboxType.WIND, new ResourceLocation(MainMod.modID, "textures/items/rotors/rotorWool.png"), "BW_WoolRotor", "rotors/itemRotorWool"); + public static final Item PaperRotor = new BW_Stonage_Rotors(9, 0.2f, 1, 10, 800, IKineticRotor.GearboxType.WIND, new ResourceLocation(MainMod.modID, "textures/items/rotors/rotorPaper.png"), "BW_PaperRotor", "rotors/itemRotorPaper"); + public static final Item CombinedRotor = new BW_Stonage_Rotors(11, 0.22f, 1, 50, 5800, IKineticRotor.GearboxType.WIND, new ResourceLocation(MainMod.modID, "textures/items/rotors/rotorCombined.png"), "BW_CombinedRotor", "rotors/itemRotorCombined"); + public static final Item craftingParts = new SimpleSubItemClass(new String[]{"grindstone_top", "grindstone_bottom", "completed_grindstone", "rotors/leatherParts", "rotors/woolParts", "rotors/paperParts", "rotors/combinedParts"}); public static final Item tab = new SimpleIconItem("GT2Coin"); public static final Block[] BW_BLOCKS = { new BW_Blocks("BW_ItemBlocks", new String[] - { - MainMod.modID+":EtchedLapisCell", - MainMod.modID+":PlatedLapisCell", - },GT2), + { + MainMod.modID + ":EtchedLapisCell", + MainMod.modID + ":PlatedLapisCell", + }, GT2), new BW_Blocks("GT_LESU_CASING", new String[]{ - MainMod.modID+":LESU_CELL", - },GT2), - new BW_Blocks("BW_Machinery_Casings",new String[]{ - MainMod.modID+":NickelFerriteBlocks", - MainMod.modID+":TransformerCoil", - // MainMod.modID+":DEHP_Casing", - // MainMod.modID+":DEHP_Casing_Base" - },BWT), + MainMod.modID + ":LESU_CELL", + }, GT2), + new BW_Blocks("BW_Machinery_Casings", new String[]{ + MainMod.modID + ":NickelFerriteBlocks", + MainMod.modID + ":TransformerCoil", + // MainMod.modID+":DEHP_Casing", + // MainMod.modID+":DEHP_Casing_Base" + }, BWT), }; + public static ItemStack[] Diode2A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] Diode4A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] Diode8A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] Diode12A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] Diode16A = new ItemStack[GT_Values.VN.length]; + public static ItemStack[] EnergyDistributor = new ItemStack[GT_Values.VN.length]; @Override public void run() { @@ -71,26 +93,35 @@ public class ItemRegistry implements Runnable { if (newStuff) { GameRegistry.registerBlock(BW_BLOCKS[2], BW_ItemBlocks.class, "BW_Machinery_Casings"); GT_OreDictUnificator.registerOre(OrePrefixes.block, Materials.NickelZincFerrite, new ItemStack(BW_BLOCKS[2])); - - GameRegistry.registerItem(LeatherRotor,"BW_LeatherRotor"); - GameRegistry.registerItem(WoolRotor,"BW_WoolRotor"); - GameRegistry.registerItem(PaperRotor,"BW_PaperRotor"); - GameRegistry.registerItem(CombinedRotor,"BW_CombinedRotor"); - GameRegistry.registerItem(craftingParts,"craftingParts"); - GameRegistry.registerTileEntity(BW_RotorBlock.class,"BWRotorBlockTE"); - GameRegistry.registerBlock(ROTORBLOCK,"BWRotorBlock"); + GameRegistry.registerItem(LeatherRotor, "BW_LeatherRotor"); + GameRegistry.registerItem(WoolRotor, "BW_WoolRotor"); + GameRegistry.registerItem(PaperRotor, "BW_PaperRotor"); + GameRegistry.registerItem(CombinedRotor, "BW_CombinedRotor"); + GameRegistry.registerItem(craftingParts, "craftingParts"); + GameRegistry.registerTileEntity(BW_RotorBlock.class, "BWRotorBlockTE"); + GameRegistry.registerBlock(ROTORBLOCK, "BWRotorBlock"); + + for (int i = 0; i < GT_Values.VN.length; i++) { + ItemRegistry.Diode2A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length + 1 + i, "Cable Diode 2A " + GT_Values.VN[i], "Cable Diode 2A " + GT_Values.VN[i], i, 2).getStackForm(1L); + ItemRegistry.Diode4A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 2 + 1 + i, "Cable Diode 4A " + GT_Values.VN[i], "Cable Diode 4A " + GT_Values.VN[i], i, 4).getStackForm(1L); + ItemRegistry.Diode8A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 3 + 1 + i, "Cable Diode 8A " + GT_Values.VN[i], "Cable Diode 8A " + GT_Values.VN[i], i, 8).getStackForm(1L); + ItemRegistry.Diode12A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 4 + 1 + i, "Cable Diode 12A " + GT_Values.VN[i], "Cable Diode 12A " + GT_Values.VN[i], i, 12).getStackForm(1L); + ItemRegistry.Diode16A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 5 + 1 + i, "Cable Diode 16A " + GT_Values.VN[i], "Cable Diode 16A " + GT_Values.VN[i], i, 16).getStackForm(1L); + ItemRegistry.EnergyDistributor[i] = new GT_MetaTileEntity_EnergyDistributor(ConfigHandler.IDOffset + 1 + i, "Energy Distributor " + GT_Values.VN[i], "Energy Distributor " + GT_Values.VN[i], i, "Splits Amperage into several Sides").getStackForm(1L); + + } } //GT2 stuff - GameRegistry.registerBlock(BW_BLOCKS[0], BW_ItemBlocks.class,"BW_ItemBlocks"); - GameRegistry.registerBlock(BW_BLOCKS[1], BW_ItemBlocks.class,"GT_LESU_CASING"); + GameRegistry.registerBlock(BW_BLOCKS[0], BW_ItemBlocks.class, "BW_ItemBlocks"); + GameRegistry.registerBlock(BW_BLOCKS[1], BW_ItemBlocks.class, "GT_LESU_CASING"); if (ConfigHandler.teslastaff) - GameRegistry.registerItem(Teslastaff,Teslastaff.getUnlocalizedName()); + GameRegistry.registerItem(Teslastaff, Teslastaff.getUnlocalizedName()); - GameRegistry.registerItem(RockcutterLV,RockcutterLV.getUnlocalizedName()); - GameRegistry.registerItem(RockcutterMV,RockcutterMV.getUnlocalizedName()); - GameRegistry.registerItem(RockcutterHV,RockcutterHV.getUnlocalizedName()); - GameRegistry.registerItem(tab,"tabIconGT2"); + GameRegistry.registerItem(RockcutterLV, RockcutterLV.getUnlocalizedName()); + GameRegistry.registerItem(RockcutterMV, RockcutterMV.getUnlocalizedName()); + GameRegistry.registerItem(RockcutterHV, RockcutterHV.getUnlocalizedName()); + GameRegistry.registerItem(tab, "tabIconGT2"); } } 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 199f4068bf..7b21cfaef0 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 @@ -1,14 +1,38 @@ +/* + * 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.common.loaders; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; + public class LoaderRegistry implements Runnable { - public ItemRegistry items = new ItemRegistry(); - public RecipeLoader recipes = new RecipeLoader(); @Override public void run() { - items.run(); - recipes.run(); + new ItemRegistry().run(); + new RecipeLoader().run(); + if (ConfigHandler.BioLab) { + new BioLabLoader().run(); + } } - } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java index a467af62bd..43619f7d7c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/RecipeLoader.java @@ -1,8 +1,32 @@ +/* + * 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.common.loaders; import com.github.bartimaeusnek.bartworks.MainMod; -import com.github.bartimaeusnek.bartworks.common.ConfigHandler; -import com.github.bartimaeusnek.bartworks.common.tileentities.*; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_TileEntity_LESU; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_TileEntity_ManualTrafo; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_TileEntity_Windmill; import gregtech.api.GregTech_API; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; @@ -17,11 +41,11 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; -import static com.github.bartimaeusnek.bartworks.common.ConfigHandler.newStuff; +import static com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler.newStuff; public class RecipeLoader implements Runnable { - private static final long bitsd = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE; + protected static final long BITSD = GT_ModHandler.RecipeBits.DISMANTLEABLE | GT_ModHandler.RecipeBits.NOT_REMOVABLE | GT_ModHandler.RecipeBits.REVERSIBLE; @Override public void run() { @@ -44,7 +68,7 @@ public class RecipeLoader implements Runnable { GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.BW_BLOCKS[1]), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "LLL", "LCL", @@ -56,8 +80,8 @@ public class RecipeLoader implements Runnable { GT_Values.RA.addCutterRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[1]), new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 1), GT_Values.NI, 100, (int) (GT_Values.V[1] - (GT_Values.V[1] / 10))); GT_Values.RA.addCompressorRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 1), new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, (int) (GT_Values.V[1] - (GT_Values.V[1] / 10))); GT_Values.RA.addCompressorRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 9, 0), new ItemStack(ItemRegistry.BW_BLOCKS[1]), 100, (int) (GT_Values.V[1] - (GT_Values.V[1] / 10))); - GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), RecipeLoader.bitsd, new Object[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1)}); - GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), RecipeLoader.bitsd, new Object[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0)}); + GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0), RecipeLoader.BITSD, new Object[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1)}); + GT_ModHandler.addShapelessCraftingRecipe(new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 1), RecipeLoader.BITSD, new Object[]{new ItemStack(ItemRegistry.BW_BLOCKS[0], 1, 0)}); } /* @@ -66,7 +90,7 @@ public class RecipeLoader implements Runnable { GT_ModHandler.addCraftingRecipe( new GT_TileEntity_LESU(ConfigHandler.IDOffset, "LESU", "LESU").getStackForm(1L), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "CDC", "SBS", @@ -80,7 +104,7 @@ public class RecipeLoader implements Runnable { GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.Destructopack), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "CPC", "PLP", @@ -92,7 +116,7 @@ public class RecipeLoader implements Runnable { GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.Destructopack), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "CPC", "PLP", @@ -104,7 +128,7 @@ public class RecipeLoader implements Runnable { GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.RockcutterMV), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "DS ", "DP ", @@ -118,7 +142,7 @@ public class RecipeLoader implements Runnable { GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.RockcutterLV), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "DS ", "DP ", @@ -132,7 +156,7 @@ public class RecipeLoader implements Runnable { GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.RockcutterHV), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "DS ", "DP ", @@ -147,7 +171,7 @@ public class RecipeLoader implements Runnable { if (ConfigHandler.teslastaff) GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.Teslastaff), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "BO ", "OP ", @@ -161,6 +185,7 @@ public class RecipeLoader implements Runnable { Materials[] cables = {Materials.Lead, Materials.Tin, Materials.AnnealedCopper, Materials.Gold, Materials.Aluminium, Materials.Tungsten, Materials.VanadiumGallium, Materials.Naquadah, Materials.NaquadahAlloy, Materials.Superconductor}; Materials[] hulls = {Materials.WroughtIron, Materials.Steel, Materials.Aluminium, Materials.StainlessSteel, Materials.Titanium, Materials.TungstenSteel, Materials.Chrome, Materials.Iridium, Materials.Osmium, Materials.Naquadah}; + for (int i = 0; i < GT_Values.VN.length; i++) { try { Materials cable = cables[i]; @@ -168,8 +193,8 @@ public class RecipeLoader implements Runnable { ItemStack machinehull = ItemList.MACHINE_HULLS[i].get(1L); GT_ModHandler.addCraftingRecipe( - new GT_MetaTileEntity_EnergyDistributor(ConfigHandler.IDOffset + 1 + i, "Energy Distributor " + GT_Values.VN[i], "Energy Distributor " + GT_Values.VN[i], i, "Splits Amperage into several Sides").getStackForm(1L), - RecipeLoader.bitsd, + ItemRegistry.EnergyDistributor[i], + RecipeLoader.BITSD, new Object[]{ "PWP", "WCW", @@ -179,8 +204,8 @@ public class RecipeLoader implements Runnable { 'C', machinehull }); GT_ModHandler.addCraftingRecipe( - ItemRegistry.Diode12A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 4 + 1 + i, "Cable Diode 12A " + GT_Values.VN[i], "Cable Diode 12A " + GT_Values.VN[i], i, 12).getStackForm(1L), - RecipeLoader.bitsd, + ItemRegistry.Diode12A[i], + RecipeLoader.BITSD, new Object[]{ "WDW", "DCD", @@ -193,7 +218,7 @@ public class RecipeLoader implements Runnable { ); GT_ModHandler.addCraftingRecipe( ItemRegistry.Diode12A[i], - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "WDW", "DCD", @@ -205,8 +230,8 @@ public class RecipeLoader implements Runnable { } ); GT_ModHandler.addCraftingRecipe( - ItemRegistry.Diode8A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 3 + 1 + i, "Cable Diode 8A " + GT_Values.VN[i], "Cable Diode 8A " + GT_Values.VN[i], i, 8).getStackForm(1L), - RecipeLoader.bitsd, + ItemRegistry.Diode8A[i], + RecipeLoader.BITSD, new Object[]{ "WDW", "DCD", @@ -219,7 +244,7 @@ public class RecipeLoader implements Runnable { ); GT_ModHandler.addCraftingRecipe( ItemRegistry.Diode8A[i], - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "WDW", "DCD", @@ -231,8 +256,8 @@ public class RecipeLoader implements Runnable { } ); GT_ModHandler.addCraftingRecipe( - ItemRegistry.Diode4A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 2 + 1 + i, "Cable Diode 4A " + GT_Values.VN[i], "Cable Diode 4A " + GT_Values.VN[i], i, 4).getStackForm(1L), - RecipeLoader.bitsd, + ItemRegistry.Diode4A[i], + RecipeLoader.BITSD, new Object[]{ "WDW", "DCD", @@ -245,7 +270,7 @@ public class RecipeLoader implements Runnable { ); GT_ModHandler.addCraftingRecipe( ItemRegistry.Diode4A[i], - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "WDW", "DCD", @@ -257,8 +282,8 @@ public class RecipeLoader implements Runnable { } ); GT_ModHandler.addCraftingRecipe( - ItemRegistry.Diode2A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length + 1 + i, "Cable Diode 2A " + GT_Values.VN[i], "Cable Diode 2A " + GT_Values.VN[i], i, 2).getStackForm(1L), - RecipeLoader.bitsd, + ItemRegistry.Diode2A[i], + RecipeLoader.BITSD, new Object[]{ "WDW", "DCD", @@ -271,7 +296,7 @@ public class RecipeLoader implements Runnable { ); GT_ModHandler.addCraftingRecipe( ItemRegistry.Diode2A[i], - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "WDW", "DCD", @@ -283,8 +308,8 @@ public class RecipeLoader implements Runnable { } ); GT_ModHandler.addCraftingRecipe( - ItemRegistry.Diode16A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 5 + 5 + i, "Cable Diode 16A " + GT_Values.VN[i], "Cable Diode 16A " + GT_Values.VN[i], i, 16).getStackForm(1L), - RecipeLoader.bitsd, + ItemRegistry.Diode16A[i], + RecipeLoader.BITSD, new Object[]{ "WHW", "DCD", @@ -298,7 +323,7 @@ public class RecipeLoader implements Runnable { ); GT_ModHandler.addCraftingRecipe( ItemRegistry.Diode16A[i], - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "WHW", "DCD", @@ -319,30 +344,30 @@ public class RecipeLoader implements Runnable { GT_Values.RA.addAssemblerRecipe( new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.AnnealedCopper, 64L), GT_Utility.getIntegratedCircuit(17)}, Materials.Plastic.getMolten(1152L), - new ItemStack(ItemRegistry.BW_BLOCKS[2],1,1), + new ItemStack(ItemRegistry.BW_BLOCKS[2], 1, 1), 20, (int) (GT_Values.V[3] - (GT_Values.V[3] / 10)) ); GT_ModHandler.addCraftingRecipe( - new GT_TileEntity_ManualTrafo(ConfigHandler.IDOffset + GT_Values.VN.length * 6 + 1, "Manual Travo", "Manual Travo").getStackForm(1L), - RecipeLoader.bitsd, - new Object[]{ - "SCS", - "CHC", - "ZCZ", - 'S', GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Titanium, 1L), - 'C', new ItemStack(ItemRegistry.BW_BLOCKS[2]), - 'H', ItemList.Hull_HV.get(1L), - 'Z', GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1L) - } + new GT_TileEntity_ManualTrafo(ConfigHandler.IDOffset + GT_Values.VN.length * 6 + 1, "Manual Travo", "Manual Travo").getStackForm(1L), + RecipeLoader.BITSD, + new Object[]{ + "SCS", + "CHC", + "ZCZ", + 'S', GT_OreDictUnificator.get(OrePrefixes.screw, Materials.Titanium, 1L), + 'C', new ItemStack(ItemRegistry.BW_BLOCKS[2]), + 'H', ItemList.Hull_HV.get(1L), + 'Z', GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 1L) + } ); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.circuit,Materials.Good,1L),Materials.Aluminium.getPlates(1),ItemList.Circuit_Board_Plastic.get(1L), ItemList.Battery_RE_LV_Lithium.get(1L)}, Materials.SolderingAlloy.getMolten(288L),new ItemStack(ItemRegistry.CircuitProgrammer),600,(int) (GT_Values.V[2] - (GT_Values.V[2] / 10))); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Good, 1L), Materials.Aluminium.getPlates(1), ItemList.Circuit_Board_Plastic.get(1L), ItemList.Battery_RE_LV_Lithium.get(1L)}, Materials.SolderingAlloy.getMolten(288L), new ItemStack(ItemRegistry.CircuitProgrammer), 600, (int) (GT_Values.V[2] - (GT_Values.V[2] / 10))); GT_ModHandler.addCraftingRecipe( - new GT_TileEntity_Windmill(ConfigHandler.IDOffset+GT_Values.VN.length*6+2,"Windmill","Windmill").getStackForm(1L), - RecipeLoader.bitsd, + new GT_TileEntity_Windmill(ConfigHandler.IDOffset + GT_Values.VN.length * 6 + 2, "Windmill", "Windmill").getStackForm(1L), + RecipeLoader.BITSD, new Object[]{ "BHB", "WGW", @@ -350,140 +375,140 @@ public class RecipeLoader implements Runnable { 'B', new ItemStack(Blocks.brick_block), 'W', GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), 'H', new ItemStack(Blocks.hopper), - 'G', new ItemStack(ItemRegistry.craftingParts,1,2), + 'G', new ItemStack(ItemRegistry.craftingParts, 1, 2), } ); GT_ModHandler.addCraftingRecipe( - new ItemStack(ItemRegistry.craftingParts,1,0), - RecipeLoader.bitsd, + new ItemStack(ItemRegistry.craftingParts, 1, 0), + RecipeLoader.BITSD, new Object[]{ "SSS", "DfD", " h ", 'S', new ItemStack(Blocks.stone), - 'D', new ItemStack(GregTech_API.sBlockGranites,1,OreDictionary.WILDCARD_VALUE), + 'D', new ItemStack(GregTech_API.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), } ); GT_ModHandler.addCraftingRecipe( - new ItemStack(ItemRegistry.craftingParts,1,1), - RecipeLoader.bitsd, + new ItemStack(ItemRegistry.craftingParts, 1, 1), + RecipeLoader.BITSD, new Object[]{ "hDf", "SSS", 'S', new ItemStack(Blocks.stone), - 'D', new ItemStack(GregTech_API.sBlockGranites,1, OreDictionary.WILDCARD_VALUE), + 'D', new ItemStack(GregTech_API.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), } ); GT_ModHandler.addCraftingRecipe( - new ItemStack(ItemRegistry.craftingParts,1,2), - RecipeLoader.bitsd, + new ItemStack(ItemRegistry.craftingParts, 1, 2), + RecipeLoader.BITSD, new Object[]{ "STS", "h f", "SBS", - 'S', new ItemStack(GregTech_API.sBlockGranites,1, OreDictionary.WILDCARD_VALUE), + 'S', new ItemStack(GregTech_API.sBlockGranites, 1, OreDictionary.WILDCARD_VALUE), 'T', new ItemStack(ItemRegistry.craftingParts, 1, 0), 'B', new ItemStack(ItemRegistry.craftingParts, 1, 1), } ); GT_ModHandler.addCraftingRecipe( - new ItemStack(ItemRegistry.craftingParts,1,3), - RecipeLoader.bitsd, + new ItemStack(ItemRegistry.craftingParts, 1, 3), + RecipeLoader.BITSD, new Object[]{ "WLs", "WLh", "WLf", 'L', new ItemStack(Items.leather), - 'W', new ItemStack(Blocks.log,1,OreDictionary.WILDCARD_VALUE), + 'W', new ItemStack(Blocks.log, 1, OreDictionary.WILDCARD_VALUE), } ); GT_ModHandler.addCraftingRecipe( - new ItemStack(ItemRegistry.craftingParts,1,4), - RecipeLoader.bitsd, + new ItemStack(ItemRegistry.craftingParts, 1, 4), + RecipeLoader.BITSD, new Object[]{ "WLs", "WLh", "WLf", 'L', new ItemStack(Blocks.carpet), - 'W', new ItemStack(Blocks.log,1,OreDictionary.WILDCARD_VALUE), + 'W', new ItemStack(Blocks.log, 1, OreDictionary.WILDCARD_VALUE), } ); GT_ModHandler.addCraftingRecipe( - new ItemStack(ItemRegistry.craftingParts,1,5), - RecipeLoader.bitsd, + new ItemStack(ItemRegistry.craftingParts, 1, 5), + RecipeLoader.BITSD, new Object[]{ "WLs", "WLh", "WLf", 'L', new ItemStack(Items.paper), - 'W', new ItemStack(Blocks.log,1,OreDictionary.WILDCARD_VALUE), + 'W', new ItemStack(Blocks.log, 1, OreDictionary.WILDCARD_VALUE), } ); GT_ModHandler.addCraftingRecipe( - new ItemStack(ItemRegistry.craftingParts,1,6), - RecipeLoader.bitsd, + new ItemStack(ItemRegistry.craftingParts, 1, 6), + RecipeLoader.BITSD, new Object[]{ "WEs", "WZh", "WDf", - 'E', new ItemStack(ItemRegistry.craftingParts,1,3), - 'Z', new ItemStack(ItemRegistry.craftingParts,1,4), - 'D', new ItemStack(ItemRegistry.craftingParts,1,5), - 'W', new ItemStack(Blocks.log,1,OreDictionary.WILDCARD_VALUE), + 'E', new ItemStack(ItemRegistry.craftingParts, 1, 3), + 'Z', new ItemStack(ItemRegistry.craftingParts, 1, 4), + 'D', new ItemStack(ItemRegistry.craftingParts, 1, 5), + 'W', new ItemStack(Blocks.log, 1, OreDictionary.WILDCARD_VALUE), } ); GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.LeatherRotor), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "hPf", "PWP", "sPr", - 'P', new ItemStack(ItemRegistry.craftingParts,1,3), + 'P', new ItemStack(ItemRegistry.craftingParts, 1, 3), 'W', GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), } ); GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.WoolRotor), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "hPf", "PWP", "sPr", - 'P', new ItemStack(ItemRegistry.craftingParts,1,4), + 'P', new ItemStack(ItemRegistry.craftingParts, 1, 4), 'W', GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), } ); GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.PaperRotor), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "hPf", "PWP", "sPr", - 'P', new ItemStack(ItemRegistry.craftingParts,1,5), + 'P', new ItemStack(ItemRegistry.craftingParts, 1, 5), 'W', GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), } ); GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.CombinedRotor), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "hPf", "PWP", "sPr", - 'P', new ItemStack(ItemRegistry.craftingParts,1,6), + 'P', new ItemStack(ItemRegistry.craftingParts, 1, 6), 'W', GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), } ); GT_ModHandler.addCraftingRecipe( new ItemStack(ItemRegistry.ROTORBLOCK), - RecipeLoader.bitsd, + RecipeLoader.BITSD, new Object[]{ "WRW", "RGR", "WRW", - 'R',GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Iron, 1L), + 'R', GT_OreDictUnificator.get(OrePrefixes.ring, Materials.Iron, 1L), 'W', new ItemStack(Blocks.planks), 'G', GT_OreDictUnificator.get(OrePrefixes.gearGt, Materials.Iron, 1L), } @@ -491,5 +516,8 @@ public class RecipeLoader implements Runnable { //next free ID: ConfigHandler.IDOffset+GT_Values.VN.length*6+3 } + + } + } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java new file mode 100644 index 0000000000..af2a08d3e8 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java @@ -0,0 +1,128 @@ +/* + * 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.common.net; + +import com.google.common.io.ByteArrayDataInput; +import com.google.common.io.ByteStreams; +import cpw.mods.fml.common.network.FMLEmbeddedChannel; +import cpw.mods.fml.common.network.FMLOutboundHandler; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.internal.FMLProxyPacket; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.server.FMLServerHandler; +import gregtech.api.enums.GT_Values; +import gregtech.api.net.GT_Packet; +import gregtech.api.net.IGT_NetworkHandler; +import io.netty.buffer.Unpooled; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.handler.codec.MessageToMessageCodec; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; + +import javax.annotation.Nonnull; +import java.util.EnumMap; +import java.util.Iterator; +import java.util.List; + +/* + * Original GT File slightly Modified + */ +@ChannelHandler.Sharable +public class BW_Network extends MessageToMessageCodec<FMLProxyPacket, GT_Packet> implements IGT_NetworkHandler { + + private EnumMap<Side, FMLEmbeddedChannel> mChannel; + private GT_Packet[] mSubChannels; + + public BW_Network() { + this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", new ChannelHandler[]{this, new HandlerShared()}); + this.mSubChannels = new GT_Packet[]{new RendererPacket()}; + } + + protected void encode(ChannelHandlerContext aContext, GT_Packet aPacket, List<Object> aOutput) throws Exception { + aOutput.add(new FMLProxyPacket(Unpooled.buffer().writeByte(aPacket.getPacketID()).writeBytes(aPacket.encode()).copy(), (String) aContext.channel().attr(NetworkRegistry.FML_CHANNEL).get())); + } + + protected void decode(ChannelHandlerContext aContext, FMLProxyPacket aPacket, List<Object> aOutput) throws Exception { + ByteArrayDataInput aData = ByteStreams.newDataInput(aPacket.payload().array()); + aOutput.add(this.mSubChannels[aData.readByte()].decode(aData)); + } + + public void sendToPlayer(@Nonnull GT_Packet aPacket, @Nonnull EntityPlayerMP aPlayer) { + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(aPlayer); + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).writeAndFlush(aPacket); + } + + public void sendToAllPlayersinWorld(@Nonnull GT_Packet aPacket, World world) { + for (String name : FMLServerHandler.instance().getServer().getAllUsernames()) { + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.PLAYER); + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(world.getPlayerEntityByName(name)); + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).writeAndFlush(aPacket); + } + } + + public void sendToAllAround(@Nonnull GT_Packet aPacket, NetworkRegistry.TargetPoint aPosition) { + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.ALLAROUNDPOINT); + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(aPosition); + ((FMLEmbeddedChannel) this.mChannel.get(Side.SERVER)).writeAndFlush(aPacket); + } + + public void sendToServer(@Nonnull GT_Packet aPacket) { + ((FMLEmbeddedChannel) this.mChannel.get(Side.CLIENT)).attr(FMLOutboundHandler.FML_MESSAGETARGET).set(FMLOutboundHandler.OutboundTarget.TOSERVER); + ((FMLEmbeddedChannel) this.mChannel.get(Side.CLIENT)).writeAndFlush(aPacket); + } + + public void sendPacketToAllPlayersInRange(World aWorld, @Nonnull GT_Packet aPacket, int aX, int aZ) { + if (!aWorld.isRemote) { + Iterator var5 = aWorld.playerEntities.iterator(); + + while (var5.hasNext()) { + Object tObject = var5.next(); + if (!(tObject instanceof EntityPlayerMP)) { + break; + } + + EntityPlayerMP tPlayer = (EntityPlayerMP) tObject; + Chunk tChunk = aWorld.getChunkFromBlockCoords(aX, aZ); + if (tPlayer.getServerForPlayer().getPlayerManager().isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) { + this.sendToPlayer(aPacket, tPlayer); + } + } + } + } + + @Sharable + static final class HandlerShared extends SimpleChannelInboundHandler<GT_Packet> { + HandlerShared() { + } + + protected void channelRead0(ChannelHandlerContext ctx, GT_Packet aPacket) throws Exception { + EntityPlayer aPlayer = GT_Values.GT.getThePlayer(); + aPacket.process(aPlayer == null ? null : GT_Values.GT.getThePlayer().worldObj); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java new file mode 100644 index 0000000000..1427cc291b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java @@ -0,0 +1,112 @@ +/* + * 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.common.net; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_TileEntity_BioVat; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.Coords; +import com.google.common.io.ByteArrayDataInput; +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.net.GT_Packet; +import net.minecraft.world.IBlockAccess; + +import java.nio.ByteBuffer; + +public class RendererPacket extends GT_Packet { + + private Coords coords; + private int integer; + private byte removal; + + public RendererPacket() { + super(true); + + } + + public RendererPacket(Coords coords, int integer, boolean removal) { + super(false); + this.coords = coords; + this.integer = integer; + this.removal = (byte) (removal ? 1 : 0); + } + + @Override + public byte getPacketID() { + return 0; + } + + @Override + public byte[] encode() { + + byte r = (byte) (((integer >> 16) & 0xFF) + Byte.MIN_VALUE); + byte g = (byte) (((integer >> 8) & 0xFF) + Byte.MIN_VALUE); + byte b = (byte) (((integer >> 0) & 0xFF) + Byte.MIN_VALUE); + byte checksum = (byte) (coords.x % 25 + coords.y % 25 + coords.z % 25 + coords.wID % 25 + integer % 25 + removal); + return ByteBuffer.allocate(19).putInt(0, coords.x).putShort(4, (short) coords.y).putInt(6, coords.z).putInt(10, coords.wID).put(14, r).put(15, g).put(16, b).put(17, removal).put(18, checksum).array(); + } + +// /** +// * only use in a debug enviroment, does not do anything on its own. +// * @param buffer +// */ +// public void decodetest (byte[] buffer){ +// this.coords=new Coords(ByteBuffer.wrap(buffer).getInt(0),ByteBuffer.wrap(buffer).getShort(4),ByteBuffer.wrap(buffer).getInt(6),ByteBuffer.wrap(buffer).getInt(10)); +// int[] rgb = {ByteBuffer.wrap(buffer).get(14)-Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(15)-Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(16)-Byte.MIN_VALUE}; +// this.integer= BW_Util.getColorFromArray(rgb); +// this.removal=ByteBuffer.wrap(buffer).get(17); +// +// byte checksum = (byte) (coords.x%25+coords.y%25+coords.z%25+coords.wID%25+integer%25+removal); +// } + + @Override + public GT_Packet decode(ByteArrayDataInput dataInput) { + + byte[] buffer = new byte[19]; + dataInput.readFully(buffer); + + this.coords = new Coords(ByteBuffer.wrap(buffer).getInt(0), ByteBuffer.wrap(buffer).getShort(4), ByteBuffer.wrap(buffer).getInt(6), ByteBuffer.wrap(buffer).getInt(10)); + int[] rgb = {ByteBuffer.wrap(buffer).get(14) - Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(15) - Byte.MIN_VALUE, ByteBuffer.wrap(buffer).get(16) - Byte.MIN_VALUE}; + this.integer = BW_Util.getColorFromArray(rgb); + this.removal = ByteBuffer.wrap(buffer).get(17); + + byte checksum = (byte) (coords.x % 25 + coords.y % 25 + coords.z % 25 + coords.wID % 25 + integer % 25 + removal); + + if (checksum != ByteBuffer.wrap(buffer).get(18)) { + MainMod.logger.error("BW Packet was corrupted or modified!"); + return null; + } + + return new RendererPacket(coords, integer, removal == 1); + } + + @Override + public void process(IBlockAccess iBlockAccess) { + if (FMLCommonHandler.instance().getSide().isClient()) { + if (removal == 0) + GT_TileEntity_BioVat.staticColorMap.put(coords, integer); + else + GT_TileEntity_BioVat.staticColorMap.remove(coords); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/BWTileEntityDimIDBridge.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/BWTileEntityDimIDBridge.java new file mode 100644 index 0000000000..d403b54079 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/BWTileEntityDimIDBridge.java @@ -0,0 +1,28 @@ +/* + * 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.common.tileentities; + +import net.minecraft.tileentity.TileEntity; + +public class BWTileEntityDimIDBridge extends TileEntity { +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/BW_RotorBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/BW_RotorBlock.java index de252a5c67..ee35c37433 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/BW_RotorBlock.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/BW_RotorBlock.java @@ -1,3 +1,25 @@ +/* + * 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.common.tileentities; import com.github.bartimaeusnek.bartworks.client.gui.BW_GUIContainer_RotorBlock; @@ -10,8 +32,8 @@ import net.minecraft.entity.player.EntityPlayer; public class BW_RotorBlock extends TileEntityWindKineticGenerator { - public int getGrindPower(){ - return super.getKuOutput(); + public int getGrindPower() { + return super.getKuOutput(); } public int getKuOutput() { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_BioLab.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_BioLab.java new file mode 100644 index 0000000000..b68e399511 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_BioLab.java @@ -0,0 +1,263 @@ +/* + * 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.common.tileentities; + +import com.github.bartimaeusnek.bartworks.common.items.LabModule; +import com.github.bartimaeusnek.bartworks.common.items.LabParts; +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 cpw.mods.fml.common.Loader; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.objects.XSTR; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { + + private static final String MGUINAME = "BW.GUI.BioLab.png"; + + public GT_MetaTileEntity_BioLab(int aID, String aName, String aNameRegional, int aTier, String aDescription) { + super(aID, aName, aNameRegional, aTier, 1, aDescription, 6, 2, MGUINAME, null, new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/fluid_extractor/OVERLAY_SIDE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/microwave/OVERLAY_FRONT")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT_ACTIVE")/*this is topactive*/), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/chemical_reactor/OVERLAY_FRONT")/*this is top*/), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM_ACTIVE")), new GT_RenderedTexture(new Textures.BlockIcons.CustomIcon("basicmachines/polarizer/OVERLAY_BOTTOM"))); + } + + public GT_MetaTileEntity_BioLab(String aName, int aTier, int aAmperage, String aDescription, ITexture[][][] aTextures, String aNEIName) { + super(aName, aTier, aAmperage, aDescription, aTextures, 6, 2, MGUINAME, aNEIName); + } + + public GT_MetaTileEntity_BioLab(String aName, int aTier, int aAmperage, String[] aDescription, ITexture[][][] aTextures, String aNEIName) { + super(aName, aTier, aAmperage, aDescription, aTextures, 6, 2, MGUINAME, aNEIName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_BioLab(this.mName, this.mTier, this.mAmperage, this.mDescriptionArray, this.mTextures, this.mNEIName); + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeList() { + return BWRecipes.instance.getMappingsFor(BWRecipes.BIOLABBYTE); + } + + @Override + public int getCapacity() { + return this.mTier * 1000; + } + + @Override + public int checkRecipe(boolean skipOC) { + + int rTier = 3; + 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; + 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 + GT_Utility.isStackValid(this.mInventory[5]) && this.mInventory[5].getItem() instanceof LabParts && this.mInventory[5].getItemDamage() == 1 && this.mInventory[5].getTagCompound() == null && + GT_Utility.isStackValid(this.mInventory[6]) && this.mInventory[6].getItem() instanceof LabParts && this.mInventory[6].getItemDamage() == 3 && + GT_Utility.areStacksEqual(this.mInventory[7], Materials.Ethanol.getCells(1)) && + this.mFluid.isFluidEqual(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) && this.mFluid.amount >= 1000 + ) { + + NBTTagCompound DNABioDataTag = this.mInventory[4].getTagCompound().getCompoundTag("DNA"); + if (DNABioDataTag == null) + return super.checkRecipe(skipOC); + BioData cultureDNABioData = BioData.getBioDataFromName(this.mInventory[4].getTagCompound().getCompoundTag("DNA").getString("Name")); + if (cultureDNABioData == null) + return super.checkRecipe(skipOC); + + if (this.mTier < rTier + cultureDNABioData.getTier()) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + + for (int i = 4; i < 8; i++) { + if (this.mInventory[i] != null) + this.mInventory[i].stackSize--; + } + + this.mFluid.amount -= 1000; + + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList.getDNASampleFlask(BioDNA.convertDataToDNA(cultureDNABioData)); + } + this.mOutputItems[1] = GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L); + this.calculateOverclockedNess(BW_Util.getMachineVoltageFromTier(rTier + cultureDNABioData.getTier()), 500); + + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + break; + case 1: { + if (GT_Utility.isStackValid(this.mInventory[4]) && this.mInventory[4].getItem() instanceof LabParts && this.mInventory[4].getItemDamage() == 1 && this.mInventory[4].getTagCompound() != null && //checks if it is a Culture + GT_Utility.isStackValid(this.mInventory[7]) && GT_Utility.areStacksEqual(this.mInventory[7], ItemList.Tool_DataOrb.get(1L)) && + GT_Utility.isStackValid(this.mInventory[5]) && GT_Utility.areStacksEqual(this.mInventory[5], FluidLoader.BioLabFluidCells[0]) && + GT_Utility.isStackValid(this.mInventory[6]) && GT_Utility.areStacksEqual(this.mInventory[6], FluidLoader.BioLabFluidCells[3]) && + this.mFluid.isFluidEqual(dnaFluid) && this.mFluid.amount >= 1000) { + NBTTagCompound DNABioDataTag = this.mInventory[4].getTagCompound(); + if (DNABioDataTag == null) + return super.checkRecipe(skipOC); + BioData cultureDNABioData = BioData.getBioDataFromName(DNABioDataTag.getString("Name")); + + if (cultureDNABioData == null) + return super.checkRecipe(skipOC); + + if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + + for (int i = 4; i < 8; i++) { + if (this.mInventory[i] != null) + this.mInventory[i].stackSize--; + } + + this.mFluid.amount -= 1000; + + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); + Behaviour_DataOrb.setDataName(Outp, cultureDNABioData.getName()); + + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = Outp; + } else + this.mOutputItems[0] = ItemList.Tool_DataOrb.get(1L); + this.mOutputItems[1] = ItemList.Cell_Universal_Fluid.get(2L); + + this.calculateOverclockedNess(BW_Util.getMachineVoltageFromTier(1 + rTier + cultureDNABioData.getTier()), 500); + + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + + } + } + break; + case 2: { + ItemStack inp2 = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(inp2, "DNA Sample"); + Behaviour_DataOrb.setDataName(inp2, BioCultureLoader.BIO_DATA_BETA_LACMATASE.getName()); + if ( + GT_Utility.isStackValid(this.mInventory[4]) && GT_Utility.areStacksEqual(FluidLoader.BioLabFluidCells[1], this.mInventory[4]) && //checks if it is a Culture + GT_Utility.isStackValid(this.mInventory[5]) && GT_Utility.areStacksEqual(this.mInventory[5], BioItemList.getPlasmidCell(null)) && + GT_Utility.isStackValid(this.mInventory[6]) && GT_Utility.areStacksEqual(this.mInventory[6], ItemList.Tool_DataOrb.get(1L), true) && + Behaviour_DataOrb.getDataTitle(this.mInventory[6]).equals("DNA Sample") && (!(Behaviour_DataOrb.getDataName(this.mInventory[6]).isEmpty())) && + GT_Utility.isStackValid(this.mInventory[7]) && GT_Utility.areStacksEqual(this.mInventory[7], inp2) && + this.mFluid.isFluidEqual(dnaFluid) && (this.mFluid.amount >= 1000)) { + BioData cultureDNABioData = BioData.getBioDataFromName(Behaviour_DataOrb.getDataName(this.mInventory[6])); + if (cultureDNABioData == null) + return super.checkRecipe(skipOC); + if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 4; i < 6; i++) { + if (this.mInventory[i] != null) + this.mInventory[i].stackSize--; + } + this.mFluid.amount -= 1000; + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList.getPlasmidCell(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + } + this.mOutputItems[1] = ItemList.Cell_Universal_Fluid.get(1L); + this.calculateOverclockedNess(BW_Util.getMachineVoltageFromTier(1 + rTier + cultureDNABioData.getTier()), 500); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + + } + break; + + 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) { + BioData cultureDNABioData = BioData.getBioDataFromNBTTag(this.mInventory[5].getTagCompound()); + BioCulture bioCulture = BioCulture.getBioCultureFromNBTTag(this.mInventory[4].getTagCompound()); + if (cultureDNABioData == null || bioCulture == null) + return super.checkRecipe(skipOC); + if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 4; i < 7; i++) { + if (this.mInventory[i] != null) + this.mInventory[i].stackSize--; + } + this.mFluid.amount -= 1000; + bioCulture.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + this.mOutputItems[0] = BioItemList.getPetriDish(bioCulture); + } + this.mOutputItems[1] = ItemList.Cell_Universal_Fluid.get(1L); + this.calculateOverclockedNess(BW_Util.getMachineVoltageFromTier(3 + rTier + cultureDNABioData.getTier()), 500); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + case 4: { + + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); + + if ( + GT_Utility.isStackValid(this.mInventory[4]) && GT_Utility.areStacksEqual(this.mInventory[4], BioItemList.getPetriDish(null)) && + GT_Utility.isStackValid(this.mInventory[5]) && GT_Utility.areStacksEqual(this.mInventory[5], BioItemList.getOther(4)) && + GT_Utility.isStackValid(this.mInventory[6]) && GT_Utility.areStacksEqual(this.mInventory[6], ItemList.Circuit_Chip_Stemcell.get(2L)) && + GT_Utility.isStackValid(this.mInventory[7]) && GT_Utility.areStacksEqual(this.mInventory[7], ItemList.Tool_DataOrb.get(1L), true) && + Behaviour_DataOrb.getDataTitle(this.mInventory[7]).equals("DNA Sample") && this.mFluid.isFluidEqual(dnaFluid) && (this.mFluid.amount >= 8000)) { + + BioData cultureDNABioData = BioData.getBioDataFromName(Behaviour_DataOrb.getDataName(this.mInventory[7])); + if (cultureDNABioData == null) + return super.checkRecipe(skipOC); + if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) + return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + for (int i = 4; i < 7; i++) { + if (this.mInventory[i] != null) + this.mInventory[i].stackSize--; + } + this.mFluid.amount -= 8000; + if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { + BioCulture out = BioCulture.getBioCulture(BioDNA.convertDataToDNA(cultureDNABioData)); + out.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); + this.mOutputItems[0] = BioItemList.getPetriDish(out); + } + this.calculateOverclockedNess(BW_Util.getMachineVoltageFromTier(3 + rTier + cultureDNABioData.getTier()), 500); + return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + } + } + break; + default: + return super.checkRecipe(skipOC); + } + } + return super.checkRecipe(skipOC); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_Diode.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_Diode.java index b2775252c9..ab8ceacff9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_Diode.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_Diode.java @@ -1,3 +1,25 @@ +/* + * 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.common.tileentities; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; @@ -12,8 +34,8 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { private long amps; public GT_MetaTileEntity_Diode(int aID, String aName, String aNameRegional, int aTier, int amps) { - super(aID, aName, aNameRegional, aTier, "A Simple diode that will allow Energy Flow in only one direction.", null); - this.amps=amps; + super(aID, aName, aNameRegional, aTier, "A Simple diode that will allow Energy Flow in only one direction."); + this.amps = amps; } public GT_MetaTileEntity_Diode(String aName, int aTier, int aInvSlotCount, String[] aDescription, ITexture[][][] aTextures) { @@ -34,7 +56,8 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new GT_MetaTileEntity_Diode(this.mName, this.mTier, this.mInventory.length, this.mDescriptionArray, this.mTextures); } + public String[] getDescription() { - return new String[] {mDescription,"Voltage: "+ ChatColorHelper.YELLOW + GT_Values.V[this.mTier],"Amperage IN: " + ChatColorHelper.YELLOW + maxAmperesIn(),"Amperage OUT: " + ChatColorHelper.YELLOW + maxAmperesOut(), "Added by bartimaeusnek via "+ChatColorHelper.DARKGREEN+"BartWorks"}; + return new String[]{mDescription, "Voltage: " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], "Amperage IN: " + ChatColorHelper.YELLOW + maxAmperesIn(), "Amperage OUT: " + ChatColorHelper.YELLOW + maxAmperesOut(), "Added by bartimaeusnek via " + ChatColorHelper.DARKGREEN + "BartWorks"}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_EnergyDistributor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_EnergyDistributor.java index 218f8f0d50..bbe86520f3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_EnergyDistributor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_EnergyDistributor.java @@ -1,3 +1,25 @@ +/* + * 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.common.tileentities; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; @@ -43,11 +65,11 @@ public class GT_MetaTileEntity_EnergyDistributor extends GT_MetaTileEntity_Trans @Override public long maxEUStore() { - return 512L + (GT_Values.V[this.mTier ] * 320L); + return 512L + (GT_Values.V[this.mTier] * 320L); } public String[] getDescription() { - return new String[] {mDescription,"Voltage: "+ ChatColorHelper.YELLOW +GT_Values.V[this.mTier],"Amperage IN: " + ChatColorHelper.YELLOW + maxAmperesIn(),"Amperage OUT: " + ChatColorHelper.YELLOW + maxAmperesOut(), "Added by bartimaeusnek via "+ChatColorHelper.DARKGREEN+"BartWorks"}; + return new String[]{mDescription, "Voltage: " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], "Amperage IN: " + ChatColorHelper.YELLOW + maxAmperesIn(), "Amperage OUT: " + ChatColorHelper.YELLOW + maxAmperesOut(), "Added by bartimaeusnek via " + ChatColorHelper.DARKGREEN + "BartWorks"}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_RadioHatch.java new file mode 100644 index 0000000000..619a025747 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_MetaTileEntity_RadioHatch.java @@ -0,0 +1,315 @@ +/* + * 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.common.tileentities; + +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_RadioHatch; +import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; + +import static com.github.bartimaeusnek.bartworks.util.BW_Util.calculateSv; + +public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { + + private final int cap; + public int sievert; + private long timer = 1; + private short[] colorForGUI; + private byte mass; + private String material; + private byte coverage = 0; + + public GT_MetaTileEntity_RadioHatch(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 1, new String[]{"Radioactive Item Chamber for Multiblocks", "Capacity: " + (aTier - 2) + " kg" + ((aTier - 2) >= 2 ? "s" : ""), "Use a screwdriver to set the containment level"}); + cap = aTier - 2; + } + + public GT_MetaTileEntity_RadioHatch(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + cap = aTier - 2; + } + + public GT_MetaTileEntity_RadioHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + cap = aTier - 2; + } + + public static long calcDecayTicks(int x) { + long ret = 0; + if (x >= 83 && x <= 100) + ret = (long) Math.ceil((8000D * Math.tanh(-x / 20D) + 8000D) * 1000D); + else if (x == 43) + ret = 5000; + else if (x == 61) + ret = 4500; + else if (x > 100) + ret = (long) Math.ceil(((8000D * Math.tanh(-x / 65D) + 8000D))); + return ret;//*20; + } + + public int getSievert() { + return this.sievert - (int) Math.ceil((float) this.sievert / 100f * (float) coverage); + } + + public short[] getColorForGUI() { + if (this.colorForGUI != null) + return this.colorForGUI; + return new short[]{0xFA, 0xFA, 0xFF}; + } + + public byte getMass() { + return this.mass; + } + + public byte getCoverage() { + return this.coverage; + } + + public void setCoverage(short coverage) { + byte nu = 0; + if (coverage > 100) + nu = 100; + else if (coverage < 0) + nu = 0; + else + nu = (byte) coverage; + this.coverage = nu; + } + + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; + } + + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[]{aBaseTexture, new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_PIPE_IN)}; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_MetaTileEntity_RadioHatch(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { + aPlayer.openGui(MainMod.modID, 2, this.getBaseMetaTileEntity().getWorld(), this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()); + //super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); + } + + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } else { + aBaseMetaTileEntity.openGUI(aPlayer); + return true; + } + } + + public void updateSlots() { + if (this.mInventory[0] != null && this.mInventory[0].stackSize <= 0) + this.mInventory[0] = null; + } + + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTimer) { + if (this.getBaseMetaTileEntity().isServerSide()) { + + if (this.mass > 0) + ++timer; + + if (this.mass > 0 && this.sievert > 0 && calcDecayTicks(this.sievert) > 0) { + if (timer % (calcDecayTicks(this.sievert)) == 0) { + this.mass--; + if (mass == 0) { + material = "Empty"; + sievert = 0; + } + timer = 1; + } + } + + ItemStack lStack = this.mInventory[0]; + + if (lStack == null) + return; + + if (GT_Utility.areStacksEqual(lStack, ItemList.NaquadahCell_1.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.NaquadahCell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.NaquadahCell_4.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.ThoriumCell_1.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.ThoriumCell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.ThoriumCell_4.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Uraniumcell_1.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Uraniumcell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Uraniumcell_4.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Moxcell_1.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Moxcell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Moxcell_4.get(1))) { + Materials materials = Materials.Uranium; + byte kg = 3; + + if (GT_Utility.areStacksEqual(lStack, ItemList.Moxcell_1.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Moxcell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Moxcell_4.get(1))) + materials = Materials.Plutonium; + else if (GT_Utility.areStacksEqual(lStack, ItemList.ThoriumCell_1.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.ThoriumCell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.ThoriumCell_4.get(1))) + materials = Materials.Thorium; + else if (GT_Utility.areStacksEqual(lStack, ItemList.NaquadahCell_1.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.NaquadahCell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.NaquadahCell_4.get(1))) + materials = Materials.Naquadah; + else + kg = 6; + + if (GT_Utility.areStacksEqual(lStack, ItemList.NaquadahCell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Moxcell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Uraniumcell_2.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.ThoriumCell_2.get(1))) + kg = (byte) (2 * kg); + else if (GT_Utility.areStacksEqual(lStack, ItemList.Moxcell_4.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.Uraniumcell_4.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.ThoriumCell_4.get(1)) || GT_Utility.areStacksEqual(lStack, ItemList.NaquadahCell_4.get(1))) + kg = (byte) (4 * kg); + + + if (this.mass == 0 || this.sievert == calculateSv(materials)) { + if (this.mass + kg <= cap) { + this.sievert = calculateSv(materials); + this.mass += kg; + this.mInventory[0].stackSize--; + updateSlots(); + colorForGUI = materials.mColor.mRGBa; + material = materials.mName; + } + } + } + + for (ItemStack varStack : BioVatLogicAdder.RadioHatch.getIsSv().keySet()) { + if (GT_Utility.areStacksEqual(varStack, lStack)) { + if (this.mass == 0 || this.sievert == BioVatLogicAdder.RadioHatch.getIsSv().get(varStack)) { + if (this.mass < this.cap) { + this.mass++; + this.sievert = BioVatLogicAdder.RadioHatch.getIsSv().get(varStack); + this.mInventory[0].stackSize--; + updateSlots(); + colorForGUI = null; + material = StatCollector.translateToLocal(varStack.getUnlocalizedName()); + return; + } + } + } + } + + //check material for general validity + if (lStack != null && GT_OreDictUnificator.getAssociation(lStack) != null && GT_OreDictUnificator.getAssociation(lStack).mMaterial != null && GT_OreDictUnificator.getAssociation(lStack).mMaterial.mMaterial != null) { + //check orePrefix for general validity + if (GT_OreDictUnificator.getAssociation(lStack).mPrefix != null) { + OrePrefixes orePrefixes = GT_OreDictUnificator.getAssociation(lStack).mPrefix; + //check orePrefix for specialised validity + if (orePrefixes.equals(OrePrefixes.stickLong) || orePrefixes.equals(OrePrefixes.stick)) { + Materials materials = GT_OreDictUnificator.getAssociation(lStack).mMaterial.mMaterial; + //check material for specialised validity + if (materials.getProtons() >= 83 && materials.getProtons() != 125 || materials.getProtons() == 61 || materials.getProtons() == 43) { + if (this.mass == 0 || this.sievert == calculateSv(materials)) { + if ((this.mass + (orePrefixes.equals(OrePrefixes.stickLong) ? 2 : 1)) <= cap) { + this.sievert = calculateSv(materials); + this.mass += orePrefixes.equals(OrePrefixes.stickLong) ? 2 : 1; + this.mInventory[0].stackSize--; + updateSlots(); + colorForGUI = materials.mColor.mRGBa; + material = materials.mName; + } + } + } + } + } + } + + + } + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[]{"Material: " + material, "Sievert: " + sievert, "Amount: " + mass, "Time (in t/s/m/h) to decay (1kg): " + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert) * 60)) + "t/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 + "s/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 / 60 + "m/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 / 60 / 60 + "h"}; + } + + public boolean isSimpleMachine() { + return true; + } + + public boolean isFacingValid(byte aFacing) { + return true; + } + + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + public boolean isValidSlot(int aIndex) { + return true; + } + + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return false; + } + + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { + return aSide == this.getBaseMetaTileEntity().getFrontFacing(); + } + + public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_Container_RadioHatch(aPlayerInventory, aBaseMetaTileEntity); + } + + public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { + return new GT_GUIContainer_RadioHatch(aPlayerInventory, aBaseMetaTileEntity, this.mName); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setByte("mMass", mass); + aNBT.setByte("mSv", (byte) (sievert - 100)); + aNBT.setByte("mCoverage", coverage); + aNBT.setInteger("mTextColor", BW_Util.getColorFromArray(getColorForGUI())); + if (material != null && !material.isEmpty()) + aNBT.setString("mMaterial", material); + aNBT.setLong("timer", timer); + super.saveNBTData(aNBT); + } + + public long getTimer() { + return this.timer; + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + timer = aNBT.getLong("timer"); + mass = aNBT.getByte("mMass"); + sievert = aNBT.getByte("mSv") + 100; + coverage = aNBT.getByte("mCoverage"); + colorForGUI = BW_Util.splitColortoArray(aNBT.getInteger("mTextColor")); + material = aNBT.getString("mMaterial"); + super.loadNBTData(aNBT); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_BioVat.java new file mode 100644 index 0000000000..a7e153bdc1 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_BioVat.java @@ -0,0 +1,674 @@ +/* + * 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.common.tileentities; + +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.items.LabParts; +import com.github.bartimaeusnek.bartworks.common.loaders.BioItemList; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; +import com.github.bartimaeusnek.bartworks.common.net.RendererPacket; +import com.github.bartimaeusnek.bartworks.util.*; +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.world.World; +import net.minecraft.world.chunk.Chunk; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nonnegative; +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; + +import static gregtech.api.enums.GT_Values.V; + +public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { + + public static final HashMap<Coords, Integer> staticColorMap = new HashMap<>(); + + private static final byte MCASING_INDEX = 49; + private static final byte TIMERDIVIDER = 20; + + private final HashSet<EntityPlayerMP> playerMPHashSet = new HashSet<EntityPlayerMP>(); + private final ArrayList<GT_MetaTileEntity_RadioHatch> mRadHatches = new ArrayList<>(); + private int height = 1; + private GT_Recipe mLastRecipe = null; + private Fluid mFluid = FluidRegistry.LAVA; + private BioCulture mCulture; + private ItemStack mStack = null; + private boolean needsVisualUpdate = true; + private byte mGlassTier = 0; + private int mSievert = 0; + + + public GT_TileEntity_BioVat(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_TileEntity_BioVat(String aName) { + super(aName); + } + + private static int[] specialValueUnpack(int aSpecialValure) { + int[] ret = new int[4]; + ret[0] = aSpecialValure & 0xF; // = glas tier + ret[1] = aSpecialValure >>> 4 & 0b11; // = special valure + ret[2] = aSpecialValure >>> 6 & 0b1; //exact svt + ret[3] = aSpecialValure >>> 7 & Integer.MAX_VALUE; // = sievert + return ret; + } + + public boolean isLiquidInput(byte aSide) { + return false; + } + + public boolean isLiquidOutput(byte aSide) { + return false; + } + + private int getInputCapacity() { + int ret = 0; + + for (GT_MetaTileEntity_Hatch_Input fluidH : this.mInputHatches) { + ret += fluidH.getCapacity(); + } + return ret; + } + + private int getOutputCapacity() { + int ret = 0; + + for (GT_MetaTileEntity_Hatch_Output fluidH : this.mOutputHatches) { + ret += fluidH.getCapacity(); + } + return ret; + } + + @Override + public int getCapacity() { + int ret = 0; + ret += getInputCapacity(); + //ret += getOutputCapacity(); + return ret; + } + + @Override + public int fill(FluidStack resource, boolean doFill) { + return super.fill(resource, doFill); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return BWRecipes.instance.getMappingsFor(BWRecipes.BACTERIALVATBYTE); + } + + private int calcMod(double x) { + return (int) Math.ceil((-0.00000025D * x * (x - this.getOutputCapacity()))); + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + GT_Recipe.GT_Recipe_Map gtRecipeMap = getRecipeMap(); + + if (gtRecipeMap == null) + return false; + + ArrayList<ItemStack> tInputList = getStoredInputs(); + int tInputList_sS = tInputList.size(); + for (int i = 0; i < tInputList_sS - 1; i++) { + for (int j = i + 1; j < tInputList_sS; j++) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize >= tInputList.get(j).stackSize) { + tInputList.remove(j--); + tInputList_sS = tInputList.size(); + } else { + tInputList.remove(i--); + tInputList_sS = tInputList.size(); + break; + } + } + } + } + ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); + + ArrayList<FluidStack> tFluidList = getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + for (int i = 0; i < tFluidList_sS - 1; i++) { + for (int j = i + 1; j < tFluidList_sS; j++) { + if (GT_Utility.areFluidsEqual(tFluidList.get(i), tFluidList.get(j))) { + if (tFluidList.get(i).amount >= tFluidList.get(j).amount) { + tFluidList.remove(j--); + tFluidList_sS = tFluidList.size(); + } else { + tFluidList.remove(i--); + tFluidList_sS = tFluidList.size(); + break; + } + } + } + } + + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); + + if (tFluidList.size() > 0) { + + GT_Recipe gtRecipe = gtRecipeMap.findRecipe(this.getBaseMetaTileEntity(), mLastRecipe, false, this.getMaxInputVoltage(), tFluids, itemStack, tInputs); + + if (gtRecipe == null) + return false; + + if (!BW_Util.areStacksEqual((ItemStack) gtRecipe.mSpecialItems, itemStack)) + return false; + + int[] conditions = specialValueUnpack(gtRecipe.mSpecialValue); + + if (conditions[2] == 0 ? (this.mSievert < conditions[3] || this.mGlassTier < conditions[0]) : (this.mSievert != conditions[3] || this.mGlassTier < conditions[0])) + return false; + + int times = 1; + + + this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiencyIncrease = 10000; + + if (gtRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { + if (getStoredFluidOutputs().size() > 0) { + this.mOutputFluids = new FluidStack[gtRecipe.mFluidOutputs.length]; + for (FluidStack storedOutputFluid : getStoredFluidOutputs()) { + if (storedOutputFluid.isFluidEqual(gtRecipe.getFluidOutput(0))) + for (FluidStack inputFluidStack : gtRecipe.mFluidInputs) { + int j = calcMod(storedOutputFluid.amount); + for (int i = 0; i < j; i++) + if (depleteInput(inputFluidStack)) + times++; + } + } + for (FluidStack storedfluidStack : getStoredFluidOutputs()) { + for (int i = 0; i < gtRecipe.mFluidOutputs.length; i++) { + if (storedfluidStack.isFluidEqual(gtRecipe.getFluidOutput(i))) + this.mOutputFluids[i] = (new FluidStack(gtRecipe.getFluidOutput(i), times * gtRecipe.getFluidOutput(0).amount)); + } + + } + } else { + this.mOutputFluids = gtRecipe.mFluidOutputs; + } + } else + return false; + + calculateOverclockedNessMulti(gtRecipe.mEUt, gtRecipe.mDuration, 1, this.getMaxInputVoltage()); + + if (mEUt > 0) + mEUt = -mEUt; + this.mProgresstime = 0; + + if (gtRecipe.mCanBeBuffered) + mLastRecipe = gtRecipe; + + updateSlots(); + return true; + } + return false; + } + + /** + * Taken from the GTNH fork, made originally by Tec? + * Calcualtes overclocked ness using long integers + * + * @param aEUt - recipe EUt + * @param aDuration - recipe Duration + * @param mAmperage - should be 1 ? + */ + protected void calculateOverclockedNessMulti(@Nonnegative int aEUt, @Nonnegative int aDuration, @Nonnegative int mAmperage, @Nonnegative long maxInputVoltage) { + byte mTier = (byte) Math.max(0, GT_Utility.getTier(maxInputVoltage)); + if (mTier == 0) { + //Long time calculation + long xMaxProgresstime = ((long) aDuration) << 1; + if (xMaxProgresstime > Integer.MAX_VALUE - 1) { + //make impossible if too long + mEUt = Integer.MAX_VALUE - 1; + mMaxProgresstime = Integer.MAX_VALUE - 1; + } else { + mEUt = aEUt >> 2; + mMaxProgresstime = (int) xMaxProgresstime; + } + } else { + //Long EUt calculation + long xEUt = aEUt; + //Isnt too low EUt check? + long tempEUt = xEUt < V[1] ? V[1] : xEUt; + + mMaxProgresstime = aDuration; + + while (tempEUt <= V[mTier - 1] * mAmperage) { + tempEUt <<= 2;//this actually controls overclocking + //xEUt *= 4;//this is effect of everclocking + mMaxProgresstime >>= 1;//this is effect of overclocking + xEUt = mMaxProgresstime == 0 ? xEUt >> 1 : xEUt << 2;//U know, if the time is less than 1 tick make the machine use less power + } + if (xEUt > Integer.MAX_VALUE - 1) { + mEUt = Integer.MAX_VALUE - 1; + mMaxProgresstime = Integer.MAX_VALUE - 1; + } else { + mEUt = (int) xEUt; + if (mEUt == 0) + mEUt = 1; + if (mMaxProgresstime == 0) + mMaxProgresstime = 1;//set time to 1 tick + } + } + } + + public ArrayList<FluidStack> getStoredFluidOutputs() { + ArrayList<FluidStack> rList = new ArrayList(); + Iterator var2 = this.mOutputHatches.iterator(); + + while (var2.hasNext()) { + GT_MetaTileEntity_Hatch_Output tHatch = (GT_MetaTileEntity_Hatch_Output) var2.next(); + if (tHatch.getFluid() != null) + rList.add(tHatch.getFluid()); + } + return rList; + } + + private boolean addRadiationInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_RadioHatch) { + ((GT_MetaTileEntity_RadioHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mRadHatches.add((GT_MetaTileEntity_RadioHatch) aMetaTileEntity); + } else { + return false; + } + } + } + + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + int blockcounter = 0; + + for (int x = -2; x <= 2; x++) + for (int z = -2; z <= 2; z++) + for (int y = 0; y < 4; y++) { + IGregTechTileEntity tileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z); + if (y == 0 || y == 3) { + //controller + if (y == 0 && xDir + x == 0 && zDir + z == 0) + continue; + if (!(this.addOutputToMachineList(tileEntity, MCASING_INDEX) || this.addRadiationInputToMachineList(tileEntity, MCASING_INDEX) || this.addInputToMachineList(tileEntity, MCASING_INDEX) || this.addMaintenanceToMachineList(tileEntity, MCASING_INDEX) || this.addEnergyInputToMachineList(tileEntity, MCASING_INDEX))) { + if (BW_Util.addBlockToMachine(x, y, z, 2, aBaseMetaTileEntity, GregTech_API.sBlockCasings4, 1)) { + ++blockcounter; + continue; + } + return false; + } + } else { + if (Math.abs(x) < 2 && Math.abs(z) != 2) { + if (!(BW_Util.addBlockToMachine(x, y, z, 2, aBaseMetaTileEntity, Blocks.air) || (BW_Util.addBlockToMachine(x, y, z, 2, aBaseMetaTileEntity, FluidLoader.bioFluidBlock)))) { + return false; + } + } else { + if (x == -2 && z == -2 && y == 1) + mGlassTier = calculateGlassTier(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z), aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)); + if (0 == mGlassTier || mGlassTier != calculateGlassTier(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z), aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z))) { + return false; + } + } + } + } + +// this.mWrench = true; +// this.mScrewdriver = true; +// this.mSoftHammer = true; +// this.mHardHammer = true; +// this.mSolderingTool = true; +// this.mCrowbar = true; + + if (blockcounter > 18) + if (this.mRadHatches.size() < 2) + if (this.mOutputHatches.size() == 1) + if (this.mMaintenanceHatches.size() == 1) + if (this.mInputHatches.size() > 0) + if (this.mEnergyHatches.size() > 0) + return true; + + return false; + } + + private byte calculateGlassTier(@Nonnull Block block, @Nonnegative Byte meta) { + + if (block.equals(BioItemList.bw_glasses[0])) + return meta > 1 ? (byte) (meta + 3) : 4; + + if (block.getUnlocalizedName().equals("blockAlloyGlass")) + return 4; + + if (block.equals(Blocks.glass)) + return 3; + + for (BioVatLogicAdder.BlockMetaPair B : BioVatLogicAdder.BioVatGlass.getGlassMap().keySet()) + if (B.getBlock().equals(block) && B.getaByte().equals(meta)) + return BioVatLogicAdder.BioVatGlass.getGlassMap().get(B); + + if (block.getMaterial().equals(Material.glass)) + return 3; + + return 0; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + private void sendAllRequiredRendererPackets() { + int height = reCalculateHeight(); + if (this.mFluid != null && height > 1 && this.reCalculateFluidAmmount() > 0) { + for (int x = -1; x < 2; x++) + for (int y = 1; y < height; y++) + for (int z = -1; z < 2; z++) + sendPackagesOrRenewRenderer(x, y, z, this.mCulture); + } + } + + private void sendPackagesOrRenewRenderer(int x, int y, int z, BioCulture lCulture) { + int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX * 2; + 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()); + + if (FMLCommonHandler.instance().getSide().isServer()) { + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity().getWorld(), + new RendererPacket( + 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(), + true + ), + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getZCoord() + ); + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity().getWorld(), + new RendererPacket( + 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(), + false + ), + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getZCoord() + ); + } + needsVisualUpdate = true; + } + + private void check_Chunk() { + World aWorld = this.getBaseMetaTileEntity().getWorld(); + if (!aWorld.isRemote) { + Iterator var5 = aWorld.playerEntities.iterator(); + + while (var5.hasNext()) { + Object tObject = var5.next(); + if (!(tObject instanceof EntityPlayerMP)) { + break; + } + EntityPlayerMP tPlayer = (EntityPlayerMP) tObject; + Chunk tChunk = aWorld.getChunkFromBlockCoords(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getZCoord()); + if (tPlayer.getServerForPlayer().getPlayerManager().isPlayerWatchingChunk(tPlayer, tChunk.xPosition, tChunk.zPosition)) { + if (!playerMPHashSet.contains(tPlayer)) { + playerMPHashSet.add(tPlayer); + sendAllRequiredRendererPackets(); + } + } else { + playerMPHashSet.remove(tPlayer); + } + + } + } + } + + private void placeFluid() { + int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ * 2; + height = reCalculateHeight(); + if (this.mFluid != null && height > 1 && this.reCalculateFluidAmmount() > 0) + for (int x = -1; x < 2; x++) { + for (int y = 0; y < height; y++) { + for (int z = -1; z < 2; z++) { + if (this.getBaseMetaTileEntity().getWorld().getBlock(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord()).equals(Blocks.air)) + this.getBaseMetaTileEntity().getWorld().setBlock(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord(), FluidLoader.bioFluidBlock); + } + } + } + } + + private int reCalculateFluidAmmount() { + int lFluidAmount = 0; + for (int i = 0; i < this.getStoredFluids().size(); i++) { + lFluidAmount += this.getStoredFluids().get(i).amount; + } + return lFluidAmount; + } + + private int reCalculateHeight() { + return (this.reCalculateFluidAmmount() > ((this.getCapacity() / 4) - 1) ? (this.reCalculateFluidAmmount() >= this.getCapacity() / 2 ? 3 : 2) : 1); + } + + public void doAllVisualThings() { + if (this.getBaseMetaTileEntity().isServerSide()) { + if (mMachine) { + ItemStack aStack = this.mInventory[1]; + BioCulture lCulture = null; + int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ * 2; + + if (this.getBaseMetaTileEntity().getTimer() % 200 == 0) { + check_Chunk(); + } + + if (needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % TIMERDIVIDER == 0) { + for (int x = -1; x < 2; x++) + for (int y = 1; y < 3; y++) + for (int z = -1; z < 2; z++) + this.getBaseMetaTileEntity().getWorld().setBlockToAir(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord()); + } + + height = reCalculateHeight(); + if (this.mFluid != null && height > 1 && this.reCalculateFluidAmmount() > 0) { + if ((!(BW_Util.areStacksEqual(aStack, mStack))) || (needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % TIMERDIVIDER == 1)) { + for (int x = -1; x < 2; x++) { + for (int y = 1; y < height; y++) { + for (int z = -1; z < 2; z++) { + if (aStack == null || (aStack != null && aStack.getItem() instanceof LabParts && aStack.getItemDamage() == 0)) { + if (mCulture == null || aStack == null || aStack.getTagCompound() == null || mCulture.getID() != aStack.getTagCompound().getInteger("ID")) { + lCulture = aStack == null || aStack.getTagCompound() == null ? null : BioCulture.getBioCulture(aStack.getTagCompound().getString("Name")); + sendPackagesOrRenewRenderer(x, y, z, lCulture); + } + } + } + } + } + mStack = aStack; + mCulture = lCulture; + } + if (needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % TIMERDIVIDER == 1) { + if (this.getBaseMetaTileEntity().isClientSide()) + new Throwable().printStackTrace(); + placeFluid(); + needsVisualUpdate = false; + } + } + } else { + onRemoval(); + } + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (height != reCalculateHeight()) + needsVisualUpdate = true; + doAllVisualThings(); + if (this.getBaseMetaTileEntity().isServerSide() && this.mRadHatches.size() == 1) + this.mSievert = this.mRadHatches.get(0).getSievert(); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("mFluidHeight", height); + if (mCulture != null && !mCulture.getName().isEmpty()) + aNBT.setString("mCulture", mCulture.getName()); + else if ((mCulture == null || mCulture.getName().isEmpty()) && !aNBT.getString("mCulture").isEmpty()) { + aNBT.removeTag("mCulture"); + } + if (this.mFluid != null) + aNBT.setString("mFluid", mFluid.getName()); + super.saveNBTData(aNBT); + } + + @Override + public void onRemoval() { + int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX * 2; + int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ * 2; + for (int x = -1; x < 2; x++) { + for (int y = 1; y < 3; y++) { + for (int z = -1; z < 2; z++) { + if (this.getBaseMetaTileEntity().getWorld().getBlock(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord()).equals(FluidLoader.bioFluidBlock)) + this.getBaseMetaTileEntity().getWorld().setBlockToAir(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord()); + staticColorMap.remove(new Coords(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord()), this.getBaseMetaTileEntity().getWorld().provider.dimensionId); + if (FMLCommonHandler.instance().getSide().isServer()) + MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( + this.getBaseMetaTileEntity().getWorld(), + new RendererPacket( + new Coords( + xDir + x + this.getBaseMetaTileEntity().getXCoord(), + y + this.getBaseMetaTileEntity().getYCoord(), + zDir + z + this.getBaseMetaTileEntity().getZCoord(), + this.getBaseMetaTileEntity().getWorld().provider.dimensionId + ), + mCulture == null ? BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB() : mCulture.getColorRGB(), + true + ), + this.getBaseMetaTileEntity().getXCoord(), + this.getBaseMetaTileEntity().getZCoord() + ); + } + } + } + super.onRemoval(); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + height = aNBT.getInteger("mFluidHeight"); + mCulture = BioCulture.getBioCulture(aNBT.getString("mCulture")); + if (!aNBT.getString("mFluid").isEmpty()) + mFluid = FluidRegistry.getFluid(aNBT.getString("mFluid")); + super.loadNBTData(aNBT); + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_TileEntity_BioVat(this.mName); + } + + @Override + public String[] getDescription() { + return new String[]{ + "Controller Block for the Bio Vat", + "LxHxD: 5x4x5", + "Bottom and top are Stainless Steel Casings", + "Bottom and top must contain:", + "1x Maintenance, 1x Output Hatch, 1 or more Input Hatches, 1 or more Input Buses, 0-1 Radiation Input Bus", + "The two middle layers must be build out of glass, hollow", + "The glass can be any glass, i.e. Tinkers Construct Clear Glass", + "Some Recipes need more advanced Glass Types", + "For maximum efficiency boost keep the Output Hatch always half filled!", + "Added by bartimaeusnek via " + ChatColorHelper.DARKGREEN + "BartWorks" + }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == aFacing ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[MCASING_INDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISTILLATION_TOWER)} : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[MCASING_INDEX]}; + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_DEHP.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_DEHP.java index 1b2a2934fb..7e6f55a02b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_DEHP.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_DEHP.java @@ -1,3 +1,25 @@ +/* + * 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.common.tileentities; import gregtech.api.enums.ItemList; @@ -62,6 +84,5 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { protected void setElectricityStats() { - } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_LESU.java index 501849bfcb..cd88cfa5ec 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_LESU.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_LESU.java @@ -1,8 +1,30 @@ +/* + * 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.common.tileentities; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.client.gui.GT_GUIContainer_LESU; -import com.github.bartimaeusnek.bartworks.common.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_LESU; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; @@ -32,24 +54,23 @@ import net.minecraft.world.World; public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { - private static IIcon[] iIcons = new IIcon[4]; - private static IIconContainer[] iIconContainers = new IIconContainer[4]; - private static ITexture[][] iTextures = new ITexture[4][1]; private static final byte TEXID_SIDE = 0; private static final byte TEXID_CHARGING = 1; private static final byte TEXID_IDLE = 2; private static final byte TEXID_EMPTY = 3; - - private long mStorage; + private static IIcon[] iIcons = new IIcon[4]; + private static IIconContainer[] iIconContainers = new IIconContainer[4]; + private static ITexture[][] iTextures = new ITexture[4][1]; public ConnectedBlocksChecker connectedcells; public ItemStack[] circuits = new ItemStack[5]; + private long mStorage; public GT_TileEntity_LESU(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); this.mStorage = ConfigHandler.energyPerCell; } - public GT_TileEntity_LESU(String aName){ + public GT_TileEntity_LESU(String aName) { super(aName); } @@ -66,13 +87,13 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public long maxEUStore() { - return (this.mStorage >= Long.MAX_VALUE-1 || this.mStorage < 0) ? Long.MAX_VALUE-1 : this.mStorage; + return (this.mStorage >= Long.MAX_VALUE - 1 || this.mStorage < 0) ? Long.MAX_VALUE - 1 : this.mStorage; } @Override public long maxAmperesIn() { int ret = 0; - for (int i = 0 ; i < 5; ++i) + for (int i = 0; i < 5; ++i) if (this.circuits[i] != null && this.circuits[i].getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem())) ret += this.circuits[i].getItemDamage(); return ret > 0 ? ret : 1; @@ -87,8 +108,8 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { public long maxEUInput() { for (int i = 1; i < GT_Values.V.length; i++) { - if (maxEUOutput() <= GT_Values.V[i] && maxEUOutput() > GT_Values.V[i-1]) - return Math.min(GT_Values.V[i],32768L); + if (maxEUOutput() <= GT_Values.V[i] && maxEUOutput() > GT_Values.V[i - 1]) + return Math.min(GT_Values.V[i], 32768L); } return 8; @@ -134,13 +155,13 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { return new String[]{ "Controller Block for the GT2-Styled L.E.S.U.", "Size: ANY", - "Storage per LESU Casing: " + ConfigHandler.energyPerCell+"EU", - "Output EU: LESU Casings amount"+ - "Input EU: Next Voltage Tier to Output EU", + "Storage per LESU Casing: " + ConfigHandler.energyPerCell + "EU", + "Output EU: LESU Casings amount" + + "Input EU: Next Voltage Tier to Output EU", "Input/Output Amps can be configured via 4 Circuits in GUI", "Output Side has a dot on it.", - ChatColorHelper.RED+"Only one Controller allowed, no Wallsharing!", - "Added by bartimaeusnek via "+ChatColorHelper.DARKGREEN+"BartWorks" + ChatColorHelper.RED + "Only one Controller allowed, no Wallsharing!", + "Added by bartimaeusnek via " + ChatColorHelper.DARKGREEN + "BartWorks" }; } @@ -148,9 +169,9 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { public void registerIcons(IIconRegister aBlockIconRegister) { for (int i = 0; i < iTextures.length; i++) { - iIcons[i]=aBlockIconRegister.registerIcon(MainMod.modID+":LESU_CASING_"+i); + iIcons[i] = aBlockIconRegister.registerIcon(MainMod.modID + ":LESU_CASING_" + i); final int finalI = i; - iIconContainers[i]=new IIconContainer() { + iIconContainers[i] = new IIconContainer() { @Override public IIcon getIcon() { return iIcons[finalI]; @@ -163,7 +184,7 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public ResourceLocation getTextureFile() { - return new ResourceLocation(MainMod.modID+":LESU_CASING_"+ finalI); + return new ResourceLocation(MainMod.modID + ":LESU_CASING_" + finalI); } }; } @@ -196,7 +217,7 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { ITexture[] ret = new ITexture[0]; - if(this.isClientSide()) { + if (this.isClientSide()) { for (int i = 0; i < iTextures.length; i++) { iTextures[i][0] = new GT_RenderedTexture(iIconContainers[i], Dyes.getModulation(0, Dyes.MACHINE_METAL.mRGBa)); @@ -233,16 +254,16 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public ItemStack getStackInSlot(int p_70301_1_) { if (p_70301_1_ > 1) - return this.circuits[(p_70301_1_-2)]; + return this.circuits[(p_70301_1_ - 2)]; return this.mInventory[p_70301_1_]; } @Override public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { if (p_70299_1_ < 2) - this.mInventory[p_70299_1_]=p_70299_2_; + this.mInventory[p_70299_1_] = p_70299_2_; else - this.circuits[(p_70299_1_-2)]=p_70299_2_; + this.circuits[(p_70299_1_ - 2)] = p_70299_2_; } @Override @@ -268,8 +289,9 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - switch (p_94041_1_){ - case 0: case 1: + switch (p_94041_1_) { + case 0: + case 1: return true; default: return p_94041_2_.getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem()); @@ -323,22 +345,22 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { } @Override - public boolean onRunningTick(ItemStack aStack){ - this.mMaxProgresstime=1; + public boolean onRunningTick(ItemStack aStack) { + this.mMaxProgresstime = 1; return true; } @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setIntArray("customCircuitInv",GT_Utility.stacksToIntArray(this.circuits)); + aNBT.setIntArray("customCircuitInv", GT_Utility.stacksToIntArray(this.circuits)); super.saveNBTData(aNBT); } @Override public void loadNBTData(NBTTagCompound aNBT) { int[] stacks = aNBT.getIntArray("customCircuitInv"); - for (int i = 0; i < stacks.length ; i++) { - this.circuits[i]=GT_Utility.intToStack(stacks[i]); + for (int i = 0; i < stacks.length; i++) { + this.circuits[i] = GT_Utility.intToStack(stacks[i]); } super.loadNBTData(aNBT); } @@ -346,29 +368,28 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { connectedcells = new ConnectedBlocksChecker(); - connectedcells.get_connected(aBaseMetaTileEntity.getWorld(),aBaseMetaTileEntity.getXCoord(),aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord(), ItemRegistry.BW_BLOCKS[1]); + connectedcells.get_connected(aBaseMetaTileEntity.getWorld(), aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), ItemRegistry.BW_BLOCKS[1]); - if (connectedcells.get_meta_of_sideblocks(aBaseMetaTileEntity.getWorld(),this.getBaseMetaTileEntity().getMetaTileID(),new int[]{aBaseMetaTileEntity.getXCoord(),aBaseMetaTileEntity.getYCoord(),aBaseMetaTileEntity.getZCoord()},true)) - { + if (connectedcells.get_meta_of_sideblocks(aBaseMetaTileEntity.getWorld(), this.getBaseMetaTileEntity().getMetaTileID(), new int[]{aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord()}, true)) { this.getBaseMetaTileEntity().disableWorking(); this.getBaseMetaTileEntity().setActive(false); - this.mStorage=0; - this.mMaxProgresstime=0; - this.mProgresstime=0; + this.mStorage = 0; + this.mMaxProgresstime = 0; + this.mProgresstime = 0; return false; } - this.mEfficiency=this.getMaxEfficiency(null); - this.mStorage=(ConfigHandler.energyPerCell * connectedcells.hashset.size() >= Long.MAX_VALUE-1 || ConfigHandler.energyPerCell * connectedcells.hashset.size() < 0) ? Long.MAX_VALUE-1 : ConfigHandler.energyPerCell * connectedcells.hashset.size() ; - this.mMaxProgresstime=1; - this.mProgresstime=0; - - this.mCrowbar=true; - this.mHardHammer=true; - this.mScrewdriver=true; - this.mSoftHammer=true; - this.mSolderingTool=true; - this.mWrench=true; + this.mEfficiency = this.getMaxEfficiency(null); + this.mStorage = (ConfigHandler.energyPerCell * connectedcells.hashset.size() >= Long.MAX_VALUE - 1 || ConfigHandler.energyPerCell * connectedcells.hashset.size() < 0) ? Long.MAX_VALUE - 1 : ConfigHandler.energyPerCell * connectedcells.hashset.size(); + this.mMaxProgresstime = 1; + this.mProgresstime = 0; + + this.mCrowbar = true; + this.mHardHammer = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mSolderingTool = true; + this.mWrench = true; this.getBaseMetaTileEntity().enableWorking(); this.getBaseMetaTileEntity().setActive(true); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_ManualTrafo.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_ManualTrafo.java index 369a69ba38..93fd85b502 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_ManualTrafo.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_ManualTrafo.java @@ -1,3 +1,25 @@ +/* + * 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.common.tileentities; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; @@ -17,17 +39,18 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase { +import static gregtech.api.enums.GT_Values.V; - private byte mode = 0; - private byte texid = 2; - private long mCoilWicks = 0; - private boolean upstep = true; +public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase { private static final byte SINGLE_UPSTEP = 0; private static final byte SINGLE_DOWNSTEP = 1; private static final byte MULTI_UPSTEP = 2; private static final byte MULTI_DOWNSTEP = 3; + private byte mode = 0; + private byte texid = 2; + private long mCoilWicks = 0; + private boolean upstep = true; public GT_TileEntity_ManualTrafo(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -46,40 +69,64 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (!this.getBaseMetaTileEntity().isAllowedToWork()) this.stopMachine(); - super.onPostTick(aBaseMetaTileEntity,aTick); + super.onPostTick(aBaseMetaTileEntity, aTick); } @Override - public boolean onRunningTick(ItemStack aStack){ - if (this.mode > SINGLE_DOWNSTEP){ - return false; - } - + public boolean onRunningTick(ItemStack aStack) { if (!this.getBaseMetaTileEntity().isAllowedToWork()) { this.stopMachine(); return false; } - this.mProgresstime=0; - this.mMaxProgresstime=1; + + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + if (this.getBaseMetaTileEntity().getTimer() % 40 == 0) if (this.mEfficiency < this.getMaxEfficiency(null)) this.mEfficiency += 100; else this.mEfficiency = this.getMaxEfficiency(null); - boolean ret = this.drainEnergyInput(this.getInputTier() * 2 * this.mEnergyHatches.size()) && this.addEnergyOutput(this.getInputTier() * 2 * this.mEnergyHatches.size() * (long)this.mEfficiency / this.getMaxEfficiency(null)); + if (this.mode > SINGLE_DOWNSTEP) { + return this.onRunningTickTabbedMode(); + } + + boolean ret = this.drainEnergyInput(this.getInputTier() * 2 * this.mEnergyHatches.size()) && this.addEnergyOutput(this.getInputTier() * 2 * this.mEnergyHatches.size() * (long) this.mEfficiency / this.getMaxEfficiency(null)); return ret; } + public boolean onRunningTickTabbedMode() { + + for (GT_MetaTileEntity_Hatch_Dynamo E : mDynamoHatches) { + for (GT_MetaTileEntity_Hatch_Energy I : mEnergyHatches) { + + long vtt = I.getEUVar() >= (V[E.mTier] / 2) && E.getEUVar() < E.maxEUStore() ? I.getEUVar() : 0; + + if (vtt == 0) + continue; + + long vtp = E.getEUVar() + (vtt); + long avt = vtp < E.maxEUStore() ? vtp : E.maxEUStore(); + E.setEUVar(avt); + I.setEUVar(I.getEUVar() - vtt); + } + + } + + return true; + } + + public long getInputTier() { - if (this.mEnergyHatches.size()>0) + if (this.mEnergyHatches.size() > 0) return (long) GT_Utility.getTier(this.mEnergyHatches.get(0).getBaseMetaTileEntity().getInputVoltage()); else return 0; } public long getOutputTier() { - if (this.mDynamoHatches.size()>0) + if (this.mDynamoHatches.size() > 0) return (long) GT_Utility.getTier(this.mDynamoHatches.get(0).getBaseMetaTileEntity().getOutputVoltage()); else return 0; } @@ -92,10 +139,10 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase return false; } this.mode = this.mInventory[1] == null ? 0 : this.mInventory[1].getUnlocalizedName().startsWith("gt.integrated_circuit") ? this.mInventory[1].getItemDamage() > 4 ? (byte) this.mInventory[1].getItemDamage() : 0 : 0; - this.upstep= (this.mode == 0 || this.mode == 2); - this.mProgresstime=0; - this.mMaxProgresstime=1; - this.mEfficiency= this.mEfficiency > 100 ? this.mEfficiency : 100; + this.upstep = (this.mode == 0 || this.mode == 2); + this.mProgresstime = 0; + this.mMaxProgresstime = 1; + this.mEfficiency = this.mEfficiency > 100 ? this.mEfficiency : 100; return this.upstep ? this.getOutputTier() - this.getInputTier() == mCoilWicks : this.getInputTier() - this.getOutputTier() == mCoilWicks; } @@ -104,7 +151,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase this.mode = this.mInventory[1] == null ? 0 : this.mInventory[1].getUnlocalizedName().startsWith("gt.integrated_circuit") ? this.mInventory[1].getItemDamage() > 4 ? (byte) this.mInventory[1].getItemDamage() : 0 : 0; - if(this.mode <= 1){ + if (this.mode <= 1) { int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; @@ -131,7 +178,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase break; } } - System.out.println(mCoilWicks); + if (mCoilWicks % 8 != 0) return false; @@ -177,132 +224,132 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase } } - // check dynamos and energy hatches for the same tier - byte outtier = this.mDynamoHatches.get(0).mTier; - for (GT_MetaTileEntity_Hatch_Dynamo out : this.mDynamoHatches) { - if (out.mTier != outtier) - return false; - } + // check dynamos and energy hatches for the same tier + byte outtier = this.mDynamoHatches.get(0).mTier; + for (GT_MetaTileEntity_Hatch_Dynamo out : this.mDynamoHatches) { + if (out.mTier != outtier) + return false; + } - byte intier = this.mEnergyHatches.get(0).mTier; - for (GT_MetaTileEntity_Hatch_Energy in : this.mEnergyHatches) { - if (in.mTier != intier) - return false; - } - } else { + byte intier = this.mEnergyHatches.get(0).mTier; + for (GT_MetaTileEntity_Hatch_Energy in : this.mEnergyHatches) { + if (in.mTier != intier) + return false; + } + } else { - int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; - int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY * 2; - int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; - //check height - int y = 1; - boolean stillcoil = true; - while (stillcoil) { - for (int x = -1; x <= 1; ++x) { - for (int z = -1; z <= 1; ++z) { - if (x != 0 || z != 0) { - stillcoil = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(ItemRegistry.BW_BLOCKS[2]) && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 1; - if (stillcoil) { - ++this.mCoilWicks; - if (mCoilWicks % 8 == 0) { - ++y; - continue; - } - } else - break; - } + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * 2; + int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY * 2; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * 2; + //check height + int y = 1; + boolean stillcoil = true; + while (stillcoil) { + for (int x = -1; x <= 1; ++x) { + for (int z = -1; z <= 1; ++z) { + if (x != 0 || z != 0) { + stillcoil = aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(ItemRegistry.BW_BLOCKS[2]) && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 1; + if (stillcoil) { + ++this.mCoilWicks; + if (mCoilWicks % 8 == 0) { + ++y; + continue; + } + } else + break; } - if (!stillcoil) - break; } + if (!stillcoil) + break; } + } - if (mCoilWicks % 8 != 0) - return false; + if (mCoilWicks % 8 != 0) + return false; - this.mCoilWicks = this.mCoilWicks / 8; + this.mCoilWicks = this.mCoilWicks / 8; - //check interior (NiFeZn02 Core) - for (int i = 1; i <= this.mCoilWicks; ++i) { - if (!aBaseMetaTileEntity.getBlockOffset(xDir, i, zDir).equals(ItemRegistry.BW_BLOCKS[2]) && aBaseMetaTileEntity.getMetaIDOffset(xDir, i, zDir) == 0) { - return false; - } + //check interior (NiFeZn02 Core) + for (int i = 1; i <= this.mCoilWicks; ++i) { + if (!aBaseMetaTileEntity.getBlockOffset(xDir, i, zDir).equals(ItemRegistry.BW_BLOCKS[2]) && aBaseMetaTileEntity.getMetaIDOffset(xDir, i, zDir) == 0) { + return false; } + } - //check Bottom - for (int x = -2; x <= 2; ++x) - for (int z = -2; z <= 2; ++z) - if (xDir + x != 0 || zDir + z != 0) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, 0, zDir + z); - if (!this.addMaintenanceToMachineList(tTileEntity, texid) && !this.addEnergyInputToMachineList(tTileEntity, texid)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + x, 0, zDir + z) != GregTech_API.sBlockCasings1) { - return false; - } + //check Bottom + for (int x = -2; x <= 2; ++x) + for (int z = -2; z <= 2; ++z) + if (xDir + x != 0 || zDir + z != 0) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, 0, zDir + z); + if (!this.addMaintenanceToMachineList(tTileEntity, texid) && !this.addEnergyInputToMachineList(tTileEntity, texid)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + x, 0, zDir + z) != GregTech_API.sBlockCasings1) { + return false; + } /* if (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, 0, zDir + z) != 11) { return false; } */ - } } + } - //check Top - for (int x = -2; x <= 2; ++x) - for (int z = -2; z <= 2; ++z) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, (int) this.mCoilWicks + 1, zDir + z); - if (!this.addMaintenanceToMachineList(tTileEntity, texid) && !this.addDynamoToMachineList(tTileEntity, texid)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + x, (int) this.mCoilWicks + 1, zDir + z) != GregTech_API.sBlockCasings1) { - return false; - } + //check Top + for (int x = -2; x <= 2; ++x) + for (int z = -2; z <= 2; ++z) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, (int) this.mCoilWicks + 1, zDir + z); + if (!this.addMaintenanceToMachineList(tTileEntity, texid) && !this.addDynamoToMachineList(tTileEntity, texid)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + x, (int) this.mCoilWicks + 1, zDir + z) != GregTech_API.sBlockCasings1) { + return false; + } /* if (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, 0, zDir + z) != 11) { return false; } */ - } } + } + + if (this.mDynamoHatches.size() <= 0 || this.mEnergyHatches.size() <= 0) + return false; - if (this.mDynamoHatches.size() <= 0 || this.mEnergyHatches.size() <= 0) + byte outtier = this.mDynamoHatches.get(0).mTier; + for (GT_MetaTileEntity_Hatch_Dynamo out : this.mDynamoHatches) { + if (out.mTier != outtier) return false; + } - byte outtier = this.mDynamoHatches.get(0).mTier; - for (GT_MetaTileEntity_Hatch_Dynamo out : this.mDynamoHatches) { - if (out.mTier != outtier) - return false; - } + byte intier = this.mEnergyHatches.get(0).mTier; + for (GT_MetaTileEntity_Hatch_Energy in : this.mEnergyHatches) { + if (in.mTier != intier) + return false; + } - byte intier = this.mEnergyHatches.get(0).mTier; - for (GT_MetaTileEntity_Hatch_Energy in : this.mEnergyHatches) { - if (in.mTier != intier) - return false; - } + //check tap hull + for (int ty = 1; ty <= y; ++ty) { + + byte leveltier = 0; + if (this.mInventory[1].getItemDamage() == 2) + leveltier = ((byte) (intier - ty)); + else if (this.mInventory[1].getItemDamage() == 3) + leveltier = ((byte) (intier + ty)); + else + return false; - //check tap hull - for (int ty = 1; ty <= y; ++ty) { - - byte leveltier = 0; - if (this.mInventory[1].getItemDamage() == 2) - leveltier = ((byte) (intier - ty)); - else if (this.mInventory[1].getItemDamage() == 3) - leveltier = ((byte) (intier + ty)); - else - return false; - - for (int x = -2; x <= 2; ++x) - for (int z = -2; z <= 2; ++z) - if (x == -2 || z == -2 || x == 2 || z == 2) { - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, ty, zDir + z); - if (!this.addMaintenanceToMachineList(tTileEntity, texid) && !this.addEnergyInputToMachineList(tTileEntity, texid, leveltier) && !this.addDynamoToMachineList(tTileEntity, texid, leveltier)) { - if (aBaseMetaTileEntity.getBlockOffset(xDir + x, ty, zDir + z) != GregTech_API.sBlockCasings1) { - return false; - } + for (int x = -2; x <= 2; ++x) + for (int z = -2; z <= 2; ++z) + if (x == -2 || z == -2 || x == 2 || z == 2) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, ty, zDir + z); + if (!this.addMaintenanceToMachineList(tTileEntity, texid) && !this.addEnergyInputToMachineList(tTileEntity, texid, leveltier) && !this.addDynamoToMachineList(tTileEntity, texid, leveltier)) { + if (aBaseMetaTileEntity.getBlockOffset(xDir + x, ty, zDir + z) != GregTech_API.sBlockCasings1) { + return false; } } - } + } } - if (this.mDynamoHatches.size() <= 0 || this.mEnergyHatches.size() <= 0) - return false; + } + if (this.mDynamoHatches.size() <= 0 || this.mEnergyHatches.size() <= 0) + return false; return true; } @@ -348,19 +395,19 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase "Middle of Dynamo Coils needs to be a NickelFerrite Core", "Top Contains at least 1 Dynamo Hatch", "Maintenance Hatch can be placed anywhere", - "Added by bartimaeusnek via "+ ChatColorHelper.DARKGREEN+"BartWorks" + "Added by bartimaeusnek via " + ChatColorHelper.DARKGREEN + "BartWorks" //"Tapped Mode is disabled." }; } @Override - public void saveNBTData(NBTTagCompound ntag){ - ntag.setLong("mCoilWicks",mCoilWicks); + public void saveNBTData(NBTTagCompound ntag) { + ntag.setLong("mCoilWicks", mCoilWicks); super.saveNBTData(ntag); } @Override - public void loadNBTData(NBTTagCompound ntag){ + public void loadNBTData(NBTTagCompound ntag) { super.loadNBTData(ntag); mCoilWicks = ntag.getLong("mCoilWicks"); } @@ -378,7 +425,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase if (aMetaTileEntity == null) { return false; } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { - if (tier == ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mTier) { + if (tier == ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTier) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return this.mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); } @@ -397,9 +444,9 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase if (aMetaTileEntity == null) { return false; } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { - if (tier == ((GT_MetaTileEntity_Hatch)aMetaTileEntity).mTier) { - ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); - return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo)aMetaTileEntity); + if (tier == ((GT_MetaTileEntity_Hatch) aMetaTileEntity).mTier) { + ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); } return false; } else { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_Windmill.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_Windmill.java index bea3a91279..79751aad87 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_Windmill.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/GT_TileEntity_Windmill.java @@ -1,3 +1,25 @@ +/* + * 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.common.tileentities; import com.github.bartimaeusnek.bartworks.MainMod; @@ -69,7 +91,7 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { return true; } - public boolean recipe_fallback(ItemStack aStack){ + public boolean recipe_fallback(ItemStack aStack) { //sight... fallback to the macerator recipes GT_Recipe.GT_Recipe_Map tMap = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; if (tMap == null) @@ -80,14 +102,15 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { if (tRecipe.getOutput(0) != null) { aStack.stackSize--; mOutputItems[0] = tRecipe.getOutput(0); - if (new XSTR().nextInt(2) == 0){ + + if (new XSTR().nextInt(2) == 0) { if (tRecipe.getOutput(1) != null) mOutputItems[1] = tRecipe.getOutput(1); - else + else if (GT_OreDictUnificator.getAssociation(aStack) == null || GT_OreDictUnificator.getAssociation(aStack).mMaterial == null || GT_OreDictUnificator.getAssociation(aStack).mMaterial.mMaterial == null) mOutputItems[1] = tRecipe.getOutput(0); } } - this.mMaxProgresstime = (tRecipe.mDuration * 2 *100); + this.mMaxProgresstime = (tRecipe.mDuration * 2 * 100); return true; } @@ -235,6 +258,11 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { this.mMaxProgresstime = 60 * 20 * 100; this.mOutputItems[0] = (GT_OreDictUnificator.get(OrePrefixes.crushed, GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial, 1L)); return true; + } else if (OrePrefixes.nugget.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)) { + itemStack.stackSize -= 1; + this.mMaxProgresstime = 15 * 20 * 100; + this.mOutputItems[0] = (GT_OreDictUnificator.get(OrePrefixes.dustTiny, GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial, 1L)); + return true; } else if (OrePrefixes.crushed.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)) { itemStack.stackSize -= 1; this.mMaxProgresstime = 30 * 20 * 100; @@ -256,7 +284,7 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { this.mOutputItems[0] = (GT_OreDictUnificator.get(OrePrefixes.dust, GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial, (GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.mSubTags.contains(SubTag.METAL) || GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTAL)) ? 9L : 1L)); return true; } else if ( - OrePrefixes.stone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) || + OrePrefixes.stone.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) || OrePrefixes.stoneBricks.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) || OrePrefixes.stoneChiseled.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) || OrePrefixes.stoneCobble.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) || @@ -279,7 +307,7 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new BW_GUIContainer_Windmill(aPlayerInventory, aBaseMetaTileEntity,this.getLocalName()); + return new BW_GUIContainer_Windmill(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName()); } public boolean addDispenserToOutputSet(TileEntity aTileEntity) { @@ -512,10 +540,10 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { "A primitive Grinder powered by Kinetic energy.", "WxHxL: 7x12x7", "Layer 1: 7x7 Bricks, corners are air, controller at front centered.", - "Layer 2-4: 5x5 Hardened Clay, corners are air, can contain one door,", + "Layer 2-5: 5x5 Hardened Clay, corners are air, can contain one door,", "hollow, must contain at least one Dispenser", - "Layer 5: 5x5 Wood Planks. Corners are filled, hollow.", - "Layer 6: 7x7 Wood Planks. Corners are air, hollow.", + "Layer 6: 5x5 Wood Planks. Corners are filled, hollow.", + "Layer 7: 7x7 Wood Planks. Corners are air, hollow.", "Layer 8: 7x7 Wood Planks. Corners are air, hollow,", "front centered must be a Primitive Kinetic Shaftbox", "Layer 9: 7x7 Wood Planks. Corners are air, hollow.", @@ -525,7 +553,7 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { "Needs a Wind Mill Rotor in the Shaftbox to operate", "Input items in Controller", "Output items will appear in the dispensers", - "Added by bartimaeusnek via "+ ChatColorHelper.DARKGREEN+"BartWorks" + "Added by bartimaeusnek via " + ChatColorHelper.DARKGREEN + "BartWorks" }; } @@ -536,26 +564,26 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister aBlockIconRegister) { - iIcons[0]=aBlockIconRegister.registerIcon("brick"); - iIconContainers[0]=new IIconContainer() { - @Override - public IIcon getIcon() { - return iIcons[0]; - } + iIcons[0] = aBlockIconRegister.registerIcon("brick"); + iIconContainers[0] = new IIconContainer() { + @Override + public IIcon getIcon() { + return iIcons[0]; + } - @Override - public IIcon getOverlayIcon() { - return iIcons[0]; - } + @Override + public IIcon getOverlayIcon() { + return iIcons[0]; + } - @Override - public ResourceLocation getTextureFile() { - return new ResourceLocation("brick"); - } - }; + @Override + public ResourceLocation getTextureFile() { + return new ResourceLocation("brick"); + } + }; - iIcons[1]=aBlockIconRegister.registerIcon(MainMod.modID+":windmill_top"); - iIconContainers[1]=new IIconContainer() { + iIcons[1] = aBlockIconRegister.registerIcon(MainMod.modID + ":windmill_top"); + iIconContainers[1] = new IIconContainer() { @Override public IIcon getIcon() { return iIcons[1]; @@ -568,7 +596,7 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { @Override public ResourceLocation getTextureFile() { - return new ResourceLocation(MainMod.modID+":windmill_top"); + return new ResourceLocation(MainMod.modID + ":windmill_top"); } }; } @@ -582,10 +610,10 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { iTextures[0] = new GT_RenderedTexture(iIconContainers[0], Dyes.getModulation(0, Dyes.MACHINE_METAL.mRGBa)); ret = new ITexture[6]; - for (int i = 0; i < 6; i++) { - ret[i] = iTextures[0]; + for (int i = 0; i < 6; i++) { + ret[i] = iTextures[0]; } - if (aSide == 1){ + if (aSide == 1) { iTextures[1] = new GT_RenderedTexture(iIconContainers[1], Dyes.getModulation(0, Dyes.MACHINE_METAL.mRGBa)); ret = new ITexture[6]; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_RadioHatch.java new file mode 100644 index 0000000000..135666a134 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_RadioHatch.java @@ -0,0 +1,216 @@ +/* + * 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.server.container; + +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_MetaTileEntity_RadioHatch; +import gregtech.api.gui.GT_Slot_Holo; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.ICrafting; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import java.util.Iterator; + +public class BW_Container_RadioHatch extends Container { + + public byte coverage, dcoverage; + long timer; + private GT_MetaTileEntity_RadioHatch iGregTechTileEntity; + + public BW_Container_RadioHatch(InventoryPlayer inventory, IMetaTileEntity iGregTechTileEntity) { + this.iGregTechTileEntity = (GT_MetaTileEntity_RadioHatch) iGregTechTileEntity; + + IInventory inv = new IInventory() { + @Override + public int getSizeInventory() { + return 0; + } + + @Override + public ItemStack getStackInSlot(int p_70301_1_) { + return null; + } + + @Override + public ItemStack decrStackSize(int p_70298_1_, int p_70298_2_) { + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int p_70304_1_) { + return null; + } + + @Override + public void setInventorySlotContents(int p_70299_1_, ItemStack p_70299_2_) { + + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 0; + } + + @Override + public void markDirty() { + + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return false; + } + + @Override + public void openInventory() { + + } + + @Override + public void closeInventory() { + + } + + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + return false; + } + }; + + for (int i = 0; i < 12; i++) { + addSlotToContainer(new GT_Slot_Holo(inv, i, -64 + i * 18, 22, false, false, 1)); + } + + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + for (int i = 0; i < 9; i++) { + addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); + } + } + + @Override + public void detectAndSendChanges() { + if (!this.iGregTechTileEntity.getBaseMetaTileEntity().isClientSide() && this.iGregTechTileEntity.getBaseMetaTileEntity().getMetaTileEntity() != null) { + coverage = iGregTechTileEntity.getCoverage(); + ++timer; + Iterator var2 = this.crafters.iterator(); + if (timer >= Long.MAX_VALUE - 1) + timer = 0; + while (true) { + do { + if (!var2.hasNext()) { + dcoverage = coverage; + return; + } + ICrafting var1 = (ICrafting) var2.next(); + if (this.timer % 500 == 10 || this.dcoverage != coverage) + var1.sendProgressBarUpdate(this, 0, coverage); + } while (this.timer % 500 != 10 && this.dcoverage != coverage); + } + } + } + + @Override + public void updateProgressBar(int p_75137_1_, int p_75137_2_) { + if (p_75137_1_ == 0) + coverage = (byte) p_75137_2_; + } + + @Override + public ItemStack slotClick(int slot, int button, int aShifthold, EntityPlayer entityPlayer) { + if (slot >= 0 && slot < 12) { + byte setto; + switch (slot) { + case 0: + setto = -100; + break; + case 1: + setto = -75; + break; + case 2: + setto = -50; + break; + case 3: + setto = -25; + break; + case 4: + setto = -10; + break; + case 5: + setto = -1; + break; + case 6: + setto = 1; + break; + case 7: + setto = 10; + break; + case 8: + setto = 25; + break; + case 9: + setto = 50; + break; + case 10: + setto = 75; + break; + case 11: + setto = 100; + break; + default: + setto = 0; + } + this.iGregTechTileEntity.setCoverage((short) (this.iGregTechTileEntity.getCoverage() + setto)); + detectAndSendChanges(); + return null; + } + return super.slotClick(slot, button, aShifthold, entityPlayer); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int SlotNR) { + return null; + } + + @Override + public boolean canInteractWith(EntityPlayer p_75145_1_) { + return true; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_CircuitProgrammer.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_CircuitProgrammer.java index aa2f248fec..cd56a04a6b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_CircuitProgrammer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_CircuitProgrammer.java @@ -1,3 +1,25 @@ +/* + * 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.server.container; import gregtech.api.gui.GT_Slot_Holo; @@ -12,17 +34,17 @@ import net.minecraft.nbt.NBTTagCompound; public class GT_Container_CircuitProgrammer extends Container { - public GT_Container_CircuitProgrammer(InventoryPlayer inventory){ + public GT_Container_CircuitProgrammer(InventoryPlayer inventory) { IInventory inv = new pinv(inventory.player); - addSlotToContainer(new Slot(inv,0,44,61));//-45, 84)); + addSlotToContainer(new Slot(inv, 0, 44, 61));//-45, 84)); for (int i = 1; i < 13; i++) { - addSlotToContainer(new GT_Slot_Holo(inv, i, -64+i*18, 22, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(inv, i, -64 + i * 18, 22, false, false, 1)); } for (int i = 0; i < 12; i++) { - addSlotToContainer(new GT_Slot_Holo(inv, i+12, -46+i*18, 40, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(inv, i + 12, -46 + i * 18, 40, false, false, 1)); } for (int i = 0; i < 3; i++) { @@ -37,13 +59,13 @@ public class GT_Container_CircuitProgrammer extends Container { } @Override - public ItemStack slotClick(int slot, int button, int aShifthold, EntityPlayer entityPlayer){ - if (slot > 0 && slot < 25 && ((Slot)this.inventorySlots.get(0)).getStack() != null){ - ((Slot)this.inventorySlots.get(0)).getStack().setItemDamage(slot); - detectAndSendChanges(); - return ( (Slot) this.inventorySlots.get(0)).getStack(); - } - return super.slotClick(slot, button, aShifthold, entityPlayer);//( (Slot) this.inventorySlots.get(slot)).getStack(); + public ItemStack slotClick(int slot, int button, int aShifthold, EntityPlayer entityPlayer) { + if (slot > 0 && slot < 25 && ((Slot) this.inventorySlots.get(0)).getStack() != null) { + ((Slot) this.inventorySlots.get(0)).getStack().setItemDamage(slot); + detectAndSendChanges(); + return ((Slot) this.inventorySlots.get(0)).getStack(); + } + return super.slotClick(slot, button, aShifthold, entityPlayer);//( (Slot) this.inventorySlots.get(slot)).getStack(); } @Override @@ -52,21 +74,20 @@ public class GT_Container_CircuitProgrammer extends Container { } @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int SlotNR) - { - Slot chipslot = (Slot)this.inventorySlots.get(0); + public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int SlotNR) { + Slot chipslot = (Slot) this.inventorySlots.get(0); if (SlotNR > 24) { Slot slot = (Slot) this.inventorySlots.get(SlotNR); - if (slot != null && slot.getStack().getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem())){ - if ( chipslot.getStack()== null ){ + if (slot != null && slot.getStack().getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem())) { + if (chipslot.getStack() == null) { chipslot.putStack(slot.getStack()); slot.decrStackSize(1); } } - }else if (SlotNR == 0 && chipslot.getStack() != null){ + } else if (SlotNR == 0 && chipslot.getStack() != null) { for (int i = 25; i < this.inventorySlots.size(); i++) { - if (((Slot)this.inventorySlots.get(i)).getStack() == null){ - Slot empty = ( (Slot) this.inventorySlots.get(i)); + if (((Slot) this.inventorySlots.get(i)).getStack() == null) { + Slot empty = ((Slot) this.inventorySlots.get(i)); empty.putStack(chipslot.getStack()); chipslot.decrStackSize(1); break; @@ -78,19 +99,19 @@ public class GT_Container_CircuitProgrammer extends Container { class pinv implements IInventory { - public pinv(EntityPlayer Player){ + ItemStack toBind; + EntityPlayer Player; + ItemStack Slot; + + public pinv(EntityPlayer Player) { super(); - this.Player=Player; - this.toBind=Player.inventory.getCurrentItem(); + this.Player = Player; + this.toBind = Player.inventory.getCurrentItem(); NBTTagCompound tag = this.toBind.getTagCompound(); if (tag.getBoolean("HasChip")) Slot = GT_Utility.getIntegratedCircuit(tag.getByte("ChipConfig")); } - ItemStack toBind; - EntityPlayer Player; - ItemStack Slot; - @Override public int getSizeInventory() { return 1; @@ -106,9 +127,9 @@ public class GT_Container_CircuitProgrammer extends Container { ItemStack ret = Slot.copy(); Slot = null; NBTTagCompound tag = toBind.getTagCompound(); - tag.setBoolean("HasChip",false); + tag.setBoolean("HasChip", false); toBind.setTagCompound(tag); - Player.inventory.setInventorySlotContents(Player.inventory.currentItem,toBind); + Player.inventory.setInventorySlotContents(Player.inventory.currentItem, toBind); return ret; } @@ -123,10 +144,10 @@ public class GT_Container_CircuitProgrammer extends Container { Slot = itemStack.copy().splitStack(1); itemStack.stackSize--; NBTTagCompound tag = toBind.getTagCompound(); - tag.setBoolean("HasChip",true); + tag.setBoolean("HasChip", true); tag.setByte("ChipConfig", (byte) itemStack.getItemDamage()); toBind.setTagCompound(tag); - Player.inventory.setInventorySlotContents(Player.inventory.currentItem,toBind); + Player.inventory.setInventorySlotContents(Player.inventory.currentItem, toBind); } } @@ -167,7 +188,7 @@ public class GT_Container_CircuitProgrammer extends Container { @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack itemStack) { - if (itemStack!= null && itemStack.getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem())) + if (itemStack != null && itemStack.getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem())) return true; return false; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java index 0de2b8b98f..edfc722bbd 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_Item_Destructopack.java @@ -1,3 +1,25 @@ +/* + * 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.server.container; import net.minecraft.entity.player.EntityPlayer; @@ -22,6 +44,7 @@ public class GT_Container_Item_Destructopack extends Container { addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); } } + @Override public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int aSlotIndex) { final Slot slotObject = (Slot) this.inventorySlots.get(aSlotIndex); @@ -33,23 +56,21 @@ public class GT_Container_Item_Destructopack extends Container { public boolean canInteractWith(EntityPlayer p_75145_1_) { return true; } + @Override - public void onCraftMatrixChanged(IInventory p_75130_1_) - { + public void onCraftMatrixChanged(IInventory p_75130_1_) { final Slot slotObject = (Slot) this.inventorySlots.get(0); slotObject.decrStackSize(0); } - class delslot extends Slot{ - public delslot() - { + class delslot extends Slot { + public delslot() { super(new InventoryPlayer(null), 0, 80, 17); } - public void putStack(ItemStack p_75215_1_) - { - p_75215_1_=null; + public void putStack(ItemStack p_75215_1_) { + p_75215_1_ = null; this.onSlotChanged(); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_LESU.java index 3e28f36d0b..95d09eefa9 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_LESU.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_LESU.java @@ -1,3 +1,25 @@ +/* + * 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.server.container; import gregtech.api.gui.GT_Container_MultiMachine; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java new file mode 100644 index 0000000000..ceb6a4cc8e --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/GT_Container_RadioHatch.java @@ -0,0 +1,155 @@ +/* + * 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.server.container; + +import com.github.bartimaeusnek.bartworks.common.tileentities.GT_MetaTileEntity_RadioHatch; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.gui.GT_Container_1by1; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.ICrafting; + +import java.nio.ByteBuffer; +import java.util.Iterator; + +public class GT_Container_RadioHatch extends GT_Container_1by1 { + + public byte mass, dmass; + public short sv, dsv, sievert, r, g, b, dsievert, dr, dg, db; + public byte[] teTimer = new byte[8], dteTimer = new byte[8]; + GT_MetaTileEntity_RadioHatch TE; + private long timer = 0; + + public GT_Container_RadioHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { + super(aInventoryPlayer, aTileEntity); + } + + public void detectAndSendChanges() { + super.detectAndSendChanges(); + if (!this.mTileEntity.isClientSide() && this.mTileEntity.getMetaTileEntity() != null) { + TE = (GT_MetaTileEntity_RadioHatch) this.mTileEntity.getMetaTileEntity(); + mass = TE.getMass(); + sievert = (short) TE.sievert; + short[] rgb = TE.getColorForGUI(); + r = rgb[0]; + g = rgb[1]; + b = rgb[2]; + sv = (short) TE.getSievert(); + teTimer = ByteBuffer.allocate(8).putLong(TE.getTimer()).array(); + ++timer; + Iterator var2 = this.crafters.iterator(); + if (timer >= Long.MAX_VALUE - 1) + timer = 0; + while (true) { + do { + if (!var2.hasNext()) { + dmass = mass; + dsievert = sievert; + dr = r; + dg = g; + db = b; + dteTimer = teTimer; + dsv = sv; + return; + } + ICrafting var1 = (ICrafting) var2.next(); + + if (this.timer % 500 == 10 || this.dmass != mass) + var1.sendProgressBarUpdate(this, 21, mass); + if (this.timer % 500 == 10 || this.dsievert != sievert) + var1.sendProgressBarUpdate(this, 22, (sievert - 100)); + if (this.timer % 500 == 10 || this.dr != r) + var1.sendProgressBarUpdate(this, 23, r); + if (this.timer % 500 == 10 || this.dg != g) + var1.sendProgressBarUpdate(this, 24, g); + if (this.timer % 500 == 10 || this.db != b) + var1.sendProgressBarUpdate(this, 25, b); + if (this.timer % 500 == 10 || this.dteTimer != teTimer) + for (int i = 0; i < teTimer.length; i++) { + var1.sendProgressBarUpdate(this, 26 + i, teTimer[i]); + } + if (this.timer % 500 == 10 || this.dsv != sv) + var1.sendProgressBarUpdate(this, 34, sv); + + } while (this.timer % 500 != 10 && this.dmass == this.mass); + } + } + } + + + @SideOnly(Side.CLIENT) + public void updateProgressBar(int par1, int par2) { + super.updateProgressBar(par1, par2); + switch (par1) { + case 21: + mass = (byte) par2; + break; + case 22: + sievert = (short) (par2 + 100); + break; + case 23: + r = (short) par2; + break; + case 24: + g = (short) par2; + break; + case 25: + b = (short) par2; + break; + case 26: + teTimer[0] = (byte) par2; + break; + case 27: + teTimer[1] = (byte) par2; + break; + case 28: + teTimer[2] = (byte) par2; + break; + case 29: + teTimer[3] = (byte) par2; + break; + case 30: + teTimer[4] = (byte) par2; + break; + case 31: + teTimer[5] = (byte) par2; + break; + case 32: + teTimer[6] = (byte) par2; + break; + case 33: + teTimer[7] = (byte) par2; + break; + case 34: + sv = (short) par2; + break; + } + } + + public boolean canInteractWith(EntityPlayer player) { + return true; + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java new file mode 100644 index 0000000000..f5f837cd0f --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -0,0 +1,580 @@ +/* + * 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.util; + +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 cpw.mods.fml.common.Loader; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.common.items.behaviors.Behaviour_DataOrb; +import ic2.core.item.ItemFluidCell; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +import javax.annotation.Nonnegative; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; + +import static com.github.bartimaeusnek.bartworks.util.BW_Util.calculateSv; +import static com.github.bartimaeusnek.bartworks.util.BW_Util.specialToByte; + +public class BWRecipes { + + public static final BWRecipes instance = new BWRecipes(); + public static final byte BIOLABBYTE = 0; + public static final byte BACTERIALVATBYTE = 1; + private GT_Recipe.GT_Recipe_Map sBiolab = new GT_Recipe.GT_Recipe_Map( + new HashSet<GT_Recipe>(150), + "bw.recipe.biolab", + "Bio Lab", + null, + "gregtech:textures/gui/basicmachines/BW.GUI.BioLab", + 6, 2, 1, 1, 1, + "", 1, "", true, true); + private BacteriaVatRecipeMap sBacteriaVat = new BacteriaVatRecipeMap( + new HashSet<GT_Recipe>(50), + "bw.recipe.BacteriaVat", + "Bacterial Vat", + null, + "gregtech:textures/gui/basicmachines/Default", + 6, 2, 0, 1, 1, + "Need Sievert: ", 1, " Sv", true, true); + + public BWRecipes() { + + FluidStack[] dnaFluid = {Loader.isModLoaded("gendustry") ? FluidRegistry.getFluidStack("liquiddna", 1000) : Materials.Biomass.getFluid(1000L)}; + + for (ItemStack stack : BioItemList.getAllPetriDishes()) { + BioData DNA = BioData.getBioDataFromNBTTag(stack.getTagCompound().getCompoundTag("DNA")); + if (DNA != null) { + ItemStack Detergent = BioItemList.getOther(1); + ItemStack DNAFlask = BioItemList.getDNASampleFlask(null); + ItemStack EthanolCell = Materials.Ethanol.getCells(1); + sBiolab.addFakeRecipe(false, + new ItemStack[]{ + stack, + DNAFlask, + Detergent, + EthanolCell + }, + new ItemStack[]{ + BioItemList.getDNASampleFlask(BioDNA.convertDataToDNA(DNA)), + GT_OreDictUnificator.get(OrePrefixes.cell, Materials.Empty, 1L) + }, + BioItemList.mBioLabParts[0], + new int[]{DNA.getChance(), 10000}, + new FluidStack[]{ + FluidRegistry.getFluidStack("ic2distilledwater", 1000) + }, + null, + 500, + BW_Util.getMachineVoltageFromTier(3 + DNA.getTier()), + BW_Util.STANDART + ); + } + } + + for (ItemStack stack : BioItemList.getAllDNASampleFlasks()) { + BioData DNA = BioData.getBioDataFromNBTTag(stack.getTagCompound()); + + if (DNA != null) { + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); + Behaviour_DataOrb.setDataName(Outp, DNA.getName()); + + sBiolab.addFakeRecipe(false, + new ItemStack[]{ + stack, + FluidLoader.BioLabFluidCells[0], + FluidLoader.BioLabFluidCells[3], + ItemList.Tool_DataOrb.get(1L) + }, + new ItemStack[]{ + Outp, + ItemList.Cell_Universal_Fluid.get(2L) + }, + BioItemList.mBioLabParts[1], + new int[]{DNA.getChance(), 10000}, + dnaFluid, + null, + 500, + BW_Util.getMachineVoltageFromTier(4 + DNA.getTier()), + BW_Util.STANDART + ); + } + } + + for (ItemStack stack : BioItemList.getAllPlasmidCells()) { + BioData DNA = BioData.getBioDataFromNBTTag(stack.getTagCompound()); + + if (DNA != null) { + ItemStack inp = ItemList.Tool_DataOrb.get(0L); + Behaviour_DataOrb.setDataTitle(inp, "DNA Sample"); + Behaviour_DataOrb.setDataName(inp, DNA.getName()); + ItemStack inp2 = ItemList.Tool_DataOrb.get(0L); + Behaviour_DataOrb.setDataTitle(inp2, "DNA Sample"); + Behaviour_DataOrb.setDataName(inp2, BioCultureLoader.BIO_DATA_BETA_LACMATASE.getName()); + + sBiolab.addFakeRecipe(false, + new ItemStack[]{ + FluidLoader.BioLabFluidCells[1], + BioItemList.getPlasmidCell(null), + inp, + inp2 + }, + new ItemStack[]{ + stack, + ItemList.Cell_Universal_Fluid.get(1L) + }, + BioItemList.mBioLabParts[2], + new int[]{DNA.getChance(), 10000}, + dnaFluid, + null, + 500, + BW_Util.getMachineVoltageFromTier(4 + DNA.getTier()), + BW_Util.STANDART + ); + } + } + + //Transformation- [Distilled Water] + Culture () + Plasmids (Gene) Cell + Penicillin Cell= Culture (Gene) + Empty Cells + sBiolab.addFakeRecipe(false, + new ItemStack[]{ + BioItemList.getPetriDish(null).setStackDisplayName("The Culture to change"), + BioItemList.getPlasmidCell(null).setStackDisplayName("The Plasmids to Inject"), + FluidLoader.BioLabFluidCells[2], + }, + new ItemStack[]{ + BioItemList.getPetriDish(null).setStackDisplayName("The changed Culture"), + ItemList.Cell_Universal_Fluid.get(1L) + }, + BioItemList.mBioLabParts[3], + new int[]{7500, 10000}, + new FluidStack[]{ + FluidRegistry.getFluidStack("ic2distilledwater", 1000) + }, + null, + 500, + BW_Util.getMachineVoltageFromTier(6), + BW_Util.STANDART + ); + + + ItemStack Outp = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(Outp, "DNA Sample"); + Behaviour_DataOrb.setDataName(Outp, "Any DNA"); + //Clonal Cellular Synthesis- [Liquid DNA] + Medium Petri Dish + Plasma Membrane + Stem Cells + Genome Data + sBiolab.addFakeRecipe(false, + new ItemStack[]{ + BioItemList.getPetriDish(null), + BioItemList.getOther(4), + ItemList.Circuit_Chip_Stemcell.get(2L), + Outp + }, + new ItemStack[]{ + BioItemList.getPetriDish(null).setStackDisplayName("The Culture made from DNA"), + }, + BioItemList.mBioLabParts[4], + new int[]{7500, 10000}, + new FluidStack[]{new FluidStack(dnaFluid[0].getFluid(), 9000)}, + null, + 500, + BW_Util.getMachineVoltageFromTier(6), + BW_Util.STANDART + ); + + FluidStack[] easyFluids = {Materials.Water.getFluid(1000L), FluidRegistry.getFluidStack("ic2distilledwater", 1000)}; + for (FluidStack fluidStack : easyFluids) { + for (BioCulture bioCulture : BioCulture.BIO_CULTURE_ARRAY_LIST) { + if (bioCulture.isBreedable() && bioCulture.getTier() == 0) { + sBacteriaVat.addRecipe( + //boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue + new BacteriaVatRecipe( + true, + new ItemStack[]{ + GT_Utility.getIntegratedCircuit(0), + new ItemStack(Items.sugar, 64) + }, + null, + BioItemList.getPetriDish(bioCulture), + null, + new FluidStack[]{ + fluidStack + }, + new FluidStack[]{ + new FluidStack(bioCulture.getFluid(), 10) + }, + 1000, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + ), true + ); + //aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue + sBiolab.addRecipe( + new BioLabRecipe( + false, + new ItemStack[]{ + BioItemList.getPetriDish(null), + fluidStack.equals(Materials.Water.getFluid(1000L)) ? Materials.Water.getCells(1) : ItemFluidCell.getUniversalFluidCell(FluidRegistry.getFluidStack("ic2distilledwater", 1000)) + }, + new ItemStack[]{ + BioItemList.getPetriDish(bioCulture), + fluidStack.equals(Materials.Water.getFluid(1000L)) ? Materials.Empty.getCells(1) : ItemList.Cell_Universal_Fluid.get(1L) + }, + null, + new int[]{ + bioCulture.getChance(), + 10000 + }, + new FluidStack[]{ + new FluidStack(bioCulture.getFluid(), 1000) + }, + null, + 500, + BW_Util.getMachineVoltageFromTier(3), + BW_Util.STANDART + )); + } + } + } + } + + /** + * @param machine 0 = biolab; 1 = BacterialVat + * @return + */ + public GT_Recipe.GT_Recipe_Map getMappingsFor(byte machine) { + switch (machine) { + case 0: + return sBiolab; + case 1: + return sBacteriaVat; + default: + return null; + } + + } + + public boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, Object 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; + } + + public boolean addBioLabRecipeIncubation(ItemStack aInput, BioCulture aOutput, int[] aChances, FluidStack[] aFluidInputs, int aDuration, int aEUt, int aSpecialValue) { + if (sBiolab.addRecipe(new BioLabRecipe(true, new ItemStack[]{BioItemList.getPetriDish(null), aInput}, new ItemStack[]{BioItemList.getPetriDish(aOutput)}, null, aChances, aFluidInputs, new FluidStack[]{GT_Values.NF}, aDuration, aEUt, aSpecialValue)) != null) + return true; + return false; + } + + @Deprecated + public boolean addBioLabRecipeDNAExtraction(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[0], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + return true; + return false; + } + + @Deprecated + public boolean addBioLabRecipePCRThermoclycling(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[1], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + return true; + return false; + } + + @Deprecated + public boolean addBioLabRecipePlasmidSynthesis(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[2], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + return true; + return false; + } + + @Deprecated + public boolean addBioLabRecipeTransformation(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[3], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + return true; + return false; + } + + @Deprecated + public boolean addBioLabRecipeClonalCellularSynthesis(ItemStack[] aInputs, ItemStack aOutput, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { + if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[4], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + return true; + return false; + } + + 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) + return true; + return false; + } + + public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCulture, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, @Nonnegative int aDuration, @Nonnegative int aEUt, @Nonnegative int aSv, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { + byte gTier = (byte) glasTier; + int aSievert = 0; + if (aSv >= 83 || aSv == 61 || aSv == 43) + aSievert += aSv; + aSievert = aSievert << 1; + aSievert = aSievert | (exactSv ? 1 : 0); + aSievert = aSievert << 2; + 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) + return true; + return false; + } + + public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCulture, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, Materials material, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { + byte gTier = (byte) glasTier; + int aSievert = 0; + if (material.getProtons() >= 83 || material.getProtons() == 61 || material.getProtons() == 43) + aSievert += calculateSv(material); + aSievert = aSievert << 1; + aSievert = aSievert | (exactSv ? 1 : 0); + aSievert = aSievert << 2; + 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) + return true; + return false; + } + + 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) + aSievert += calculateSv(material); + 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) + return true; + return false; + } + + public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture culture, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, Materials material, int aSpecialValue, boolean exactSv) { + int aSievert = 0; + if (material.getProtons() >= 83 || material.getProtons() == 61 || material.getProtons() == 43) + aSievert += calculateSv(material); + aSievert = aSievert << 1; + aSievert = aSievert | (exactSv ? 1 : 0); + 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) + return true; + return false; + } + + /** + * Adds a Vat recipe without Rad requirements but with Glas requirements + */ + public boolean addBacterialVatRecipe(ItemStack[] aInputs, BioCulture culture, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, byte glasTier) { + 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) + return true; + return false; + } + + /** + * 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) + return true; + return false; + } + + + public boolean addTrimmedBacterialVatRecipe(ItemStack[] aInputs, BioCulture aCulture, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, Materials material, @Nonnegative int glasTier, int aSpecialValue, boolean exactSv) { + byte gTier = (byte) glasTier; + int aSievert = 0; + if (material.getProtons() >= 83 || material.getProtons() == 61 || material.getProtons() == 43) + aSievert += material.getProtons(); + aSievert = aSievert << 1; + aSievert = aSievert | (exactSv ? 1 : 0); + aSievert = aSievert << 2; + 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) + return true; + return false; + } + + 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) { + 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) { + super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); + } + } + + 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); + } + + /** + * finds a Recipe matching the aFluid and ItemStack Inputs. + * + * @param aTileEntity an Object representing the current coordinates of the executing Block/Entity/Whatever. This may be null, especially during Startup. + * @param aRecipe in case this is != null it will try to use this Recipe first when looking things up. + * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs + * @param aDontCheckStackSizes if set to false will only return recipes that can be executed at least once with the provided input + * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage + * @param aFluids the Fluid Inputs + * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. + * @param aInputs the Item Inputs + * @return the Recipe it has found or null for no matching Recipe + */ + public GT_Recipe findRecipe(IHasWorldObjectAndCoords aTileEntity, GT_Recipe aRecipe, boolean aNotUnificated, boolean aDontCheckStackSizes, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + // No Recipes? Well, nothing to be found then. + if (mRecipeList.isEmpty()) return null; + + // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes. + // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes. + if (GregTech_API.sPostloadFinished) { + if (mMinimalInputFluids > 0) { + if (aFluids == null) return null; + int tAmount = 0; + for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; + if (tAmount < mMinimalInputFluids) return null; + } + if (mMinimalInputItems > 0) { + if (aInputs == null) return null; + int tAmount = 0; + for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; + if (tAmount < mMinimalInputItems) return null; + } + } + + // Unification happens here in case the Input isn't already unificated. + if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); + + // Check the Recipe which has been used last time in order to not have to search for it again, if possible. + if (aRecipe != null) + if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) && BW_Util.areStacksEqual((ItemStack) aRecipe.mSpecialItems, aSpecialSlot)) + return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; + + // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. + if (mUsualInputCount > 0 && aInputs != null) + for (ItemStack tStack : aInputs) + if (tStack != null) { + Collection<GT_Recipe> tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); + if (tRecipes != null) + for (GT_Recipe tRecipe : tRecipes) + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) && BW_Util.areStacksEqual((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(GT_Values.W, tStack))); + if (tRecipes != null) + for (GT_Recipe tRecipe : tRecipes) + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) && BW_Util.areStacksEqual((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + } + + // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too. + if (mMinimalInputItems == 0 && aFluids != null) + for (FluidStack aFluid : aFluids) + if (aFluid != null) { + Collection<GT_Recipe> tRecipes = mRecipeFluidMap.get(aFluid.getFluid()); + if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) + if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, aDontCheckStackSizes, aFluids, aInputs) && BW_Util.areStacksEqual((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + } + + // And nothing has been found. + return null; + } + + protected GT_Recipe addRecipe(GT_Recipe aRecipe, boolean aCheckForCollisions, boolean aFakeRecipe, boolean aHidden) { + aRecipe.mHidden = aHidden; + aRecipe.mFakeRecipe = aFakeRecipe; + GT_Recipe isthere = this.findRecipe((IHasWorldObjectAndCoords) null, false, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs); + + if (aRecipe.mFluidInputs.length < this.mMinimalInputFluids && aRecipe.mInputs.length < this.mMinimalInputItems) { + return null; + } else { + return aCheckForCollisions && isthere != null && BW_Util.areStacksEqual((ItemStack) isthere.mSpecialItems, (ItemStack) aRecipe.mSpecialItems) ? null : this.add(aRecipe); + } + } + + public GT_Recipe addRecipe(GT_Recipe aRecipe, boolean VanillaGT) { + if (VanillaGT) + return addRecipe(aRecipe, true, false, false); + else + return addRecipe(aRecipe); + } + + public GT_Recipe addRecipe(GT_Recipe aRecipe) { + if (aRecipe.mInputs.length > 0 && GT_Utility.areStacksEqual(aRecipe.mInputs[aRecipe.mInputs.length - 1], GT_Utility.getIntegratedCircuit(32767))) + return aRecipe; + else { + ItemStack[] nu1 = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); + nu1[nu1.length - 1] = GT_Utility.getIntegratedCircuit(9 + nu1.length); + aRecipe.mInputs = nu1; + } + if (this.findRecipe((IHasWorldObjectAndCoords) null, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs) != null) { + ItemStack[] nu = Arrays.copyOf(aRecipe.mInputs, aRecipe.mInputs.length + 1); + int i = 9 + nu.length; + do { + nu[nu.length - 1] = GT_Utility.getIntegratedCircuit(i); + i++; + aRecipe.mInputs = nu; + if (i > 24) + i = 1; + if (i == 9 + nu.length) + return null; + } + while (this.findRecipe((IHasWorldObjectAndCoords) null, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs) != null); + } + return this.addRecipe(aRecipe, false, false, false); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java new file mode 100644 index 0000000000..19b5897fcf --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -0,0 +1,122 @@ +/* + * 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.util; + +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.GT_Utility; +import net.minecraft.block.Block; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.Iterator; + +public class BW_Util { + + public static final int STANDART = 0; + public static final int CLEANROOM = -100; + public static final int LOWGRAVITY = -200; + + public static byte specialToByte(int aSpecialValue) { + byte special = 0; + if (aSpecialValue == (CLEANROOM)) + special = 1; + else if (aSpecialValue == (LOWGRAVITY)) + special = 2; + else if (aSpecialValue == (CLEANROOM | LOWGRAVITY)) { + special = 3; + } + return special; + } + + public static boolean addBlockToMachine(int x, int y, int z, int offsetsize, IGregTechTileEntity aBaseMetaTileEntity, Block block) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * offsetsize; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * offsetsize; + + return aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(block); + } + + public static boolean addBlockToMachine(int x, int y, int z, int offsetsize, IGregTechTileEntity aBaseMetaTileEntity, Block block, int damage) { + byte dmg = (byte) damage; + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * offsetsize; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * offsetsize; + + return aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(block) && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == dmg; + } + + public static int calculateSv(Materials materials) { + Iterator it = BioVatLogicAdder.RadioHatch.getMaSv().iterator(); + while (it.hasNext()) { + BioVatLogicAdder.MaterialSvPair pair = (BioVatLogicAdder.MaterialSvPair) it.next(); + if (pair.getMaterials().equals(materials)) + return pair.getSievert(); + } + return (int) (materials.getProtons() == 43L ? (materials.equals(Materials.NaquadahEnriched) ? 140 : materials.equals(Materials.Naquadria) ? 150 : materials.equals(Materials.Naquadah) ? 130 : 43) : materials.getProtons()); + } + + public static int getMachineVoltageFromTier(int tier) { + return (int) (30 * Math.pow(4, (tier - 1))); + } + + public static short[] splitColortoArray(int rgb) { + return new short[]{(short) ((rgb >> 16) & 0xFF), (short) ((rgb >> 8) & 0xFF), (short) (rgb & 0xFF)}; + } + + public static int getColorFromArray(short[] color) { + return ((color[0] & 0x0ff) << 16) | ((color[1] & 0x0ff) << 8) | (color[2] & 0x0ff); + } + + public static int getColorFromArray(int[] color) { + return ((color[0] & 0x0ff) << 16) | ((color[1] & 0x0ff) << 8) | (color[2] & 0x0ff); + } + + public static boolean areStacksEqual(ItemStack aStack1, ItemStack aStack2) { + return (aStack1 == null && aStack2 == null) || GT_Utility.areStacksEqual(aStack1, aStack2); + } + + public static byte getByteFromRarity(EnumRarity rarity) { + if (rarity.equals(EnumRarity.uncommon)) + return 1; + else if (rarity.equals(EnumRarity.epic)) + return 2; + else if (rarity.equals(EnumRarity.rare)) + return 3; + return 0; + } + + public static EnumRarity getRarityFromByte(byte b) { + switch (b) { + case 1: + return EnumRarity.uncommon; + case 2: + return EnumRarity.rare; + case 3: + return EnumRarity.epic; + default: + return EnumRarity.common; + } + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java new file mode 100644 index 0000000000..f36a8d54ac --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioCulture.java @@ -0,0 +1,189 @@ +/* + * 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.util; + + +import com.github.bartimaeusnek.bartworks.MainMod; +import net.minecraft.item.EnumRarity; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +import java.awt.*; +import java.util.ArrayList; +import java.util.Objects; + +public class BioCulture extends BioData { + + public static final ArrayList<BioCulture> BIO_CULTURE_ARRAY_LIST = new ArrayList<BioCulture>(); + + Color color; + BioPlasmid plasmid; + BioDNA dDNA; + boolean bBreedable; + Fluid mFluid; + + protected BioCulture(Color color, String name, int ID, BioPlasmid plasmid, BioDNA dDNA, EnumRarity rarity, boolean bBreedable) { + super(name, ID, rarity); + this.color = color; + this.plasmid = plasmid; + this.dDNA = dDNA; + this.bBreedable = bBreedable; + } + + protected BioCulture(Color color, String name, int ID, BioPlasmid plasmid, BioDNA dDNA) { + super(name, ID, dDNA.getRarity()); + this.color = color; + this.plasmid = plasmid; + this.dDNA = dDNA; + } + + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, EnumRarity rarity, boolean breedable) { + BioCulture ret = new BioCulture(color, name, BIO_CULTURE_ARRAY_LIST.size(), plasmid, dna, rarity, breedable); + BIO_CULTURE_ARRAY_LIST.add(ret); + return ret; + } + + public static BioCulture createAndRegisterBioCulture(Color color, String name, BioPlasmid plasmid, BioDNA dna, boolean breedable) { + BioCulture ret = new BioCulture(color, name, BIO_CULTURE_ARRAY_LIST.size(), plasmid, dna, dna.getRarity(), breedable); + BIO_CULTURE_ARRAY_LIST.add(ret); + return ret; + } + + public static NBTTagCompound getNBTTagFromCulture(BioCulture bioCulture) { + if (bioCulture == null) + return new NBTTagCompound(); + NBTTagCompound ret = new NBTTagCompound(); + ret.setString("Name", bioCulture.name); + 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))); + ret.setBoolean("Breedable", bioCulture.bBreedable); + ret.setByte("Rarety", BW_Util.getByteFromRarity(bioCulture.rarity)); + if (bioCulture.bBreedable) + ret.setString("Fluid", bioCulture.getFluid().getName()); + return ret; + } + + 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") + ); + if (ret.bBreedable) + ret.setFluid(FluidRegistry.getFluid(tag.getString("Fluid"))); + return ret; + } + + public static BioCulture getBioCulture(String Name) { + for (BioCulture b : BIO_CULTURE_ARRAY_LIST) + if (b.name.equals(Name)) + return b; + return null; + } + + public static BioCulture getBioCulture(BioDNA DNA) { + for (BioCulture b : BIO_CULTURE_ARRAY_LIST) + if (b.getdDNA().equals(DNA)) + return b; + return null; + } + + public Fluid getFluid() { + if (this.mFluid == null) + MainMod.logger.error("Fluid has not been set yet! The issuring Culture is: " + this.name); + return this.mFluid; + } + + public void setFluid(Fluid mFluid) { + this.mFluid = mFluid; + } + + public boolean isBreedable() { + return this.bBreedable; + } + + public void setbBreedable(boolean bBreedable) { + this.bBreedable = bBreedable; + } + + public int getColorRGB() { + return BW_Util.getColorFromArray(new int[]{this.color.getRed(), this.color.getGreen(), this.color.getBlue()}); + } + + public Color getColor() { + return this.color; + } + + public void setColor(Color color) { + this.color = color; + } + +// public static BioCulture createAndRegisterBioCulture(Color color, String name, long ID, BioPlasmid plasmid, BioDNA dDNA,EnumRarity rarity){ +// BioCulture ret =new BioCulture(color,name,ID,plasmid,dDNA,rarity); +// BIO_CULTURE_ARRAY_LIST.add(ret); +// return ret; +// } + + public BioPlasmid getPlasmid() { + return this.plasmid; + } + + public void setPlasmid(BioPlasmid plasmid) { + this.plasmid = plasmid; + } + + public BioDNA getdDNA() { + return this.dDNA; + } + + public void setdDNA(BioDNA dDNA) { + this.dDNA = dDNA; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + BioCulture culture = (BioCulture) o; + return this.isBreedable() == culture.isBreedable() && + Objects.equals(this.getColor(), culture.getColor()) && + Objects.equals(this.getPlasmid(), culture.getPlasmid()) && + Objects.equals(this.getdDNA(), culture.getdDNA()) && + Objects.equals(this.mFluid, culture.mFluid); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), this.getColor(), this.getPlasmid(), this.getdDNA(), this.isBreedable(), this.mFluid); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java new file mode 100644 index 0000000000..65a7de4ab0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioDNA.java @@ -0,0 +1,63 @@ +/* + * 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.util; + +import net.minecraft.item.EnumRarity; + +public class BioDNA extends BioData { + + protected BioDNA(String name, int ID, EnumRarity rarity) { + super(name, ID, rarity); + } + + protected BioDNA(BioData bioData) { + super(bioData); + this.name = bioData.name; + this.ID = bioData.ID; + this.rarity = bioData.rarity; + } + + public static BioDNA convertDataToDNA(BioData bioData) { + return new BioDNA(bioData); + } + + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity); + return new BioDNA(ret); + } + + public static BioDNA createAndRegisterBioDNA(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity, chance, tier); + return new BioDNA(ret); + } + + @Override + public String toString() { + return "BioDNA{" + + "name='" + name + '\'' + + ", ID=" + ID + + '}'; + } + + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java new file mode 100644 index 0000000000..ac9c7d2083 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioData.java @@ -0,0 +1,171 @@ +/* + * 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.util; + +import net.minecraft.item.EnumRarity; +import net.minecraft.nbt.NBTTagCompound; + +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; + protected int chance; + protected int tier; + + protected BioData(String name, int ID, EnumRarity rarity, int chance, int tier) { + this.name = name; + this.ID = ID; + this.rarity = rarity; + this.chance = chance; + this.tier = tier; + } + + protected BioData(String name, int ID, EnumRarity rarity) { + this.name = name; + this.ID = ID; + this.rarity = rarity; + this.chance = 7500; + this.tier = 0; + } + + protected BioData(BioData bioData) { + this.rarity = bioData.rarity; + this.name = bioData.name; + this.ID = bioData.ID; + this.chance = bioData.chance; + } + + public static BioData convertBioPlasmidToBioData(BioPlasmid bioPlasmid) { + return new BioData(bioPlasmid.name, bioPlasmid.ID, bioPlasmid.rarity, bioPlasmid.chance, bioPlasmid.tier); + } + + public static BioData convertBioDNAToBioData(BioDNA bioDNA) { + return new BioData(bioDNA.name, bioDNA.ID, bioDNA.rarity, bioDNA.chance, bioDNA.tier); + } + + public static BioData createAndRegisterBioData(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = new BioData(aName, BIO_DATA_ARRAY_LIST.size(), rarity, chance, tier); + BIO_DATA_ARRAY_LIST.add(ret); + return ret; + } + + public static BioData createAndRegisterBioData(String aName, EnumRarity rarity) { + BioData ret = new BioData(aName, BIO_DATA_ARRAY_LIST.size(), rarity); + BIO_DATA_ARRAY_LIST.add(ret); + return ret; + } + + public static NBTTagCompound getNBTTagFromBioData(BioData 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("Chance", bioData.chance); + ret.setInteger("Tier", bioData.tier); + return ret; + } + + public static BioData getBioDataFromNBTTag(NBTTagCompound tag) { + if (tag == null) + return null; + return getBioDataFromName(tag.getString("Name")); + } + + public static BioData getBioDataFromName(String Name) { + for (BioData bd : BIO_DATA_ARRAY_LIST) + if (bd.name.equals(Name)) + return bd; + return null; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + BioData bioData = (BioData) o; + return this.getID() == bioData.getID() && + this.getChance() == bioData.getChance() && + this.getTier() == bioData.getTier() && + Objects.equals(this.getName(), bioData.getName()) && + this.getRarity() == bioData.getRarity(); + } + + @Override + public int hashCode() { + return Objects.hash(this.getName(), this.getID(), this.getRarity(), this.getChance(), this.getTier()); + } + + public int getTier() { + return this.tier; + } + + public void setTier(int tier) { + this.tier = tier; + } + + @Override + public String toString() { + return "BioData{" + + "name='" + name + '\'' + + ", ID=" + ID + + '}'; + } + + public EnumRarity getRarity() { + return this.rarity; + } + + public void setRarity(EnumRarity rarity) { + this.rarity = rarity; + } + + public int getChance() { + return this.chance; + } + + public void setChance(int chance) { + this.chance = chance; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * DO NOT USE GET ID TO GET THE OBJECT! THIS SHOULD ONLY BE USED FOR COMPARISON! + * + * @return the position in the loading list + */ + public int getID() { + return this.ID; + } + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java new file mode 100644 index 0000000000..7b034f8c43 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BioPlasmid.java @@ -0,0 +1,62 @@ +/* + * 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.util; + +import net.minecraft.item.EnumRarity; + +public class BioPlasmid extends BioData { + private BioPlasmid(String name, int ID, EnumRarity rarity) { + super(name, ID, rarity); + } + + protected BioPlasmid(BioData bioData) { + super(bioData); + this.name = bioData.name; + this.ID = bioData.ID; + this.rarity = bioData.rarity; + } + + public static BioPlasmid convertDataToPlasmid(BioData bioData) { + return new BioPlasmid(bioData); + } + + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity); + return new BioPlasmid(ret); + } + + public static BioPlasmid createAndRegisterBioPlasmid(String aName, EnumRarity rarity, int chance, int tier) { + BioData ret = BioData.createAndRegisterBioData(aName, rarity, chance, tier); + return new BioPlasmid(ret); + } + + @Override + public String toString() { + return "BioPlasmid{" + + "name='" + name + '\'' + + ", ID=" + ID + + '}'; + } + + +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java index 456a98cf76..b78e39afe1 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ChatColorHelper.java @@ -1,3 +1,25 @@ +/* + * 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.util; public class ChatColorHelper { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java index 71a158463c..388d888cf4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java @@ -1,3 +1,25 @@ +/* + * 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.util; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -6,166 +28,143 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import java.util.HashSet; -import java.util.Objects; public class ConnectedBlocksChecker { public final HashSet<Coords> hashset = new HashSet<Coords>(); - public int get_connected(World w, int x, int y, int z, Block b){ + public int get_connected(World w, int x, int y, int z, Block b) { int ret = 0; + int wID = w.provider.dimensionId; + byte sides = check_sourroundings(w, x, y, z, b); - if (((sides | 0b111110) == 0b111111) && !hashset.contains(new Coords(x,y+1,z))) { + if (((sides | 0b111110) == 0b111111) && !hashset.contains(new Coords(x, y + 1, z, wID))) { ret++; - ret += get_connected(w, x, y + 1, z,b); + ret += get_connected(w, x, y + 1, z, b); } - if (( (sides | 0b111101) == 0b111111) && !hashset.contains(new Coords(x,y-1,z))) { + if (((sides | 0b111101) == 0b111111) && !hashset.contains(new Coords(x, y - 1, z, wID))) { ret++; - ret += get_connected(w, x, y - 1, z,b); + ret += get_connected(w, x, y - 1, z, b); } - if (( (sides | 0b111011) == 0b111111) && !hashset.contains(new Coords(x+1,y,z))) { + if (((sides | 0b111011) == 0b111111) && !hashset.contains(new Coords(x + 1, y, z, wID))) { ret++; - ret += get_connected(w, x+1, y, z,b); + ret += get_connected(w, x + 1, y, z, b); } - if (( (sides | 0b110111) == 0b111111) && !hashset.contains(new Coords(x-1,y,z))) { + if (((sides | 0b110111) == 0b111111) && !hashset.contains(new Coords(x - 1, y, z, wID))) { ret++; - ret += get_connected(w, x-1, y, z,b); + ret += get_connected(w, x - 1, y, z, b); } - if (( (sides | 0b101111) == 0b111111) && !hashset.contains(new Coords(x,y,z+1))) { + if (((sides | 0b101111) == 0b111111) && !hashset.contains(new Coords(x, y, z + 1, wID))) { ret++; - ret += get_connected(w, x, y, z+1,b); + ret += get_connected(w, x, y, z + 1, b); } - if (( (sides | 0b011111) == 0b111111) && !hashset.contains(new Coords(x,y,z-1))) { + if (((sides | 0b011111) == 0b111111) && !hashset.contains(new Coords(x, y, z - 1, wID))) { ret++; - ret += get_connected(w, x, y, z-1,b); + ret += get_connected(w, x, y, z - 1, b); } return ret; } - public byte check_sourroundings(World w, int x, int y, int z,Block b){ + public byte check_sourroundings(World w, int x, int y, int z, Block b) { byte ret = 0; + int wID = w.provider.dimensionId; - if (hashset.contains(new Coords(x,y,z))) + if (hashset.contains(new Coords(x, y, z, wID))) return ret; - hashset.add(new Coords(x,y,z)); + hashset.add(new Coords(x, y, z, wID)); - if (w.getBlock(x,y+1,z).equals(b)) + if (w.getBlock(x, y + 1, z).equals(b)) ret = (byte) (ret | 0b000001); - if (w.getBlock(x,y-1,z).equals(b)) + if (w.getBlock(x, y - 1, z).equals(b)) ret = (byte) (ret | 0b000010); - if (w.getBlock(x+1,y,z).equals(b)) + if (w.getBlock(x + 1, y, z).equals(b)) ret = (byte) (ret | 0b000100); - if (w.getBlock(x-1,y,z).equals(b)) + if (w.getBlock(x - 1, y, z).equals(b)) ret = (byte) (ret | 0b001000); - if (w.getBlock(x,y,z+1).equals(b)) + if (w.getBlock(x, y, z + 1).equals(b)) ret = (byte) (ret | 0b010000); - if (w.getBlock(x,y,z-1).equals(b)) + if (w.getBlock(x, y, z - 1).equals(b)) ret = (byte) (ret | 0b100000); return ret; } - public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT){ + public boolean get_meta_of_sideblocks(World w, int n, int[] xyz, boolean GT) { - Coords Controller = new Coords(xyz[0],xyz[1],xyz[2]); + int wID = w.provider.dimensionId; + Coords Controller = new Coords(xyz[0], xyz[1], xyz[2], wID); - for (Coords C : hashset){ + for (Coords C : hashset) { if (GT) { TileEntity t; t = w.getTileEntity(C.x, C.y + 1, C.z); - if (t != null && !new Coords(C.x, C.y + 1, C.z).equals(Controller)) { + if (t != null && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) { if (t instanceof IGregTechTileEntity) if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; } t = w.getTileEntity(C.x, C.y - 1, C.z); - if (t != null && !new Coords(C.x, C.y - 1, C.z).equals(Controller)) { + if (t != null && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) { if (t instanceof IGregTechTileEntity) if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; } t = w.getTileEntity(C.x + 1, C.y, C.z); - if (t != null && !new Coords(C.x + 1, C.y, C.z).equals(Controller)) { + if (t != null && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) { if (t instanceof IGregTechTileEntity) if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; } t = w.getTileEntity(C.x - 1, C.y, C.z); - if (t != null && !new Coords(C.x - 1, C.y, C.z).equals(Controller)) { + if (t != null && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) { if (t instanceof IGregTechTileEntity) if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; } t = w.getTileEntity(C.x, C.y, C.z + 1); - if (t != null && !new Coords(C.x, C.y, C.z + 1).equals(Controller)) { + if (t != null && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) { if (t instanceof IGregTechTileEntity) if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; } t = w.getTileEntity(C.x, C.y, C.z - 1); - if (t != null && !new Coords(C.x, C.y, C.z - 1).equals(Controller)) { + if (t != null && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) { if (t instanceof IGregTechTileEntity) if (((IGregTechTileEntity) t).getMetaTileID() == n) return true; } - }else { - if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z).equals(Controller)) + } else { + if (n == w.getBlockMetadata(C.x, C.y + 1, C.z) && !new Coords(C.x, C.y + 1, C.z, wID).equals(Controller)) return true; - if (n == w.getBlockMetadata(C.x, C.y - 1, C.z) && !new Coords(C.x, C.y - 1, C.z).equals(Controller)) + if (n == w.getBlockMetadata(C.x, C.y - 1, C.z) && !new Coords(C.x, C.y - 1, C.z, wID).equals(Controller)) return true; - if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) && !new Coords(C.x + 1, C.y, C.z).equals(Controller)) + if (n == w.getBlockMetadata(C.x + 1, C.y, C.z) && !new Coords(C.x + 1, C.y, C.z, wID).equals(Controller)) return true; - if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) && !new Coords(C.x - 1, C.y, C.z).equals(Controller)) + if (n == w.getBlockMetadata(C.x - 1, C.y, C.z) && !new Coords(C.x - 1, C.y, C.z, wID).equals(Controller)) return true; - if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) && !new Coords(C.x, C.y, C.z + 1).equals(Controller)) + if (n == w.getBlockMetadata(C.x, C.y, C.z + 1) && !new Coords(C.x, C.y, C.z + 1, wID).equals(Controller)) return true; - if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) && !new Coords(C.x, C.y, C.z - 1).equals(Controller)) + if (n == w.getBlockMetadata(C.x, C.y, C.z - 1) && !new Coords(C.x, C.y, C.z - 1, wID).equals(Controller)) return true; } } return false; } - - class Coords { - - public int x,y,z; - - public Coords(int x, int y, int z){ - this.x=x; - this.y=y; - this.z=z; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Coords coords = (Coords) o; - return x == coords.x && - y == coords.y && - z == coords.z; - } - - @Override - public int hashCode() { - return Objects.hash(x, y, z); - } - } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java new file mode 100644 index 0000000000..7d9f60015b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/Coords.java @@ -0,0 +1,63 @@ +/* + * 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.util; + +import java.util.Objects; + +public class Coords { + + public int x, y, z, wID; + + public Coords(int x, int y, int z, int wID) { + this(x, y, z); + this.wID = wID; + } + + public Coords(int x, int y, int z) { + this.x = x; + this.y = y; + this.z = z; + this.wID = 0; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || this.getClass() != o.getClass()) return false; + Coords coords = (Coords) o; + return this.x == coords.x && + this.y == coords.y && + this.z == coords.z && + this.wID == coords.wID; + } + + @Override + public int hashCode() { + return Objects.hash(this.x, this.y, this.z, this.wID); + } + + @Override + public String toString() { + return x + "," + y + "," + z + "," + wID; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java index 2b634986d2..e1e1df39c2 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java @@ -1,8 +1,31 @@ +/* + * 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.util; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; import cpw.mods.fml.common.Optional; import net.minecraft.item.ItemStack; @@ -10,21 +33,22 @@ import net.minecraft.item.ItemStack; @Optional.Interface(iface = "codechicken.nei.api.API", modid = "NotEnoughItems") public class NEIbartworksConfig implements IConfigureNEI { - @Optional.Method(modid="NotEnoughItems") + @Optional.Method(modid = "NotEnoughItems") @Override public String getName() { return MainMod.name; } - @Optional.Method(modid="NotEnoughItems") + @Optional.Method(modid = "NotEnoughItems") @Override public String getVersion() { return MainMod.version; } - @Optional.Method(modid="NotEnoughItems") + @Optional.Method(modid = "NotEnoughItems") @Override public void loadConfig() { API.hideItem(new ItemStack(ItemRegistry.tab)); + API.hideItem(new ItemStack(FluidLoader.bioFluidBlock)); } }
\ No newline at end of file diff --git a/src/main/resources/assets/bartworks/lang/en_US.lang b/src/main/resources/assets/bartworks/lang/en_US.lang index 400cf182fc..cdcef27970 100644 --- a/src/main/resources/assets/bartworks/lang/en_US.lang +++ b/src/main/resources/assets/bartworks/lang/en_US.lang @@ -1,3 +1,4 @@ +itemGroup.GT2C=Gregtech 2 Compat item.GT_Rockcutter_Item_LV.name=Rockcutter LV item.GT_Rockcutter_Item_MV.name=Rockcutter MV item.GT_Rockcutter_Item_HV.name=Rockcutter HV @@ -5,7 +6,7 @@ item.GT_Teslastaff_Item.name=Teslastaff BW_ItemBlocks.0.name=Etched Lapis Cell BW_ItemBlocks.1.name=Plated Lapis Cell GT_LESU_CASING.0.name=LESU Casing -itemGroup.GT2C=Gregtech 2 Compat + itemGroup.bartworks=BartWorks Inter Temporal BW_Machinery_Casings.0.name=Nickel-Zinc Ferrite Block BW_Machinery_Casings.1.name=Transformer-Winding Block @@ -20,4 +21,26 @@ item.completed_grindstone.name=Grindstone item.rotors.leatherParts.name=Leather Covered Wood Frame item.rotors.woolParts.name=Wool Covered Wood Frame item.rotors.paperParts.name=Paper Covered Wood Frame -item.rotors.combinedParts.name=Multiple Material Covered Wood Frame
\ No newline at end of file +item.rotors.combinedParts.name=Multiple Material Covered Wood Frame + +itemGroup.BioTab=BartWorks BioEngineering +filled.item.petriDish.name=Petri Dish with a Culture +item.petriDish.name=Sterilized Petri Dish +item.DNASampleFlask.name=DNA Sample Flask +item.PlasmidCell.name=Plasmid Sample Flask +item.DetergentPowder.name=Detergent Powder +item.Agarose.name=Agarose +item.IncubationModule.name=Incubation Module +item.Cells.name=Bacterial Cells +item.PlasmaMembrane.name=Plasma Membrane +labModule.item.DNAExtractionModule.name=DNA Extraction Module +labModule.item.PCRThermoclyclingModule.name=PCR Thermoclycle Module +labModule.item.PlasmidSynthesisModule.name=Plasmid Synthesis Module +labModule.item.TransformationModule.name=Transformation Module +labModule.item.ClonalCellularSynthesisModule.name=Clonal Cellular Synthesis Module +BW_GlasBlocks.0.name=Borosilicate Glass Blocks +BW_GlasBlocks.1.name=Nickel Reinforced Boroilicate GlassBlock +BW_GlasBlocks.2.name=Tungsten Reinforced Boroilicate GlassBlock +BW_GlasBlocks.3.name=Chrome Reinforced Boroilicate GlassBlock +BW_GlasBlocks.4.name=Iridium Reinforced Boroilicate GlassBlock +BW_GlasBlocks.5.name=Osmium Reinforced Boroilicate GlassBlock
\ No newline at end of file diff --git a/src/main/resources/assets/bartworks/textures/GUI/GUI_RSC.png b/src/main/resources/assets/bartworks/textures/GUI/GUI_RSC.png Binary files differnew file mode 100644 index 0000000000..065a6fa929 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/GUI/GUI_RSC.png diff --git a/src/main/resources/assets/bartworks/textures/GUI/RadHatch.png b/src/main/resources/assets/bartworks/textures/GUI/RadHatch.png Binary files differnew file mode 100644 index 0000000000..1950ff0985 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/GUI/RadHatch.png diff --git a/src/main/resources/assets/bartworks/textures/blocks/BoronSilicateGlassBlock.png b/src/main/resources/assets/bartworks/textures/blocks/BoronSilicateGlassBlock.png Binary files differnew file mode 100644 index 0000000000..4ea5e5973f --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/blocks/BoronSilicateGlassBlock.png diff --git a/src/main/resources/assets/bartworks/textures/blocks/BoronSilicateGlassBlockRand.png b/src/main/resources/assets/bartworks/textures/blocks/BoronSilicateGlassBlockRand.png Binary files differnew file mode 100644 index 0000000000..0e27ddbb62 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/blocks/BoronSilicateGlassBlockRand.png diff --git a/src/main/resources/assets/bartworks/textures/blocks/ChromeReinforcedBoronSilicateGlassBlock.png b/src/main/resources/assets/bartworks/textures/blocks/ChromeReinforcedBoronSilicateGlassBlock.png Binary files differnew file mode 100644 index 0000000000..213f8feafd --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/blocks/ChromeReinforcedBoronSilicateGlassBlock.png diff --git a/src/main/resources/assets/bartworks/textures/blocks/IridiumReinforcedBoronSilicateGlassBlock.png b/src/main/resources/assets/bartworks/textures/blocks/IridiumReinforcedBoronSilicateGlassBlock.png Binary files differnew file mode 100644 index 0000000000..9a87942ef9 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/blocks/IridiumReinforcedBoronSilicateGlassBlock.png diff --git a/src/main/resources/assets/bartworks/textures/blocks/NickelReinforcedBoronSilicateGlassBlock.png b/src/main/resources/assets/bartworks/textures/blocks/NickelReinforcedBoronSilicateGlassBlock.png Binary files differnew file mode 100644 index 0000000000..9ab096b467 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/blocks/NickelReinforcedBoronSilicateGlassBlock.png diff --git a/src/main/resources/assets/bartworks/textures/blocks/OsmiumReinforcedBoronSilicateGlassBlock.png b/src/main/resources/assets/bartworks/textures/blocks/OsmiumReinforcedBoronSilicateGlassBlock.png Binary files differnew file mode 100644 index 0000000000..e5be40d5ff --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/blocks/OsmiumReinforcedBoronSilicateGlassBlock.png diff --git a/src/main/resources/assets/bartworks/textures/blocks/TungstenReinforcedBoronSilicateGlassBlock.png b/src/main/resources/assets/bartworks/textures/blocks/TungstenReinforcedBoronSilicateGlassBlock.png Binary files differnew file mode 100644 index 0000000000..b3823b02fc --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/blocks/TungstenReinforcedBoronSilicateGlassBlock.png diff --git a/src/main/resources/assets/bartworks/textures/blocks/brick.png b/src/main/resources/assets/bartworks/textures/blocks/brick.png Binary files differdeleted file mode 100644 index fd6959c2f5..0000000000 --- a/src/main/resources/assets/bartworks/textures/blocks/brick.png +++ /dev/null diff --git a/src/main/resources/assets/bartworks/textures/items/Agarose.png b/src/main/resources/assets/bartworks/textures/items/Agarose.png Binary files differnew file mode 100644 index 0000000000..fe6add0bb0 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/Agarose.png diff --git a/src/main/resources/assets/bartworks/textures/items/ClonalCellularSynthesisModule.png b/src/main/resources/assets/bartworks/textures/items/ClonalCellularSynthesisModule.png Binary files differnew file mode 100644 index 0000000000..a420873554 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/ClonalCellularSynthesisModule.png diff --git a/src/main/resources/assets/bartworks/textures/items/DNAExtractionModule.png b/src/main/resources/assets/bartworks/textures/items/DNAExtractionModule.png Binary files differnew file mode 100644 index 0000000000..99dc1c9b95 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/DNAExtractionModule.png diff --git a/src/main/resources/assets/bartworks/textures/items/DNASampleFlask.png b/src/main/resources/assets/bartworks/textures/items/DNASampleFlask.png Binary files differnew file mode 100644 index 0000000000..69c6c649b9 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/DNASampleFlask.png diff --git a/src/main/resources/assets/bartworks/textures/items/DetergentPowder.png b/src/main/resources/assets/bartworks/textures/items/DetergentPowder.png Binary files differnew file mode 100644 index 0000000000..92fe5e9d81 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/DetergentPowder.png diff --git a/src/main/resources/assets/bartworks/textures/items/IncubationModule.png b/src/main/resources/assets/bartworks/textures/items/IncubationModule.png Binary files differnew file mode 100644 index 0000000000..e0ea17749d --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/IncubationModule.png diff --git a/src/main/resources/assets/bartworks/textures/items/PCRThermoclyclingModule.png b/src/main/resources/assets/bartworks/textures/items/PCRThermoclyclingModule.png Binary files differnew file mode 100644 index 0000000000..c0e5b9a822 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/PCRThermoclyclingModule.png diff --git a/src/main/resources/assets/bartworks/textures/items/PlasmaMembrane.png b/src/main/resources/assets/bartworks/textures/items/PlasmaMembrane.png Binary files differnew file mode 100644 index 0000000000..f51730a7af --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/PlasmaMembrane.png diff --git a/src/main/resources/assets/bartworks/textures/items/PlasmidCell.png b/src/main/resources/assets/bartworks/textures/items/PlasmidCell.png Binary files differnew file mode 100644 index 0000000000..680963b8ab --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/PlasmidCell.png diff --git a/src/main/resources/assets/bartworks/textures/items/PlasmidSynthesisModule.png b/src/main/resources/assets/bartworks/textures/items/PlasmidSynthesisModule.png Binary files differnew file mode 100644 index 0000000000..9c20f554e7 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/PlasmidSynthesisModule.png diff --git a/src/main/resources/assets/bartworks/textures/items/TransformationModule.png b/src/main/resources/assets/bartworks/textures/items/TransformationModule.png Binary files differnew file mode 100644 index 0000000000..36b8a44f4d --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/TransformationModule.png diff --git a/src/main/resources/assets/bartworks/textures/items/petriDish.png b/src/main/resources/assets/bartworks/textures/items/petriDish.png Binary files differnew file mode 100644 index 0000000000..4b151f9be8 --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/petriDish.png diff --git a/src/main/resources/assets/gregtech/textures/GUI/basicmachines/BW.GUI.BioLab.png b/src/main/resources/assets/gregtech/textures/GUI/basicmachines/BW.GUI.BioLab.png Binary files differnew file mode 100644 index 0000000000..fb9c0e113c --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/GUI/basicmachines/BW.GUI.BioLab.png |