diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-09-03 08:56:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-03 08:56:33 +0200 |
commit | e09a824caa76de1f5ae473805e92d10f38ac9f38 (patch) | |
tree | 978f0b29dfc43923b155df14ef4a68b469e2fad3 | |
parent | ad2554e0c3d719eee9ec9537a047ee6e620a3956 (diff) | |
parent | e353a91980806712ef011d542bfb2c64f9f7ba26 (diff) | |
download | GT5-Unofficial-e09a824caa76de1f5ae473805e92d10f38ac9f38.tar.gz GT5-Unofficial-e09a824caa76de1f5ae473805e92d10f38ac9f38.tar.bz2 GT5-Unofficial-e09a824caa76de1f5ae473805e92d10f38ac9f38.zip |
Merge pull request #37 from bartimaeusnek/05NewCircuits
05 new circuits
Former-commit-id: b31934def649c9ac1fd8614f3cf5f177b6740d6b
137 files changed, 5564 insertions, 1553 deletions
diff --git a/build.gradle b/build.gradle index e25c1e8bf7..bd21e845de 100644 --- a/build.gradle +++ b/build.gradle @@ -51,8 +51,6 @@ version = config.majorUpdate+"."+config.minorUpdate+"."+config.buildNumber group= "com.github.bartimaeusnek.bartworks" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "bartworks"+ "[" + config.mc_version + "]" - - minecraft { version = "1.7.10-10.13.4.1614-1.7.10" replaceIn "MainMod.java" @@ -138,8 +136,7 @@ processResources jar { manifest { - attributes 'FMLCorePlugin': 'com.github.bartimaeusnek.ASM.BWCorePlugin', - 'FMLCorePluginContainsFMLMod': 'true' + attributes 'FMLCorePlugin': 'com.github.bartimaeusnek.ASM.BWCorePlugin','FMLCorePluginContainsFMLMod': 'true' } } diff --git a/build.properties b/build.properties index ecc130725e..7daca1c59d 100644 --- a/build.properties +++ b/build.properties @@ -22,9 +22,9 @@ mc_version=1.7.10 majorUpdate=0 -minorUpdate=4 -buildNumber=18 -APIVersion=7 +minorUpdate=5 +buildNumber=1 +APIVersion=8 ic2.version=2.2.828-experimental gregtech.version=5.09.32.36 gregtech.jenkinsbuild=143 diff --git a/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java index d3e3eb727b..f2631564c4 100644 --- a/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java +++ b/src/main/java/com/github/bartimaeusnek/ASM/BWCoreTransformer.java @@ -23,17 +23,12 @@ package com.github.bartimaeusnek.ASM; import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.Launch; -import net.minecraftforge.oredict.OreDictionary; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassWriter; import org.objectweb.asm.tree.*; -import java.io.File; -import java.io.IOException; import java.util.Arrays; import java.util.List; -import java.util.jar.JarFile; import static org.objectweb.asm.Opcodes.*; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java b/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java new file mode 100644 index 0000000000..76612ad404 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/API/INoiseGen.java @@ -0,0 +1,33 @@ +/* + * 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 interface INoiseGen { + + double getNoise(int x, int z); + double[][] getNoiseForRegion(int xStart, int zStart, int xEnd, int zEnd); + void setOctaves(int octaves); + void setFrequency(double freq); + void setSeed(long seed); + void setAmplitude(double amplitude); +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index 297abb2ca2..9a5e86b39c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -25,20 +25,28 @@ package com.github.bartimaeusnek.bartworks; import com.github.bartimaeusnek.bartworks.API.API_REFERENCE; import com.github.bartimaeusnek.bartworks.API.BioObjectAdder; +import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import com.github.bartimaeusnek.bartworks.client.ClientEventHandler.TooltipEventHandler; import com.github.bartimaeusnek.bartworks.client.creativetabs.BioTab; import com.github.bartimaeusnek.bartworks.client.creativetabs.GT2Tab; import com.github.bartimaeusnek.bartworks.client.creativetabs.bartworksTab; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; -import com.github.bartimaeusnek.bartworks.common.loaders.*; +import com.github.bartimaeusnek.bartworks.common.loaders.BioCultureLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.BioLabLoader; +import com.github.bartimaeusnek.bartworks.common.loaders.GTNHBlocks; +import com.github.bartimaeusnek.bartworks.common.loaders.LoaderRegistry; import com.github.bartimaeusnek.bartworks.common.net.BW_Network; import com.github.bartimaeusnek.bartworks.server.EventHandler.ServerEventHandler; import com.github.bartimaeusnek.bartworks.system.log.DebugLog; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitPartLoader; import com.github.bartimaeusnek.bartworks.system.material.ThreadedLoader; import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; -import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.DownTierLoader; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.google.common.collect.ArrayListMultimap; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; @@ -48,23 +56,31 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartedEvent; import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.NetworkRegistry; +import gregtech.api.GregTech_API; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.SubTag; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; +import gregtech.api.objects.GT_ItemStack; +import gregtech.api.util.*; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.IOException; -import java.util.HashSet; +import java.lang.reflect.Field; +import java.util.*; import static com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor.eicMap; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.*; +import static gregtech.api.enums.GT_Values.VN; @Mod( modid = MainMod.MOD_ID, name = MainMod.NAME, version = MainMod.VERSION, @@ -79,21 +95,21 @@ public final class MainMod { public static final String VERSION = "@version@"; public static final String MOD_ID = "bartworks"; public static final String APIVERSION = "@apiversion@"; - public static final Logger LOGGER = LogManager.getLogger(NAME); + public static final Logger LOGGER = LogManager.getLogger(MainMod.NAME); public static final CreativeTabs GT2 = new GT2Tab("GT2C"); public static final CreativeTabs BIO_TAB = new BioTab("BioTab"); public static final CreativeTabs BWT = new bartworksTab("bartworks"); public static final IGuiHandler GH = new GuiHandler(); - @Mod.Instance(MOD_ID) + @Mod.Instance(MainMod.MOD_ID) public static MainMod instance; public static BW_Network BW_Network_instance = new BW_Network(); @Mod.EventHandler public void preInit(FMLPreInitializationEvent preinit) { - if (!(API_REFERENCE.VERSION.equals(APIVERSION))) { - LOGGER.error("Something has loaded an old API. Please contact the Mod authors to update!"); + if (!(API_REFERENCE.VERSION.equals(MainMod.APIVERSION))) { + MainMod.LOGGER.error("Something has loaded an old API. Please contact the Mod authors to update!"); } //fixing BorosilicateGlass... -_-' @@ -111,15 +127,16 @@ public final class MainMod { } } if (ConfigHandler.GTNH) - LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE."); + MainMod.LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE."); if (ConfigHandler.BioLab) { BioCultureLoader bioCultureLoader = new BioCultureLoader(); bioCultureLoader.run(); } if (ConfigHandler.newStuff) { - WerkstoffLoader.INSTANCE.init(); + INSTANCE.init(); Werkstoff.init(); + GregTech_API.sAfterGTPostload.add(new CircuitPartLoader()); } } @@ -127,8 +144,11 @@ public final class MainMod { public void init(FMLInitializationEvent init) { if (FMLCommonHandler.instance().getSide().isClient() && ConfigHandler.tooltips) MinecraftForge.EVENT_BUS.register(new TooltipEventHandler()); - if (FMLCommonHandler.instance().getSide().isServer()) - MinecraftForge.EVENT_BUS.register(new ServerEventHandler()); + if (FMLCommonHandler.instance().getSide().isServer()) { + ServerEventHandler serverEventHandler = new ServerEventHandler(); + MinecraftForge.EVENT_BUS.register(serverEventHandler); +// FMLCommonHandler.instance().bus().register(serverEventHandler); + } new LoaderRegistry().run(); if (ConfigHandler.BioLab) new BioLabLoader().run(); @@ -136,65 +156,311 @@ public final class MainMod { if (ConfigHandler.experimentalThreadedLoader) new ThreadedLoader().runInit(); else - WerkstoffLoader.INSTANCE.runInit(); + INSTANCE.runInit(); } } @Mod.EventHandler public void postInit(FMLPostInitializationEvent postinit) { - NetworkRegistry.INSTANCE.registerGuiHandler(instance, GH); - if (ConfigHandler.BioLab) + NetworkRegistry.INSTANCE.registerGuiHandler(MainMod.instance, MainMod.GH); + if (ConfigHandler.BioLab) { new GTNHBlocks().run(); + for (Map.Entry<BioVatLogicAdder.BlockMetaPair, Byte>pair : BioVatLogicAdder.BioVatGlass.getGlassMap().entrySet()){ + GT_OreDictUnificator.registerOre("blockGlass"+VN[pair.getValue()],new ItemStack(pair.getKey().getBlock(),1,pair.getKey().getaByte())); + } + } + BioObjectAdder.regenerateBioFluids(); if (ConfigHandler.newStuff) { if (ConfigHandler.experimentalThreadedLoader) new ThreadedLoader().run(); else - WerkstoffLoader.INSTANCE.run(); + INSTANCE.run(); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.electricimplosioncompressor","Electric Implosions?"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.electricimplosioncompressor.desc","Basically a giant Hammer that presses Stuff - No more TNT!"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.DEHP","Heat from below!"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.DEHP.desc","Get ALL the thermal energy!"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.CircuitAssemblyLine","Cheaper Circuits?"); + GT_LanguageManager.addStringLocalization("achievement.gt.blockmachines.CircuitAssemblyLine.desc","Well, yes, but actually no..."); } } @Mod.EventHandler public void onServerStarted(FMLServerStartedEvent event) { + MainMod.runOnPlayerJoined(ConfigHandler.classicMode, ConfigHandler.disableExtraGassesForEBF); + } + + public static void runOnPlayerJoined(boolean classicMode, boolean extraGasRecipes){ OreDictHandler.adaptCacheForWorld(); - WerkstoffLoader.removeIC2Recipes(); - this.addElectricImplosionCompressorRecipes(); + removeIC2Recipes(); + MainMod.addElectricImplosionCompressorRecipes(); + MainMod.unificationEnforcer(); + + if (!extraGasRecipes) { + ArrayListMultimap<SubTag, GT_Recipe> toChange = MainMod.getRecipesToChange(NOBLE_GAS, ANAEROBE_GAS); + HashSet<ItemStack> noGas = MainMod.getNoGasItems(toChange); + MainMod.editRecipes(toChange, noGas); + } + new CircuitImprintLoader().run(); + if (classicMode) + new DownTierLoader().run(); } - private void addElectricImplosionCompressorRecipes(){ - if (eicMap == null) { - eicMap = new GT_Recipe.GT_Recipe_Map(new HashSet<GT_Recipe>(GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList.size()), "gt.recipe.electricimplosioncompressor", "Electric Implosion Compressor", (String) null, "gregtech:textures/gui/basicmachines/Default", 1, 2, 1, 0, 1, "", 1, "", true, true); - recipeLoop: - for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList) { - if (recipe == null || recipe.mInputs == null) - continue; - try { - ItemStack input = recipe.mInputs[0]; - int i = 0; - if (this.checkForExplosives(recipe.mInputs[1])) { - continue; + private static void unificationEnforcer() { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashMap.values()) { + if (werkstoff.getGenerationFeatures().enforceUnification) { + if (werkstoff.contains(NOBLE_GAS)){ + String name = werkstoff.getFluidOrGas(1).getFluid().getName(); + String wrongname ="molten."+name; + FluidStack wrongNamedFluid = FluidRegistry.getFluidStack(wrongname,1); + for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) { + for (GT_Recipe recipe : map.mRecipeList) { + for (int i = 0; i < recipe.mFluidInputs.length; i++) { + if (GT_Utility.areFluidsEqual(recipe.mFluidInputs[i], wrongNamedFluid)) { + Collection<GT_Recipe> col = map.mRecipeFluidMap.get(wrongNamedFluid.getFluid()); + map.mRecipeFluidMap.remove(wrongNamedFluid.getFluid()); + map.mRecipeFluidMap.put(werkstoff.getFluidOrGas(1).getFluid(),col); + recipe.mFluidInputs[i] = werkstoff.getFluidOrGas(recipe.mFluidInputs[i].amount); + map.mRecipeFluidNameMap.add(werkstoff.getFluidOrGas(1).getFluid().getName()); + } + } + for (int i = 0; i < recipe.mFluidOutputs.length; i++) { + if (GT_Utility.areFluidsEqual(recipe.mFluidOutputs[i], wrongNamedFluid)) { + recipe.mFluidOutputs[i] = werkstoff.getFluidOrGas(recipe.mFluidOutputs[i].amount); + } + } + } + } + GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.add(new BWRecipes.DynamicGTRecipe(false,null,null,null,null,new FluidStack[]{wrongNamedFluid},new FluidStack[]{werkstoff.getFluidOrGas(1)},1,1,0)); + } + MainMod.runMoltenUnificationEnfocement(werkstoff); + for (OrePrefixes prefixes : OrePrefixes.values()) { + if (OreDictionary.getOres(prefixes + werkstoff.getDefaultName()).size() > 1) { + for (int j = 0; j < OreDictionary.getOres(prefixes + werkstoff.getDefaultName()).size(); j++) { + ItemStack toReplace = OreDictionary.getOres(prefixes + werkstoff.getDefaultName()).get(j); + ItemStack replacement = werkstoff.get(prefixes); + if (GT_Utility.areStacksEqual(toReplace,replacement) || replacement == null || replacement.getItem() == null) + continue; + if (toReplace != null) { + for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) { + HashSet<GT_Recipe> toRem = new HashSet<>(); + for (GT_Recipe recipe : map.mRecipeList) { + boolean removal = map.equals(GT_Recipe.GT_Recipe_Map.sFluidExtractionRecipes) || map.equals(GT_Recipe.GT_Recipe_Map.sFluidSolidficationRecipes); + for (int i = 0; i < recipe.mInputs.length; i++) { + if (GT_Utility.areStacksEqual(recipe.mInputs[i], toReplace)) { + if (removal) + toRem.add(recipe); + else + recipe.mInputs[i] = replacement; + } + } + for (int i = 0; i < recipe.mOutputs.length; i++) { + if (GT_Utility.areStacksEqual(recipe.mOutputs[i], toReplace)) { + if (removal) + toRem.add(recipe); + else + recipe.mOutputs[i] = replacement; + } + } + if (recipe.mSpecialItems instanceof ItemStack) { + if (GT_Utility.areStacksEqual((ItemStack) recipe.mSpecialItems, toReplace)) { + if (removal) + toRem.add(recipe); + else + recipe.mSpecialItems = replacement; + } + } + } + map.mRecipeList.removeAll(toRem); + } + } + } } - while (this.checkForExplosives(input)) { - if (GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("industrialTnt", 1L))) { - i++; - input = recipe.mInputs[i]; + } + } + } + } + + private static void runMoltenUnificationEnfocement(Werkstoff werkstoff){ + if (werkstoff.getGenerationFeatures().enforceUnification && werkstoff.getGenerationFeatures().hasMolten()) { + try { + FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData(new FluidStack(molten.get(werkstoff), 144), werkstoff.get(cellMolten), Materials.Empty.getCells(1)); + Field f = GT_Utility.class.getDeclaredField("sFilledContainerToData"); + f.setAccessible(true); + Map<GT_ItemStack, FluidContainerRegistry.FluidContainerData> sFilledContainerToData = (Map<GT_ItemStack, FluidContainerRegistry.FluidContainerData>) f.get(null); + HashSet torem = new HashSet<>(); + ItemStack toReplace = null; + for (Map.Entry<GT_ItemStack, FluidContainerRegistry.FluidContainerData> entry : sFilledContainerToData.entrySet()) { + if (entry.getValue().fluid.equals(data.fluid) && !entry.getValue().filledContainer.equals(data.filledContainer)) { + toReplace = entry.getValue().filledContainer; + torem.add(entry); + } + } + sFilledContainerToData.entrySet().removeAll(torem); + torem.clear(); + if (toReplace != null) { + for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) { + torem.clear(); + for (GT_Recipe recipe : map.mRecipeList) { + for (int i = 0; i < recipe.mInputs.length; i++) { + if (GT_Utility.areStacksEqual(recipe.mInputs[i], toReplace)) { + torem.add(recipe); + // recipe.mInputs[i] = data.filledContainer; + } + } + for (int i = 0; i < recipe.mOutputs.length; i++) { + if (GT_Utility.areStacksEqual(recipe.mOutputs[i], toReplace)) { + torem.add(recipe); + // recipe.mOutputs[i] = data.filledContainer; + if (map == GT_Recipe.GT_Recipe_Map.sFluidCannerRecipes && GT_Utility.areStacksEqual(recipe.mOutputs[i], data.filledContainer) && !recipe.mFluidInputs[0].equals(data.fluid)) { + torem.add(recipe); + // recipe.mOutputs[i] = data.filledContainer; + } + } + } + if (recipe.mSpecialItems instanceof ItemStack) { + if (GT_Utility.areStacksEqual((ItemStack) recipe.mSpecialItems, toReplace)) { + torem.add(recipe); + // recipe.mSpecialItems = data.filledContainer; + } + } } - else - continue recipeLoop; + map.mRecipeList.removeAll(torem); + } + } + GT_Utility.addFluidContainerData(data); + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) { + e.printStackTrace(); + } + } + } + private static ArrayListMultimap<SubTag,GT_Recipe> getRecipesToChange(SubTag... GasTags){ + Iterator<GT_Recipe> it = GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.iterator(); + ArrayListMultimap<SubTag,GT_Recipe> toAdd = ArrayListMultimap.create(); + while (it.hasNext()) { + GT_Recipe recipe = it.next(); + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) { + String FluidString = recipe.mFluidInputs[0].getFluid().getName().replaceAll("molten", "").replaceAll("fluid", ""); + Materials mat = Materials.get(FluidString.substring(0, 1).toUpperCase() + FluidString.substring(1)); + if (mat != Materials._NULL) { + for (SubTag tag : GasTags){ + if (mat.contains(tag)) { + DebugLog.log("Found EBF Recipe to change, Output:"+ BW_Util.translateGTItemStack(recipe.mOutputs[0])); + toAdd.put(tag, recipe); + } } + } + } + } + return toAdd; + } - eicMap.addRecipe(true, new ItemStack[]{input}, recipe.mOutputs, null, null, null, recipe.mDuration, BW_Util.getMachineVoltageFromTier(10), 0); - } catch (ArrayIndexOutOfBoundsException e) { - MainMod.LOGGER.error("CAUGHT DEFECTIVE IMPLOSION COMPRESSOR RECIPE!"); - e.printStackTrace(); + private static HashSet<ItemStack> getNoGasItems(ArrayListMultimap<SubTag,GT_Recipe> base){ + Iterator<GT_Recipe> it = GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.iterator(); + HashSet<ItemStack> toAdd = new HashSet<>(); + ArrayListMultimap<SubTag,GT_Recipe> repToAdd = ArrayListMultimap.create(); + while (it.hasNext()) { + GT_Recipe recipe = it.next(); + for (SubTag tag : base.keySet()) + recipeLoop: + for (GT_Recipe baseRe : base.get(tag)) { + if (recipe.mInputs.length == baseRe.mInputs.length && recipe.mOutputs.length == baseRe.mOutputs.length) + for (int i = 0; i < recipe.mInputs.length; i++) { + if ((recipe.mFluidInputs == null || recipe.mFluidInputs.length == 0) && BW_Util.checkStackAndPrefix(recipe.mInputs[i]) && BW_Util.checkStackAndPrefix(baseRe.mInputs[i]) && GT_OreDictUnificator.getAssociation(recipe.mInputs[i]).mMaterial.mMaterial.equals(GT_OreDictUnificator.getAssociation(baseRe.mInputs[i]).mMaterial.mMaterial) && GT_Utility.areStacksEqual(recipe.mOutputs[0], baseRe.mOutputs[0])) { + toAdd.add(recipe.mOutputs[0]); + repToAdd.put(tag,recipe); + continue recipeLoop; + } + } + } + } + base.putAll(repToAdd); + return toAdd; + } + + private static void editRecipes(ArrayListMultimap<SubTag,GT_Recipe> base, HashSet<ItemStack> noGas) { + if (GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeFluidNameMap.contains(fluids.get(Oganesson).getName())) + return; + HashSet<GT_Recipe> toAdd = new HashSet<>(); + for (SubTag GasTag : base.keySet()) { + for (GT_Recipe recipe : base.get(GasTag)) { + if (recipe.mFluidInputs != null && recipe.mFluidInputs.length > 0) { + String materialString = recipe.mFluidInputs[0].getFluid().getName().replaceAll("molten", "").replaceAll("fluid", ""); + Materials mat = Materials.get(materialString.substring(0, 1).toUpperCase() + materialString.substring(1)); + if (mat != Materials._NULL) { + for (Werkstoff werkstoff : Werkstoff.werkstoffHashMap.values()) { + if (!werkstoff.contains(GasTag)) + continue; + int time = (int) ((double) recipe.mDuration / 200D * (200D + (werkstoff.getStats().getProtons() >= mat.getProtons() ? (double) mat.getProtons() - (double) werkstoff.getStats().getProtons() : (double) mat.getProtons()*2.75D - (double) werkstoff.getStats().getProtons()))); + toAdd.add(new BWRecipes.DynamicGTRecipe(false, recipe.mInputs, recipe.mOutputs, recipe.mSpecialItems, recipe.mChances, new FluidStack[]{new FluidStack(fluids.get(werkstoff), recipe.mFluidInputs[0].amount)}, recipe.mFluidOutputs, time, recipe.mEUt, recipe.mSpecialValue)); + } + for (Materials materials : Materials.values()) { + if (!materials.contains(GasTag)) + continue; + int time = (int) ((double) recipe.mDuration / 200D * (200D + (materials.getProtons() >= mat.getProtons() ? (double) mat.getProtons() - (double) materials.getProtons() : (double) mat.getProtons()*2.75D - (double) materials.getProtons()))); + toAdd.add(new BWRecipes.DynamicGTRecipe(false, recipe.mInputs, recipe.mOutputs, recipe.mSpecialItems, recipe.mChances, new FluidStack[]{materials.getGas(recipe.mFluidInputs[0].amount)}, recipe.mFluidOutputs, time, recipe.mEUt, recipe.mSpecialValue)); + } + for (ItemStack is : noGas) { + byte circuitConfiguration = 1; + if (GT_Utility.areStacksEqual(is, recipe.mOutputs[0])) { + ArrayList<ItemStack> inputs = new ArrayList<>(recipe.mInputs.length); + for (ItemStack stack : recipe.mInputs) + if (!GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(11), stack) && !GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(14), stack) && !GT_Utility.areStacksEqual(GT_Utility.getIntegratedCircuit(19), stack)) { + if (BW_Util.checkStackAndPrefix(stack)) + circuitConfiguration = (byte) (GT_OreDictUnificator.getAssociation(stack).mPrefix.equals(OrePrefixes.dustSmall) ? 4 : GT_OreDictUnificator.getAssociation(stack).mPrefix.equals(OrePrefixes.dustTiny) ? 9 : 1); + inputs.add(stack); + } + inputs.add(GT_Utility.getIntegratedCircuit(circuitConfiguration)); + toAdd.add(new BWRecipes.DynamicGTRecipe(false, inputs.toArray(new ItemStack[0]), recipe.mOutputs, recipe.mSpecialItems, recipe.mChances, null, recipe.mFluidOutputs, (int) ((double) recipe.mDuration / 200D * (200D + ((double) mat.getProtons() * 2.75D))), recipe.mEUt, recipe.mSpecialValue)); + break; + } + } + } + } + } + GT_Recipe.GT_Recipe_Map.sBlastRecipes.mRecipeList.removeAll(base.get(GasTag)); + } + HashSet<GT_Recipe> duplicates = new HashSet<>(); + for (GT_Recipe recipe : toAdd){ + for (GT_Recipe recipe2 : toAdd){ + if (recipe.mEUt != recipe2.mEUt || recipe.mDuration != recipe2.mDuration || recipe.mSpecialValue != recipe2.mSpecialValue || recipe == recipe2 || recipe.mInputs.length != recipe2.mInputs.length || recipe.mFluidInputs.length != recipe2.mFluidInputs.length) + continue; + boolean isSame = true; + for (int i = 0; i < recipe.mInputs.length; i++) { + if (!GT_Utility.areStacksEqual(recipe.mInputs[i],recipe2.mInputs[i])) + isSame = false; + } + for (int i = 0; i < recipe.mFluidInputs.length; i++) { + if (!GT_Utility.areFluidsEqual(recipe.mFluidInputs[i],recipe2.mFluidInputs[i])) + isSame = false; } + if (isSame) + duplicates.add(recipe2); + } + } + toAdd.removeAll(duplicates); + for (GT_Recipe recipe : toAdd) + GT_Recipe.GT_Recipe_Map.sBlastRecipes.add(recipe); + } + + private static void addElectricImplosionCompressorRecipes() { + if (eicMap == null) { + eicMap = new GT_Recipe.GT_Recipe_Map(new HashSet<GT_Recipe>(GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList.size()), "gt.recipe.electricimplosioncompressor", "Electric Implosion Compressor", (String) null, "gregtech:textures/gui/basicmachines/Default", 1, 2, 1, 0, 1, "", 1, "", true, true); + for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList) { + if (recipe == null || recipe.mInputs == null) + continue; + HashSet<ItemStack> inputs = new HashSet<>(); + for (ItemStack is : recipe.mInputs) + if (!MainMod.checkForExplosives(is)) + inputs.add(is); + eicMap.addRecipe(true, inputs.toArray(new ItemStack[0]), recipe.mOutputs, null, null, null, recipe.mDuration, BW_Util.getMachineVoltageFromTier(10), 0); } } } - private boolean checkForExplosives(ItemStack input) { + private static boolean checkForExplosives(ItemStack input) { return (GT_Utility.areStacksEqual(input, new ItemStack(Blocks.tnt)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("industrialTnt", 1L)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("dynamite", 1L)) || GT_Utility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L))); } -} +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java index 5702c32252..f3590b4e90 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipCache.java @@ -26,7 +26,10 @@ import com.github.bartimaeusnek.bartworks.util.Pair; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; class TooltipCache { private static final HashMap<Pair<Integer, Short>, char[]> cache = new HashMap<>(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java index 72c0db2735..2532357218 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/ClientEventHandler/TooltipEventHandler.java @@ -84,14 +84,14 @@ public class TooltipEventHandler { } } - final Block BLOCK = Block.getBlockFromItem(event.itemStack.getItem()); + Block BLOCK = Block.getBlockFromItem(event.itemStack.getItem()); if (BLOCK != null && BLOCK != Blocks.air) { if (BLOCK instanceof BW_Blocks) { TooltipCache.put(event.itemStack, tooAdd); return; } - final BioVatLogicAdder.BlockMetaPair PAIR = new BioVatLogicAdder.BlockMetaPair(BLOCK, (byte) event.itemStack.getItemDamage()); - final HashMap<BioVatLogicAdder.BlockMetaPair, Byte> GLASSMAP = BioVatLogicAdder.BioVatGlass.getGlassMap(); + BioVatLogicAdder.BlockMetaPair PAIR = new BioVatLogicAdder.BlockMetaPair(BLOCK, (byte) event.itemStack.getItemDamage()); + HashMap<BioVatLogicAdder.BlockMetaPair, Byte> GLASSMAP = BioVatLogicAdder.BioVatGlass.getGlassMap(); if (GLASSMAP.containsKey(PAIR)) { int tier = GLASSMAP.get(PAIR); tooAdd.add( 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 540f597051..8686cee0be 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 @@ -43,7 +43,7 @@ public class GT_GUIContainer_LESU extends GT_GUIContainer { public static final ResourceLocation texture = new ResourceLocation(MainMod.MOD_ID, "textures/GT2/gui/LESU.png"); protected GT_Container_LESU mContainer; - private GT_TileEntity_LESU c; + private final GT_TileEntity_LESU c; public GT_GUIContainer_LESU(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(new GT_Container_LESU(aInventoryPlayer, aTileEntity), GT_GUIContainer_LESU.texture.getResourceDomain()); @@ -52,16 +52,16 @@ public class GT_GUIContainer_LESU extends GT_GUIContainer { } @Override - protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { + protected void drawGuiContainerForegroundLayer(int par1, int par2) { 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(this.c.getBaseMetaTileEntity().getInputAmperage()), 11, 48, 16448255); - if (c.maxEUStore() >= Long.MAX_VALUE - 1) { + this.drawString(this.fontRendererObj, "EU: " + this.mContainer.mEnergy, 11, 16, 16448255); + this.drawString(this.fontRendererObj, "MAX: " + (this.c.getBaseMetaTileEntity().isActive() ? this.mContainer.mOutput + percell : Integer.toString(0)), 11, 24, 16448255); + this.drawString(this.fontRendererObj, "MAX EU/t IN: " + this.mContainer.mInput, 11, 32, 16448255); + this.drawString(this.fontRendererObj, "EU/t OUT: " + this.mContainer.mOutput, 11, 40, 16448255); + this.drawString(this.fontRendererObj, "AMP/t IN/OUT: " + this.c.getBaseMetaTileEntity().getInputAmperage(), 11, 48, 16448255); + if (this.c.maxEUStore() >= Long.MAX_VALUE - 1) { this.drawString(this.fontRendererObj, StatCollector.translateToLocal("tooltip.LESU.0.name"), 11, 56, Color.YELLOW.getRGB()); } if (!this.c.getBaseMetaTileEntity().isActive()) { @@ -71,14 +71,14 @@ public class GT_GUIContainer_LESU extends GT_GUIContainer { } @Override - protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) { + protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - Minecraft.getMinecraft().getTextureManager().bindTexture(texture); - final int x = (this.width - this.xSize) / 2; - final int y = (this.height - this.ySize) / 2; + Minecraft.getMinecraft().getTextureManager().bindTexture(GT_GUIContainer_LESU.texture); + 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 != null) { - final long tScale = this.mContainer.mEnergy / Math.max(1, c.maxEUStore() / 116); + long tScale = this.mContainer.mEnergy / Math.max(1, this.c.maxEUStore() / 116); this.drawTexturedModalRect(x + 8, y + 73, 0, 251, (int) tScale, 5); } } 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 index d214b4b09e..86779b71d0 100644 --- 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 @@ -26,8 +26,6 @@ import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_RadioHatch; import com.github.bartimaeusnek.bartworks.server.container.GT_Container_RadioHatch; -import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; -import com.github.bartimaeusnek.bartworks.util.BW_Util; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.java new file mode 100644 index 0000000000..a59fb87635 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_ItemRenderer.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.client.renderer; + +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_Meta_Items; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_Utility; +import gregtech.common.render.GT_RenderUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderItem; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import org.lwjgl.opengl.GL11; + +@SideOnly(Side.CLIENT) +public class BW_GT_ItemRenderer implements IItemRenderer { + public BW_GT_ItemRenderer() { + for (BW_Meta_Items.BW_GT_MetaGen_Item_Hook tItem : BW_Meta_Items.BW_GT_MetaGen_Item_Hook.sInstances) { + MinecraftForgeClient.registerItemRenderer(tItem, this); + } + + } + + @Override + public boolean handleRenderType(ItemStack aStack, IItemRenderer.ItemRenderType aType) { + if (!GT_Utility.isStackInvalid(aStack) && aStack.getItemDamage() >= 0) { + return aType == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON || aType == IItemRenderer.ItemRenderType.INVENTORY || aType == IItemRenderer.ItemRenderType.EQUIPPED || aType == IItemRenderer.ItemRenderType.ENTITY; + } else { + return false; + } + } + @Override + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType aType, ItemStack aStack, IItemRenderer.ItemRendererHelper aHelper) { + if (GT_Utility.isStackInvalid(aStack)) { + return false; + } else { + return aType == IItemRenderer.ItemRenderType.ENTITY; + } + } + @Override + public void renderItem(IItemRenderer.ItemRenderType type, ItemStack aStack, Object... data) { + if (!GT_Utility.isStackInvalid(aStack)) { + short aMetaData = (short) aStack.getItemDamage(); + if (aMetaData >= 0) { + BW_Meta_Items.BW_GT_MetaGen_Item_Hook aItem = (BW_Meta_Items.BW_GT_MetaGen_Item_Hook) aStack.getItem(); + GL11.glEnable(3042); + if (type == IItemRenderer.ItemRenderType.ENTITY) { + if (RenderItem.renderInFrame) { + GL11.glScalef(0.85F, 0.85F, 0.85F); + GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslated(-0.5D, -0.42D, 0.0D); + } else { + GL11.glTranslated(-0.5D, -0.42D, 0.0D); + } + } + + GL11.glColor3f(1.0F, 1.0F, 1.0F); + IIcon tIcon = (IIcon) BW_Util.get2DCoordFrom1DArray(aMetaData, 0, 2, aItem.mIconList); + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { + if (aMetaData < CircuitImprintLoader.reverseIDs) + GT_RenderUtil.renderItemIcon(tIcon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + else { + for (int i = 0; i < 4; i++) { + GT_RenderUtil.renderItemIcon(tIcon, 0.0D+i*2D,0.0D+i*2D,10.0D+i*2D,10.0D+i*2D, 0.001D, 0.0F, 0.0F, -1.0F); + } + } + } else { + if (aMetaData < CircuitImprintLoader.reverseIDs) + ItemRenderer.renderItemIn2D(Tessellator.instance,tIcon.getMaxU(), tIcon.getMinV(), tIcon.getMinU(), tIcon.getMaxV(), tIcon.getIconWidth(), tIcon.getIconHeight(), 0.0625F); +// else { +// for (int i = 0; i < 4; i++) { +// ItemRenderer.renderItemIn2D(Tessellator.instance, 0.0F+i*2F,0.0F+i*2F,10.0F+i*2F,10.0F+i*2F, tIcon.getIconWidth(), tIcon.getIconHeight(),0.0625F); +// } +// } +// ItemRenderer.renderItemIn2D(Tessellator.instance, tIcon.getMaxU(), tIcon.getMinV(), tIcon.getMinU(), tIcon.getMaxV(), tIcon.getIconWidth(), tIcon.getIconHeight(), 0.0625F); + } + + IIcon tOverlay = (IIcon) BW_Util.get2DCoordFrom1DArray(aMetaData, 1, 2, aItem.mIconList); + GL11.glColor3f(1.0F, 1.0F, 1.0F); + if (tOverlay != null) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (type.equals(IItemRenderer.ItemRenderType.INVENTORY)) { + GT_RenderUtil.renderItemIcon(tOverlay, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D(Tessellator.instance, tOverlay.getMaxU(), tOverlay.getMinV(), tOverlay.getMinU(), tOverlay.getMaxV(), tOverlay.getIconWidth(), tOverlay.getIconHeight(), 0.0625F); + } + } + } + + GL11.glDisable(3042); + } + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java index bb93e0e506..879274d114 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_GT_Vanilla_Texture.java @@ -49,7 +49,7 @@ public class BW_GT_Vanilla_Texture implements IIconContainer { @Override public IIcon getIcon() { - return packed; + return this.packed; } @Override @@ -59,6 +59,6 @@ public class BW_GT_Vanilla_Texture implements IIconContainer { @Override public ResourceLocation getTextureFile() { - return new ResourceLocation(packed.getIconName()); + return new ResourceLocation(this.packed.getIconName()); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java index 7f537b5054..bb5078ebff 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java @@ -25,7 +25,6 @@ package com.github.bartimaeusnek.bartworks.client.renderer; import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGeneratedOreTE; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; -import gregtech.common.render.GT_Renderer_Block; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; @@ -48,27 +47,27 @@ public class BW_Renderer_Block_Ores implements ISimpleBlockRenderingHandler { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 0), true); + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 0), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 1), true); + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 1), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 2), true); + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 2), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 3), true); + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 3), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 4), true); + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 4), true); Tessellator.instance.draw(); Tessellator.instance.startDrawingQuads(); Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing((IBlockAccess) null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 5), true); + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 5), true); Tessellator.instance.draw(); aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); aRenderer.setRenderBoundsFromBlock(aBlock); @@ -77,7 +76,7 @@ public class BW_Renderer_Block_Ores implements ISimpleBlockRenderingHandler { @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { - return GT_Renderer_Block.renderStandardBlock(world, x, y, z, block, renderer); + return renderStandardBlock(world, x, y, z, block, renderer); } @Override @@ -87,6 +86,6 @@ public class BW_Renderer_Block_Ores implements ISimpleBlockRenderingHandler { @Override public int getRenderId() { - return mRenderID; + return this.mRenderID; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java index 423fb20468..82150c7913 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java @@ -90,6 +90,6 @@ public class RendererGlasBlock implements ISimpleBlockRenderingHandler { @Override public int getRenderId() { - return RID; + return RendererGlasBlock.RID; } } 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 9860ec1c41..cf81a296f3 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 @@ -42,7 +42,7 @@ public class BW_Blocks extends Block { @SideOnly(Side.CLIENT) protected IIcon[] texture; - protected String[] textureNames; + String[] textureNames; protected String name; public BW_Blocks(String name, String[] texture) { @@ -73,14 +73,14 @@ public class BW_Blocks extends Block { } @Override - public int damageDropped(final int meta) { + public int damageDropped(int meta) { return meta; } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { - for (int i = 0; i < textureNames.length; i++) { + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < this.textureNames.length; i++) { list.add(new ItemStack(item, 1, i)); } } @@ -88,21 +88,21 @@ public class BW_Blocks extends Block { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { - return meta < texture.length ? texture[meta] : texture[0]; + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { - texture = new IIcon[textureNames.length]; - for (int i = 0; i < textureNames.length; i++) { - texture[i] = par1IconRegister.registerIcon(textureNames[i]); + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); } } @Override public String getUnlocalizedName() { - return name; + return this.name; } @Override 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 index 893afa625f..3d6d3e41b0 100644 --- 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 @@ -36,14 +36,15 @@ import net.minecraftforge.common.util.ForgeDirection; public class BW_GlasBlocks extends BW_Blocks { @SideOnly(Side.CLIENT) - IIcon[] connectedTexture; + private IIcon[] connectedTexture; - boolean connectedTex, fake; - short[][] color = new short[textureNames.length][3]; + private final boolean connectedTex; + private boolean fake; + private short[][] color = new short[this.textureNames.length][3]; public BW_GlasBlocks(String name, String[] texture, CreativeTabs tabs) { super(name, texture, tabs, Material.glass); - connectedTex = false; + this.connectedTex = false; } @@ -55,7 +56,7 @@ public class BW_GlasBlocks extends BW_Blocks { } public short[] getColor(int meta) { - return meta < texture.length ? color[meta] : color[0]; + return meta < this.texture.length ? this.color[meta] : this.color[0]; } @Override @@ -75,25 +76,25 @@ public class BW_GlasBlocks extends BW_Blocks { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { - return meta < texture.length ? texture[meta] : texture[0]; + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { - if (!connectedTex) { - texture = new IIcon[textureNames.length]; - for (int i = 0; i < textureNames.length; i++) { - texture[i] = par1IconRegister.registerIcon(textureNames[i]); + if (!this.connectedTex) { + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); } return; } - texture = new IIcon[textureNames.length]; - connectedTexture = new IIcon[16]; - for (int i = 0; i < textureNames.length; i++) { - texture[i] = par1IconRegister.registerIcon(textureNames[i]); + this.texture = new IIcon[this.textureNames.length]; + this.connectedTexture = new IIcon[16]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); for (int j = 0; j < 16; j++) { - connectedTexture[j] = par1IconRegister.registerIcon(textureNames[0] + "_" + j); + this.connectedTexture[j] = par1IconRegister.registerIcon(this.textureNames[0] + "_" + j); } } } @@ -102,7 +103,7 @@ public class BW_GlasBlocks extends BW_Blocks { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess worldClient, int xCoord, int yCoord, int zCoord, int aSide) { - if (!connectedTex) + if (!this.connectedTex) return super.getIcon(worldClient, xCoord, yCoord, zCoord, aSide); ForgeDirection dir = ForgeDirection.getOrientation(aSide); @@ -170,7 +171,7 @@ public class BW_GlasBlocks extends BW_Blocks { break; } } - return connectedTexture[sides]; + return this.connectedTexture[sides]; } @Override @@ -181,7 +182,7 @@ public class BW_GlasBlocks extends BW_Blocks { @Override public int getRenderType() { - if (!fake && FMLCommonHandler.instance().getSide().isClient()) + if (!this.fake && FMLCommonHandler.instance().getSide().isClient()) return RendererGlasBlock.RID; else return 0; 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 4cc851df67..b6a1ee611d 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 @@ -43,7 +43,6 @@ import net.minecraft.entity.EnumCreatureType; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; @@ -54,7 +53,7 @@ import net.minecraftforge.fluids.IFluidContainerItem; public class BW_TileEntityContainer extends BlockContainer implements ITileAddsInformation { - Class<? extends TileEntity> tileEntity = null; + Class<? extends TileEntity> tileEntity; public BW_TileEntityContainer(Material p_i45386_1_, Class<? extends TileEntity> tileEntity, String blockName) { super(p_i45386_1_); @@ -71,7 +70,7 @@ public class BW_TileEntityContainer extends BlockContainer implements ITileAddsI if (worldObj.isRemote) { return false; } - final TileEntity tile = worldObj.getTileEntity(x, y, z); + TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof BW_TileEntity_HeatedWaterPump) { if (player.getHeldItem() != null && (player.getHeldItem().getItem().equals(Items.bucket) || player.getHeldItem().getItem() instanceof IFluidContainerItem) && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false) != null) if (player.getHeldItem().getItem().equals(Items.bucket) && ((BW_TileEntity_HeatedWaterPump) tile).drain(1000, false).amount == 1000) { @@ -93,14 +92,14 @@ public class BW_TileEntityContainer extends BlockContainer implements ITileAddsI return false; } - 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); + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof IWrenchable && itemStack != null) { - final IWrenchable tile2 = (IWrenchable) tile; + 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; + int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; switch (face) { case 0: tile2.setFacing((short) 2); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java index 112d57de9b..eac3b5fd28 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_TileEntityContainer_Multiple.java @@ -49,9 +49,9 @@ import java.util.List; public class BW_TileEntityContainer_Multiple extends BlockContainer { - final protected String[] textureNames; - final protected String name; - final Class<? extends TileEntity>[] tileEntityArray; + protected final String[] textureNames; + protected final String name; + protected final Class<? extends TileEntity>[] tileEntityArray; @SideOnly(Side.CLIENT) protected IIcon[] texture; @@ -59,8 +59,8 @@ public class BW_TileEntityContainer_Multiple extends BlockContainer { super(p_i45386_1_); this.setHardness(15.0F); this.setResistance(30.0F); - tileEntityArray = tileEntity; - name = blockName; + this.tileEntityArray = tileEntity; + this.name = blockName; this.textureNames = textureNames; this.setCreativeTab(tabs); this.setBlockName(blockName); @@ -73,7 +73,7 @@ public class BW_TileEntityContainer_Multiple extends BlockContainer { return true; } if (!player.isSneaking()) { - final TileEntity tile = worldObj.getTileEntity(x, y, z); + TileEntity tile = worldObj.getTileEntity(x, y, z); if (tile instanceof IHasGui) { return worldObj.isRemote || IC2.platform.launchGui(player, (IHasGui) tile); } else if (tile instanceof ITileWithGUI) { @@ -84,14 +84,14 @@ public class BW_TileEntityContainer_Multiple extends BlockContainer { return false; } - 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); + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemStack) { + TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof IWrenchable && itemStack != null) { - final IWrenchable tile2 = (IWrenchable) tile; + 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; + int face = MathHelper.floor_double(entity.rotationYaw * 4.0f / 360.0f + 0.5) & 0x3; switch (face) { case 0: tile2.setFacing((short) 2); @@ -111,14 +111,14 @@ public class BW_TileEntityContainer_Multiple extends BlockContainer { } @Override - public int damageDropped(final int meta) { + public int damageDropped(int meta) { return meta; } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(final Item item, final CreativeTabs tab, final List list) { - for (int i = 0; i < textureNames.length; i++) { + public void getSubBlocks(Item item, CreativeTabs tab, List list) { + for (int i = 0; i < this.textureNames.length; i++) { list.add(new ItemStack(item, 1, i)); } } @@ -126,15 +126,15 @@ public class BW_TileEntityContainer_Multiple extends BlockContainer { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int meta) { - return meta < texture.length ? texture[meta] : texture[0]; + return meta < this.texture.length ? this.texture[meta] : this.texture[0]; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { - texture = new IIcon[textureNames.length]; - for (int i = 0; i < textureNames.length; i++) { - texture[i] = par1IconRegister.registerIcon(textureNames[i]); + this.texture = new IIcon[this.textureNames.length]; + for (int i = 0; i < this.textureNames.length; i++) { + this.texture[i] = par1IconRegister.registerIcon(this.textureNames[i]); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java new file mode 100644 index 0000000000..ec85e7e1d4 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/ChangeConfig.java @@ -0,0 +1,82 @@ +/* + * 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.commands; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import net.minecraft.command.CommandBase; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import java.lang.reflect.Field; + +public class ChangeConfig extends CommandBase { + @Override + public String getCommandName() { + return "bwcfg"; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "bwcfg <NameOfVariable> <newValue>"; + } + + @Override + public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { + try{ + Field f = ConfigHandler.class.getField(p_71515_2_[0]); + Class c = f.getType(); + if (c.equals(int.class)) { + int l; + try { + l = Integer.parseInt(p_71515_2_[1]); + } catch (NumberFormatException e) { + p_71515_1_.addChatMessage(new ChatComponentText("you need to enter a number!")); + return; + } + f.setInt(null, Integer.parseInt(p_71515_2_[1])); + } + else if (c.equals(long.class)) { + long l; + try{ + l = Long.parseLong(p_71515_2_[1]); + }catch (NumberFormatException e){ + p_71515_1_.addChatMessage(new ChatComponentText("you need to enter a number!")); + return; + } + f.setLong(null, l); + } + else if (c.equals(boolean.class)){ + if (p_71515_2_[1].equalsIgnoreCase("true") || p_71515_2_[1].equalsIgnoreCase("1") ) + f.setBoolean(null,true); + else if (p_71515_2_[1].equalsIgnoreCase("false") || p_71515_2_[1].equalsIgnoreCase("0") ) + f.setBoolean(null,false); + else { + p_71515_1_.addChatMessage(new ChatComponentText("booleans need to be set to true or false")); + return; + } + } + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java index f569d62abe..48f7a6d236 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/commands/SummonRuin.java @@ -35,7 +35,7 @@ public class SummonRuin extends CommandBase { @Override public String getCommandUsage(ICommandSender p_71518_1_) { - return "SummonRuin x z"; + return "SummonRuin <x> <z>"; } @Override 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 index 3ecfd658b3..b5d5d8b972 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/configs/ConfigHandler.java @@ -23,7 +23,8 @@ package com.github.bartimaeusnek.bartworks.common.configs; -import com.github.bartimaeusnek.ASM.BWCoreTransformer;; +import com.github.bartimaeusnek.ASM.BWCoreTransformer; +import gregtech.api.enums.GT_Values; import net.minecraftforge.common.config.Configuration; import java.util.Arrays; @@ -42,7 +43,9 @@ public class ConfigHandler { public static int ross128batier = 3; public static int landerType = 3; public static int ross128bRuinChance = 512; - public static int creativeScannerID = 0; + public static int creativeScannerID; + public static int bioVatMaxParallelBonus = 1000; + public static int cutoffTier = 5; public static long energyPerCell = 1000000L; @@ -50,8 +53,11 @@ public class ConfigHandler { public static boolean BioLab = true; public static boolean Ross128Enabled = true; + public static boolean disableExtraGassesForEBF; + public static boolean disableMagicalForest; public static boolean DEHPDirectSteam; public static boolean teslastaff; + public static boolean classicMode; public static boolean experimentalThreadedLoader; public static boolean GTNH; public static boolean ezmode; @@ -64,17 +70,24 @@ public class ConfigHandler { public ConfigHandler(Configuration C) { ConfigHandler.c = C; + ConfigHandler.classicMode= ConfigHandler.c.get("System", "Enable Classic Mode", false, "Enables the classic Mode (all recipes in normal machines are doable in MV").getBoolean(false); ConfigHandler.creativeScannerID = ConfigHandler.c.get("System", "Creative Debug Scanner", 0, "ID for the Creative Debug Scanner Block").getInt(0); ConfigHandler.tooltips = ConfigHandler.c.get("System", "BartWorksToolTips", true, "If you wish to enable extra tooltips").getBoolean(true); ConfigHandler.IDOffset = ConfigHandler.c.get("System", "ID Offset", 12600, "ID Offset for this mod. This Mod uses " + ConfigHandler.IDU + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS").getInt(12600); - ConfigHandler.energyPerCell = ConfigHandler.c.get("Multiblocks", "energyPerLESUCell", 1000000, "This will set Up the Energy per LESU Cell", 1000000, Integer.MAX_VALUE).getInt(1000000); ConfigHandler.ezmode = ConfigHandler.c.get("System", "Mode switch", false, "If GTNH is Loaded, this will enable easy recipes, if not, it will enable harder recipes.").getBoolean(false); ConfigHandler.teslastaff = ConfigHandler.c.get("System", "Enable Teslastaff", false, "Enables the Teslastaff, an Item used to destroy Electric Armors").getBoolean(false); ConfigHandler.newStuff = !ConfigHandler.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); ConfigHandler.BioLab = !ConfigHandler.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); + ConfigHandler.cutoffTier = ConfigHandler.c.get("System", "Tier to nerf circuits", 5, "This switch sets the lowest unnerfed Circuit Recipe Tier. -1 to disable it completely.").getInt(5); + ConfigHandler.cutoffTier = (ConfigHandler.cutoffTier == -1 ? GT_Values.VN.length : ConfigHandler.cutoffTier); + ConfigHandler.disableExtraGassesForEBF = ConfigHandler.c.get("System", "Disable Extra Gases for EBF", false, "This switch disables extra gas recipes for the EBF, i.e. Xenon instead of Nitrogen").getBoolean(false); + + ConfigHandler.mbWaterperSec = ConfigHandler.c.get("Singleblocks", "mL Water per Sec for the StirlingPump", 150).getInt(150); + + ConfigHandler.energyPerCell = ConfigHandler.c.get("Multiblocks", "energyPerLESUCell", 1000000, "This will set Up the Energy per LESU Cell", 1000000, Integer.MAX_VALUE).getInt(1000000); ConfigHandler.DEHPDirectSteam = ConfigHandler.c.get("Multiblocks", "DEHP Direct Steam Mode", false, "This switch enables the Direct Steam Mode of the DEHP. If enabled it will take in Waterand output steam. If disabled it will Input IC2Coolant and output hot coolant").getBoolean(false); ConfigHandler.megaMachinesMax = ConfigHandler.c.get("Multiblocks", "Mega Machines Maximum Recipes per Operation", 256, "This changes the Maximum Recipes per Operation to the specified Valure").getInt(256); - ConfigHandler.mbWaterperSec = ConfigHandler.c.get("Singleblocks", "mL Water per Sec for the StirlingPump", 150).getInt(150); + ConfigHandler.bioVatMaxParallelBonus = ConfigHandler.c.get("Multiblocks","BioVat Maximum Bonus on Recipes", 1000,"This are the maximum parallel Operations the BioVat can do, when the output is half full.").getInt(1000); if (ConfigHandler.IDOffset == 0) { ConfigHandler.IDOffset = 12600; ConfigHandler.c.get("System", "ID Offset", 12600, "ID Offset for this mod. This Mod uses " + ConfigHandler.IDU + " IDs. DO NOT CHANGE IF YOU DONT KNOW WHAT THIS IS").set(12600); @@ -87,7 +100,6 @@ public class ConfigHandler { } ConfigHandler.enabledPatches = new boolean[BWCoreTransformer.shouldTransform.length]; ConfigHandler.enabledPatches = Arrays.copyOf(BWCoreTransformer.shouldTransform,BWCoreTransformer.shouldTransform.length); - ConfigHandler.ross128BID = ConfigHandler.c.get("CrossMod Interactions", "DimID - Ross128b", -64, "The Dim ID for Ross128b").getInt(-64); ConfigHandler.ross128BAID = ConfigHandler.c.get("CrossMod Interactions", "DimID - Ross128ba", -63, "The Dim ID for Ross128ba (Ross128b's Moon)").getInt(-63); ConfigHandler.ross128btier = ConfigHandler.c.get("CrossMod Interactions", "Rocket Tier - Ross128b", 3, "The Rocket Tier for Ross128b").getInt(3); @@ -95,6 +107,8 @@ public class ConfigHandler { ConfigHandler.ross128bRuinChance = ConfigHandler.c.get("CrossMod Interactions", "Ruin Chance - Ross128b", 512, "Higher Values mean lesser Ruins.").getInt(512); ConfigHandler.Ross128Enabled = ConfigHandler.c.get("CrossMod Interactions", "Galacticraft - Activate Ross128 System", true, "If the Ross128 System should be activated").getBoolean(true); ConfigHandler.landerType = ConfigHandler.c.get("CrossMod Interactions", "LanderType", 3, "1 = Moon Lander, 2 = Landing Balloons, 3 = Asteroid Lander").getInt(3); + ConfigHandler.disableMagicalForest = ConfigHandler.c.get("CrossMod Interactions", "Disable Magical Forest - Ross128b", false, "True disables the magical Forest Biome on Ross for more performance during World generation.").getBoolean(false); + ConfigHandler.setUpComments(); if (ConfigHandler.c.hasChanged()) @@ -103,8 +117,8 @@ public class ConfigHandler { private static void setUpComments() { ConfigHandler.c.addCustomCategoryComment("ASM fixes", "Disable ASM fixes here."); - ConfigHandler.c.addCustomCategoryComment("Multiblocks", "Multliblock Options can be set here."); ConfigHandler.c.addCustomCategoryComment("Singleblocks", "Singleblock Options can be set here."); + ConfigHandler.c.addCustomCategoryComment("Multiblocks", "Multliblock Options can be set here."); ConfigHandler.c.addCustomCategoryComment("System", "Different System Settings can be set here."); ConfigHandler.c.addCustomCategoryComment("CrossMod Interactions", "CrossMod Interaction Settings can be set here. For Underground Fluid settings change the Gregtech.cfg!"); } 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 86ea3198eb..db5a66173f 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 @@ -44,10 +44,10 @@ import java.util.List; public class BW_ItemBlocks extends ItemBlock { - 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!"); + private final String mNoMobsToolTip = GT_LanguageManager.addStringLocalization("gt.nomobspawnsonthisblock", "Mobs cannot Spawn on this Block"); + private final String mNoTileEntityToolTip = GT_LanguageManager.addStringLocalization("gt.notileentityinthisblock", "This is NOT a TileEntity!"); - public BW_ItemBlocks(final Block par1) { + public BW_ItemBlocks(Block par1) { super(par1); this.setMaxDamage(0); this.setHasSubtypes(true); @@ -55,18 +55,18 @@ public class BW_ItemBlocks extends ItemBlock { } @Override - public int getMetadata(final int aMeta) { + public int getMetadata(int aMeta) { return aMeta; } @Override - public String getUnlocalizedName(final ItemStack aStack) { + public String getUnlocalizedName(ItemStack aStack) { return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); } @Override @SideOnly(Side.CLIENT) - public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { if (this.field_150939_a instanceof BW_GlasBlocks) aList.add(StatCollector.translateToLocal("tooltip.glas.0.name") + " " + BW_ColorUtil.getColorForTier(BW_Util.getTierFromGlasMeta(aStack.getItemDamage())) + GT_Values.VN[BW_Util.getTierFromGlasMeta(aStack.getItemDamage())]); if (this.field_150939_a instanceof ITileAddsInformation) { @@ -90,7 +90,7 @@ public class BW_ItemBlocks extends ItemBlock { @Override @SideOnly(Side.CLIENT) public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { - return getIcon(stack, renderPass); + return this.getIcon(stack, renderPass); } @Override 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 f67a912aee..6c11a9be64 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 @@ -44,13 +44,13 @@ import static ic2.api.item.IKineticRotor.GearboxType.WIND; public class BW_Stonage_Rotors extends Item implements IKineticRotor { - private int[] DiaMinMax = new int[3]; - private float eff; - private GearboxType type; - private ResourceLocation tex; - private String itemTex; + private final int[] DiaMinMax = new int[3]; + private final float eff; + private final IKineticRotor.GearboxType type; + private final ResourceLocation tex; + private final String itemTex; - public BW_Stonage_Rotors(int diameter, float eff, int min, int max, int durability, GearboxType type, ResourceLocation tex, String Name, String itemTex) { + public BW_Stonage_Rotors(int diameter, float eff, int min, int max, int durability, IKineticRotor.GearboxType type, ResourceLocation tex, String Name, String itemTex) { this.DiaMinMax[0] = diameter; this.DiaMinMax[1] = min; this.DiaMinMax[2] = max; @@ -65,12 +65,12 @@ public class BW_Stonage_Rotors extends Item implements IKineticRotor { @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon(MainMod.MOD_ID + ":" + itemTex); + this.itemIcon = iconRegister.registerIcon(MainMod.MOD_ID + ":" + this.itemTex); } public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) { info.add(StatCollector.translateToLocalFormatted("ic2.itemrotor.wind.info", this.DiaMinMax[1], this.DiaMinMax[2])); - GearboxType type = null; + IKineticRotor.GearboxType type = null; if (Minecraft.getMinecraft().currentScreen instanceof GuiWaterKineticGenerator) { type = WATER; } else if (Minecraft.getMinecraft().currentScreen instanceof GuiWindKineticGenerator) { @@ -111,7 +111,7 @@ public class BW_Stonage_Rotors extends Item implements IKineticRotor { } @Override - public boolean isAcceptedType(ItemStack itemStack, GearboxType gearboxType) { + public boolean isAcceptedType(ItemStack itemStack, IKineticRotor.GearboxType gearboxType) { return gearboxType.equals(this.type); } } 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 c3491ca6f3..136ccb27b5 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 @@ -69,13 +69,13 @@ public class Circuit_Programmer extends GT_Generic_Item implements IElectricItem @SideOnly(Side.CLIENT) public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { + if (this.getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); itemList.add(charged); } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); } } 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 f744be70b7..5d5f8b790c 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 @@ -51,36 +51,36 @@ import java.util.List; import java.util.Set; 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; + private static Set mineableBlocks = Sets.newHashSet(Blocks.stone, Blocks.cobblestone, Blocks.sand, Blocks.clay); + private final int mCharge; + private final int mTransfer; public int mTier; @SideOnly(Side.CLIENT) private IIcon icon; - private int multi; + private final int multi; public GT_Rockcutter_Item(int aTier) { - super(2 * aTier, ToolMaterial.EMERALD, mineableBlocks); + super(2 * aTier, Item.ToolMaterial.EMERALD, GT_Rockcutter_Item.mineableBlocks); this.mTier = aTier; - multi = (int) Math.pow(10, (mTier - 1)); - this.mineableBlocks = new HashSet(); + this.multi = (int) Math.pow(10, (this.mTier - 1)); + GT_Rockcutter_Item.mineableBlocks = new HashSet(); this.maxStackSize = 1; - this.mCharge = 10000 * multi; - this.mTransfer = (int) GT_Values.V[mTier]; - this.efficiencyOnProperMaterial = 2.0f * mTier; + this.mCharge = 10000 * this.multi; + this.mTransfer = (int) GT_Values.V[this.mTier]; + this.efficiencyOnProperMaterial = 2.0f * this.mTier; this.setCreativeTab(MainMod.GT2); - this.setMaxDamage(27 + 10 * multi); + this.setMaxDamage(27 + 10 * this.multi); this.setNoRepair(); - this.setUnlocalizedName("GT_Rockcutter_Item_" + GT_Values.VN[mTier]); + this.setUnlocalizedName("GT_Rockcutter_Item_" + GT_Values.VN[this.mTier]); } - public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, final List aList, final boolean aF3_H) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { aList.add(StatCollector.translateToLocal("tooltip.bw.tier.name") + " " + GT_Values.VN[this.mTier]); aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + 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 * this.multi)) { if (aStack.isItemEnchanted()) { aStack.getTagCompound().removeTag("ench"); } @@ -94,10 +94,10 @@ public class GT_Rockcutter_Item extends ItemTool implements IElectricItem { 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) { + public boolean onBlockDestroyed(ItemStack var1, World var2, Block var3, int var4, int var5, int var6, EntityLivingBase var7) { ElectricItem.manager.use(var1, 0, var7); - if (ElectricItem.manager.canUse(var1, 500 * multi)) { - ElectricItem.manager.use(var1, 500 * multi, var7); + if (ElectricItem.manager.canUse(var1, 500 * this.multi)) { + ElectricItem.manager.use(var1, 500 * this.multi, var7); } else { ElectricItem.manager.discharge(var1, Integer.MAX_VALUE, Integer.MAX_VALUE, true, true, false); } @@ -106,19 +106,19 @@ public class GT_Rockcutter_Item extends ItemTool implements IElectricItem { @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) || mineableBlocks.contains(par1Block); } @SideOnly(Side.CLIENT) public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { + if (this.getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); itemList.add(charged); } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); } } 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 4a25b7e951..b45b831bae 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 @@ -45,15 +45,15 @@ import java.util.List; import java.util.Set; public class GT_Teslastaff_Item extends ItemTool implements IElectricItem { - private static Set effective = Sets.newHashSet(Blocks.web); - public double mCharge; - public double mTransfer; + private static final Set effective = Sets.newHashSet(Blocks.web); + private final double mCharge; + private final double mTransfer; public int mTier; @SideOnly(Side.CLIENT) private IIcon icon; public GT_Teslastaff_Item() { - super(0, ToolMaterial.GOLD, effective); + super(0, Item.ToolMaterial.GOLD, GT_Teslastaff_Item.effective); this.setCreativeTab(MainMod.GT2); this.setNoRepair(); this.mCharge = 10000000D; @@ -65,15 +65,15 @@ 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) { + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { aList.add(StatCollector.translateToLocal("tooltip.teslastaff.0.name")); aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + 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; + EntityLiving tTarget = (EntityLiving) aTarget; + EntityLivingBase tPlayer = 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) { @@ -87,13 +87,13 @@ public class GT_Teslastaff_Item extends ItemTool implements IElectricItem { @SideOnly(Side.CLIENT) public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List itemList) { ItemStack itemStack = new ItemStack(this, 1); - if (getChargedItem(itemStack) == this) { + if (this.getChargedItem(itemStack) == this) { ItemStack charged = new ItemStack(this, 1); ElectricItem.manager.charge(charged, Integer.MAX_VALUE, Integer.MAX_VALUE, true, false); itemList.add(charged); } - if (getEmptyItem(itemStack) == this) { - itemList.add(new ItemStack(this, 1, getMaxDamage())); + if (this.getEmptyItem(itemStack) == this) { + itemList.add(new ItemStack(this, 1, this.getMaxDamage())); } } 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 c38be6c6c0..ab19b5d967 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 @@ -29,15 +29,15 @@ import net.minecraft.item.Item; public class SimpleIconItem extends Item { - String tex; + private final String tex; public SimpleIconItem(String tex) { - super(); this.tex = tex; } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - itemIcon = iconRegister.registerIcon("bartworks:" + tex); + this.itemIcon = iconRegister.registerIcon("bartworks:" + this.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 8c6d810869..3d312d6e37 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 @@ -49,9 +49,9 @@ public class SimpleSubItemClass extends Item { @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - itemIcon = new IIcon[tex.length]; - for (int i = 0; i < tex.length; i++) { - itemIcon[i] = iconRegister.registerIcon(MainMod.MOD_ID + ":" + tex[i]); + this.itemIcon = new IIcon[this.tex.length]; + for (int i = 0; i < this.tex.length; i++) { + this.itemIcon[i] = iconRegister.registerIcon(MainMod.MOD_ID + ":" + this.tex[i]); } } @@ -64,21 +64,21 @@ public class SimpleSubItemClass extends Item { @Override public void getSubItems(Item p_150895_1_, CreativeTabs p_150895_2_, List p_150895_3_) { - for (int i = 0; i < tex.length; i++) { + for (int i = 0; i < this.tex.length; i++) { p_150895_3_.add(new ItemStack(p_150895_1_, 1, i)); } } @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int p_77617_1_) { - if (p_77617_1_ < tex.length) + if (p_77617_1_ < this.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) + if (p_77667_1_.getItemDamage() < this.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/BeforeGTPreload.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.java new file mode 100644 index 0000000000..de0e57a138 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BeforeGTPreload.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.loaders; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.items.BW_ItemBlocks; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_RotorBlock; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_ExperimentalFloodGate; +import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_OreDictUnificator; +import ic2.core.Ic2Items; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.lang.reflect.Field; + +import static com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler.newStuff; + +public class BeforeGTPreload implements Runnable { + @Override + public void run() { + Field fieldModController = FieldUtils.getDeclaredField(Loader.class,"modController",true); + LoadController modController = null; + try { + modController = (LoadController) fieldModController.get(Loader.instance()); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance().exitJava(-1,true); + } + ModContainer bartworks = null; + ModContainer gregtech = null; + assert modController != null; + for (ModContainer mod : modController.getActiveModList()){ + if (mod.getModId().equals(MainMod.MOD_ID)) { + bartworks = mod; + } + if (mod.getModId().equals("gregtech")) + gregtech=mod; + if (bartworks!= null && gregtech != null) + break; + } + if (bartworks == null || gregtech == null) + FMLCommonHandler.instance().exitJava(-1,true); + Field activeContainer = FieldUtils.getDeclaredField(LoadController.class,"activeContainer",true); + + try { + activeContainer.set(modController,bartworks); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance().exitJava(-1,true); + } + + if (newStuff) { + GameRegistry.registerBlock(ItemRegistry.bw_glasses[0], BW_ItemBlocks.class, "BW_GlasBlocks"); + GameRegistry.registerBlock(ItemRegistry.bw_fake_glasses, "BW_FakeGlasBlock"); + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[2], BW_ItemBlocks.class, "BW_Machinery_Casings"); + GameRegistry.registerItem(ItemRegistry.LEATHER_ROTOR, "BW_LeatherRotor"); + GameRegistry.registerItem(ItemRegistry.WOOL_ROTOR, "BW_WoolRotor"); + GameRegistry.registerItem(ItemRegistry.PAPER_ROTOR, "BW_PaperRotor"); + GameRegistry.registerItem(ItemRegistry.COMBINED_ROTOR, "BW_CombinedRotor"); + GameRegistry.registerItem(ItemRegistry.CRAFTING_PARTS, "craftingParts"); + GameRegistry.registerTileEntity(BW_RotorBlock.class, "BWRotorBlockTE"); + GameRegistry.registerBlock(ItemRegistry.ROTORBLOCK, BW_ItemBlocks.class, "BWRotorBlock"); + GameRegistry.registerTileEntity(BW_TileEntity_HeatedWaterPump.class, "BWHeatedWaterPumpTE"); + GameRegistry.registerBlock(ItemRegistry.PUMPBLOCK, BW_ItemBlocks.class, "BWHeatedWaterPumpBlock"); + GameRegistry.registerItem(ItemRegistry.PUMPPARTS, "BWPumpParts"); + GameRegistry.registerItem(ItemRegistry.WINDMETER, "BW_SimpleWindMeter"); + GameRegistry.registerTileEntity(BW_TileEntity_ExperimentalFloodGate.class, "BWExpReversePump"); + GameRegistry.registerBlock(ItemRegistry.EXPPUMP, BW_ItemBlocks.class, "BWExpReversePumpBlock"); + } + + //GT2 stuff + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[0], BW_ItemBlocks.class, "BW_ItemBlocks"); + GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[1], BW_ItemBlocks.class, "GT_LESU_CASING"); + if (ConfigHandler.teslastaff) + GameRegistry.registerItem(ItemRegistry.TESLASTAFF, ItemRegistry.TESLASTAFF.getUnlocalizedName()); + + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_LV, ItemRegistry.ROCKCUTTER_LV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_MV, ItemRegistry.ROCKCUTTER_MV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_HV, ItemRegistry.ROCKCUTTER_HV.getUnlocalizedName()); + GameRegistry.registerItem(ItemRegistry.TAB, "tabIconGT2"); + + OreDictionary.registerOre("blockGlassHV",new ItemStack(Blocks.glass,1,Short.MAX_VALUE)); + OreDictionary.registerOre("blockGlassHV",new ItemStack(ItemRegistry.bw_glasses[0],1,0)); + OreDictionary.registerOre("blockGlassEV", Ic2Items.reinforcedGlass); + OreDictionary.registerOre("blockGlassEV",new ItemStack(ItemRegistry.bw_glasses[0],1,1)); + OreDictionary.registerOre("blockGlassIV",new ItemStack(ItemRegistry.bw_glasses[0],1,2)); + OreDictionary.registerOre("blockGlassIV",new ItemStack(ItemRegistry.bw_glasses[0],1,12)); + OreDictionary.registerOre("blockGlassLuV",new ItemStack(ItemRegistry.bw_glasses[0],1,3)); + OreDictionary.registerOre("blockGlassZPM",new ItemStack(ItemRegistry.bw_glasses[0],1,4)); + OreDictionary.registerOre("blockGlassUV",new ItemStack(ItemRegistry.bw_glasses[0],1,5)); + + try { + activeContainer.set(modController,gregtech); + } catch (IllegalAccessException e) { + e.printStackTrace(); + FMLCommonHandler.instance().exitJava(-1,true); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java index 78ff73554f..57a9ee9aac 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioCultureLoader.java @@ -38,20 +38,22 @@ public class BioCultureLoader implements Runnable { 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); + private static final BioDNA BIO_DNA_ANAEROBIC_OIL = BioDNA.createAndRegisterBioDNA("Pseudomonas Veronii", EnumRarity.uncommon); + private static final BioData BIO_DATA_ANAEROBIC_OIL = BioData.createAndRegisterBioData("Pseudomonas Veronii", EnumRarity.uncommon, 5000, 1); public static BioCulture CommonYeast; public static BioCulture WhineYeast; public static BioCulture BeerYeast; public static BioCulture rottenFleshBacteria; public static BioCulture eColi; - + public static BioCulture anaerobicOil; @Override public void run() { - 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); - + BioCultureLoader.CommonYeast = BioCulture.createAndRegisterBioCulture(new Color(255, 248, 200), "Saccharomyces cerevisiae", BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DATA_YEAST), BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_YEAST), true); + BioCultureLoader.WhineYeast = BioCulture.createAndRegisterBioCulture(new Color(255, 248, 200), "Saccharomyces cerevisiae var bayanus", BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DATA_YEAST), BioCultureLoader.BIO_DNA_WHINE_YEAST, true); + BioCultureLoader.BeerYeast = BioCulture.createAndRegisterBioCulture(new Color(255, 248, 200), "Saccharomyces cerevisiae var cerevisiae", BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DATA_YEAST), BioCultureLoader.BIO_DNA_BEER_YEAST, true); + BioCultureLoader.rottenFleshBacteria = BioCulture.createAndRegisterBioCulture(new Color(110, 40, 25), "Escherichia cadaver", BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DATA_BETA_LACMATASE), BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_BETA_LACMATASE), false); + BioCultureLoader.eColi = BioCulture.createAndRegisterBioCulture(new Color(149, 132, 75), "Escherichia koli", BioPlasmid.convertDataToPlasmid(BioCultureLoader.eColiData), BioDNA.convertDataToDNA(BioCultureLoader.eColiData), true); + BioCultureLoader.anaerobicOil = BioCulture.createAndRegisterBioCulture(new Color(0, 0, 0), "Pseudomonas Veronii", BioPlasmid.convertDataToPlasmid(BioCultureLoader.BIO_DNA_ANAEROBIC_OIL), BioDNA.convertDataToDNA(BioCultureLoader.BIO_DATA_ANAEROBIC_OIL), 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 index 590cc6048d..7968e2996c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioItemList.java @@ -40,18 +40,18 @@ public class BioItemList { 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)}; + public static final ItemStack[] mBioLabParts = {new ItemStack(BioItemList.mItemBioLabParts), new ItemStack(BioItemList.mItemBioLabParts, 1, 1), new ItemStack(BioItemList.mItemBioLabParts, 1, 2), new ItemStack(BioItemList.mItemBioLabParts, 1, 3), new ItemStack(BioItemList.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.registerItem(BioItemList.mItemBioLabParts, "BioLabModules"); + GameRegistry.registerItem(BioItemList.vanillaBioLabParts, "BioLabParts"); } public static Collection<ItemStack> getAllPetriDishes() { HashSet<ItemStack> ret = new HashSet<>(); for (BioCulture Culture : BioCulture.BIO_CULTURE_ARRAY_LIST) { - ret.add(getPetriDish(Culture)); + ret.add(BioItemList.getPetriDish(Culture)); } return ret; } @@ -59,7 +59,7 @@ public class BioItemList { public static Collection<ItemStack> getAllDNASampleFlasks() { HashSet<ItemStack> ret = new HashSet<>(); for (BioData dna : BioData.BIO_DATA_ARRAY_LIST) { - ret.add(getDNASampleFlask(BioDNA.convertDataToDNA(dna))); + ret.add(BioItemList.getDNASampleFlask(BioDNA.convertDataToDNA(dna))); } return ret; } @@ -67,32 +67,32 @@ public class BioItemList { public static Collection<ItemStack> getAllPlasmidCells() { HashSet<ItemStack> ret = new HashSet<>(); for (BioData dna : BioData.BIO_DATA_ARRAY_LIST) { - ret.add(getPlasmidCell(BioPlasmid.convertDataToPlasmid(dna))); + ret.add(BioItemList.getPlasmidCell(BioPlasmid.convertDataToPlasmid(dna))); } return ret; } public static ItemStack getPetriDish(BioCulture Culture) { if (Culture == null) - return new ItemStack(vanillaBioLabParts); - ItemStack ret = new ItemStack(vanillaBioLabParts); + return new ItemStack(BioItemList.vanillaBioLabParts); + ItemStack ret = new ItemStack(BioItemList.vanillaBioLabParts); ret.setTagCompound(BioCulture.getNBTTagFromCulture(Culture)); return ret; } public static ItemStack getDNASampleFlask(BioDNA dna) { if (dna == null) - return new ItemStack(vanillaBioLabParts, 1, 1); + return new ItemStack(BioItemList.vanillaBioLabParts, 1, 1); - ItemStack ret = new ItemStack(vanillaBioLabParts, 1, 1); + ItemStack ret = new ItemStack(BioItemList.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); + return new ItemStack(BioItemList.vanillaBioLabParts, 1, 2); + ItemStack ret = new ItemStack(BioItemList.vanillaBioLabParts, 1, 2); ret.setTagCompound(BioData.getNBTTagFromBioData(plasmid)); return ret; } @@ -111,6 +111,6 @@ public class BioItemList { if (selection < 1 || selection > 4) return null; - return new ItemStack(vanillaBioLabParts, 1, 2 + selection); + return new ItemStack(BioItemList.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 index 4f862ba6a9..dbb060700a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioLabLoader.java @@ -25,16 +25,16 @@ package com.github.bartimaeusnek.bartworks.common.loaders; public class BioLabLoader implements Runnable { - FluidLoader fluidLoader; - BioItemList bioItemList; - BioRecipeLoader bioRecipeLoader; + private FluidLoader fluidLoader; + private BioItemList bioItemList; + private BioRecipeLoader bioRecipeLoader; @Override public void run() { - fluidLoader = new FluidLoader(); - fluidLoader.run(); - bioItemList = new BioItemList(); - bioRecipeLoader = new BioRecipeLoader(); - bioRecipeLoader.run(); + this.fluidLoader = new FluidLoader(); + this.fluidLoader.run(); + this.bioItemList = new BioItemList(); + this.bioRecipeLoader = new BioRecipeLoader(); + this.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 index fab53818a7..7d5409bf00 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/BioRecipeLoader.java @@ -312,6 +312,16 @@ public class BioRecipeLoader extends RecipeLoader { BW_Util.STANDART ); + BWRecipes.instance.addBioLabRecipeIncubation( + new ItemStack(Blocks.dirt), + BioCultureLoader.anaerobicOil, + new int[]{100}, + new FluidStack[]{fluidStack}, + 1500, + BW_Util.getMachineVoltageFromTier(4), + BW_Util.STANDART + ); + BWRecipes.instance.addBacterialVatRecipe( new ItemStack[]{new ItemStack(Items.sugar, 64)}, new FluidStack[]{new FluidStack(fluidStack, 100)}, @@ -357,5 +367,17 @@ public class BioRecipeLoader extends RecipeLoader { 400, BW_Util.getMachineVoltageFromTier(1) ); + + BWRecipes.instance.addBacterialVatRecipe( + null, + new FluidStack[]{Materials.FermentedBiomass.getFluid(10000)}, + BioCultureLoader.anaerobicOil, + new FluidStack[]{new FluidStack(FluidLoader.fulvicAcid,1000)}, + 2748, + BW_Util.getMachineVoltageFromTier(3) + ); + GT_Values.RA.addFluidHeaterRecipe(GT_Utility.getIntegratedCircuit(10),new FluidStack(FluidLoader.fulvicAcid,1000),new FluidStack(FluidLoader.heatedfulvicAcid,1000),90, BW_Util.getMachineVoltageFromTier(2)); + GT_Values.RA.addChemicalRecipe(GT_Utility.getIntegratedCircuit(10),null,new FluidStack(FluidLoader.heatedfulvicAcid,1000),new FluidStack(FluidLoader.Kerogen,1000),null,75, BW_Util.getMachineVoltageFromTier(2)); + GT_Values.RA.addPyrolyseRecipe(Materials.Wood.getDust(10),new FluidStack(FluidLoader.Kerogen,1000),10,null,Materials.Oil.getFluid(1000),105, BW_Util.getMachineVoltageFromTier(3)); } -} +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java index 8285eb9789..5fa6e23213 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java @@ -43,6 +43,7 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; +import java.awt.*; import java.util.Arrays; public class FluidLoader implements Runnable { @@ -54,23 +55,29 @@ public class FluidLoader implements Runnable { public static Fluid[] BioLabFluidMaterials; public static ItemStack[] BioLabFluidCells; + //OilProcessing chain + public static Fluid fulvicAcid,heatedfulvicAcid,Kerogen; + @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[]{ + FluidLoader.fulvicAcid = FluidLoader.createAndRegisterFluid("Fulvic Acid", new Color(20, 20, 20)); + FluidLoader.heatedfulvicAcid = FluidLoader.createAndRegisterFluid("Heated Fulvic Acid", new Color(40, 20, 20),720); + FluidLoader.Kerogen = FluidLoader.createAndRegisterFluid("Kerogen", new Color(85, 85, 85)); + FluidLoader.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)); + FluidLoader.BioLabFluidCells = new ItemStack[FluidLoader.BioLabFluidMaterials.length]; + for (int i = 0; i < FluidLoader.BioLabFluidMaterials.length; i++) { + FluidRegistry.registerFluid(FluidLoader.BioLabFluidMaterials[i]); + FluidLoader.BioLabFluidCells[i] = ItemFluidCell.getUniversalFluidCell(new FluidStack(FluidLoader.BioLabFluidMaterials[i], 1000)); } // BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).setFluid(new GT_Fluid("_NULL", "molten.autogenerated", BW_Util.splitColorToRBGArray(BioCulture.BIO_CULTURE_ARRAY_LIST.get(0).getColorRGB()))); @@ -83,12 +90,24 @@ public class FluidLoader implements Runnable { } } - bioFluidBlock = new BioFluidBlock(); - GameRegistry.registerBlock(bioFluidBlock, "coloredFluidBlock"); + FluidLoader.bioFluidBlock = new BioFluidBlock(); + GameRegistry.registerBlock(FluidLoader.bioFluidBlock, "coloredFluidBlock"); GameRegistry.registerTileEntity(BWTileEntityDimIDBridge.class, "bwTEDimIDBridge"); if (FMLCommonHandler.instance().getSide().isClient()) { RenderingRegistry.registerBlockHandler(RendererSwitchingColorFluid.instance); RenderingRegistry.registerBlockHandler(RendererGlasBlock.instance); } } + + public static Fluid createAndRegisterFluid(String Name,Color color){ + Fluid f = new GT_Fluid(Name,"molten.autogenerated",new short[]{(short) color.getRed(),(short) color.getGreen(),(short) color.getBlue(), (short) color.getAlpha()}); + FluidRegistry.registerFluid(f); + return f; + } + public static Fluid createAndRegisterFluid(String Name, Color color, int temperature){ + Fluid f = new GT_Fluid(Name,"molten.autogenerated",new short[]{(short) color.getRed(),(short) color.getGreen(),(short) color.getBlue(), (short) color.getAlpha()}); + f.setTemperature(temperature); + FluidRegistry.registerFluid(f); + return f; + } } 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 faf503d33f..f14e5f8051 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 @@ -32,15 +32,17 @@ import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_RotorBl import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_ExperimentalFloodGate; import com.github.bartimaeusnek.bartworks.common.tileentities.classic.BW_TileEntity_HeatedWaterPump; import com.github.bartimaeusnek.bartworks.common.tileentities.debug.CreativeScanner; +import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_CircuitAssemblyLine; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_DEHP; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ElectricImplosionCompressor; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_THTR; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaBlastFurnace; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega.GT_TileEntity_MegaVacuumFreezer; -import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_AcidGenerator; -import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_Diode; -import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.GT_MetaTileEntity_EnergyDistributor; +import com.github.bartimaeusnek.bartworks.common.tileentities.tiered.*; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import cpw.mods.fml.common.LoadController; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.GT_Values; import gregtech.api.enums.Materials; @@ -53,6 +55,9 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; +import org.apache.commons.lang3.reflect.FieldUtils; + +import java.lang.reflect.Field; import static com.github.bartimaeusnek.bartworks.MainMod.BWT; import static com.github.bartimaeusnek.bartworks.MainMod.GT2; @@ -135,33 +140,19 @@ public class ItemRegistry { public static ItemStack dehp; public static ItemStack thtr; public static ItemStack eic; + public static ItemStack cal; + public static ItemStack compressedHatch; + public static ItemStack giantOutputHatch; public static void run() { - if (newStuff) { if (ConfigHandler.creativeScannerID != 0) - new CreativeScanner(ConfigHandler.creativeScannerID,"ZPM Creative Debug Scanner","ZPM Creative Debug Scanner",7); + new CreativeScanner(ConfigHandler.creativeScannerID,"Creative Debug Scanner","Creative Debug Scanner",20); ItemRegistry.eic = new GT_TileEntity_ElectricImplosionCompressor(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 6, "ElectricImplosionCompressor", "Electric Implosion Compressor").getStackForm(1L); ItemRegistry.thtr = new GT_TileEntity_THTR(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 5, "THTR", "Thorium High Temperature Reactor").getStackForm(1L); GT_TileEntity_THTR.THTRMaterials.registeraTHR_Materials(); - GameRegistry.registerBlock(ItemRegistry.bw_glasses[0], BW_ItemBlocks.class, "BW_GlasBlocks"); - GameRegistry.registerBlock(ItemRegistry.bw_fake_glasses, "BW_FakeGlasBlock"); GT_OreDictUnificator.add(OrePrefixes.block, Materials.BorosilicateGlass, new ItemStack(ItemRegistry.bw_glasses[0], 1, 0)); - GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[2], BW_ItemBlocks.class, "BW_Machinery_Casings"); GT_OreDictUnificator.registerOre(OrePrefixes.block, Materials.NickelZincFerrite, new ItemStack(ItemRegistry.BW_BLOCKS[2])); - GameRegistry.registerItem(ItemRegistry.LEATHER_ROTOR, "BW_LeatherRotor"); - GameRegistry.registerItem(ItemRegistry.WOOL_ROTOR, "BW_WoolRotor"); - GameRegistry.registerItem(ItemRegistry.PAPER_ROTOR, "BW_PaperRotor"); - GameRegistry.registerItem(ItemRegistry.COMBINED_ROTOR, "BW_CombinedRotor"); - GameRegistry.registerItem(ItemRegistry.CRAFTING_PARTS, "craftingParts"); - GameRegistry.registerTileEntity(BW_RotorBlock.class, "BWRotorBlockTE"); - GameRegistry.registerBlock(ItemRegistry.ROTORBLOCK, BW_ItemBlocks.class, "BWRotorBlock"); - GameRegistry.registerTileEntity(BW_TileEntity_HeatedWaterPump.class, "BWHeatedWaterPumpTE"); - GameRegistry.registerBlock(ItemRegistry.PUMPBLOCK, BW_ItemBlocks.class, "BWHeatedWaterPumpBlock"); - GameRegistry.registerItem(ItemRegistry.PUMPPARTS, "BWPumpParts"); - GameRegistry.registerItem(ItemRegistry.WINDMETER, "BW_SimpleWindMeter"); - GameRegistry.registerTileEntity(BW_TileEntity_ExperimentalFloodGate.class, "BWExpReversePump"); - GameRegistry.registerBlock(ItemRegistry.EXPPUMP, BW_ItemBlocks.class, "BWExpReversePumpBlock"); 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, "diode" + "2A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 2A " + GT_Values.VN[i], i).getStackForm(1L); ItemRegistry.diode4A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 2 + 1 + i, "diode" + "4A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 4A " + GT_Values.VN[i], i).getStackForm(1L); @@ -169,7 +160,6 @@ public class ItemRegistry { ItemRegistry.diode12A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 4 + 1 + i, "diode" + "12A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 12A " + GT_Values.VN[i], i).getStackForm(1L); ItemRegistry.diode16A[i] = new GT_MetaTileEntity_Diode(ConfigHandler.IDOffset + GT_Values.VN.length * 5 + 1 + i, "diode" + "16A" + GT_Values.VN[i], StatCollector.translateToLocal("tile.diode.name") + " 16A " + GT_Values.VN[i], i).getStackForm(1L); ItemRegistry.energyDistributor[i] = new GT_MetaTileEntity_EnergyDistributor(ConfigHandler.IDOffset + 1 + i, "energydistributor" + GT_Values.VN[i], StatCollector.translateToLocal("tile.energydistributor.name") + " " + GT_Values.VN[i], i).getStackForm(1L); - } for (int i = 0; i < 3; i++) { ItemRegistry.acidGens[i] = new GT_MetaTileEntity_AcidGenerator(ConfigHandler.IDOffset + GT_Values.VN.length * 8 - 2 + i, "acidgenerator" + GT_Values.VN[i + 2], StatCollector.translateToLocal("tile.acidgenerator.name") + " " + GT_Values.VN[i + 2], i + 2).getStackForm(1); @@ -177,18 +167,9 @@ public class ItemRegistry { ItemRegistry.dehp = new GT_TileEntity_DEHP(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 1, 1, "DEHP", "Deep Earth Heating Pump").getStackForm(1L); ItemRegistry.megaMachines[0] = new GT_TileEntity_MegaBlastFurnace(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 2, "MegaBlastFurnace", StatCollector.translateToLocal("tile.bw.mbf.name")).getStackForm(1L); ItemRegistry.megaMachines[1] = new GT_TileEntity_MegaVacuumFreezer(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 3, "MegaVacuumFreezer", StatCollector.translateToLocal("tile.bw.mvf.name")).getStackForm(1L); + ItemRegistry.cal = new GT_TileEntity_CircuitAssemblyLine(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 7, "CircuitAssemblyLine", "Circuit Assembly Line").getStackForm(1L); + ItemRegistry.compressedHatch = new GT_MetaTileEntity_CompressedFluidHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 8, "CompressedFluidHatch", "Liquid Air Fluid Hatch").getStackForm(1L); + ItemRegistry.giantOutputHatch = new GT_MetaTileEntity_GiantOutputHatch(ConfigHandler.IDOffset + GT_Values.VN.length * 8 + 9, "GiantOutputHatch", "Giant Output Hatch").getStackForm(1L); } - - - //GT2 stuff - GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[0], BW_ItemBlocks.class, "BW_ItemBlocks"); - GameRegistry.registerBlock(ItemRegistry.BW_BLOCKS[1], BW_ItemBlocks.class, "GT_LESU_CASING"); - if (ConfigHandler.teslastaff) - GameRegistry.registerItem(ItemRegistry.TESLASTAFF, ItemRegistry.TESLASTAFF.getUnlocalizedName()); - - GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_LV, ItemRegistry.ROCKCUTTER_LV.getUnlocalizedName()); - GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_MV, ItemRegistry.ROCKCUTTER_MV.getUnlocalizedName()); - GameRegistry.registerItem(ItemRegistry.ROCKCUTTER_HV, ItemRegistry.ROCKCUTTER_HV.getUnlocalizedName()); - GameRegistry.registerItem(ItemRegistry.TAB, "tabIconGT2"); } } 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 7174c2176b..5426e20a99 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 @@ -27,11 +27,13 @@ import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEnti import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_ManualTrafo; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_THTR; import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_Windmill; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Util; import gregtech.api.GregTech_API; import gregtech.api.enums.*; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import ic2.core.Ic2Items; import net.minecraft.init.Blocks; @@ -222,7 +224,7 @@ public class RecipeLoader implements Runnable { if (!ConfigHandler.GTNH) GT_ModHandler.addCraftingRecipe( ItemRegistry.dehp, - BITSD, + RecipeLoader.BITSD, new Object[]{ "GPG", "NCN", @@ -771,6 +773,27 @@ public class RecipeLoader implements Runnable { 240000, BW_Util.getMachineVoltageFromTier(8) ); + GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.add(new BWRecipes.DynamicGTRecipe(false,new ItemStack[]{ItemList.Hatch_Input_HV.get(64),Materials.LiquidAir.getCells(1),GT_Utility.getIntegratedCircuit(17)},new ItemStack[]{ItemRegistry.compressedHatch.copy()},null,null,null,null,300, BW_Util.getMachineVoltageFromTier(3),0)); + GT_Recipe.GT_Recipe_Map.sAssemblerRecipes.add(new BWRecipes.DynamicGTRecipe(false,new ItemStack[]{ItemList.Hatch_Output_HV.get(64),GT_Utility.getIntegratedCircuit(17)},new ItemStack[]{ItemRegistry.giantOutputHatch.copy()},null,null,null,null,300, BW_Util.getMachineVoltageFromTier(3),0)); + + GT_Values.RA.addAssemblylineRecipe( + ItemList.Machine_LuV_CircuitAssembler.get(1L),24000, + new ItemStack[]{ + ItemList.Machine_LuV_CircuitAssembler.get(1L), + ItemList.Robot_Arm_LuV.get(4L), + ItemList.Electric_Motor_LuV.get(4L), + ItemList.Field_Generator_LuV.get(1L), + ItemList.Emitter_LuV.get(1L), + ItemList.Sensor_LuV.get(1L), + Materials.Chrome.getPlates(8) + }, + new FluidStack[]{ + Materials.SolderingAlloy.getMolten(1440) + }, + ItemRegistry.cal.copy(), + 24000, + BW_Util.getMachineVoltageFromTier(6) + ); } } 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 index 277823b5f4..bb32c7aeb4 100644 --- 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 @@ -45,7 +45,6 @@ import net.minecraft.world.chunk.Chunk; import javax.annotation.Nonnull; import java.util.EnumMap; -import java.util.Iterator; import java.util.List; /* @@ -54,12 +53,12 @@ import java.util.List; @ChannelHandler.Sharable public class BW_Network extends MessageToMessageCodec<FMLProxyPacket, GT_Packet> implements IGT_NetworkHandler { - private EnumMap<Side, FMLEmbeddedChannel> mChannel; - private GT_Packet[] mSubChannels; + private final EnumMap<Side, FMLEmbeddedChannel> mChannel; + private final GT_Packet[] mSubChannels; public BW_Network() { - this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", new ChannelHandler[]{this, new HandlerShared()}); - this.mSubChannels = new GT_Packet[]{new RendererPacket(), new CircuitProgrammerPacket(), new OrePacket(), new OreDictCachePacket()}; + this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", this, new BW_Network.HandlerShared()); + this.mSubChannels = new GT_Packet[]{new RendererPacket(), new CircuitProgrammerPacket(), new OrePacket(), new OreDictCachePacket(), new ServerJoinedPackage()}; } protected void encode(ChannelHandlerContext aContext, GT_Packet aPacket, List<Object> aOutput) throws Exception { @@ -98,10 +97,8 @@ public class BW_Network extends MessageToMessageCodec<FMLProxyPacket, GT_Packet> 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(); + for (Object tObject : aWorld.playerEntities) { if (!(tObject instanceof EntityPlayerMP)) { break; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java index 23cf7a263f..0da061e352 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/CircuitProgrammerPacket.java @@ -60,7 +60,7 @@ public class CircuitProgrammerPacket extends GT_Packet { @Override public byte[] encode() { - return ByteBuffer.allocate(9).putInt(0, dimID).putInt(4, playerID).put(8, (hasChip ? chipCfg : -1)).array(); + return ByteBuffer.allocate(9).putInt(0, this.dimID).putInt(4, this.playerID).put(8, (this.hasChip ? this.chipCfg : -1)).array(); } @Override @@ -72,18 +72,18 @@ public class CircuitProgrammerPacket extends GT_Packet { @Override public void process(IBlockAccess iBlockAccess) { - World w = DimensionManager.getWorld(dimID); - if (w != null && w.getEntityByID(playerID) instanceof EntityPlayer) { - ItemStack stack = ((EntityPlayer) w.getEntityByID(playerID)).getHeldItem(); + World w = DimensionManager.getWorld(this.dimID); + if (w != null && w.getEntityByID(this.playerID) instanceof EntityPlayer) { + ItemStack stack = ((EntityPlayer) w.getEntityByID(this.playerID)).getHeldItem(); if ((stack != null) && (stack.stackSize > 0)) { Item item = stack.getItem(); if (item instanceof Circuit_Programmer) { NBTTagCompound nbt = stack.getTagCompound(); - nbt.setBoolean("HasChip", hasChip); - if (hasChip) - nbt.setByte("ChipConfig", chipCfg); + nbt.setBoolean("HasChip", this.hasChip); + if (this.hasChip) + nbt.setByte("ChipConfig", this.chipCfg); stack.setTagCompound(nbt); - ((EntityPlayer) w.getEntityByID(playerID)).inventory.setInventorySlotContents(((EntityPlayer) w.getEntityByID(playerID)).inventory.currentItem, stack); + ((EntityPlayer) w.getEntityByID(this.playerID)).inventory.setInventorySlotContents(((EntityPlayer) w.getEntityByID(this.playerID)).inventory.currentItem, stack); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java index d44fc42cce..793f59c899 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OreDictCachePacket.java @@ -42,7 +42,7 @@ public class OreDictCachePacket extends GT_Packet { public OreDictCachePacket(HashSet<Pair<Integer,Short>> set) { super(false); - hashSet = set; + this.hashSet = set; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OrePacket.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OrePacket.java index 36fd4dfa36..4147087a51 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OrePacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/OrePacket.java @@ -59,8 +59,8 @@ public class OrePacket extends GT_Packet { @Override public byte[] encode() { - int hash = MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(12).putInt(x).putInt(z).putShort(y).putShort(meta).array(), 0, 12, 31); - return ByteBuffer.allocate(16).putInt(x).putInt(z).putShort(y).putShort(meta).putInt(hash).array(); + int hash = MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(12).putInt(this.x).putInt(this.z).putShort(this.y).putShort(this.meta).array(), 0, 12, 31); + return ByteBuffer.allocate(16).putInt(this.x).putInt(this.z).putShort(this.y).putShort(this.meta).putInt(hash).array(); } @Override @@ -68,12 +68,12 @@ public class OrePacket extends GT_Packet { byte[] tmp = new byte[16]; byteArrayDataInput.readFully(tmp); ByteBuffer buff = ByteBuffer.wrap(tmp); - x = buff.getInt(); - z = buff.getInt(); - y = buff.getShort(); - meta = buff.getShort(); - OrePacket todecode = new OrePacket(x, y, z, meta); - if (buff.getInt() != MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(12).putInt(x).putInt(z).putShort(y).putShort(meta).array(), 0, 12, 31)) { + this.x = buff.getInt(); + this.z = buff.getInt(); + this.y = buff.getShort(); + this.meta = buff.getShort(); + OrePacket todecode = new OrePacket(this.x, this.y, this.z, this.meta); + if (buff.getInt() != MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(12).putInt(this.x).putInt(this.z).putShort(this.y).putShort(this.meta).array(), 0, 12, 31)) { MainMod.LOGGER.error("PACKET HASH DOES NOT MATCH!"); return null; } 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 index a5f5f4089f..90a3adc69a 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/RendererPacket.java @@ -59,11 +59,11 @@ public class RendererPacket extends GT_Packet { @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(); + byte r = (byte) (((this.integer >> 16) & 0xFF) + Byte.MIN_VALUE); + byte g = (byte) (((this.integer >> 8) & 0xFF) + Byte.MIN_VALUE); + byte b = (byte) (((this.integer) & 0xFF) + Byte.MIN_VALUE); + byte checksum = (byte) (this.coords.x % 25 + this.coords.y % 25 + this.coords.z % 25 + this.coords.wID % 25 + this.integer % 25 + this.removal); + return ByteBuffer.allocate(19).putInt(0, this.coords.x).putShort(4, this.coords.y).putInt(6, this.coords.z).putInt(10, this.coords.wID).put(14, r).put(15, g).put(16, b).put(17, this.removal).put(18, checksum).array(); } // /** @@ -90,23 +90,23 @@ public class RendererPacket extends GT_Packet { this.integer = BW_ColorUtil.getColorFromRGBArray(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); + byte checksum = (byte) (this.coords.x % 25 + this.coords.y % 25 + this.coords.z % 25 + this.coords.wID % 25 + this.integer % 25 + this.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); + return new RendererPacket(this.coords, this.integer, this.removal == 1); } @Override public void process(IBlockAccess iBlockAccess) { if (FMLCommonHandler.instance().getSide().isClient()) { - if (removal == 0) - GT_TileEntity_BioVat.staticColorMap.put(coords, integer); + if (this.removal == 0) + GT_TileEntity_BioVat.staticColorMap.put(this.coords, this.integer); else - GT_TileEntity_BioVat.staticColorMap.remove(coords); + GT_TileEntity_BioVat.staticColorMap.remove(this.coords); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java new file mode 100644 index 0000000000..149db03d5b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java @@ -0,0 +1,67 @@ +/* + * 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.configs.ConfigHandler; +import com.google.common.io.ByteArrayDataInput; +import gregtech.api.net.GT_Packet; +import net.minecraft.world.IBlockAccess; + +public class ServerJoinedPackage extends GT_Packet { + + private byte config; + + ServerJoinedPackage() { + super(true); + } + + public ServerJoinedPackage(Object obj) { + super(false); + this.config =(byte) (ConfigHandler.classicMode && ConfigHandler.disableExtraGassesForEBF ? 3 : ConfigHandler.classicMode ? 2 : ConfigHandler.disableExtraGassesForEBF ? 1 : 0); + + } + + @Override + public byte getPacketID() { + return 4; + } + + @Override + public byte[] encode() { + return new byte[]{this.config}; + } + + @Override + public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) { + this.config = byteArrayDataInput.readByte(); + return this; + } + + @Override + public void process(IBlockAccess iBlockAccess) { + boolean gas = (this.config & 1) != 0; + boolean classic = (this.config & 0b10) != 0; + MainMod.runOnPlayerJoined(classic,gas); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java index d71969e12b..0e54e9264d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_ExperimentalFloodGate.java @@ -35,9 +35,9 @@ import java.util.List; public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implements ITileAddsInformation { - recursiveBelowCheck check = new recursiveBelowCheck(); - private long ticks = 0; - private long noOfIts = 0; + BW_TileEntity_ExperimentalFloodGate.recursiveBelowCheck check = new BW_TileEntity_ExperimentalFloodGate.recursiveBelowCheck(); + private long ticks; + private long noOfIts; private Coords paused; public BW_TileEntity_ExperimentalFloodGate() { @@ -46,31 +46,31 @@ public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implem @Override public void updateEntity() { - if (paused == null) { + if (this.paused == null) { this.paused = new Coords(this.xCoord, this.yCoord, this.zCoord, this.worldObj.provider.dimensionId); } - ticks++; - if (check.called != -1) { - if (ticks % 20 == 0) { + this.ticks++; + if (this.check.called != -1) { + if (this.ticks % 20 == 0) { HashSet<Coords> toRem = new HashSet<>(); - for (Coords c : check.hashset) { + for (Coords c : this.check.hashset) { this.worldObj.setBlock(c.x, c.y, c.z, Blocks.water, 0, 4); toRem.add(c); } - check.hashset.removeAll(toRem); + this.check.hashset.removeAll(toRem); } } else { - noOfIts = 0; - setUpHashSet(); - this.paused = check.hashset.get(check.hashset.size() - 1); + this.noOfIts = 0; + this.setUpHashSet(); + this.paused = this.check.hashset.get(this.check.hashset.size() - 1); } - if (ticks % 50 == 0) - ticks = 0; + if (this.ticks % 50 == 0) + this.ticks = 0; } private synchronized void setUpHashSet() { - check = new recursiveBelowCheck(); - Thread t = new Thread(check); + this.check = new BW_TileEntity_ExperimentalFloodGate.recursiveBelowCheck(); + Thread t = new Thread(this.check); t.run(); while (t.isAlive()) { try { @@ -79,7 +79,7 @@ public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implem e.printStackTrace(); } } - check.hashset.remove(new Coords(this.xCoord, this.yCoord, this.zCoord, this.worldObj.provider.dimensionId)); + this.check.hashset.remove(new Coords(this.xCoord, this.yCoord, this.zCoord, this.worldObj.provider.dimensionId)); } @Override @@ -108,10 +108,10 @@ public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implem byte ret = 0; int wID = w.provider.dimensionId; - if (hashset.contains(new Coords(x, y, z, wID))) + if (this.hashset.contains(new Coords(x, y, z, wID))) return ret; - hashset.add(new Coords(x, y, z, wID)); + this.hashset.add(new Coords(x, y, z, wID)); if (w.getBlock(x, y + 1, z).equals(b)) ret = (byte) (ret | 0b000001); @@ -142,53 +142,53 @@ public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implem int ret = 0; iterations++; int wID = w.provider.dimensionId; - byte sides = check_sourroundings(w, x, y, z, b); + byte sides = this.check_sourroundings(w, x, y, z, b); - if (((sides | 0b111110) == 0b111111) && !hashset.contains(new Coords(x, y + 1, z, wID)) && y + 1 <= yCoord) { - tail = get_connected(w, x, y + 1, z, b, iterations); + if (((sides | 0b111110) == 0b111111) && !this.hashset.contains(new Coords(x, y + 1, z, wID)) && y + 1 <= BW_TileEntity_ExperimentalFloodGate.this.yCoord) { + tail = this.get_connected(w, x, y + 1, z, b, iterations); if (tail == -1) - return tail; + return -1; ret++; ret += tail; } - if (((sides | 0b111101) == 0b111111) && !hashset.contains(new Coords(x, y - 1, z, wID))) { - tail = get_connected(w, x, y - 1, z, b, iterations); + if (((sides | 0b111101) == 0b111111) && !this.hashset.contains(new Coords(x, y - 1, z, wID))) { + tail = this.get_connected(w, x, y - 1, z, b, iterations); if (tail == -1) - return tail; + return -1; ret++; ret += tail; } - if (((sides | 0b111011) == 0b111111) && !hashset.contains(new Coords(x + 1, y, z, wID))) { - tail = get_connected(w, x + 1, y, z, b, iterations); + if (((sides | 0b111011) == 0b111111) && !this.hashset.contains(new Coords(x + 1, y, z, wID))) { + tail = this.get_connected(w, x + 1, y, z, b, iterations); if (tail == -1) - return tail; + return -1; ret++; ret += tail; } - if (((sides | 0b110111) == 0b111111) && !hashset.contains(new Coords(x - 1, y, z, wID))) { - tail = get_connected(w, x - 1, y, z, b, iterations); + if (((sides | 0b110111) == 0b111111) && !this.hashset.contains(new Coords(x - 1, y, z, wID))) { + tail = this.get_connected(w, x - 1, y, z, b, iterations); if (tail == -1) - return tail; + return -1; ret++; ret += tail; } - if (((sides | 0b101111) == 0b111111) && !hashset.contains(new Coords(x, y, z + 1, wID))) { - tail = get_connected(w, x, y, z + 1, b, iterations); + if (((sides | 0b101111) == 0b111111) && !this.hashset.contains(new Coords(x, y, z + 1, wID))) { + tail = this.get_connected(w, x, y, z + 1, b, iterations); if (tail == -1) - return tail; + return -1; ret++; ret += tail; } - if (((sides | 0b011111) == 0b111111) && !hashset.contains(new Coords(x, y, z - 1, wID))) { - tail = get_connected(w, x, y, z - 1, b, iterations); + if (((sides | 0b011111) == 0b111111) && !this.hashset.contains(new Coords(x, y, z - 1, wID))) { + tail = this.get_connected(w, x, y, z - 1, b, iterations); if (tail == -1) - return tail; + return -1; ret++; ret += tail; } @@ -198,8 +198,8 @@ public class BW_TileEntity_ExperimentalFloodGate extends TileFluidHandler implem @Override public synchronized void run() { - called = check.get_connected(worldObj, paused.x, paused.y, paused.z, Blocks.air, 0); - notifyAll(); + this.called = BW_TileEntity_ExperimentalFloodGate.this.check.get_connected(BW_TileEntity_ExperimentalFloodGate.this.worldObj, BW_TileEntity_ExperimentalFloodGate.this.paused.x, BW_TileEntity_ExperimentalFloodGate.this.paused.y, BW_TileEntity_ExperimentalFloodGate.this.paused.z, Blocks.air, 0); + this.notifyAll(); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java index 416e4fb56e..ea9bfe6395 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_HeatedWaterPump.java @@ -31,7 +31,6 @@ import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; -import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -46,63 +45,63 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr public static final Fluid WATER = FluidRegistry.WATER; public ItemStack fuelstack; public FluidStack outputstack = new FluidStack(FluidRegistry.WATER, 0); - public int fuel = 0; - public byte tick = 0; - public int maxfuel = 0; + public int fuel; + public byte tick; + public int maxfuel; public ItemStack fakestack = new ItemStack(Blocks.water); @Override public void writeToNBT(NBTTagCompound p_145841_1_) { NBTTagCompound subItemStack = new NBTTagCompound(); - if (fuelstack == null) + if (this.fuelstack == null) p_145841_1_.setTag("ItemStack", subItemStack); else { - fuelstack.writeToNBT(subItemStack); + this.fuelstack.writeToNBT(subItemStack); p_145841_1_.setTag("ItemStack", subItemStack); } NBTTagCompound subFluidStack = new NBTTagCompound(); - outputstack.writeToNBT(subFluidStack); + this.outputstack.writeToNBT(subFluidStack); p_145841_1_.setTag("FluidStack", subFluidStack); - p_145841_1_.setInteger("fuel", fuel); - p_145841_1_.setInteger("maxfuel", maxfuel); - p_145841_1_.setByte("tick", tick); + p_145841_1_.setInteger("fuel", this.fuel); + p_145841_1_.setInteger("maxfuel", this.maxfuel); + p_145841_1_.setByte("tick", this.tick); super.writeToNBT(p_145841_1_); } @Override public void readFromNBT(NBTTagCompound p_145839_1_) { - tick = p_145839_1_.getByte("tick"); - fuel = p_145839_1_.getInteger("fuel"); - maxfuel = p_145839_1_.getInteger("maxfuel"); - outputstack = FluidStack.loadFluidStackFromNBT(p_145839_1_.getCompoundTag("FluidStack")); + this.tick = p_145839_1_.getByte("tick"); + this.fuel = p_145839_1_.getInteger("fuel"); + this.maxfuel = p_145839_1_.getInteger("maxfuel"); + this.outputstack = FluidStack.loadFluidStackFromNBT(p_145839_1_.getCompoundTag("FluidStack")); if (!p_145839_1_.getCompoundTag("ItemStack").equals(new NBTTagCompound())) - fuelstack = ItemStack.loadItemStackFromNBT(p_145839_1_.getCompoundTag("ItemStack")); + this.fuelstack = ItemStack.loadItemStackFromNBT(p_145839_1_.getCompoundTag("ItemStack")); super.readFromNBT(p_145839_1_); } @Override public void updateEntity() { - if (worldObj.isRemote || ((fuelstack == null || fuelstack.stackSize <= 0) && fuel <= 0) || (tick == 0 && worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord) == Blocks.air)) { + if (this.worldObj.isRemote || ((this.fuelstack == null || this.fuelstack.stackSize <= 0) && this.fuel <= 0) || (this.tick == 0 && this.worldObj.getBlock(this.xCoord, this.yCoord - 1, this.zCoord) == Blocks.air)) { return; } - if (fuel < 0) - fuel = 0; + if (this.fuel < 0) + this.fuel = 0; - if (fuelstack != null && fuel == 0) { - fuel = maxfuel = TileEntityFurnace.getItemBurnTime(fuelstack); - --fuelstack.stackSize; + if (this.fuelstack != null && this.fuel == 0) { + this.fuel = this.maxfuel = TileEntityFurnace.getItemBurnTime(this.fuelstack); + --this.fuelstack.stackSize; if (this.fuelstack.stackSize <= 0) this.fuelstack = null; } - if (fuel > 0) { - ++tick; - --fuel; - if (tick % 20 == 0) { - if (outputstack.amount <= (8000 - ConfigHandler.mbWaterperSec)) - outputstack.amount += ConfigHandler.mbWaterperSec; - tick = 0; + if (this.fuel > 0) { + ++this.tick; + --this.fuel; + if (this.tick % 20 == 0) { + if (this.outputstack.amount <= (8000 - ConfigHandler.mbWaterperSec)) + this.outputstack.amount += ConfigHandler.mbWaterperSec; + this.tick = 0; } } } @@ -130,17 +129,17 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr @Override public ItemStack getStackInSlot(int p_70301_1_) { if (p_70301_1_ == 0) - return fuelstack; + return this.fuelstack; else - return fakestack; + return this.fakestack; } @Override public ItemStack decrStackSize(int slot, int ammount) { - if (slot != FUELSLOT || fuelstack == null || ammount > fuelstack.stackSize) + if (slot != BW_TileEntity_HeatedWaterPump.FUELSLOT || this.fuelstack == null || ammount > this.fuelstack.stackSize) return null; - return fuelstack.splitStack(ammount); + return this.fuelstack.splitStack(ammount); } @Override @@ -150,10 +149,10 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr @Override public void setInventorySlotContents(int slot, ItemStack p_70299_2_) { - if (slot == FUELSLOT) - fuelstack = p_70299_2_; + if (slot == BW_TileEntity_HeatedWaterPump.FUELSLOT) + this.fuelstack = p_70299_2_; else - fakestack = p_70299_2_; + this.fakestack = p_70299_2_; } @Override @@ -187,17 +186,17 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr @Override public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { - return TileEntityFurnace.getItemBurnTime(p_94041_2_) > 0 && p_94041_1_ == FUELSLOT; + return TileEntityFurnace.getItemBurnTime(p_94041_2_) > 0 && p_94041_1_ == BW_TileEntity_HeatedWaterPump.FUELSLOT; } @Override public FluidStack getFluid() { - return outputstack.amount > 0 ? outputstack : null; + return this.outputstack.amount > 0 ? this.outputstack : null; } @Override public int getFluidAmount() { - return outputstack.amount; + return this.outputstack.amount; } @Override @@ -218,14 +217,14 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr @Override public FluidStack drain(int maxDrain, boolean doDrain) { int actualdrain = maxDrain; - if (actualdrain > outputstack.amount) - actualdrain = outputstack.amount; - FluidStack ret = new FluidStack(WATER, actualdrain); + if (actualdrain > this.outputstack.amount) + actualdrain = this.outputstack.amount; + FluidStack ret = new FluidStack(BW_TileEntity_HeatedWaterPump.WATER, actualdrain); if (ret.amount == 0) ret = null; if (doDrain) { - outputstack.amount -= actualdrain; - FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(outputstack, this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord, this, actualdrain)); + this.outputstack.amount -= actualdrain; + FluidEvent.fireEvent(new FluidEvent.FluidDrainingEvent(this.outputstack, this.getWorldObj(), this.xCoord, this.yCoord, this.zCoord, this, actualdrain)); } return ret; } @@ -242,14 +241,14 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - if (resource != null && resource.getFluid() == WATER && drain(resource.amount, false) != null) - return drain(resource.amount, doDrain); + if (resource != null && resource.getFluid() == BW_TileEntity_HeatedWaterPump.WATER && this.drain(resource.amount, false) != null) + return this.drain(resource.amount, doDrain); return null; } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return drain(maxDrain, doDrain); + return this.drain(maxDrain, doDrain); } @Override @@ -259,12 +258,12 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { - return fluid == null || fluid == WATER; + return fluid == null || fluid == BW_TileEntity_HeatedWaterPump.WATER; } @Override public FluidTankInfo[] getTankInfo(ForgeDirection from) { - return new FluidTankInfo[]{getInfo()}; + return new FluidTankInfo[]{this.getInfo()}; } @Override @@ -274,10 +273,10 @@ public class BW_TileEntity_HeatedWaterPump extends TileEntity implements ITileDr @Override public void registerBlockIcons(IIconRegister par1IconRegister) { - texture[ForgeDirection.UP.ordinal()] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpTop"); - texture[ForgeDirection.DOWN.ordinal()] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpDown"); + ITileHasDifferentTextureSides.texture[ForgeDirection.UP.ordinal()] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpTop"); + ITileHasDifferentTextureSides.texture[ForgeDirection.DOWN.ordinal()] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpDown"); for (int i = 2; i < 7; i++) { - texture[i] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpSide"); + ITileHasDifferentTextureSides.texture[i] = par1IconRegister.registerIcon(MainMod.MOD_ID + ":heatedWaterPumpSide"); } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java index 989e1618b9..f9e7553760 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/classic/BW_TileEntity_InfinityTank.java @@ -41,17 +41,17 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank @Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { - return fill(resource, doFill); + return this.fill(resource, doFill); } @Override public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { - return drain(from, resource != null ? resource.amount : 0, doDrain); + return this.drain(from, resource != null ? resource.amount : 0, doDrain); } @Override public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { - return drain(maxDrain, doDrain); + return this.drain(maxDrain, doDrain); } @Override @@ -62,10 +62,10 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { HashSet<Boolean> ret = new HashSet<Boolean>(); - for (FluidStack stack : INTERNALTANKS) { + for (FluidStack stack : this.INTERNALTANKS) { ret.add(GT_Utility.areFluidsEqual(stack, new FluidStack(fluid, 0))); if (ret.contains(Boolean.TRUE)) - selectedTank = this.INTERNALTANKS.indexOf(stack); + this.selectedTank = this.INTERNALTANKS.indexOf(stack); } return ret.contains(Boolean.TRUE); } @@ -77,15 +77,15 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank @Override public FluidStack getFluid() { - if (INTERNALTANKS.get(selectedTank) == null || INTERNALTANKS.get(selectedTank).amount == 0) - if (selectedTank > 0) - selectedTank = this.INTERNALTANKS.size() - 1; - return INTERNALTANKS.get(selectedTank); + if (this.INTERNALTANKS.get(this.selectedTank) == null || this.INTERNALTANKS.get(this.selectedTank).amount == 0) + if (this.selectedTank > 0) + this.selectedTank = this.INTERNALTANKS.size() - 1; + return this.INTERNALTANKS.get(this.selectedTank); } @Override public int getFluidAmount() { - return INTERNALTANKS.get(selectedTank) != null ? INTERNALTANKS.get(selectedTank).amount : 0; + return this.INTERNALTANKS.get(this.selectedTank) != null ? this.INTERNALTANKS.get(this.selectedTank).amount : 0; } @Override @@ -94,12 +94,12 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank NBTTagList lInternalTank = new NBTTagList(); - for (int i = 0; i < INTERNALTANKS.size(); i++) { - if (INTERNALTANKS.get(i) != null) { + for (int i = 0; i < this.INTERNALTANKS.size(); i++) { + if (this.INTERNALTANKS.get(i) != null) { NBTTagCompound entry = new NBTTagCompound(); - entry.setString("FluidName", INTERNALTANKS.get(i).getFluid().getName()); - entry.setInteger("Ammount", INTERNALTANKS.get(i).amount); - entry.setTag("FluidTag", INTERNALTANKS.get(i).tag); + entry.setString("FluidName", this.INTERNALTANKS.get(i).getFluid().getName()); + entry.setInteger("Ammount", this.INTERNALTANKS.get(i).amount); + entry.setTag("FluidTag", this.INTERNALTANKS.get(i).tag); lInternalTank.appendTag(entry); } } @@ -119,7 +119,7 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank @Override public int fill(FluidStack resource, boolean doFill) { - if (worldObj.isRemote || resource == null || resource.amount == 0) + if (this.worldObj.isRemote || resource == null || resource.amount == 0) return 0; if (!doFill) @@ -127,16 +127,16 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank int id = 0; - if (canDrain(null, resource.getFluid())) { - for (FluidStack stack : INTERNALTANKS) + if (this.canDrain(null, resource.getFluid())) { + for (FluidStack stack : this.INTERNALTANKS) if (GT_Utility.areFluidsEqual(stack, resource)) { this.INTERNALTANKS.get(id = this.INTERNALTANKS.indexOf(stack)).amount += resource.amount; - selectedTank = id; + this.selectedTank = id; } } else { this.INTERNALTANKS.add(resource); id = this.INTERNALTANKS.size() - 1; - selectedTank = id; + this.selectedTank = id; } return this.INTERNALTANKS.get(id).amount; } @@ -144,8 +144,8 @@ public class BW_TileEntity_InfinityTank extends TileEntity implements IFluidTank @Override public FluidStack drain(int maxDrain, boolean doDrain) { - FluidStack outputstack = INTERNALTANKS.get(selectedTank); - if (worldObj.isRemote || maxDrain == 0 || this.getFluid() == null || outputstack == null) + FluidStack outputstack = this.INTERNALTANKS.get(this.selectedTank); + if (this.worldObj.isRemote || maxDrain == 0 || this.getFluid() == null || outputstack == null) return null; int actualdrain = maxDrain; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java index b3fce2c4ac..1a8b555478 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_BioVat.java @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis; import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.items.LabParts; import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; @@ -73,14 +74,14 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { 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 GT_Recipe mLastRecipe; private Fluid mFluid = FluidRegistry.LAVA; private BioCulture mCulture; - private ItemStack mStack = null; + private ItemStack mStack; private boolean needsVisualUpdate = true; - private byte mGlassTier = 0; - private int mSievert = 0; - private int mNeededSievert = 0; + private byte mGlassTier; + private int mSievert; + private int mNeededSievert; public GT_TileEntity_BioVat(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -90,12 +91,12 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { super(aName); } - public static int[] specialValueUnpack(int aSpecialValure) { + public static int[] specialValueUnpack(int aSpecialValue) { 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 + ret[0] = aSpecialValue & 0xF; // = glas tier + ret[1] = aSpecialValue >>> 4 & 0b11; // = special valure + ret[2] = aSpecialValue >>> 6 & 0b1; //boolean exact svt | 1 = true | 0 = false + ret[3] = aSpecialValue >>> 7 & Integer.MAX_VALUE; // = sievert return ret; } @@ -128,7 +129,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { @Override public int getCapacity() { int ret = 0; - ret += getInputCapacity(); + ret += this.getInputCapacity(); //ret += getOutputCapacity(); return ret; } @@ -149,17 +150,18 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { } private int calcMod(double x) { - return (int) Math.ceil((-0.00000025D * x * (x - this.getOutputCapacity()))); + int ret = (int) Math.ceil(ConfigHandler.bioVatMaxParallelBonus*(-(((2D*x/(double)this.getOutputCapacity())-1D)*(2D*x/(double)this.getOutputCapacity()-1D))+1D)); + return ret <= 0 ? 1 : ret > 100 ? 100 : ret;//(int) Math.ceil((-0.00000025D * x * (x - this.getOutputCapacity()))); } @Override public boolean checkRecipe(ItemStack itemStack) { - GT_Recipe.GT_Recipe_Map gtRecipeMap = getRecipeMap(); + GT_Recipe.GT_Recipe_Map gtRecipeMap = this.getRecipeMap(); if (gtRecipeMap == null) return false; - ArrayList<ItemStack> tInputList = getStoredInputs(); + ArrayList<ItemStack> tInputList = this.getStoredInputs(); int tInputList_sS = tInputList.size(); for (int i = 0; i < tInputList_sS - 1; i++) { for (int j = i + 1; j < tInputList_sS; j++) { @@ -177,7 +179,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { } ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); - ArrayList<FluidStack> tFluidList = getStoredFluids(); + ArrayList<FluidStack> tFluidList = this.getStoredFluids(); int tFluidList_sS = tFluidList.size(); for (int i = 0; i < tFluidList_sS - 1; i++) { for (int j = i + 1; j < tFluidList_sS; j++) { @@ -198,7 +200,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { if (tFluidList.size() > 0) { - GT_Recipe gtRecipe = gtRecipeMap.findRecipe(this.getBaseMetaTileEntity(), mLastRecipe, false, this.getMaxInputVoltage(), tFluids, itemStack, tInputs); + GT_Recipe gtRecipe = gtRecipeMap.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, this.getMaxInputVoltage(), tFluids, itemStack, tInputs); if (gtRecipe == null) return false; @@ -206,7 +208,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { if (!BW_Util.areStacksEqualOrNull((ItemStack) gtRecipe.mSpecialItems, itemStack)) return false; - int[] conditions = specialValueUnpack(gtRecipe.mSpecialValue); + int[] conditions = GT_TileEntity_BioVat.specialValueUnpack(gtRecipe.mSpecialValue); this.mNeededSievert = conditions[3]; @@ -216,22 +218,22 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { int times = 1; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; if (gtRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { - if (getStoredFluidOutputs().size() > 0) { + if (this.getStoredFluidOutputs().size() > 0) { this.mOutputFluids = new FluidStack[gtRecipe.mFluidOutputs.length]; - for (FluidStack storedOutputFluid : getStoredFluidOutputs()) { + for (FluidStack storedOutputFluid : this.getStoredFluidOutputs()) { if (storedOutputFluid.isFluidEqual(gtRecipe.getFluidOutput(0))) for (FluidStack inputFluidStack : gtRecipe.mFluidInputs) { - int j = calcMod(storedOutputFluid.amount); + int j = this.calcMod(storedOutputFluid.amount); for (int i = 0; i < j; i++) - if (depleteInput(inputFluidStack)) + if (this.depleteInput(inputFluidStack)) times++; } } - for (FluidStack storedfluidStack : getStoredFluidOutputs()) { + for (FluidStack storedfluidStack : this.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)); @@ -246,14 +248,14 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { BW_Util.calculateOverclockedNessMulti(gtRecipe.mEUt, gtRecipe.mDuration, 1, this.getMaxInputVoltage(), this); - if (mEUt > 0) - mEUt = -mEUt; + if (this.mEUt > 0) + this.mEUt = -this.mEUt; this.mProgresstime = 0; if (gtRecipe.mCanBeBuffered) - mLastRecipe = gtRecipe; + this.mLastRecipe = gtRecipe; - updateSlots(); + this.updateSlots(); return true; } return false; @@ -302,7 +304,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { //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 (!(this.addOutputToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX) || this.addRadiationInputToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX) || this.addInputToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX) || this.addMaintenanceToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX) || this.addEnergyInputToMachineList(tileEntity, GT_TileEntity_BioVat.MCASING_INDEX))) { if (BW_Util.addBlockToMachine(x, y, z, 2, aBaseMetaTileEntity, GregTech_API.sBlockCasings4, 1)) { ++blockcounter; continue; @@ -316,8 +318,8 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { } } 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))) { + this.mGlassTier = this.calculateGlassTier(aBaseMetaTileEntity.getBlockOffset(xDir + -2, y, zDir + z), aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)); + if (0 == this.mGlassTier || this.mGlassTier != this.calculateGlassTier(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z), aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z))) { return false; } } @@ -329,8 +331,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { if (this.mOutputHatches.size() == 1) if (this.mMaintenanceHatches.size() == 1) if (this.mInputHatches.size() > 0) - if (this.mEnergyHatches.size() > 0) - return true; + return this.mEnergyHatches.size() > 0; return false; } @@ -372,12 +373,12 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { } private void sendAllRequiredRendererPackets() { - int height = reCalculateHeight(); + int height = this.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); + this.sendPackagesOrRenewRenderer(x, y, z, this.mCulture); } } @@ -385,8 +386,8 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { 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.NULLCULTURE.getColorRGB() : lCulture.getColorRGB()); + GT_TileEntity_BioVat.staticColorMap.remove(new Coords(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId)); + GT_TileEntity_BioVat.staticColorMap.put(new Coords(xDir + x + this.getBaseMetaTileEntity().getXCoord(), y + this.getBaseMetaTileEntity().getYCoord(), zDir + z + this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId), lCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : lCulture.getColorRGB()); if (FMLCommonHandler.instance().getSide().isServer()) { MainMod.BW_Network_instance.sendPacketToAllPlayersInRange( @@ -420,7 +421,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { this.getBaseMetaTileEntity().getZCoord() ); } - needsVisualUpdate = true; + this.needsVisualUpdate = true; } private void check_Chunk() { @@ -436,12 +437,12 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { 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(); + if (!this.playerMPHashSet.contains(tPlayer)) { + this.playerMPHashSet.add(tPlayer); + this.sendAllRequiredRendererPackets(); } } else { - playerMPHashSet.remove(tPlayer); + this.playerMPHashSet.remove(tPlayer); } } @@ -451,10 +452,10 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { 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) + this.height = this.reCalculateHeight(); + if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) for (int x = -1; x < 2; x++) { - for (int y = 0; y < height; y++) { + for (int y = 0; y < this.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); @@ -477,50 +478,50 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { public void doAllVisualThings() { if (this.getBaseMetaTileEntity().isServerSide()) { - if (mMachine) { + if (this.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(); + this.check_Chunk(); } - if (needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % TIMERDIVIDER == 0) { + if (this.needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % GT_TileEntity_BioVat.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.areStacksEqualOrNull(aStack, mStack))) || (needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % TIMERDIVIDER == 1)) { + this.height = this.reCalculateHeight(); + if (this.mFluid != null && this.height > 1 && this.reCalculateFluidAmmount() > 0) { + if ((!(BW_Util.areStacksEqualOrNull(aStack, this.mStack))) || (this.needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % GT_TileEntity_BioVat.TIMERDIVIDER == 1)) { for (int x = -1; x < 2; x++) { - for (int y = 1; y < height; y++) { + for (int y = 1; y < this.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")) { + if (this.mCulture == null || aStack == null || aStack.getTagCompound() == null || this.mCulture.getID() != aStack.getTagCompound().getInteger("ID")) { lCulture = aStack == null || aStack.getTagCompound() == null ? null : BioCulture.getBioCulture(aStack.getTagCompound().getString("Name")); - sendPackagesOrRenewRenderer(x, y, z, lCulture); + this.sendPackagesOrRenewRenderer(x, y, z, lCulture); } } } } } - mStack = aStack; - mCulture = lCulture; + this.mStack = aStack; + this.mCulture = lCulture; } - if (needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % TIMERDIVIDER == 1) { + if (this.needsVisualUpdate && this.getBaseMetaTileEntity().getTimer() % GT_TileEntity_BioVat.TIMERDIVIDER == 1) { if (this.getBaseMetaTileEntity().isClientSide()) new Throwable().printStackTrace(); - placeFluid(); - needsVisualUpdate = false; + this.placeFluid(); + this.needsVisualUpdate = false; } } } else { - onRemoval(); + this.onRemoval(); } } } @@ -528,9 +529,9 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); - if (height != reCalculateHeight()) - needsVisualUpdate = true; - doAllVisualThings(); + if (this.height != this.reCalculateHeight()) + this.needsVisualUpdate = true; + this.doAllVisualThings(); if (this.getBaseMetaTileEntity().isServerSide() && this.mRadHatches.size() == 1) { this.mSievert = this.mRadHatches.get(0).getSievert(); if (this.getBaseMetaTileEntity().isActive() && this.mNeededSievert > this.mSievert) @@ -540,14 +541,14 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { @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.setInteger("mFluidHeight", this.height); + if (this.mCulture != null && !this.mCulture.getName().isEmpty()) + aNBT.setString("mCulture", this.mCulture.getName()); + else if ((this.mCulture == null || this.mCulture.getName().isEmpty()) && !aNBT.getString("mCulture").isEmpty()) { aNBT.removeTag("mCulture"); } if (this.mFluid != null) - aNBT.setString("mFluid", mFluid.getName()); + aNBT.setString("mFluid", this.mFluid.getName()); aNBT.setInteger("mSievert",this.mSievert); aNBT.setInteger("mNeededSievert",this.mNeededSievert); super.saveNBTData(aNBT); @@ -562,7 +563,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { 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); + GT_TileEntity_BioVat.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(), @@ -573,7 +574,7 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { zDir + z + this.getBaseMetaTileEntity().getZCoord(), this.getBaseMetaTileEntity().getWorld().provider.dimensionId ), - mCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : mCulture.getColorRGB(), + this.mCulture == null ? BioCulture.NULLCULTURE.getColorRGB() : this.mCulture.getColorRGB(), true ), this.getBaseMetaTileEntity().getXCoord(), @@ -619,6 +620,6 @@ public class GT_TileEntity_BioVat extends GT_MetaTileEntity_MultiBlockBase { @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[GT_TileEntity_BioVat.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]}; + return aSide == aFacing ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GT_TileEntity_BioVat.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[GT_TileEntity_BioVat.MCASING_INDEX]}; } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java index 9b145f0123..ef71506d0e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CircuitAssemblyLine.java @@ -22,22 +22,39 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_Meta_Items; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.CircuitImprintLoader; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +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_MultiBlockBase; -import gregtech.api.objects.GT_ItemStack; +import gregtech.api.metatileentity.implementations.*; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; import java.util.Collection; +import java.util.HashSet; public class GT_TileEntity_CircuitAssemblyLine extends GT_MetaTileEntity_MultiBlockBase { - private NBTTagCompound type; - private GT_Recipe bufferedRecipe = null; + public String getTypeForDisplay() { + if (this.type.equals(new NBTTagCompound())) + return ""; + return GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(CircuitImprintLoader.getStackFromTag(this.type))); + } + + private NBTTagCompound type = new NBTTagCompound(); + private GT_Recipe bufferedRecipe; public GT_TileEntity_CircuitAssemblyLine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -47,67 +64,210 @@ public class GT_TileEntity_CircuitAssemblyLine extends GT_MetaTileEntity_MultiBl super(aName); } + private boolean imprintMachine(ItemStack itemStack){ + if (!this.type.equals(new NBTTagCompound())) + return true; + if (!GT_Utility.isStackValid(itemStack)) + return false; + if (itemStack.getItem() instanceof BW_Meta_Items.BW_GT_MetaGenCircuits && itemStack.getItemDamage() == 0 && itemStack.getTagCompound() != null && this.type.equals(new NBTTagCompound())){ + this.type = itemStack.getTagCompound(); + this.mInventory[1] = null; + this.getBaseMetaTileEntity().issueBlockUpdate(); + return true; + } + return false; + } + @Override public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } - return false; + @Override + public void startSoundLoop(byte aIndex, double aX, double aY, double aZ) { + super.startSoundLoop(aIndex, aX, aY, aZ); + if (aIndex == 20) { + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(212), 10, 1.0F, aX, aY, aZ); + } } @Override public void loadNBTData(NBTTagCompound aNBT) { + this.type = aNBT.getCompoundTag("Type"); super.loadNBTData(aNBT); - type = aNBT.getCompoundTag("Type"); } @Override public void saveNBTData(NBTTagCompound aNBT) { + if (!this.type.equals(new NBTTagCompound())) + aNBT.setTag("Type", this.type); super.saveNBTData(aNBT); - aNBT.setTag("Type",type); + } + private final Collection<GT_Recipe> GT_RECIPE_COLLECTION = new HashSet<>(); + @Override public boolean checkRecipe(ItemStack itemStack) { - if (type == null) - return false; + if (this.type.equals(new NBTTagCompound())) + if (!this.imprintMachine(itemStack)) + return false; - if (bufferedRecipe != null && bufferedRecipe.isRecipeInputEqual(false,true,BW_Util.getFluidsFromInputHatches(this),BW_Util.getItemsFromInputBusses(this))) + if (this.bufferedRecipe != null && this.bufferedRecipe.isRecipeInputEqual(true,false, BW_Util.getFluidsFromInputHatches(this), BW_Util.getItemsFromInputBusses(this))) { + BW_Util.calculateOverclockedNessMulti(this.bufferedRecipe.mEUt,this.bufferedRecipe.mDuration,1,this.getMaxInputVoltage(),this); + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = this.bufferedRecipe.mOutputs; + this.mOutputFluids = this.bufferedRecipe.mFluidOutputs; + this.updateSlots(); return true; + } - ItemStack stack = ItemStack.loadItemStackFromNBT(type); + ItemStack stack = ItemStack.loadItemStackFromNBT(this.type); if (stack == null) return false; - Collection<GT_Recipe> recipes = null; - - for (GT_ItemStack GTitemstack : GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeItemMap.keySet()){ - if (GTitemstack.mItem.equals(stack.getItem()) && GTitemstack.mMetaData == (short) stack.getItemDamage()){ - recipes = GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeItemMap.get(GTitemstack); - break; + if (this.GT_RECIPE_COLLECTION.isEmpty()) { + for (GT_Recipe recipe : BWRecipes.instance.getMappingsFor((byte) 3).mRecipeList) { + if (GT_Utility.areStacksEqual(recipe.mOutputs[0], stack, true)) { + this.GT_RECIPE_COLLECTION.add(recipe); + } } } - if (recipes == null || recipes.isEmpty()) - return false; + for (GT_Recipe recipe : this.GT_RECIPE_COLLECTION) { + if (recipe.isRecipeInputEqual(true,false, BW_Util.getFluidsFromInputHatches(this), BW_Util.getItemsFromInputBusses(this))) + this.bufferedRecipe = recipe; + else + continue; - for (GT_Recipe recipe : recipes){ - if (recipe.isRecipeInputEqual(false,true,BW_Util.getFluidsFromInputHatches(this),BW_Util.getItemsFromInputBusses(this))) - bufferedRecipe = recipe; + BW_Util.calculateOverclockedNessMulti(this.bufferedRecipe.mEUt,this.bufferedRecipe.mDuration,1,this.getMaxInputVoltage(),this); + this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); + this.mOutputItems = this.bufferedRecipe.mOutputs; + this.mOutputFluids = this.bufferedRecipe.mFluidOutputs; + this.updateSlots(); + return true; } + return false; + } + @Override + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int r; + int i; + IGregTechTileEntity tTileEntity; + if (xDir != 0) { + for(r = 0; r <= 7; ++r) { + i = r * xDir; + tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, 0, i); + if (!this.addEnergyInputToMachineList(tTileEntity, 16)) + if ((aBaseMetaTileEntity.getBlockOffset(0, 0, i) != GregTech_API.sBlockCasings3 || aBaseMetaTileEntity.getMetaIDOffset(0, 0, i) != 10) && r == 1) + return false; + if (!aBaseMetaTileEntity.getBlockOffset(0, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) + return false; - return true; + tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(0, -2, i); + if (!this.addMaintenanceToMachineList(tTileEntity, 16) && !this.addInputToMachineList(tTileEntity, 16)) + if (aBaseMetaTileEntity.getBlockOffset(0, -2, i) != GregTech_API.sBlockCasings2 || aBaseMetaTileEntity.getMetaIDOffset(0, -2, i) != 0) + return false; + + if (i != 0 && (aBaseMetaTileEntity.getBlockOffset(xDir, -1, i) != GregTech_API.sBlockCasings2 || aBaseMetaTileEntity.getMetaIDOffset(xDir, -1, i) != 5)) + return false; + + if (!aBaseMetaTileEntity.getBlockOffset(xDir * 2, -1, i).getUnlocalizedName().equals("blockAlloyGlass")) + return false; + + tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir * 2, -2, i); + if (!this.addMaintenanceToMachineList(tTileEntity, 16) && !this.addInputToMachineList(tTileEntity, 16)) + if (aBaseMetaTileEntity.getBlockOffset(xDir * 2, -2, i) != GregTech_API.sBlockCasings2 || aBaseMetaTileEntity.getMetaIDOffset(xDir * 2, -2, i) != 0) + return false; + + tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir, -2, i); + if (!this.addInputToMachineList(tTileEntity, 16) && this.addOutputToMachineList(tTileEntity, 16)) + return r > 0 && this.mEnergyHatches.size() > 0; + + } + } else { + + for(r = 0; r <= 7; ++r) { + i = r * -zDir; + + //top with grate and energy hatch + tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, 0, zDir); + if (!this.addEnergyInputToMachineList(tTileEntity, 16)) + if ((aBaseMetaTileEntity.getBlockOffset(i, 0, 0) != GregTech_API.sBlockCasings3 || aBaseMetaTileEntity.getMetaIDOffset(i, 0, 0) != 10) && r == 1) + return false; + + if (!aBaseMetaTileEntity.getBlockOffset(i, -1, 0).getUnlocalizedName().equals("blockAlloyGlass")) + return false; + + tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, 0); + if (!this.addMaintenanceToMachineList(tTileEntity, 16) && !this.addInputToMachineList(tTileEntity, 16)) + if (aBaseMetaTileEntity.getBlockOffset(i, -2, 0) != GregTech_API.sBlockCasings2 || aBaseMetaTileEntity.getMetaIDOffset(i, -2, 0) != 0) + return false; + + if (i != 0 && (aBaseMetaTileEntity.getBlockOffset(i, -1, zDir) != GregTech_API.sBlockCasings2 || aBaseMetaTileEntity.getMetaIDOffset(i, -1, zDir) != 5)) + return false; + + if (!aBaseMetaTileEntity.getBlockOffset(i, -1, zDir * 2).getUnlocalizedName().equals("blockAlloyGlass")) + return false; + + + tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir * 2); + if (!this.addMaintenanceToMachineList(tTileEntity, 16) && !this.addInputToMachineList(tTileEntity, 16)) + if (aBaseMetaTileEntity.getBlockOffset(i, -2, zDir * 2) != GregTech_API.sBlockCasings2 || aBaseMetaTileEntity.getMetaIDOffset(i, -2, zDir * 2) != 0) + return false; + + tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(i, -2, zDir); + if (!this.addInputToMachineList(tTileEntity, 16) && this.addOutputToMachineList(tTileEntity, 16)) + return r > 0 && this.mEnergyHatches.size() == 1; + } + } + + return false; } @Override - public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return false; + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputHatches.add((GT_MetaTileEntity_Hatch_Input)aMetaTileEntity); + } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus && ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier == 0) { + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity).mRecipeMap = this.getRecipeMap(); + return this.mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus)aMetaTileEntity); + } else { + return false; + } + } + } + + @Override + public boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus && ((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity).mTier == 0) { + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus)aMetaTileEntity); + } else { + return false; + } + } } @Override public int getMaxEfficiency(ItemStack itemStack) { - return 0; + return 10000; } @Override @@ -132,11 +292,35 @@ public class GT_TileEntity_CircuitAssemblyLine extends GT_MetaTileEntity_MultiBl @Override public String[] getDescription() { - return new String[0]; + return new String[]{ + "Circuit Assembly Line", "Size(WxHxD): (2-7)x3x3, variable length", + "Bottom: Steel Machine Casing(or 1x Maintenance or Input Hatch),", + "ULV Input Bus (Last ULV Output Bus), Steel Machine Casing", + "Middle: Reinforced Glass, Assembling Line Casing, Reinforced Glass", + "Top: Grate Machine Casing (or Controller or 1x Energy Hatch)", + "Up to 7 repeating slices, last is Output Bus", + "Imprint this machine with a Circuit Imprint,", + "by putting the imprint in the controller.", + "Every Circuit Assembly Line can only be imprinted ONCE.", + StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks" + }; + } + + @Override + public String[] getInfoData() { + String[] ret = new String[super.getInfoData().length+1]; + System.arraycopy(super.getInfoData(),0,ret,0,super.getInfoData().length); + ret[super.getInfoData().length] = "Imprinted with: "+ GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(CircuitImprintLoader.getStackFromTag(this.type))); + return ret; + } + + @Override + public boolean isGivingInformation() { + return true; } @Override - public ITexture[] getTexture(IGregTechTileEntity iGregTechTileEntity, byte b, byte b1, byte b2, boolean b3, boolean b4) { - return new ITexture[0]; + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + return aSide == aFacing ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ASSEMBLY_LINE)} : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[16]}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java index f7ac05a7f9..50e2c7e632 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_CrackingDistillTower.java @@ -72,10 +72,10 @@ public class GT_TileEntity_CrackingDistillTower extends GT_MetaTileEntity_Distil } BWRecipes.DynamicGTRecipe combined = new BWRecipes.DynamicGTRecipe(true, null, recipeDistill.mOutputs, null, recipeDistill.mChances, recipeCracking.mFluidInputs, nuoutputs, (int) (Math.floor(recipeDistill.mDuration * ratio)) + recipeCracking.mDuration, Math.max((int) (Math.floor(recipeDistill.mEUt * ratio)), recipeCracking.mEUt), 0); if (combined.isRecipeInputEqual(true, array)) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; BW_Util.calculateOverclockedNessMulti(combined.mEUt, combined.mDuration, 1, this.getMaxInputVoltage(), this); - if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; if (this.mEUt > 0) { this.mEUt = (-this.mEUt); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java index cb582e8e5d..9b826dc9f4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_DEHP.java @@ -52,12 +52,12 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { public GT_TileEntity_DEHP(int aID, int tier, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - mTier = (byte) tier; + this.mTier = (byte) tier; } public GT_TileEntity_DEHP(String aName, byte mTier) { super(aName); - this.mTier = (byte) mTier; + this.mTier = mTier; } @Override @@ -66,7 +66,7 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { Class c = TileEntityNuclearReactorElectric.class; Field f = c.getDeclaredField("huOutputModifier"); f.setAccessible(true); - nulearHeatMod = f.getFloat(f); + GT_TileEntity_DEHP.nulearHeatMod = f.getFloat(f); } catch (SecurityException | IllegalArgumentException | ExceptionInInitializerError | NullPointerException | IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } @@ -75,21 +75,21 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mTier", mTier); - aNBT.setByte("mMode", mMode); + aNBT.setByte("mTier", this.mTier); + aNBT.setByte("mMode", this.mMode); super.saveNBTData(aNBT); } @Override public void loadNBTData(NBTTagCompound aNBT) { - mTier = aNBT.getByte("mTier"); - mMode = aNBT.getByte("mMode"); + this.mTier = aNBT.getByte("mTier"); + this.mMode = aNBT.getByte("mMode"); super.loadNBTData(aNBT); } @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new GT_TileEntity_DEHP(this.mName, mTier); + return new GT_TileEntity_DEHP(this.mName, this.mTier); } @Override @@ -99,8 +99,8 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { @Override public String[] getDescription() { - String[] dscSteam = {"Controller Block for the Deep Earth Heat Pump " + (mTier > 1 ? mTier : ""), "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", "3x1x3 Base of " + getCasingBlockItem().name(), "1x3x1 " + getCasingBlockItem().name() + " pillar (Center of base)", "1x3x1 " + this.getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", "1x Input Hatch (One of base casings)", "1x Output Hatch (One of base casings)", "1x Maintenance Hatch (One of base casings)", "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", "Consumes " + GT_Values.V[mTier + 2] + "EU/t", "Has 4 Modes, use the Screwdriver to change them:", "0 Idle, 1 Steam, 2 Superheated Steam (requires Distilled Water), 3 Retract", "Explodes when it runs out of Water/Distilled Water", "Converts " + (long) (mTier * 1200 * 20) + "L/s Water(minus 10% per Maintenance Problem) to Steam", "Converts " + (long) (mTier * 600 * 20) + "L/s Distilled Water(minus 10% per Maintenance Problem) to SuperheatedSteam"}; - String[] dscCooleant = {"Controller Block for the Deep Earth Heat Pump " + (mTier > 1 ? mTier : ""), "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", "3x1x3 Base of " + getCasingBlockItem().name(), "1x3x1 " + getCasingBlockItem().name() + " pillar (Center of base)", "1x3x1 " + this.getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", "1x Input Hatch (One of base casings)", "1x Output Hatch (One of base casings)", "1x Maintenance Hatch (One of base casings)", "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", "Consumes " + GT_Values.V[mTier + 2] + "EU/t", "Has 4 Modes, use the Screwdriver to change them:", "0 Idle, 1 & 2 Coolant Heating Mode (no Difference between them), 3 Retract", "Explodes when it runs out of Coolant", "Heats up " + (long) (mTier * 24 * ((double) nulearHeatMod)) * 20 + "L/s Coolant(minus 10% per Maintenance Problem)"}; + String[] dscSteam = {"Controller Block for the Deep Earth Heat Pump " + (this.mTier > 1 ? this.mTier : ""), "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", "3x1x3 Base of " + this.getCasingBlockItem().name(), "1x3x1 " + this.getCasingBlockItem().name() + " pillar (Center of base)", "1x3x1 " + this.getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", "1x Input Hatch (One of base casings)", "1x Output Hatch (One of base casings)", "1x Maintenance Hatch (One of base casings)", "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", "Consumes " + GT_Values.V[this.mTier + 2] + "EU/t", "Has 4 Modes, use the Screwdriver to change them:", "0 Idle, 1 Steam, 2 Superheated Steam (requires Distilled Water), 3 Retract", "Explodes when it runs out of Water/Distilled Water", "Converts " + (long) (this.mTier * 1200 * 20) + "L/s Water(minus 10% per Maintenance Problem) to Steam", "Converts " + (long) (this.mTier * 600 * 20) + "L/s Distilled Water(minus 10% per Maintenance Problem) to SuperheatedSteam"}; + String[] dscCooleant = {"Controller Block for the Deep Earth Heat Pump " + (this.mTier > 1 ? this.mTier : ""), "Size(WxHxD): 3x7x3", "Controller (Front middle at bottom)", "3x1x3 Base of " + this.getCasingBlockItem().name(), "1x3x1 " + this.getCasingBlockItem().name() + " pillar (Center of base)", "1x3x1 " + this.getFrameMaterial().mName + " Frame Boxes (Each pillar side and on top)", "1x Input Hatch (One of base casings)", "1x Output Hatch (One of base casings)", "1x Maintenance Hatch (One of base casings)", "1x " + GT_Values.VN[this.getMinTier()] + "+ Energy Hatch (Any bottom layer casing)", "Consumes " + GT_Values.V[this.mTier + 2] + "EU/t", "Has 4 Modes, use the Screwdriver to change them:", "0 Idle, 1 & 2 Coolant Heating Mode (no Difference between them), 3 Retract", "Explodes when it runs out of Coolant", "Heats up " + (long) (this.mTier * 24 * ((double) GT_TileEntity_DEHP.nulearHeatMod)) * 20 + "L/s Coolant(minus 10% per Maintenance Problem)"}; return ConfigHandler.DEHPDirectSteam ? dscSteam : dscCooleant; } @@ -121,7 +121,7 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { @Override protected int getMinTier() { - return 2 + mTier; + return 2 + this.mTier; } @Override @@ -153,7 +153,7 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { @Override protected boolean workingUpward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { - if (mMode != 3) { + if (this.mMode != 3) { this.isPickingPipes = false; try { Field workState = this.getClass().getField("workState"); @@ -169,15 +169,15 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { if (this.getBaseMetaTileEntity().getWorld().isRemote) return; - ++mMode; - if (mMode >= 4) - mMode = 0; - GT_Utility.sendChatToPlayer(aPlayer, "Mode: " + mMode); + ++this.mMode; + if (this.mMode >= 4) + this.mMode = 0; + GT_Utility.sendChatToPlayer(aPlayer, "Mode: " + this.mMode); super.onScrewdriverRightClick(aSide, aPlayer, aX, aY, aZ); } protected boolean workingDownward(ItemStack aStack, int xDrill, int yDrill, int zDrill, int xPipe, int zPipe, int yHead, int oldYHead) { - if (mMode == 3) { + if (this.mMode == 3) { this.isPickingPipes = true; try { Field workState = this.getClass().getSuperclass().getDeclaredField("workState"); @@ -191,40 +191,40 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { if (this.waitForPipes()) { return false; } else { - if (mMode == 0) - mMode = 1; + if (this.mMode == 0) + this.mMode = 1; if (ConfigHandler.DEHPDirectSteam) { - if (mMode == 1) { - long steamProduced = (mTier * 600 * 2L * this.mEfficiency / 10000L); + if (this.mMode == 1) { + long steamProduced = (this.mTier * 600 * 2L * this.mEfficiency / 10000L); long waterConsume = ((steamProduced + 160) / 160); - if (getWaterFromHatches(false) - waterConsume > 0) { - consumeFluid(FluidRegistry.WATER, waterConsume); - addOutput(GT_ModHandler.getSteam(steamProduced)); + if (this.getWaterFromHatches(false) - waterConsume > 0) { + this.consumeFluid(FluidRegistry.WATER, waterConsume); + this.addOutput(GT_ModHandler.getSteam(steamProduced)); } else { - explodeMultiblock(); + this.explodeMultiblock(); return false; } - } else if (mMode == 2) { - long steamProduced = (mTier * 300 * 2L * this.mEfficiency / 10000L); + } else if (this.mMode == 2) { + long steamProduced = (this.mTier * 300 * 2L * this.mEfficiency / 10000L); long waterConsume = ((steamProduced + 160) / 160); - if (getWaterFromHatches(true) - waterConsume > 0) { - consumeFluid(GT_ModHandler.getDistilledWater(1).getFluid(), waterConsume); - addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", (int) steamProduced)); + if (this.getWaterFromHatches(true) - waterConsume > 0) { + this.consumeFluid(GT_ModHandler.getDistilledWater(1).getFluid(), waterConsume); + this.addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", (int) steamProduced)); } else { - explodeMultiblock(); + this.explodeMultiblock(); return false; } } } else { - if (mMode == 1 || mMode == 2) { - long coolantConverted = (long) (mTier * 24 * ((double) nulearHeatMod) * this.mEfficiency / 10000L); - if (getFluidFromHatches(FluidRegistry.getFluid("ic2coolant")) - coolantConverted > 0) { - consumeFluid(FluidRegistry.getFluid("ic2coolant"), coolantConverted); - addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", (int) coolantConverted)); + if (this.mMode == 1 || this.mMode == 2) { + long coolantConverted = (long) (this.mTier * 24 * ((double) GT_TileEntity_DEHP.nulearHeatMod) * this.mEfficiency / 10000L); + if (this.getFluidFromHatches(FluidRegistry.getFluid("ic2coolant")) - coolantConverted > 0) { + this.consumeFluid(FluidRegistry.getFluid("ic2coolant"), coolantConverted); + this.addOutput(FluidRegistry.getFluidStack("ic2hotcoolant", (int) coolantConverted)); } else { - explodeMultiblock(); + this.explodeMultiblock(); return false; } } @@ -249,11 +249,8 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { } } - if (tmp[tmp.length - 1] <= 0) { - return true; - } + return tmp[tmp.length - 1] <= 0; - return false; } long tmp = ammount; @@ -269,14 +266,14 @@ public class GT_TileEntity_DEHP extends GT_MetaTileEntity_DrillerBase { @Override protected void setElectricityStats() { try { - this.mEUt = isPickingPipes ? 60 : Math.toIntExact(GT_Values.V[getMinTier()]); + this.mEUt = this.isPickingPipes ? 60 : Math.toIntExact(GT_Values.V[this.getMinTier()]); } catch (ArithmeticException e) { e.printStackTrace(); this.mEUt = Integer.MAX_VALUE - 7; } this.mProgresstime = 0; this.mMaxProgresstime = 1; - this.mEfficiency = this.getCurrentEfficiency((ItemStack) null); + this.mEfficiency = this.getCurrentEfficiency(null); this.mEfficiencyIncrease = 10000; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java index cd45301d4f..2dff59f0a2 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ElectricImplosionCompressor.java @@ -35,7 +35,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; @@ -65,8 +64,8 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity for (int i = 0; i < tInputList_sS - 1; ++i) { for (int j = i + 1; j < tInputList_sS; ++j) { - if (GT_Utility.areStacksEqual((ItemStack) tInputList.get(i), (ItemStack) tInputList.get(j))) { - if (((ItemStack) tInputList.get(i)).stackSize < ((ItemStack) tInputList.get(j)).stackSize) { + if (GT_Utility.areStacksEqual(tInputList.get(i), tInputList.get(j))) { + if (tInputList.get(i).stackSize < tInputList.get(j).stackSize) { tInputList.remove(i--); tInputList_sS = tInputList.size(); break; @@ -78,10 +77,10 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity } } - ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); + ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); if (tInputList.size() > 0) { - GT_Recipe tRecipe = eicMap.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, (FluidStack[]) null, tInputs); - if (tRecipe != null && tRecipe.isRecipeInputEqual(true, (FluidStack[]) null, tInputs)) { + GT_Recipe tRecipe = GT_TileEntity_ElectricImplosionCompressor.eicMap.findRecipe(this.getBaseMetaTileEntity(), false, 9223372036854775807L, null, tInputs); + if (tRecipe != null && tRecipe.isRecipeInputEqual(true, null, tInputs)) { this.mEfficiency = 10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000; this.mEfficiencyIncrease = 10000; this.mEUt = -tRecipe.mEUt; @@ -99,24 +98,24 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity @Override public boolean onRunningTick(ItemStack aStack) { if (this.mRuntime % 10 == 0) - togglePiston(); + this.togglePiston(); return super.onRunningTick(aStack); } public void stopMachine() { - resetPiston(); + this.resetPiston(); super.stopMachine(); } @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - piston = true; + this.piston = true; } private void resetPiston() { if (this.getBaseMetaTileEntity().getWorld().isRemote) return; - if (!piston) { + if (!this.piston) { int xDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetX; int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; int aX = this.getBaseMetaTileEntity().getXCoord(), aY = this.getBaseMetaTileEntity().getYCoord(), aZ = this.getBaseMetaTileEntity().getZCoord(); @@ -126,8 +125,8 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity this.getBaseMetaTileEntity().getWorld().setBlock(xDir + aX + x, aY + 2, zDir + aZ + z, GregTech_API.sBlockMetal5, 2, 3); } } - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); - piston = !piston; + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); + this.piston = !this.piston; } } @@ -138,7 +137,7 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity int zDir = ForgeDirection.getOrientation(this.getBaseMetaTileEntity().getBackFacing()).offsetZ; int aX = this.getBaseMetaTileEntity().getXCoord(), aY = this.getBaseMetaTileEntity().getYCoord(), aZ = this.getBaseMetaTileEntity().getZCoord(); boolean hax = false; - if (piston) { + if (this.piston) { for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { if (!(Math.abs(x) == 1 && Math.abs(z) == 1)) { @@ -149,8 +148,8 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity } } } - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); - piston = !piston; + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); + this.piston = !this.piston; } else { for (int x = -1; x <= 1; x++) { for (int z = -1; z <= 1; z++) { @@ -158,8 +157,8 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity this.getBaseMetaTileEntity().getWorld().setBlock(xDir + aX + x, aY + 2, zDir + aZ + z, GregTech_API.sBlockMetal5, 2, 3); } } - GT_Utility.doSoundAtClient((String) GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); - piston = !piston; + GT_Utility.doSoundAtClient(GregTech_API.sSoundList.get(5), 10, 1.0F, aX, aY, aZ); + this.piston = !this.piston; } if (hax) this.explodeMultiblock(); @@ -167,13 +166,13 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("piston", piston); + aNBT.setBoolean("piston", this.piston); super.saveNBTData(aNBT); } @Override public void loadNBTData(NBTTagCompound aNBT) { - piston = aNBT.getBoolean("piston"); + this.piston = aNBT.getBoolean("piston"); super.loadNBTData(aNBT); } @@ -217,18 +216,18 @@ public class GT_TileEntity_ElectricImplosionCompressor extends GT_MetaTileEntity } } else if (y == 1) { - if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 1, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 1, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, 1, zDir + z)), Materials.Neutronium.getBlocks(1))) return false; } else if (y == 2) { - if (!piston) { + if (!this.piston) { if (Math.abs(x) == 1 && Math.abs(z) == 1) { - if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, 2, zDir + z)), Materials.Neutronium.getBlocks(1))) return false; } } else if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 2, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) return false; } else if (y == 3) { - if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 3, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z)), Materials.Neutronium.getBlocks(1))) + if (!GT_Utility.areStacksEqual(new ItemStack(aBaseMetaTileEntity.getBlockOffset(xDir + x, 3, zDir + z), 1, aBaseMetaTileEntity.getMetaIDOffset(xDir + x, 3, zDir + z)), Materials.Neutronium.getBlocks(1))) return false; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java index 471373e3dd..06ecfecd26 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_LESU.java @@ -61,9 +61,9 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { private static final byte TEXID_CHARGING = 1; private static final byte TEXID_IDLE = 2; private static final byte TEXID_EMPTY = 3; - 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 IIcon[] iIcons = new IIcon[4]; + private static final IIconContainer[] iIconContainers = new IIconContainer[4]; + private static final ITexture[][] iTextures = new ITexture[4][1]; public ConnectedBlocksChecker connectedcells; public ItemStack[] circuits = new ItemStack[5]; private long mStorage; @@ -104,14 +104,14 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public long maxAmperesOut() { - return maxAmperesIn(); + return this.maxAmperesIn(); } @Override 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]) + if (this.maxEUOutput() <= GT_Values.V[i] && this.maxEUOutput() > GT_Values.V[i - 1]) return Math.min(GT_Values.V[i], 32768L); } @@ -150,7 +150,7 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new GT_TileEntity_LESU(mName); + return new GT_TileEntity_LESU(this.mName); } @Override @@ -173,18 +173,18 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister aBlockIconRegister) { - for (int i = 0; i < iTextures.length; i++) { - iIcons[i] = aBlockIconRegister.registerIcon(MainMod.MOD_ID + ":LESU_CASING_" + i); - final int finalI = i; - iIconContainers[i] = new IIconContainer() { + for (int i = 0; i < GT_TileEntity_LESU.iTextures.length; i++) { + GT_TileEntity_LESU.iIcons[i] = aBlockIconRegister.registerIcon(MainMod.MOD_ID + ":LESU_CASING_" + i); + int finalI = i; + GT_TileEntity_LESU.iIconContainers[i] = new IIconContainer() { @Override public IIcon getIcon() { - return iIcons[finalI]; + return GT_TileEntity_LESU.iIcons[finalI]; } @Override public IIcon getOverlayIcon() { - return iIcons[finalI]; + return GT_TileEntity_LESU.iIcons[finalI]; } @Override @@ -207,8 +207,8 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { } public boolean isClientSide() { - if (getWorld() != null) - return getWorld().isRemote ? FMLCommonHandler.instance().getSide() == Side.CLIENT : FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT; + if (this.getWorld() != null) + return this.getWorld().isRemote ? FMLCommonHandler.instance().getSide() == Side.CLIENT : FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT; return FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT; } @@ -220,18 +220,18 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { 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)); + for (int i = 0; i < GT_TileEntity_LESU.iTextures.length; i++) { + GT_TileEntity_LESU.iTextures[i][0] = new GT_RenderedTexture(GT_TileEntity_LESU.iIconContainers[i], Dyes.getModulation(0, Dyes.MACHINE_METAL.mRGBa)); } if (aSide == aFacing && this.getBaseMetaTileEntity().getUniversalEnergyStored() <= 0) - ret = iTextures[TEXID_EMPTY]; + ret = GT_TileEntity_LESU.iTextures[GT_TileEntity_LESU.TEXID_EMPTY]; else if (aSide == aFacing && !aActive) - ret = iTextures[TEXID_IDLE]; + ret = GT_TileEntity_LESU.iTextures[GT_TileEntity_LESU.TEXID_IDLE]; else if (aSide == aFacing && aActive) - ret = iTextures[TEXID_CHARGING]; + ret = GT_TileEntity_LESU.iTextures[GT_TileEntity_LESU.TEXID_CHARGING]; else - ret = iTextures[TEXID_SIDE]; + ret = GT_TileEntity_LESU.iTextures[GT_TileEntity_LESU.TEXID_SIDE]; } return ret; @@ -321,7 +321,7 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - checkMachine(aBaseMetaTileEntity, null); + this.checkMachine(aBaseMetaTileEntity, null); super.onFirstTick(aBaseMetaTileEntity); } @@ -330,7 +330,7 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { if (aBaseMetaTileEntity.isServerSide()) { this.mMaxProgresstime = 1; if (aTick % 20 == 0) - checkMachine(aBaseMetaTileEntity, null); + this.checkMachine(aBaseMetaTileEntity, null); this.mWrench = true; this.mScrewdriver = true; this.mSoftHammer = true; @@ -369,10 +369,10 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { long startingTime = System.nanoTime(); - connectedcells = new ConnectedBlocksChecker(); - connectedcells.get_connected(aBaseMetaTileEntity.getWorld(), aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), ItemRegistry.BW_BLOCKS[1]); + this.connectedcells = new ConnectedBlocksChecker(); + this.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 (this.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; @@ -382,7 +382,7 @@ public class GT_TileEntity_LESU extends GT_MetaTileEntity_MultiBlockBase { } 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.mStorage = (ConfigHandler.energyPerCell * this.connectedcells.hashset.size() >= Long.MAX_VALUE - 1 || ConfigHandler.energyPerCell * this.connectedcells.hashset.size() < 0) ? Long.MAX_VALUE - 1 : ConfigHandler.energyPerCell * this.connectedcells.hashset.size(); this.mMaxProgresstime = 1; this.mProgresstime = 0; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java index c403d990d6..9543643c3c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_ManualTrafo.java @@ -48,9 +48,9 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase 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 byte mode; + private final byte texid = 2; + private long mCoilWicks; private boolean upstep = true; public GT_TileEntity_ManualTrafo(int aID, String aName, String aNameRegional) { @@ -89,7 +89,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase else this.mEfficiency = this.getMaxEfficiency(null); - if (this.mode > SINGLE_DOWNSTEP) { + if (this.mode > GT_TileEntity_ManualTrafo.SINGLE_DOWNSTEP) { return this.onRunningTickTabbedMode(); } @@ -100,8 +100,8 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase public boolean onRunningTickTabbedMode() { boolean ret = false; - for (GT_MetaTileEntity_Hatch_Dynamo E : mDynamoHatches) { - for (GT_MetaTileEntity_Hatch_Energy I : mEnergyHatches) { + for (GT_MetaTileEntity_Hatch_Dynamo E : this.mDynamoHatches) { + for (GT_MetaTileEntity_Hatch_Energy I : this.mEnergyHatches) { long vtt = I.getEUVar() >= (V[E.mTier] / 2) && E.getEUVar() < E.maxEUStore() ? I.getEUVar() : 0; @@ -143,7 +143,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase 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; + return this.upstep ? this.getOutputTier() - this.getInputTier() == this.mCoilWicks : this.getInputTier() - this.getOutputTier() == this.mCoilWicks; } @Override @@ -166,7 +166,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase 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) { + if (this.mCoilWicks % 8 == 0) { ++y; continue; } @@ -179,7 +179,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase } } - if (mCoilWicks % 8 != 0) + if (this.mCoilWicks % 8 != 0) return false; this.mCoilWicks = this.mCoilWicks / 8; @@ -196,7 +196,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase for (int z = -1; z <= 1; ++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 (!this.addMaintenanceToMachineList(tTileEntity, this.texid) && !this.addEnergyInputToMachineList(tTileEntity, this.texid)) { if (aBaseMetaTileEntity.getBlockOffset(xDir + x, 0, zDir + z) != GregTech_API.sBlockCasings1) { return false; } @@ -212,7 +212,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase for (int x = -1; x <= 1; ++x) for (int z = -1; z <= 1; ++z) { IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, (int) this.mCoilWicks + 1, zDir + z); - if (!this.addMaintenanceToMachineList(tTileEntity, texid) && !this.addDynamoToMachineList(tTileEntity, texid)) { + if (!this.addMaintenanceToMachineList(tTileEntity, this.texid) && !this.addDynamoToMachineList(tTileEntity, this.texid)) { if (aBaseMetaTileEntity.getBlockOffset(xDir + x, (int) this.mCoilWicks + 1, zDir + z) != GregTech_API.sBlockCasings1) { return false; } @@ -251,7 +251,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase 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) { + if (this.mCoilWicks % 8 == 0) { ++y; continue; } @@ -264,7 +264,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase } } - if (mCoilWicks % 8 != 0) + if (this.mCoilWicks % 8 != 0) return false; this.mCoilWicks = this.mCoilWicks / 8; @@ -281,7 +281,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase 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 (!this.addMaintenanceToMachineList(tTileEntity, this.texid) && !this.addEnergyInputToMachineList(tTileEntity, this.texid)) { if (aBaseMetaTileEntity.getBlockOffset(xDir + x, 0, zDir + z) != GregTech_API.sBlockCasings1) { return false; } @@ -297,7 +297,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase 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 (!this.addMaintenanceToMachineList(tTileEntity, this.texid) && !this.addDynamoToMachineList(tTileEntity, this.texid)) { if (aBaseMetaTileEntity.getBlockOffset(xDir + x, (int) this.mCoilWicks + 1, zDir + z) != GregTech_API.sBlockCasings1) { return false; } @@ -340,7 +340,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase 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 (!this.addMaintenanceToMachineList(tTileEntity, this.texid) && !this.addEnergyInputToMachineList(tTileEntity, this.texid, leveltier) && !this.addDynamoToMachineList(tTileEntity, this.texid, leveltier)) { if (aBaseMetaTileEntity.getBlockOffset(xDir + x, ty, zDir + z) != GregTech_API.sBlockCasings1) { return false; } @@ -348,10 +348,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase } } } - if (this.mDynamoHatches.isEmpty() || this.mEnergyHatches.isEmpty()) - return false; - - return true; + return !this.mDynamoHatches.isEmpty() && !this.mEnergyHatches.isEmpty(); } @Override @@ -376,7 +373,7 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new GT_TileEntity_ManualTrafo(mName); + return new GT_TileEntity_ManualTrafo(this.mName); } @Override @@ -392,19 +389,19 @@ public class GT_TileEntity_ManualTrafo extends GT_MetaTileEntity_MultiBlockBase @Override public void saveNBTData(NBTTagCompound ntag) { - ntag.setLong("mCoilWicks", mCoilWicks); + ntag.setLong("mCoilWicks", this.mCoilWicks); super.saveNBTData(ntag); } @Override public void loadNBTData(NBTTagCompound ntag) { super.loadNBTData(ntag); - mCoilWicks = ntag.getLong("mCoilWicks"); + this.mCoilWicks = ntag.getLong("mCoilWicks"); } @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[texid], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)} : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[texid]}; + return aSide == aFacing ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[this.texid], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE)} : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[this.texid]}; } public boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex, short tier) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java index 193a1ffacb..d1b0d2ebce 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_THTR.java @@ -76,30 +76,30 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - HeliumSupply=aNBT.getInteger("HeliumSupply"); - BISOPeletSupply=aNBT.getInteger("BISOPeletSupply"); - TRISOPeletSupply=aNBT.getInteger("TRISOPeletSupply"); - empty=aNBT.getBoolean("EmptyMode"); + this.HeliumSupply =aNBT.getInteger("HeliumSupply"); + this.BISOPeletSupply =aNBT.getInteger("BISOPeletSupply"); + this.TRISOPeletSupply =aNBT.getInteger("TRISOPeletSupply"); + this.empty =aNBT.getBoolean("EmptyMode"); } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setInteger("HeliumSupply",HeliumSupply); - aNBT.setInteger("BISOPeletSupply",BISOPeletSupply); - aNBT.setInteger("TRISOPeletSupply",TRISOPeletSupply); - aNBT.setBoolean("EmptyMode",empty); + aNBT.setInteger("HeliumSupply", this.HeliumSupply); + aNBT.setInteger("BISOPeletSupply", this.BISOPeletSupply); + aNBT.setInteger("TRISOPeletSupply", this.TRISOPeletSupply); + aNBT.setBoolean("EmptyMode", this.empty); } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { super.onPostTick(aBaseMetaTileEntity, aTick); if (aBaseMetaTileEntity.isServerSide()){ - if (HeliumSupply < HELIUM_NEEDED){ + if (this.HeliumSupply < GT_TileEntity_THTR.HELIUM_NEEDED){ for (FluidStack fluidStack : this.getStoredFluids()){ if (fluidStack.isFluidEqual(Materials.Helium.getGas(1000))) { - while (HeliumSupply < HELIUM_NEEDED && fluidStack.amount > 0) { - HeliumSupply++; + while (this.HeliumSupply < GT_TileEntity_THTR.HELIUM_NEEDED && fluidStack.amount > 0) { + this.HeliumSupply++; fluidStack.amount--; } } @@ -107,18 +107,18 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { } for (ItemStack itemStack : this.getStoredInputs()) { if (GT_Utility.areStacksEqual(itemStack, new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 3))) { - if (BISOPeletSupply + TRISOPeletSupply < 675000) { - while (BISOPeletSupply + TRISOPeletSupply < 675000 && itemStack.stackSize > 0) { + if (this.BISOPeletSupply + this.TRISOPeletSupply < 675000) { + while (this.BISOPeletSupply + this.TRISOPeletSupply < 675000 && itemStack.stackSize > 0) { itemStack.stackSize--; - TRISOPeletSupply++; + this.TRISOPeletSupply++; } this.updateSlots(); } } else if (GT_Utility.areStacksEqual(itemStack, new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, 1, 1))) { - if (BISOPeletSupply + TRISOPeletSupply < 675000) { - while (BISOPeletSupply + TRISOPeletSupply < 675000 && itemStack.stackSize > 0) { + if (this.BISOPeletSupply + this.TRISOPeletSupply < 675000) { + while (this.BISOPeletSupply + this.TRISOPeletSupply < 675000 && itemStack.stackSize > 0) { itemStack.stackSize--; - BISOPeletSupply++; + this.BISOPeletSupply++; } this.updateSlots(); @@ -131,7 +131,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { @Override public boolean checkRecipe(ItemStack controllerStack) { - if (!(HeliumSupply >= HELIUM_NEEDED && BISOPeletSupply + TRISOPeletSupply >= 100000)) + if (!(this.HeliumSupply >= GT_TileEntity_THTR.HELIUM_NEEDED && this.BISOPeletSupply + this.TRISOPeletSupply >= 100000)) return false; if (new XSTR().nextBoolean()) { @@ -149,21 +149,20 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { this.updateSlots(); if (this.mOutputFluids == null || this.mOutputFluids[0] == null) this.mOutputFluids = new FluidStack[]{FluidRegistry.getFluidStack("ic2hotcoolant",0)}; - //this.mOutputFluids[0].amount+=toProduce; + this.mEUt=0; this.mMaxProgresstime=648000; - return true; } @Override public boolean onRunningTick(ItemStack aStack) { - if (empty){ - this.addOutput(Materials.Helium.getGas(HeliumSupply)); - this.addOutput(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, TRISOPeletSupply, 3)); - this.addOutput(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, BISOPeletSupply, 1)); + if (this.empty){ + this.addOutput(Materials.Helium.getGas(this.HeliumSupply)); + this.addOutput(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, this.TRISOPeletSupply, 3)); + this.addOutput(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials, this.BISOPeletSupply, 1)); this.HeliumSupply = 0; this.TRISOPeletSupply = 0; this.BISOPeletSupply = 0; @@ -178,7 +177,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { } } - toProduce = (long) ((0.03471*(float)this.TRISOPeletSupply + 0.0267*(float)this.BISOPeletSupply)); + toProduce = (long) ((0.00711111111111111111111111111111D*(double)this.TRISOPeletSupply + 0.00474074074074074074074074074074D*(double)this.BISOPeletSupply)); if (toProduce > accessibleCoolant) { // new ExplosionIC2( @@ -213,7 +212,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack itemStack) { - final byte xz = 5; + byte xz = 5; int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * xz; int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * xz; for (int x = -xz; x <= xz; x++) { @@ -230,9 +229,9 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { if (!(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 12)) { if ( ( - !(this.addInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), BASECASINGINDEX) && y == 11) && - !(this.addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), BASECASINGINDEX) && y == 0)) && - !this.addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), BASECASINGINDEX) + !(this.addInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), GT_TileEntity_THTR.BASECASINGINDEX) && y == 11) && + !(this.addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), GT_TileEntity_THTR.BASECASINGINDEX) && y == 0)) && + !this.addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), GT_TileEntity_THTR.BASECASINGINDEX) ) { return false; } @@ -250,7 +249,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { { if (!(aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z) == GregTech_API.sBlockCasings3 && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == 12)) { if ( - !this.addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), BASECASINGINDEX)) + !this.addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), GT_TileEntity_THTR.BASECASINGINDEX)) { return false; } @@ -296,7 +295,7 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { "Progress:", this.mProgresstime / 20 + "secs", this.mMaxProgresstime / 20 + "secs", "BISO-Pebbles:", this.BISOPeletSupply + "pcs.", "TRISO-Pebbles:", this.TRISOPeletSupply + "pcs.", - "Helium-Level:", this.HeliumSupply+"L / "+HELIUM_NEEDED+"L", + "Helium-Level:", this.HeliumSupply+"L / "+ GT_TileEntity_THTR.HELIUM_NEEDED +"L", "Coolant/t:", this.BISOPeletSupply+this.TRISOPeletSupply >= 100000 ? (long) ((0.03471*(float)this.TRISOPeletSupply + 0.0267*(float)this.BISOPeletSupply))+"L/t" : "0L/t", "Problems:", String.valueOf(this.getIdealStatus() - this.getRepairStatus()) }; @@ -315,13 +314,13 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { @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[BASECASINGINDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)} : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[BASECASINGINDEX]}; + return aSide == aFacing ? new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GT_TileEntity_THTR.BASECASINGINDEX], new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER)} : new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[GT_TileEntity_THTR.BASECASINGINDEX]}; } @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - empty = !empty; - GT_Utility.sendChatToPlayer(aPlayer,empty ? "THTR will now empty itself." : "THTR is back in normal Operation"); + this.empty = !this.empty; + GT_Utility.sendChatToPlayer(aPlayer, this.empty ? "THTR will now empty itself." : "THTR is back in normal Operation"); } public static class THTRMaterials{ @@ -339,17 +338,17 @@ public class GT_TileEntity_THTR extends GT_MetaTileEntity_MultiBlockBase { new ItemStack(GregTech_API.sBlockCasings3,1,12), 40, BW_Util.getMachineVoltageFromTier(5) - ); - GT_Values.RA.addMixerRecipe(WerkstoffLoader.Thorium232.get(OrePrefixes.dust,10),Materials.Uranium235.getDust(1),GT_Utility.getIntegratedCircuit(1),null,null,null,new ItemStack(aTHTR_Materials),400,30); - GT_Values.RA.addFormingPressRecipe(new ItemStack(aTHTR_Materials),Materials.Graphite.getDust(64),new ItemStack(aTHTR_Materials,1,4),40,30); + ); + GT_Values.RA.addMixerRecipe(WerkstoffLoader.Thorium232.get(OrePrefixes.dust,10),Materials.Uranium235.getDust(1),GT_Utility.getIntegratedCircuit(1),null,null,null,new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials),400,30); + GT_Values.RA.addFormingPressRecipe(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials),Materials.Graphite.getDust(64),new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,1,4),40,30); ItemStack[] pellets = new ItemStack[6]; - Arrays.fill(pellets,new ItemStack(aTHTR_Materials,64,1)); - GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe(false,new ItemStack[]{new ItemStack(aTHTR_Materials,1,4),GT_Utility.getIntegratedCircuit(17)},pellets,null,null,null,null,24000,30,0); - GT_Values.RA.addFormingPressRecipe(new ItemStack(aTHTR_Materials,1,4),Materials.Silicon.getDust(64),new ItemStack(aTHTR_Materials,1,2),40,30); - GT_Values.RA.addFormingPressRecipe(new ItemStack(aTHTR_Materials,1,2),Materials.Graphite.getDust(64),new ItemStack(aTHTR_Materials,1,5),40,30); + Arrays.fill(pellets,new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,64,1)); + GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe(false,new ItemStack[]{new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,1,4),GT_Utility.getIntegratedCircuit(17)},pellets,null,null,null,null,24000,30,0); + GT_Values.RA.addFormingPressRecipe(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,1,4),Materials.Silicon.getDust(64),new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,1,2),40,30); + GT_Values.RA.addFormingPressRecipe(new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,1,2),Materials.Graphite.getDust(64),new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,1,5),40,30); pellets = new ItemStack[6]; - Arrays.fill(pellets,new ItemStack(aTHTR_Materials,64,3)); - GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe(false,new ItemStack[]{new ItemStack(aTHTR_Materials,1,5),GT_Utility.getIntegratedCircuit(17)},pellets,null,null,null,null,48000,30,0); + Arrays.fill(pellets,new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,64,3)); + GT_Recipe.GT_Recipe_Map.sCentrifugeRecipes.addRecipe(false,new ItemStack[]{new ItemStack(GT_TileEntity_THTR.THTRMaterials.aTHTR_Materials,1,5),GT_Utility.getIntegratedCircuit(17)},pellets,null,null,null,null,48000,30,0); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java index a1b10d27a8..625e857401 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/GT_TileEntity_Windmill.java @@ -63,9 +63,9 @@ import static gregtech.api.enums.GT_Values.V; public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { - private static IIcon[] iIcons = new IIcon[2]; - private static IIconContainer[] iIconContainers = new IIconContainer[2]; - private static ITexture[] iTextures = new ITexture[3]; + private static final IIcon[] iIcons = new IIcon[2]; + private static final IIconContainer[] iIconContainers = new IIconContainer[2]; + private static final ITexture[] iTextures = new ITexture[3]; private final ArrayList<TileEntityDispenser> tedList = new ArrayList<TileEntityDispenser>(); private BW_RotorBlock rotorBlock; @@ -104,35 +104,35 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { GT_Recipe.GT_Recipe_Map tMap = GT_Recipe.GT_Recipe_Map.sMaceratorRecipes; if (tMap == null) return false; - GT_Recipe tRecipe = tMap.findRecipe(getBaseMetaTileEntity(), false, false, V[1], null, aStack); + GT_Recipe tRecipe = tMap.findRecipe(this.getBaseMetaTileEntity(), false, false, V[1], null, aStack); if (tRecipe == null) return false; if (tRecipe.getOutput(0) != null) { aStack.stackSize--; - mOutputItems[0] = tRecipe.getOutput(0); + this.mOutputItems[0] = tRecipe.getOutput(0); if (new XSTR().nextInt(2) == 0) { if (tRecipe.getOutput(1) != null) - mOutputItems[1] = tRecipe.getOutput(1); - else if (!BW_Util.checkStackAndPrefix(mOutputItems[0]) || + this.mOutputItems[1] = tRecipe.getOutput(1); + else if (!BW_Util.checkStackAndPrefix(this.mOutputItems[0]) || !( - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.METAL) || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTAL) || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTALLISABLE) + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.METAL) || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTAL) || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial.mSubTags.contains(SubTag.CRYSTALLISABLE) ) || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Flint || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Sugar || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Wheat || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Wood || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Clay || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Ash || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Snow || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.Stone || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.MeatRaw || - BW_Util.checkStackAndPrefix(mOutputItems[0]) && GT_OreDictUnificator.getAssociation(mOutputItems[0]).mMaterial.mMaterial == Materials.MeatCooked + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.Flint || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.Sugar || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.Wheat || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.Wood || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.Clay || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.Ash || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.Snow || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.Stone || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.MeatRaw || + BW_Util.checkStackAndPrefix(this.mOutputItems[0]) && GT_OreDictUnificator.getAssociation(this.mOutputItems[0]).mMaterial.mMaterial == Materials.MeatCooked ) - mOutputItems[1] = tRecipe.getOutput(0); + this.mOutputItems[1] = tRecipe.getOutput(0); } } this.mMaxProgresstime = (tRecipe.mDuration * 2 * 100); @@ -273,7 +273,7 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial == null || GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.getDust(1) == null ) - return recipe_fallback(itemStack); //fallback for all non-unificated Items + return this.recipe_fallback(itemStack); //fallback for all non-unificated Items //Ore Unificator shit for balance if (OrePrefixes.ingot.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix) || OrePrefixes.gem.equals(GT_OreDictUnificator.getAssociation(itemStack).mPrefix)) { @@ -330,7 +330,7 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { this.mOutputItems[0] = (GT_OreDictUnificator.get(OrePrefixes.dust, GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial, 1L)); return true; } - return recipe_fallback(itemStack); //2nd fallback + return this.recipe_fallback(itemStack); //2nd fallback } @Override @@ -573,16 +573,16 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { @Override public String[] getInfoData() { - return new String[]{"Progress:", this.mProgresstime + " Grindings of " + this.mMaxProgresstime + " needed Grindings", "GrindPower:", Integer.toString(this.rotorBlock.getGrindPower()) + "KU/t"}; + return new String[]{"Progress:", this.mProgresstime + " Grindings of " + this.mMaxProgresstime + " needed Grindings", "GrindPower:", this.rotorBlock.getGrindPower() + "KU/t"}; } @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister aBlockIconRegister) { - iIcons[0] = Blocks.brick_block.getIcon(0, 0); - iIconContainers[0] = new IIconContainer() { + GT_TileEntity_Windmill.iIcons[0] = Blocks.brick_block.getIcon(0, 0); + GT_TileEntity_Windmill.iIconContainers[0] = new IIconContainer() { @Override public IIcon getIcon() { - return iIcons[0]; + return GT_TileEntity_Windmill.iIcons[0]; } @Override @@ -596,11 +596,11 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { } }; - iIcons[1] = aBlockIconRegister.registerIcon(MainMod.MOD_ID + ":windmill_top"); - iIconContainers[1] = new IIconContainer() { + GT_TileEntity_Windmill.iIcons[1] = aBlockIconRegister.registerIcon(MainMod.MOD_ID + ":windmill_top"); + GT_TileEntity_Windmill.iIconContainers[1] = new IIconContainer() { @Override public IIcon getIcon() { - return iIcons[1]; + return GT_TileEntity_Windmill.iIcons[1]; } @Override @@ -622,22 +622,22 @@ public class GT_TileEntity_Windmill extends GT_MetaTileEntity_MultiBlockBase { ITexture[] ret = new ITexture[6]; - if (isClientSide()) { + if (this.isClientSide()) { if (aFacing == aSide || aSide == 0) { - iTextures[0] = new GT_RenderedTexture(iIconContainers[0]); + GT_TileEntity_Windmill.iTextures[0] = new GT_RenderedTexture(GT_TileEntity_Windmill.iIconContainers[0]); for (int i = 0; i < ret.length; i++) { - ret[i] = iTextures[0]; + ret[i] = GT_TileEntity_Windmill.iTextures[0]; } } else if (aSide == 1) { - iTextures[1] = new GT_RenderedTexture(iIconContainers[1]); + GT_TileEntity_Windmill.iTextures[1] = new GT_RenderedTexture(GT_TileEntity_Windmill.iIconContainers[1]); for (int i = 0; i < ret.length; i++) { - ret[i] = iTextures[1]; + ret[i] = GT_TileEntity_Windmill.iTextures[1]; } } else { - iTextures[2] = new GT_RenderedTexture(Textures.BlockIcons.COVER_WOOD_PLATE); + GT_TileEntity_Windmill.iTextures[2] = new GT_RenderedTexture(Textures.BlockIcons.COVER_WOOD_PLATE); for (int i = 0; i < ret.length; i++) { - ret[i] = iTextures[2]; + ret[i] = GT_TileEntity_Windmill.iTextures[2]; } } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java index 13a94b30f0..6c90893975 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaBlastFurnace.java @@ -24,7 +24,6 @@ package com.github.bartimaeusnek.bartworks.common.tileentities.multis.mega; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; -import com.github.bartimaeusnek.bartworks.system.log.DebugLog; import com.github.bartimaeusnek.bartworks.util.BW_Util; import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import gregtech.api.GregTech_API; @@ -32,6 +31,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ElectricBlastFurnace; @@ -43,15 +43,14 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import static gregtech.api.enums.GT_Values.V; public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBlastFurnace { - private int mHeatingCapacity = 0; - private byte glasTier = 0; + private int mHeatingCapacity; + private byte glasTier; private int polPtick = super.getPollutionPerTick(null) * ConfigHandler.megaMachinesMax; public GT_TileEntity_MegaBlastFurnace(int aID, String aName, String aNameRegional) { @@ -65,7 +64,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl public String[] getDescription() { String[] dsc = StatCollector.translateToLocal("tooltip.tile.mbf.0.name").split(";"); String tmp = dsc[dsc.length - 1]; - dsc[dsc.length - 1] = tmp + " " + Integer.toString(20 * this.getPollutionPerTick((ItemStack) null)) + " " + StatCollector.translateToLocal("tooltip.tile.mbf.1.name"); + dsc[dsc.length - 1] = tmp + " " + 20 * this.getPollutionPerTick(null) + " " + StatCollector.translateToLocal("tooltip.tile.mbf.1.name"); String[] fdsc = new String[dsc.length + 1]; for (int i = 0; i < dsc.length; i++) { fdsc[i] = dsc[i]; @@ -79,8 +78,8 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl return true; long allTheEu = 0; int hatches = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) { + for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { allTheEu += tHatch.getEUVar(); hatches++; } @@ -88,7 +87,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl return false; long euperhatch = aEU / hatches; HashSet<Boolean> returnset = new HashSet<>(); - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false)) returnset.add(true); else @@ -113,8 +112,8 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl @Override public boolean checkRecipe(ItemStack itemStack) { - ItemStack[] tInputs = (ItemStack[]) this.getStoredInputs().toArray(new ItemStack[0]); - FluidStack[] tFluids = (FluidStack[]) this.getStoredFluids().toArray(new FluidStack[0]); + ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]); + FluidStack[] tFluids = this.getStoredFluids().toArray(new FluidStack[0]); long tVoltage = this.getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); @@ -129,7 +128,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl int processed = 0; long nominalV = BW_Util.getnominalVoltage(this); - int tHeatCapacityDivTiers = (mHeatingCapacity - tRecipe.mSpecialValue) / 900; + int tHeatCapacityDivTiers = (this.mHeatingCapacity - tRecipe.mSpecialValue) / 900; long precutRecipeVoltage = (long) (tRecipe.mEUt * Math.pow(0.95, tHeatCapacityDivTiers)); while (this.getStoredInputs().size() > 0 && processed < ConfigHandler.megaMachinesMax) { @@ -147,7 +146,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl } if (found_Recipe) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; byte overclockCount = 0; @@ -158,11 +157,11 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl actualEUT = actualEUT / 2; divider++; } - overclockCount = calculateOverclockednessEBF((int) (actualEUT / (divider * 2)), tRecipe.mDuration * (divider * 2), nominalV); + overclockCount = this.calculateOverclockednessEBF((int) (actualEUT / (divider * 2)), tRecipe.mDuration * (divider * 2), nominalV); } else - overclockCount = calculateOverclockednessEBF(actualEUT, tRecipe.mDuration, nominalV); + overclockCount = this.calculateOverclockednessEBF(actualEUT, tRecipe.mDuration, nominalV); //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; if (this.mEUt > 0) { this.mEUt = (-this.mEUt); @@ -200,37 +199,42 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl 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; + this.mEUt = Integer.MAX_VALUE - 1; + this.mMaxProgresstime = Integer.MAX_VALUE - 1; } else { - mEUt = (int) (aEUt >> 2); - mMaxProgresstime = (int) xMaxProgresstime; + this.mEUt = (int) (aEUt >> 2); + this.mMaxProgresstime = (int) xMaxProgresstime; } //return 0; } else { //Long EUt calculation long xEUt = aEUt; //Isnt too low EUt check? - long tempEUt = xEUt < V[1] ? V[1] : xEUt; - - mMaxProgresstime = aDuration; + long tempEUt = Math.max(xEUt, V[1]); + this.mMaxProgresstime = aDuration; while (tempEUt <= V[mTier - 1]) { 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 + this.mMaxProgresstime >>= 1;//this is effect of overclocking + xEUt = this.mMaxProgresstime <= 0 ? xEUt >> 1 : xEUt << 2;//U know, if the time is less than 1 tick make the machine use less power timesOverclocked++; } + if (xEUt > maxInputVoltage){ + //downclock one notch, we have overshot. + xEUt >>=2; + this.mMaxProgresstime <<= 1; + timesOverclocked--; + } if (xEUt > Integer.MAX_VALUE - 1) { - mEUt = Integer.MAX_VALUE - 1; - mMaxProgresstime = Integer.MAX_VALUE - 1; + this.mEUt = Integer.MAX_VALUE - 1; + this.mMaxProgresstime = Integer.MAX_VALUE - 1; } else { - mEUt = (int) xEUt; - if (mEUt == 0) - mEUt = 1; - if (mMaxProgresstime == 0) - mMaxProgresstime = 1;//set time to 1 tick + this.mEUt = (int) xEUt; + if (this.mEUt == 0) + this.mEUt = 1; + if (this.mMaxProgresstime <= 0) + this.mMaxProgresstime = 1;//set time to 1 tick } } return timesOverclocked; @@ -238,41 +242,41 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl @Override public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - mHeatingCapacity = 0; + this.mHeatingCapacity = 0; HashSet<Boolean> ret = new HashSet<Boolean>(); ret.add(BW_Util.check_layer(iGregTechTileEntity, 7, -2, -1, GregTech_API.sBlockCasings1, 11, 7, false,false,true,GregTech_API.sBlockCasings1,11,true,11)); ret.add(BW_Util.check_layer(iGregTechTileEntity, 7, 17, 18, GregTech_API.sBlockCasings1, 11, 7, false, null, -1, 11)); ret.add(BW_Util.check_layer(iGregTechTileEntity, 6, -1, 17, GregTech_API.sBlockCasings5, -1, 7, false, false, true, Blocks.air, -1, false, 11)); for (int y = -1; y < 17; y++) { - ret.add(BW_Util.check_layer(iGregTechTileEntity, 7, y, y + 1, ItemRegistry.bw_glasses[0], -1, 7, y == 0, false, false, null, -1, true, 11)); - if (!getCoilHeat(iGregTechTileEntity, 7, y, 6)) + ret.add(BW_Util.check_layer(iGregTechTileEntity, 7, y, y + 1, ItemRegistry.bw_glasses[0], -1, 7, y == 0, false, false, null, -1, false, 11)); + if (!this.getCoilHeat(iGregTechTileEntity, 7, y, 6)) return false; List<Byte> metasFromLayer = BW_Util.getMetasFromLayer(iGregTechTileEntity, 7, y, y + 1, 7, y == 0, false, false); for (Byte meta : metasFromLayer) { byte inttier = BW_Util.getTierFromGlasMeta(meta); - if (glasTier > 0 && inttier != glasTier) + if (this.glasTier > 0 && inttier != this.glasTier) return false; - else if (glasTier == 0) - glasTier = inttier; + else if (this.glasTier == 0) + this.glasTier = inttier; } } int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX * 7; int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ * 7; for (int z = -6; z <= 6; z++) for (int x = -6; x <= 6; x++) { - if (!addMufflerToMachineList(iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + x, 17, zDir + z), 11)) { + if (!this.addMufflerToMachineList(iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + x, 17, zDir + z), 11)) { return false; } } if (!this.mOutputHatches.isEmpty()) { - for (GT_MetaTileEntity_Hatch_Output hatchOutput : mOutputHatches) + for (GT_MetaTileEntity_Hatch_Output hatchOutput : this.mOutputHatches) if (hatchOutput.getBaseMetaTileEntity().getYCoord() < iGregTechTileEntity.getYCoord()) return false; } - if (glasTier != 8 && !mEnergyHatches.isEmpty()) - for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : mEnergyHatches) { - if (glasTier < hatchEnergy.mTier) + if (this.glasTier != 8 && !this.mEnergyHatches.isEmpty()) + for (GT_MetaTileEntity_Hatch_Energy hatchEnergy : this.mEnergyHatches) { + if (this.glasTier < hatchEnergy.mTier) return false; } @@ -319,10 +323,10 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl default: break; } - if (mHeatingCapacity > 0 && internalH != mHeatingCapacity) + if (this.mHeatingCapacity > 0 && internalH != this.mHeatingCapacity) return false; - else if (mHeatingCapacity == 0) - mHeatingCapacity = internalH; + else if (this.mHeatingCapacity == 0) + this.mHeatingCapacity = internalH; } } return true; @@ -330,7 +334,7 @@ public class GT_TileEntity_MegaBlastFurnace extends GT_MetaTileEntity_ElectricBl @Override public int getPollutionPerTick(ItemStack aStack) { - return polPtick; + return this.polPtick; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java index 56b9197a2d..3c7c1db53d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaProcessingArray.java @@ -40,8 +40,8 @@ import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Basi public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_ProcessingArray { private GT_Recipe mLastRecipe; - private int tTier = 0; - private int mMult = 0; + private int tTier; + private int mMult; private String mMachine = ""; private GT_MetaTileEntity_Hatch_InputBus machineBus; public GT_TileEntity_MegaProcessingArray(int aID, String aName, String aNameRegional) { @@ -53,77 +53,77 @@ public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_Process } public boolean checkRecipe(ItemStack aStack) { - if (!isCorrectMachinePart(machineBus.mInventory[0])) { + if (!this.isCorrectMachinePart(this.machineBus.mInventory[0])) { return false; } - GT_Recipe.GT_Recipe_Map map = getRecipeMap(); + GT_Recipe.GT_Recipe_Map map = this.getRecipeMap(); if (map == null) return false; - ArrayList<ItemStack> tInputList = getStoredInputs(); + ArrayList<ItemStack> tInputList = this.getStoredInputs(); - if (mInventory[1].getUnlocalizedName().endsWith("10")) { - tTier = 9; - mMult = 2;//u need 4x less machines and they will use 4x less power - } else if (mInventory[1].getUnlocalizedName().endsWith("11")) { - tTier = 9; - mMult = 4;//u need 16x less machines and they will use 16x less power - } else if (mInventory[1].getUnlocalizedName().endsWith("12") || - mInventory[1].getUnlocalizedName().endsWith("13") || - mInventory[1].getUnlocalizedName().endsWith("14") || - mInventory[1].getUnlocalizedName().endsWith("15")) { - tTier = 9; - mMult = 6;//u need 64x less machines and they will use 64x less power - } else if (mInventory[1].getUnlocalizedName().endsWith("1")) { - tTier = 1; - mMult = 0;//*1 - } else if (mInventory[1].getUnlocalizedName().endsWith("2")) { - tTier = 2; - mMult = 0;//*1 - } else if (mInventory[1].getUnlocalizedName().endsWith("3")) { - tTier = 3; - mMult = 0;//*1 - } else if (mInventory[1].getUnlocalizedName().endsWith("4")) { - tTier = 4; - mMult = 0;//*1 - } else if (mInventory[1].getUnlocalizedName().endsWith("5")) { - tTier = 5; - mMult = 0;//*1 - } else if (mInventory[1].getUnlocalizedName().endsWith("6")) { - tTier = 6; - mMult = 0;//*1 - } else if (mInventory[1].getUnlocalizedName().endsWith("7")) { - tTier = 7; - mMult = 0;//*1 - } else if (mInventory[1].getUnlocalizedName().endsWith("8")) { - tTier = 8; - mMult = 0;//*1 - } else if (mInventory[1].getUnlocalizedName().endsWith("9")) { - tTier = 9; - mMult = 0;//*1 + if (this.mInventory[1].getUnlocalizedName().endsWith("10")) { + this.tTier = 9; + this.mMult = 2;//u need 4x less machines and they will use 4x less power + } else if (this.mInventory[1].getUnlocalizedName().endsWith("11")) { + this.tTier = 9; + this.mMult = 4;//u need 16x less machines and they will use 16x less power + } else if (this.mInventory[1].getUnlocalizedName().endsWith("12") || + this.mInventory[1].getUnlocalizedName().endsWith("13") || + this.mInventory[1].getUnlocalizedName().endsWith("14") || + this.mInventory[1].getUnlocalizedName().endsWith("15")) { + this.tTier = 9; + this.mMult = 6;//u need 64x less machines and they will use 64x less power + } else if (this.mInventory[1].getUnlocalizedName().endsWith("1")) { + this.tTier = 1; + this.mMult = 0;//*1 + } else if (this.mInventory[1].getUnlocalizedName().endsWith("2")) { + this.tTier = 2; + this.mMult = 0;//*1 + } else if (this.mInventory[1].getUnlocalizedName().endsWith("3")) { + this.tTier = 3; + this.mMult = 0;//*1 + } else if (this.mInventory[1].getUnlocalizedName().endsWith("4")) { + this.tTier = 4; + this.mMult = 0;//*1 + } else if (this.mInventory[1].getUnlocalizedName().endsWith("5")) { + this.tTier = 5; + this.mMult = 0;//*1 + } else if (this.mInventory[1].getUnlocalizedName().endsWith("6")) { + this.tTier = 6; + this.mMult = 0;//*1 + } else if (this.mInventory[1].getUnlocalizedName().endsWith("7")) { + this.tTier = 7; + this.mMult = 0;//*1 + } else if (this.mInventory[1].getUnlocalizedName().endsWith("8")) { + this.tTier = 8; + this.mMult = 0;//*1 + } else if (this.mInventory[1].getUnlocalizedName().endsWith("9")) { + this.tTier = 9; + this.mMult = 0;//*1 } else { - tTier = 0; - mMult = 0;//*1 + this.tTier = 0; + this.mMult = 0;//*1 } - if (!mMachine.equals(mInventory[1].getUnlocalizedName())) mLastRecipe = null; - mMachine = mInventory[1].getUnlocalizedName(); - ItemStack[] tInputs = (ItemStack[]) tInputList.toArray(new ItemStack[tInputList.size()]); + if (!this.mMachine.equals(this.mInventory[1].getUnlocalizedName())) this.mLastRecipe = null; + this.mMachine = this.mInventory[1].getUnlocalizedName(); + ItemStack[] tInputs = tInputList.toArray(new ItemStack[tInputList.size()]); - ArrayList<FluidStack> tFluidList = getStoredFluids(); + ArrayList<FluidStack> tFluidList = this.getStoredFluids(); - FluidStack[] tFluids = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); + FluidStack[] tFluids = tFluidList.toArray(new FluidStack[tFluidList.size()]); if (tInputList.size() > 0 || tFluids.length > 0) { - GT_Recipe tRecipe = map.findRecipe(getBaseMetaTileEntity(), mLastRecipe, false, gregtech.api.enums.GT_Values.V[tTier], tFluids, tInputs); + GT_Recipe tRecipe = map.findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, false, gregtech.api.enums.GT_Values.V[this.tTier], tFluids, tInputs); if (tRecipe != null) { if (GT_Mod.gregtechproxy.mLowGravProcessing && tRecipe.mSpecialValue == -100 && - !isValidForLowGravity(tRecipe, getBaseMetaTileEntity().getWorld().provider.dimensionId)) + !isValidForLowGravity(tRecipe, this.getBaseMetaTileEntity().getWorld().provider.dimensionId)) return false; - mLastRecipe = tRecipe; + this.mLastRecipe = tRecipe; this.mEUt = 0; this.mOutputItems = null; this.mOutputFluids = null; - int machines = Math.min(64, mInventory[1].stackSize << mMult); //Upped max Cap to 64 + int machines = Math.min(64, this.mInventory[1].stackSize << this.mMult); //Upped max Cap to 64 int i = 0; for (; i < machines; i++) { if (!tRecipe.isRecipeInputEqual(true, tFluids, tInputs)) { @@ -134,14 +134,14 @@ public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_Process } } this.mMaxProgresstime = tRecipe.mDuration; - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - BW_Util.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, map.mAmperage, GT_Values.V[tTier], this); + BW_Util.calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, map.mAmperage, GT_Values.V[this.tTier], this); //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; - this.mEUt = GT_Utility.safeInt(((long) this.mEUt * i) >> mMult, 1); - if (mEUt == Integer.MAX_VALUE - 1) + this.mEUt = GT_Utility.safeInt(((long) this.mEUt * i) >> this.mMult, 1); + if (this.mEUt == Integer.MAX_VALUE - 1) return false; if (this.mEUt > 0) { @@ -159,7 +159,7 @@ public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_Process for (int f = 0; f < tOut.length; f++) { if (tRecipe.mOutputs[f] != null && tOut[f] != null) { for (int g = 0; g < i; g++) { - if (getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) + if (this.getBaseMetaTileEntity().getRandomNumber(10000) < tRecipe.getOutputChance(f)) tOut[f].stackSize += tRecipe.mOutputs[f].stackSize; } } @@ -168,7 +168,7 @@ public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_Process int tSize = tFOut.amount; tFOut.amount = tSize * i; } - tOut = clean(tOut); + tOut = GT_MetaTileEntity_ProcessingArray.clean(tOut); this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); List<ItemStack> overStacks = new ArrayList<ItemStack>(); for (int f = 0; f < tOut.length; f++) { @@ -193,7 +193,7 @@ public class GT_TileEntity_MegaProcessingArray extends GT_MetaTileEntity_Process tOut = tSList.toArray(new ItemStack[tSList.size()]); this.mOutputItems = tOut; this.mOutputFluids = new FluidStack[]{tFOut}; - updateSlots(); + this.updateSlots(); return true; }/* else{ ...remoteRecipeCheck() diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java index a2227eb7a4..fd5fec2e16 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/multis/mega/GT_TileEntity_MegaVacuumFreezer.java @@ -29,6 +29,7 @@ import gregtech.api.GregTech_API; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_VacuumFreezer; @@ -71,8 +72,8 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre return true; long allTheEu = 0; int hatches = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) { + for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { allTheEu += tHatch.getEUVar(); hatches++; } @@ -80,7 +81,7 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre return false; long euperhatch = aEU / hatches; HashSet<Boolean> returnset = new HashSet<>(); - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) + for (GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euperhatch, false)) returnset.add(true); else @@ -90,7 +91,7 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre @Override public boolean checkRecipe(ItemStack itemStack) { - ItemStack[] tInputs = (ItemStack[]) this.getStoredInputs().toArray(new ItemStack[0]); + ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]); ArrayList<ItemStack> outputItems = new ArrayList<ItemStack>(); long tVoltage = this.getMaxInputVoltage(); @@ -112,7 +113,7 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre } if (found_Recipe) { - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); + this.mEfficiency = (10000 - (this.getIdealStatus() - this.getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; long actualEUT = (long) (tRecipe.mEUt) * processed; if (actualEUT > Integer.MAX_VALUE) { @@ -125,7 +126,7 @@ public class GT_TileEntity_MegaVacuumFreezer extends GT_MetaTileEntity_VacuumFre } else BW_Util.calculateOverclockedNessMulti((int) actualEUT, tRecipe.mDuration, 1, nominalV, this); //In case recipe is too OP for that machine - if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + if (this.mMaxProgresstime == Integer.MAX_VALUE - 1 && this.mEUt == Integer.MAX_VALUE - 1) return false; if (this.mEUt > 0) { this.mEUt = (-this.mEUt); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java index e138445f01..2453610894 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_AcidGenerator.java @@ -56,7 +56,7 @@ public class GT_MetaTileEntity_AcidGenerator extends GT_MetaTileEntity_BasicGene @Override public int getEfficiency() { - return 100 - 3 * mTier; + return 100 - 3 * this.mTier; } @Override @@ -110,6 +110,6 @@ public class GT_MetaTileEntity_AcidGenerator extends GT_MetaTileEntity_BasicGene @SuppressWarnings("deprecation") public String[] getDescription() { - return new String[]{StatCollector.translateToLocal("tooltip.tile.acidgen.0.name"), StatCollector.translateToLocal("tooltip.tile.acidgen.1.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + ChatColorHelper.YELLOW + getEfficiency(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + ChatColorHelper.YELLOW + maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; + return new String[]{StatCollector.translateToLocal("tooltip.tile.acidgen.0.name"), StatCollector.translateToLocal("tooltip.tile.acidgen.1.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.rotor.2.name") + " " + ChatColorHelper.YELLOW + this.getEfficiency(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + ChatColorHelper.YELLOW + this.maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java index e26b50cdd1..5ca5d59a19 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_BioLab.java @@ -54,11 +54,11 @@ 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) { - super(aID, aName, aNameRegional, aTier, 1, (String) null, 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"))); + super(aID, aName, aNameRegional, aTier, 1, null, 6, 2, GT_MetaTileEntity_BioLab.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); + super(aName, aTier, aAmperage, aDescription, aTextures, 6, 2, GT_MetaTileEntity_BioLab.MGUINAME, aNEIName); } @Override @@ -83,7 +83,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { FluidStack dnaFluid = Loader.isModLoaded("gendustry") ? FluidRegistry.getFluidStack("liquiddna", 1000) : Materials.Biomass.getFluid(1000L); if (this.getSpecialSlot() != null && this.getSpecialSlot().getItem() instanceof LabModule) { - int damage = getSpecialSlot().getItemDamage(); + int damage = this.getSpecialSlot().getItemDamage(); switch (damage) { case 0: if (GT_Utility.isStackValid(this.mInventory[4]) && this.mInventory[4].getItem() instanceof LabParts && this.mInventory[4].getItemDamage() == 0 && this.mInventory[4].getTagCompound() != null && //checks if it is a Culture @@ -101,7 +101,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { return super.checkRecipe(skipOC); if (this.mTier < rTier + cultureDNABioData.getTier()) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 4; i < 8; i++) { if (this.mInventory[i] != null) @@ -116,7 +116,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { 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; + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; } break; case 1: { @@ -133,7 +133,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { return super.checkRecipe(skipOC); if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 4; i < 8; i++) { if (this.mInventory[i] != null) @@ -154,7 +154,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { this.calculateOverclockedNess(BW_Util.getMachineVoltageFromTier(1 + rTier + cultureDNABioData.getTier()), 500); - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; } } @@ -174,7 +174,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { if (cultureDNABioData == null) return super.checkRecipe(skipOC); if (this.mTier < 1 + rTier + cultureDNABioData.getTier()) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 4; i < 6; i++) { if (this.mInventory[i] != null) this.mInventory[i].stackSize--; @@ -185,7 +185,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { } 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; + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; } } @@ -202,7 +202,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { if (cultureDNABioData == null || bioCulture == null) return super.checkRecipe(skipOC); if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 4; i < 7; i++) { if (this.mInventory[i] != null) this.mInventory[i].stackSize--; @@ -210,11 +210,11 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { this.mFluid.amount -= 1000; bioCulture.setPlasmid(BioPlasmid.convertDataToPlasmid(cultureDNABioData)); if (cultureDNABioData.getChance() > new XSTR().nextInt(10000)) { - this.mOutputItems[0] = BioItemList.getPetriDish(checkForExisting(bioCulture)); + this.mOutputItems[0] = BioItemList.getPetriDish(this.checkForExisting(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; + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; } } break; @@ -234,7 +234,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { if (cultureDNABioData == null) return super.checkRecipe(skipOC); if (this.mTier < 3 + rTier + cultureDNABioData.getTier()) - return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; + return GT_MetaTileEntity_BasicMachine.FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; for (int i = 4; i < 7; i++) { if (this.mInventory[i] != null) this.mInventory[i].stackSize--; @@ -246,7 +246,7 @@ public class GT_MetaTileEntity_BioLab extends GT_MetaTileEntity_BasicMachine { this.mOutputItems[0] = BioItemList.getPetriDish(out); } this.calculateOverclockedNess(BW_Util.getMachineVoltageFromTier(3 + rTier + cultureDNABioData.getTier()), 500); - return FOUND_AND_SUCCESSFULLY_USED_RECIPE; + return GT_MetaTileEntity_BasicMachine.FOUND_AND_SUCCESSFULLY_USED_RECIPE; } } break; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_CompressedFluidHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_CompressedFluidHatch.java new file mode 100644 index 0000000000..d4382eac7a --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_CompressedFluidHatch.java @@ -0,0 +1,57 @@ +/* + * 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.tiered; + +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.util.GT_Utility; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_CompressedFluidHatch extends GT_MetaTileEntity_Hatch_Input { + public GT_MetaTileEntity_CompressedFluidHatch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + this.mDescriptionArray[1] = "Capacity: 100000000L"; + } + + public GT_MetaTileEntity_CompressedFluidHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public int getCapacity() { + return 100000000; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return GT_Utility.areFluidsEqual(aFluid, Materials.LiquidAir.getFluid(1)); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_CompressedFluidHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java index 909d84bb31..8d3d6d1777 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Diode.java @@ -36,13 +36,13 @@ import net.minecraft.util.StatCollector; public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { - private long maxAmps = 0L; - private long aAmps = 0L; + private long maxAmps; + private long aAmps; public GT_MetaTileEntity_Diode(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, StatCollector.translateToLocal("tooltip.tile.diode.0.name")); - maxAmps = getAmpsfromMeta(aID); - aAmps = maxAmps; + this.maxAmps = this.getAmpsfromMeta(aID); + this.aAmps = this.maxAmps; } public GT_MetaTileEntity_Diode(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { @@ -52,9 +52,9 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { super.onFirstTick(aBaseMetaTileEntity); - if (maxAmps == 0 && !this.getBaseMetaTileEntity().getWorld().isRemote) { - maxAmps = getAmpsfromMeta(this.getBaseMetaTileEntity().getMetaTileID()); - aAmps = maxAmps; + if (this.maxAmps == 0 && !this.getBaseMetaTileEntity().getWorld().isRemote) { + this.maxAmps = this.getAmpsfromMeta(this.getBaseMetaTileEntity().getMetaTileID()); + this.aAmps = this.maxAmps; } } @@ -65,40 +65,40 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { if (this.getBaseMetaTileEntity().getWorld().isRemote) return; if (!aPlayer.isSneaking()) { - --aAmps; - if (aAmps < 0) - aAmps = maxAmps; - GT_Utility.sendChatToPlayer(aPlayer, "Max Amps: " + aAmps); + --this.aAmps; + if (this.aAmps < 0) + this.aAmps = this.maxAmps; + GT_Utility.sendChatToPlayer(aPlayer, "Max Amps: " + this.aAmps); }else{ - ++aAmps; - if (aAmps > maxAmps) - aAmps = 0; - GT_Utility.sendChatToPlayer(aPlayer, "Max Amps: " + aAmps); + ++this.aAmps; + if (this.aAmps > this.maxAmps) + this.aAmps = 0; + GT_Utility.sendChatToPlayer(aPlayer, "Max Amps: " + this.aAmps); } } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setLong("maxAmp", maxAmps); - aNBT.setLong("Amps", aAmps); + aNBT.setLong("maxAmp", this.maxAmps); + aNBT.setLong("Amps", this.aAmps); } @Override public void loadNBTData(NBTTagCompound aNBT) { - maxAmps = aNBT.getLong("maxAmp"); - aAmps = aNBT.getLong("Amps"); + this.maxAmps = aNBT.getLong("maxAmp"); + this.aAmps = aNBT.getLong("Amps"); super.loadNBTData(aNBT); } @Override public long maxAmperesOut() { - return aAmps; + return this.aAmps; } @Override public long maxAmperesIn() { - return aAmps; + return this.aAmps; } @Override @@ -123,6 +123,6 @@ public class GT_MetaTileEntity_Diode extends GT_MetaTileEntity_BasicHull { @SuppressWarnings("deprecation") public String[] getDescription() { - return new String[]{mDescription, StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.tile.tiereddsc.1.name") + " " + ChatColorHelper.YELLOW + maxAmperesIn(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + ChatColorHelper.YELLOW + maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; + return new String[]{this.mDescription, StatCollector.translateToLocal("tooltip.tile.tiereddsc.0.name") + " " + ChatColorHelper.YELLOW + GT_Values.V[this.mTier], StatCollector.translateToLocal("tooltip.tile.tiereddsc.1.name") + " " + ChatColorHelper.YELLOW + this.maxAmperesIn(), StatCollector.translateToLocal("tooltip.tile.tiereddsc.2.name") + " " + ChatColorHelper.YELLOW + this.maxAmperesOut(), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_GiantOutputHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_GiantOutputHatch.java new file mode 100644 index 0000000000..8bc01b5554 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_GiantOutputHatch.java @@ -0,0 +1,50 @@ +/* + * 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.tiered; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; + +public class GT_MetaTileEntity_GiantOutputHatch extends GT_MetaTileEntity_Hatch_Output { + + public GT_MetaTileEntity_GiantOutputHatch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + this.mDescriptionArray[1] = "Capacity: 100000000L"; + } + + public GT_MetaTileEntity_GiantOutputHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_GiantOutputHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public int getCapacity() { + return 100000000; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java index b88c6209a0..c84fbdfd13 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_RadioHatch.java @@ -58,21 +58,21 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { private short[] colorForGUI; private byte mass; private String material; - private byte coverage = 0; + private byte coverage; public GT_MetaTileEntity_RadioHatch(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 1, new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.0.name"), StatCollector.translateToLocal("tooltip.tile.tiereddsc.3.name") + " " + (aTier - 2) + " " + ((aTier - 2) >= 2 ? StatCollector.translateToLocal("tooltip.bw.kg.1.name") : StatCollector.translateToLocal("tooltip.bw.kg.0.name")), StatCollector.translateToLocal("tooltip.tile.radhatch.1.name"), StatCollector.translateToLocal("tooltip.bw.1.name") + ChatColorHelper.DARKGREEN + " BartWorks"}); - cap = aTier - 2; + this.cap = aTier - 2; } public GT_MetaTileEntity_RadioHatch(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 1, aDescription, aTextures); - cap = aTier - 2; + this.cap = aTier - 2; } public GT_MetaTileEntity_RadioHatch(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { super(aName, aTier, 1, aDescription, aTextures); - cap = aTier - 2; + this.cap = aTier - 2; } public static long calcDecayTicks(int x) { @@ -89,7 +89,7 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { } public int getSievert() { - return this.sievert - (int) Math.ceil((float) this.sievert / 100f * (float) coverage); + return this.sievert - (int) Math.ceil((float) this.sievert / 100f * (float) this.coverage); } public short[] getColorForGUI() { @@ -127,7 +127,7 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { - return new GT_MetaTileEntity_RadioHatch(mName, mTier, mDescriptionArray, mTextures); + return new GT_MetaTileEntity_RadioHatch(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); } @Override @@ -154,16 +154,16 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { if (this.getBaseMetaTileEntity().isServerSide()) { if (this.mass > 0) - ++timer; + ++this.timer; - if (this.mass > 0 && this.sievert > 0 && calcDecayTicks(this.sievert) > 0) { - if (timer % (calcDecayTicks(this.sievert)) == 0) { + if (this.mass > 0 && this.sievert > 0 && GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert) > 0) { + if (this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) == 0) { this.mass--; - if (mass == 0) { - material = StatCollector.translateToLocal("tooltip.bw.empty.name"); - sievert = 0; + if (this.mass == 0) { + this.material = StatCollector.translateToLocal("tooltip.bw.empty.name"); + this.sievert = 0; } - timer = 1; + this.timer = 1; } } @@ -217,13 +217,13 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { if (this.mass == 0 || this.sievert == calculateSv(materials)) { - if (this.mass + kg <= cap) { + if (this.mass + kg <= this.cap) { this.sievert = calculateSv(materials); this.mass += kg; this.mInventory[0].stackSize--; - updateSlots(); - colorForGUI = materials.mColor.mRGBa; - material = materials.mName; + this.updateSlots(); + this.colorForGUI = materials.mColor.mRGBa; + this.material = materials.mName; } } } @@ -235,9 +235,9 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { this.mass++; this.sievert = BioVatLogicAdder.RadioHatch.getIsSv().get(varStack); this.mInventory[0].stackSize--; - updateSlots(); - colorForGUI = null; - material = StatCollector.translateToLocal(varStack.getUnlocalizedName()); + this.updateSlots(); + this.colorForGUI = null; + this.material = StatCollector.translateToLocal(varStack.getUnlocalizedName()); return; } } @@ -255,13 +255,13 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { //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) { + if ((this.mass + (orePrefixes.equals(OrePrefixes.stickLong) ? 2 : 1)) <= this.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; + this.updateSlots(); + this.colorForGUI = materials.mColor.mRGBa; + this.material = materials.mName; } } } @@ -280,8 +280,8 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { @Override public String[] getInfoData() { - if (calcDecayTicks(this.sievert) != 0) - return new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + material, StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + sievert, StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + mass, StatCollector.translateToLocal("tooltip.tile.radhatch.5.name") + " " + +((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert) * 60)) + StatCollector.translateToLocal("tooltip.tile.radhatch.6.name") + "/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 + StatCollector.translateToLocal("tooltip.tile.radhatch.7.name") + "/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.8.name") + "/" + ((calcDecayTicks(this.sievert)) - timer % (calcDecayTicks(this.sievert))) / 20 / 60 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.9.name")}; + if (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert) != 0) + return new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + this.material, StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + this.sievert, StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + this.mass, StatCollector.translateToLocal("tooltip.tile.radhatch.5.name") + " " + +((GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) - this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert) * 60)) + StatCollector.translateToLocal("tooltip.tile.radhatch.6.name") + "/" + ((GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) - this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert))) / 20 + StatCollector.translateToLocal("tooltip.tile.radhatch.7.name") + "/" + ((GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) - this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert))) / 20 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.8.name") + "/" + ((GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert)) - this.timer % (GT_MetaTileEntity_RadioHatch.calcDecayTicks(this.sievert))) / 20 / 60 / 60 + StatCollector.translateToLocal("tooltip.tile.radhatch.9.name")}; else return new String[]{StatCollector.translateToLocal("tooltip.tile.radhatch.2.name") + " " + StatCollector.translateToLocal("tooltip.bw.empty.name"), StatCollector.translateToLocal("tooltip.tile.radhatch.3.name") + " " + "0", StatCollector.translateToLocal("tooltip.tile.radhatch.4.name") + " " + "0"}; } @@ -320,13 +320,13 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { @Override public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setByte("mMass", mass); - aNBT.setByte("mSv", (byte) (sievert - 100)); - aNBT.setByte("mCoverage", coverage); - aNBT.setInteger("mTextColor", BW_ColorUtil.getColorFromRGBArray(getColorForGUI())); - if (material != null && !material.isEmpty()) - aNBT.setString("mMaterial", material); - aNBT.setLong("timer", timer); + aNBT.setByte("mMass", this.mass); + aNBT.setByte("mSv", (byte) (this.sievert - 100)); + aNBT.setByte("mCoverage", this.coverage); + aNBT.setInteger("mTextColor", BW_ColorUtil.getColorFromRGBArray(this.getColorForGUI())); + if (this.material != null && !this.material.isEmpty()) + aNBT.setString("mMaterial", this.material); + aNBT.setLong("timer", this.timer); super.saveNBTData(aNBT); } @@ -336,12 +336,12 @@ public class GT_MetaTileEntity_RadioHatch extends GT_MetaTileEntity_Hatch { @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_ColorUtil.splitColorToRBGArray(aNBT.getInteger("mTextColor")); - material = aNBT.getString("mMaterial"); + this.timer = aNBT.getLong("timer"); + this.mass = aNBT.getByte("mMass"); + this.sievert = aNBT.getByte("mSv") + 100; + this.coverage = aNBT.getByte("mCoverage"); + this.colorForGUI = BW_ColorUtil.splitColorToRBGArray(aNBT.getInteger("mTextColor")); + this.material = aNBT.getString("mMaterial"); super.loadNBTData(aNBT); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java index 95625ea9f3..5fd9b5b5d7 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/tileentities/tiered/GT_MetaTileEntity_Transistor.java @@ -35,7 +35,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; public class GT_MetaTileEntity_Transistor extends GT_MetaTileEntity_TieredMachineBlock { - boolean powered = false; + boolean powered; public GT_MetaTileEntity_Transistor(int aID, String aName, String aNameRegional, int aTier, String aDescription, ITexture... aTextures) { super(aID, aName, aNameRegional, aTier, 0, aDescription, aTextures); @@ -91,25 +91,25 @@ public class GT_MetaTileEntity_Transistor extends GT_MetaTileEntity_TieredMachin if (aBaseMetaTileEntity.inputEnergyFrom(side)) { TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); if (!(tTileEntity instanceof IBasicEnergyContainer)) { - powered = false; + this.powered = false; return; } IBasicEnergyContainer tileAtSide = (IBasicEnergyContainer) tTileEntity; if (!tileAtSide.outputsEnergyTo((byte) ForgeDirection.WEST.flag) || !tileAtSide.isUniversalEnergyStored(4L)) { - powered = false; + this.powered = false; return; } if (!tileAtSide.decreaseStoredEnergyUnits(4, false)) { - powered = false; + this.powered = false; return; } if (aBaseMetaTileEntity.injectEnergyUnits(side, 4L, 1L) == 4L) { - powered = true; + this.powered = true; } } if (aBaseMetaTileEntity.isAllowedToWork()) - powered = !powered; + this.powered = !this.powered; } } @@ -124,11 +124,11 @@ public class GT_MetaTileEntity_Transistor extends GT_MetaTileEntity_TieredMachin @Override public long maxAmperesOut() { - return powered ? 1L : 0; + return this.powered ? 1L : 0; } public long maxEUOutput() { - return powered ? GT_Values.V[this.mTier] : 0; + return this.powered ? GT_Values.V[this.mTier] : 0; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java index 8590f1f713..0dd86aa030 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioLabHandler.java @@ -37,9 +37,9 @@ import java.awt.*; public class BW_NEI_BioLabHandler extends GT_NEI_DefaultHandler { public BW_NEI_BioLabHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) { super(aRecipeMap); - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getOverlayIdentifier())); if (!NEI_BW_Config.sIsAdded) { - FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtech@" + getRecipeName() + "@" + getOverlayIdentifier()); + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtech@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); GuiCraftingRecipe.craftinghandlers.add(this); GuiUsageRecipe.usagehandlers.add(this); } @@ -51,7 +51,7 @@ public class BW_NEI_BioLabHandler extends GT_NEI_DefaultHandler { public void loadCraftingRecipes(ItemStack aResult) { if (aResult != null && aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3) { - for (GT_Recipe recipe : getSortedRecipes()) { + for (GT_Recipe recipe : this.getSortedRecipes()) { if (aResult.getTagCompound() != null && recipe != null) for (int i = 0; i < recipe.mOutputs.length; i++) { if (recipe.mOutputs[i] != null) @@ -69,7 +69,7 @@ public class BW_NEI_BioLabHandler extends GT_NEI_DefaultHandler { @Override public void loadUsageRecipes(ItemStack aResult) { if (aResult != null && aResult.getItem() instanceof LabParts && aResult.getItemDamage() < 3) { - for (GT_Recipe recipe : getSortedRecipes()) { + for (GT_Recipe recipe : this.getSortedRecipes()) { if (aResult.getTagCompound() != null && recipe != null) for (int i = 0; i < recipe.mInputs.length; i++) { if (recipe.mInputs[i] != null) diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java index 4cf03fb000..ddf1da1e15 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_BioVatHandler.java @@ -42,9 +42,9 @@ public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { public BW_NEI_BioVatHandler(GT_Recipe.GT_Recipe_Map aRecipeMap) { super(aRecipeMap); - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), this.getOverlayIdentifier())); if (!NEI_BW_Config.sIsAdded) { - FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtech@" + getRecipeName() + "@" + getOverlayIdentifier()); + FMLInterModComms.sendRuntimeMessage(GT_Values.GT, "NEIPlugins", "register-crafting-handler", "gregtech@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); GuiCraftingRecipe.craftinghandlers.add(this); GuiUsageRecipe.usagehandlers.add(this); } @@ -63,38 +63,38 @@ public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { int tSpecial; if (recipeDesc == null) { if (tEUt != 0) { - drawText(10, lines[0], this.trans("152", "Total: ") + (long) tDuration * (long) tEUt + " EU", -16777216); - drawText(10, lines[1], this.trans("153", "Usage: ") + tEUt + " EU/t", -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[0], this.trans("152", "Total: ") + (long) tDuration * (long) tEUt + " EU", -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[1], this.trans("153", "Usage: ") + tEUt + " EU/t", -16777216); if (this.mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10, lines[2], this.trans("154", "Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); - drawText(10, lines[3], this.trans("155", "Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[2], this.trans("154", "Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[3], this.trans("155", "Amperage: ") + this.mRecipeMap.mAmperage, -16777216); } else { - drawText(10, lines[2], this.trans("156", "Voltage: unspecified"), -16777216); - drawText(10, lines[3], this.trans("157", "Amperage: unspecified"), -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[2], this.trans("156", "Voltage: unspecified"), -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[3], this.trans("157", "Amperage: unspecified"), -16777216); } } if (tDuration > 0) { - drawText(10, lines[4], this.trans("158", "Time: ") + String.format("%.2f " + this.trans("161", " secs"), 0.05F * (float) tDuration), -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[4], this.trans("158", "Time: ") + String.format("%.2f " + this.trans("161", " secs"), 0.05F * (float) tDuration), -16777216); } tSpecial = ((GT_NEI_DefaultHandler.CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; int[] tSpecialA = GT_TileEntity_BioVat.specialValueUnpack(tSpecial); - drawText(10, lines[5], StatCollector.translateToLocal("nei.biovat.0.name") + " " + tSpecialA[0], -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[5], StatCollector.translateToLocal("nei.biovat.0.name") + " " + tSpecialA[0], -16777216); if (tSpecialA[1] == -100 && GT_Mod.gregtechproxy.mLowGravProcessing) { - drawText(10, lines[7], this.trans("159", "Needs Low Gravity"), -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[7], this.trans("159", "Needs Low Gravity"), -16777216); } else if (tSpecialA[1] == -200 && GT_Mod.gregtechproxy.mEnableCleanroom) { - drawText(10, lines[7], this.trans("160", "Needs Cleanroom"), -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[7], this.trans("160", "Needs Cleanroom"), -16777216); } else if (tSpecialA[1] == -300 && GT_Mod.gregtechproxy.mEnableCleanroom) { - drawText(10, lines[7], this.trans("160", "Needs Cleanroom & LowGrav"), -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[7], this.trans("160", "Needs Cleanroom & LowGrav"), -16777216); } else if (tSpecialA[1] == -400) { - drawText(10, lines[7], this.trans("216", "Deprecated Recipe"), -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[7], this.trans("216", "Deprecated Recipe"), -16777216); } else if (GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePre) || GT_Utility.isStringValid(this.mRecipeMap.mNEISpecialValuePost)) { - drawText(10, lines[6], (tSpecialA[2] == 1 ? StatCollector.translateToLocal("nei.biovat.1.name") : StatCollector.translateToLocal("nei.biovat.2.name")) + this.mRecipeMap.mNEISpecialValuePre + tSpecialA[3] * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); + GT_NEI_DefaultHandler.drawText(10, lines[6], (tSpecialA[2] == 1 ? StatCollector.translateToLocal("nei.biovat.1.name") : StatCollector.translateToLocal("nei.biovat.2.name")) + this.mRecipeMap.mNEISpecialValuePre + tSpecialA[3] * this.mRecipeMap.mNEISpecialValueMultiplier + this.mRecipeMap.mNEISpecialValuePost, -16777216); } } else { tSpecial = 0; @@ -103,7 +103,7 @@ public class BW_NEI_BioVatHandler extends GT_NEI_DefaultHandler { for (int var8 = 0; var8 < var7; ++var8) { String descLine = var6[var8]; - drawText(10, 73 + 10 * tSpecial, descLine, -16777216); + GT_NEI_DefaultHandler.drawText(10, 73 + 10 * tSpecial, descLine, -16777216); ++tSpecial; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java index 1012cffc01..4f5f1a8cd2 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/BW_NEI_OreHandler.java @@ -29,9 +29,9 @@ import codechicken.nei.recipe.TemplateRecipeHandler; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Ores; import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; -import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import com.github.bartimaeusnek.bartworks.system.oregen.BW_OreLayer; import com.github.bartimaeusnek.bartworks.system.oregen.BW_WorldGenRoss128b; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; import cpw.mods.fml.common.event.FMLInterModComms; import gregtech.api.GregTech_API; import gregtech.api.enums.OrePrefixes; @@ -47,7 +47,7 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { public BW_NEI_OreHandler() { if (!NEI_BW_Config.sIsAdded) { - FMLInterModComms.sendRuntimeMessage(MainMod.MOD_ID, "NEIPlugins", "register-crafting-handler", MainMod.MOD_ID + "@" + getRecipeName() + "@" + getOverlayIdentifier()); + FMLInterModComms.sendRuntimeMessage(MainMod.MOD_ID, "NEIPlugins", "register-crafting-handler", MainMod.MOD_ID + "@" + this.getRecipeName() + "@" + this.getOverlayIdentifier()); GuiCraftingRecipe.craftinghandlers.add(this); // GuiUsageRecipe.usagehandlers.add(this); } @@ -60,7 +60,7 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { @Override public void loadTransferRects() { - transferRects.add(new RecipeTransferRect(new Rectangle(0,40,40,10),"quickanddirtyneihandler")); + this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(0,40,40,10),"quickanddirtyneihandler")); } @Override @@ -77,13 +77,13 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { continue; if (w.getGenerationFeatures().hasOres()) { ItemStack result = w.get(OrePrefixes.ore); - CachedRecipe tmp = new CachedRecipe() { + TemplateRecipeHandler.CachedRecipe tmp = new TemplateRecipeHandler.CachedRecipe() { PositionedStack stack = new PositionedStack(result, 0, 0); @Override public PositionedStack getResult() { - return stack; + return this.stack; } @Override @@ -96,7 +96,7 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { if (worldGen.mPrimaryMeta == baseMeta || worldGen.mSecondaryMeta == baseMeta || worldGen.mBetweenMeta == baseMeta || worldGen.mSporadicMeta == baseMeta) { ItemStack other; other = result.copy().setStackDisplayName(result.getDisplayName().replaceAll("Ore", "Vein")); - stack = new PositionedStack(other, 83, 0); + this.stack = new PositionedStack(other, 83, 0); if (((worldGen.bwOres & 0b1000) != 0)) { other = result.copy(); other.setItemDamage(worldGen.mPrimaryMeta); @@ -141,7 +141,7 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { } }; boolean add = true; - for (TemplateRecipeHandler.CachedRecipe recipe: arecipes) { + for (TemplateRecipeHandler.CachedRecipe recipe: this.arecipes) { if (recipe == null || recipe.getOtherStacks() == null || recipe.getOtherStacks().get(0) == null || recipe.getOtherStacks().get(0).item == null) continue; if (GT_Utility.areStacksEqual(recipe.getOtherStacks().get(0).item,tmp.getOtherStacks().get(0).item)) @@ -173,13 +173,13 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { @Override public void loadCraftingRecipes(ItemStack result) { if (Block.getBlockFromItem(result.getItem()) instanceof BW_MetaGenerated_Ores) { - CachedRecipe tmp = new CachedRecipe() { + TemplateRecipeHandler.CachedRecipe tmp = new TemplateRecipeHandler.CachedRecipe() { PositionedStack stack = new PositionedStack(result, 0, 0); @Override public PositionedStack getResult() { - return stack; + return this.stack; } @Override @@ -192,7 +192,7 @@ public class BW_NEI_OreHandler extends TemplateRecipeHandler { if (worldGen.mPrimaryMeta == baseMeta || worldGen.mSecondaryMeta == baseMeta || worldGen.mBetweenMeta == baseMeta || worldGen.mSporadicMeta == baseMeta) { ItemStack other; other = result.copy().setStackDisplayName(result.getDisplayName().replaceAll("Ore", "Vein")); - stack = new PositionedStack(other, 83, 0); + this.stack = new PositionedStack(other, 83, 0); if (((worldGen.bwOres & 0b1000) != 0)) { other = result.copy(); other.setItemDamage(worldGen.mPrimaryMeta); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java index d760f09cea..284fdc973c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/neiHandler/NEI_BW_Config.java @@ -40,11 +40,11 @@ public class NEI_BW_Config implements IConfigureNEI { API.hideItem(new ItemStack(ItemRegistry.TAB)); API.hideItem(new ItemStack(FluidLoader.bioFluidBlock)); API.hideItem(new ItemStack(ItemRegistry.bw_fake_glasses)); - sIsAdded = false; + NEI_BW_Config.sIsAdded = false; new BW_NEI_OreHandler(); new BW_NEI_BioVatHandler(BWRecipes.instance.getMappingsFor(BWRecipes.BACTERIALVATBYTE)); new BW_NEI_BioLabHandler(BWRecipes.instance.getMappingsFor(BWRecipes.BIOLABBYTE)); - sIsAdded = true; + NEI_BW_Config.sIsAdded = true; } @Optional.Method(modid = "NotEnoughItems") diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java index 9fc72b31cd..0b2822dae8 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.server.EventHandler; import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.common.net.OreDictCachePacket; +import com.github.bartimaeusnek.bartworks.common.net.ServerJoinedPackage; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.EventPriority; @@ -32,10 +33,32 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.event.entity.EntityJoinWorldEvent; public class ServerEventHandler { + @SubscribeEvent(priority = EventPriority.LOWEST) - public void getTooltip(EntityJoinWorldEvent event) { + public void EntityJoinWorldEvent(EntityJoinWorldEvent event) { if (event == null || !(event.entity instanceof EntityPlayerMP) || !FMLCommonHandler.instance().getSide().isServer()) return; MainMod.BW_Network_instance.sendToPlayer(new OreDictCachePacket(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity); + MainMod.BW_Network_instance.sendToPlayer(new ServerJoinedPackage(null),(EntityPlayerMP) event.entity); } + +// @SubscribeEvent(priority = EventPriority.HIGHEST) +// public void onPlayerTickEventServer(TickEvent.PlayerTickEvent event) { +// if (!BWUnificationEnforcer.isEnabled() || event == null || !(event.player instanceof EntityPlayerMP) || !FMLCommonHandler.instance().getSide().isServer()) +// return; +// +// for (int i = 0; i < event.player.inventory.mainInventory.length; i++) { +// ItemStack stack = event.player.inventory.mainInventory[i]; +// for (int id : OreDictionary.getOreIDs(stack)) +// if (BWUnificationEnforcer.getUnificationTargets().contains(OreDictionary.getOreName(id))){ +// ArrayList<ItemStack> stacks = OreDictionary.getOres(OreDictionary.getOreName(id)); +// for (int j = 0; j < stacks.size(); j++) { +// GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(stacks.get(j).getItem()); +// if (UI.modId.equals(MainMod.MOD_ID)){ +// event.player.inventory.mainInventory[i] = stacks.get(j).copy().splitStack(stack.stackSize); +// } +// } +// } +// } +// } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java index 121f628df8..f18b34c734 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/container/BW_Container_HeatedWaterPump.java @@ -42,7 +42,7 @@ public class BW_Container_HeatedWaterPump extends Container { final BW_TileEntity_HeatedWaterPump TILE; final IInventory INVENTORY; public int fuel, water, awater, maxfuel; - long timer = 0; + long timer; byte[] anetfuel, netfuel, anetmaxfuel, netmaxfuel; public BW_Container_HeatedWaterPump(BW_TileEntity_HeatedWaterPump TILE, EntityPlayer INVENTORY) { @@ -77,108 +77,108 @@ public class BW_Container_HeatedWaterPump extends Container { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if (TILE.getWorldObj().isRemote) + if (this.TILE.getWorldObj().isRemote) return; - fuel = this.TILE.fuel; - maxfuel = this.TILE.maxfuel; - water = this.TILE.outputstack.amount; - netfuel = ByteBuffer.allocate(8).putInt(fuel).array(); - netmaxfuel = ByteBuffer.allocate(8).putInt(maxfuel).array(); - ++timer; + this.fuel = this.TILE.fuel; + this.maxfuel = this.TILE.maxfuel; + this.water = this.TILE.outputstack.amount; + this.netfuel = ByteBuffer.allocate(8).putInt(this.fuel).array(); + this.netmaxfuel = ByteBuffer.allocate(8).putInt(this.maxfuel).array(); + ++this.timer; Iterator var2 = this.crafters.iterator(); - if (timer >= Long.MAX_VALUE - 1) - timer = 0; + if (this.timer >= Long.MAX_VALUE - 1) + this.timer = 0; while (true) { do { if (!var2.hasNext()) { - netfuel = anetfuel; - netmaxfuel = anetmaxfuel; - water = awater; + this.netfuel = this.anetfuel; + this.netmaxfuel = this.anetmaxfuel; + this.water = this.awater; return; } ICrafting var1 = (ICrafting) var2.next(); - if (this.timer % 500 == 10 || this.water != awater) - var1.sendProgressBarUpdate(this, 0, water); - if (this.timer % 500 == 10 || netfuel != anetfuel) - for (int i = 0; i < netfuel.length; i++) { - var1.sendProgressBarUpdate(this, i + 1, netfuel[i]); + if (this.timer % 500 == 10 || this.water != this.awater) + var1.sendProgressBarUpdate(this, 0, this.water); + if (this.timer % 500 == 10 || this.netfuel != this.anetfuel) + for (int i = 0; i < this.netfuel.length; i++) { + var1.sendProgressBarUpdate(this, i + 1, this.netfuel[i]); } - if (this.timer % 500 == 10 || netmaxfuel != anetmaxfuel) - for (int i = 0; i < netmaxfuel.length; i++) { - var1.sendProgressBarUpdate(this, i + 9, netmaxfuel[i]); + if (this.timer % 500 == 10 || this.netmaxfuel != this.anetmaxfuel) + for (int i = 0; i < this.netmaxfuel.length; i++) { + var1.sendProgressBarUpdate(this, i + 9, this.netmaxfuel[i]); } - } while (this.timer % 500 != 10 && this.water != awater); + } while (this.timer % 500 != 10 && this.water != this.awater); } } @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int packetID, int valure) { - if (netfuel == null) - netfuel = new byte[8]; - if (netmaxfuel == null) - netmaxfuel = new byte[8]; + if (this.netfuel == null) + this.netfuel = new byte[8]; + if (this.netmaxfuel == null) + this.netmaxfuel = new byte[8]; switch (packetID) { case 0: { - water = valure; + this.water = valure; this.getSlot(1).putStack(this.getSlot(1).getStack().setStackDisplayName(this.water + "L Water")); break; } case 1: - netfuel[0] = (byte) valure; + this.netfuel[0] = (byte) valure; break; case 2: - netfuel[1] = (byte) valure; + this.netfuel[1] = (byte) valure; break; case 3: - netfuel[2] = (byte) valure; + this.netfuel[2] = (byte) valure; break; case 4: - netfuel[3] = (byte) valure; + this.netfuel[3] = (byte) valure; break; case 5: - netfuel[4] = (byte) valure; + this.netfuel[4] = (byte) valure; break; case 6: - netfuel[5] = (byte) valure; + this.netfuel[5] = (byte) valure; break; case 7: - netfuel[6] = (byte) valure; + this.netfuel[6] = (byte) valure; break; case 8: - netfuel[7] = (byte) valure; + this.netfuel[7] = (byte) valure; break; case 9: - netmaxfuel[0] = (byte) valure; + this.netmaxfuel[0] = (byte) valure; break; case 10: - netmaxfuel[1] = (byte) valure; + this.netmaxfuel[1] = (byte) valure; break; case 11: - netmaxfuel[2] = (byte) valure; + this.netmaxfuel[2] = (byte) valure; break; case 12: - netmaxfuel[3] = (byte) valure; + this.netmaxfuel[3] = (byte) valure; break; case 13: - netmaxfuel[4] = (byte) valure; + this.netmaxfuel[4] = (byte) valure; break; case 14: - netmaxfuel[5] = (byte) valure; + this.netmaxfuel[5] = (byte) valure; break; case 15: - netmaxfuel[6] = (byte) valure; + this.netmaxfuel[6] = (byte) valure; break; case 16: - netmaxfuel[7] = (byte) valure; + this.netmaxfuel[7] = (byte) valure; break; default: break; } if (packetID > 0 && packetID < 9) - this.fuel = ByteBuffer.wrap(netfuel).getInt(); + this.fuel = ByteBuffer.wrap(this.netfuel).getInt(); if (packetID > 8 && packetID < 17) - this.maxfuel = ByteBuffer.wrap(netmaxfuel).getInt(); + this.maxfuel = ByteBuffer.wrap(this.netmaxfuel).getInt(); } } 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 index b30c3fbbd4..42bdc56e3b 100644 --- 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 @@ -39,7 +39,7 @@ public class BW_Container_RadioHatch extends Container { public byte coverage, dcoverage; long timer; - private GT_MetaTileEntity_RadioHatch iGregTechTileEntity; + private final GT_MetaTileEntity_RadioHatch iGregTechTileEntity; public BW_Container_RadioHatch(InventoryPlayer inventory, IMetaTileEntity iGregTechTileEntity) { this.iGregTechTileEntity = (GT_MetaTileEntity_RadioHatch) iGregTechTileEntity; @@ -112,37 +112,37 @@ public class BW_Container_RadioHatch extends Container { }; for (int i = 0; i < 12; i++) { - addSlotToContainer(new GT_Slot_Holo(inv, i, -64 + i * 18, 22, false, false, 1)); + this.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)); + this.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)); + this.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; + this.coverage = this.iGregTechTileEntity.getCoverage(); + ++this.timer; Iterator var2 = this.crafters.iterator(); - if (timer >= Long.MAX_VALUE - 1) - timer = 0; + if (this.timer >= Long.MAX_VALUE - 1) + this.timer = 0; while (true) { do { if (!var2.hasNext()) { - dcoverage = coverage; + this.dcoverage = this.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); + if (this.timer % 500 == 10 || this.dcoverage != this.coverage) + var1.sendProgressBarUpdate(this, 0, this.coverage); + } while (this.timer % 500 != 10 && this.dcoverage != this.coverage); } } } @@ -150,7 +150,7 @@ public class BW_Container_RadioHatch extends Container { @Override public void updateProgressBar(int p_75137_1_, int p_75137_2_) { if (p_75137_1_ == 0) - coverage = (byte) p_75137_2_; + this.coverage = (byte) p_75137_2_; } @Override @@ -198,7 +198,7 @@ public class BW_Container_RadioHatch extends Container { setto = 0; } this.iGregTechTileEntity.setCoverage((short) (this.iGregTechTileEntity.getCoverage() + setto)); - detectAndSendChanges(); + this.detectAndSendChanges(); return null; } return super.slotClick(slot, button, aShifthold, entityPlayer); 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 65fb30e847..7545d5225a 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 @@ -47,30 +47,30 @@ public class GT_Container_CircuitProgrammer extends Container { public GT_Container_CircuitProgrammer(InventoryPlayer inventory) { - player = inventory.player; + this.player = inventory.player; - IInventory inv = new pinv(player); + IInventory inv = new pinv(this.player); - addSlotToContainer(new Slot(inv, 0, 44, 61));//-45, 84)); + this.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)); + this.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)); + this.addSlotToContainer(new GT_Slot_Holo(inv, i + 12, -46 + i * 18, 40, 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)); + this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; i++) { if (GT_Utility.isStackValid(inventory.getStackInSlot(i)) && inventory.getStackInSlot(i).getItem() instanceof Circuit_Programmer) - addSlotToContainer(new GT_Slot_Render(inventory, i, 8 + i * 18, 142)); + this.addSlotToContainer(new GT_Slot_Render(inventory, i, 8 + i * 18, 142)); else - addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); + this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 142)); } } @@ -80,10 +80,10 @@ public class GT_Container_CircuitProgrammer extends Container { ItemStack iCircuit = GT_Utility.getIntegratedCircuit(slot); iCircuit.stackSize = 1; ((Slot) this.inventorySlots.get(0)).putStack(iCircuit); - detectAndSendChanges(); + this.detectAndSendChanges(); return ((Slot) this.inventorySlots.get(0)).getStack(); } - detectAndSendChanges(); + this.detectAndSendChanges(); return super.slotClick(slot, button, aShifthold, entityPlayer); } @@ -113,7 +113,7 @@ public class GT_Container_CircuitProgrammer extends Container { } } } - detectAndSendChanges(); + this.detectAndSendChanges(); return null; } @@ -125,13 +125,12 @@ public class GT_Container_CircuitProgrammer extends Container { NBTTagCompound tag; public pinv(EntityPlayer Player) { - super(); this.Player = Player; this.toBind = Player.inventory.getCurrentItem(); - tag = this.toBind.getTagCompound(); - if (tag.getBoolean("HasChip")) { - Slot = GT_Utility.getIntegratedCircuit(tag.getByte("ChipConfig")); - Slot.stackSize = 1; + this.tag = this.toBind.getTagCompound(); + if (this.tag.getBoolean("HasChip")) { + this.Slot = GT_Utility.getIntegratedCircuit(this.tag.getByte("ChipConfig")); + this.Slot.stackSize = 1; } } @@ -142,60 +141,60 @@ public class GT_Container_CircuitProgrammer extends Container { @Override public ItemStack getStackInSlot(int slot) { - return slot == 0 ? Slot : null; + return slot == 0 ? this.Slot : null; } @Override public ItemStack decrStackSize(int slotNR, int count) { - ItemStack ret = Slot.copy(); - Slot = null; - tag = toBind.getTagCompound(); - tag.setBoolean("HasChip", false); - toBind.setTagCompound(tag); - Player.inventory.setInventorySlotContents(Player.inventory.currentItem, toBind); + ItemStack ret = this.Slot.copy(); + this.Slot = null; + this.tag = this.toBind.getTagCompound(); + this.tag.setBoolean("HasChip", false); + this.toBind.setTagCompound(this.tag); + this.Player.inventory.setInventorySlotContents(this.Player.inventory.currentItem, this.toBind); return ret; } @Override public ItemStack getStackInSlotOnClosing(int p_70304_1_) { - return Slot; + return this.Slot; } @Override public void setInventorySlotContents(int slotNR, ItemStack itemStack) { if (itemStack != null && itemStack.getItem() != null && itemStack.getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem())) { - Slot = itemStack.copy().splitStack(1); + this.Slot = itemStack.copy().splitStack(1); itemStack.stackSize--; - tag = toBind.getTagCompound(); - tag.setBoolean("HasChip", true); - tag.setByte("ChipConfig", (byte) itemStack.getItemDamage()); - toBind.setTagCompound(tag); - Player.inventory.setInventorySlotContents(Player.inventory.currentItem, toBind); - if (!Player.isClientWorld()) - MainMod.BW_Network_instance.sendToServer(new CircuitProgrammerPacket(Player.worldObj.provider.dimensionId, Player.getEntityId(), true, (byte) itemStack.getItemDamage())); + this.tag = this.toBind.getTagCompound(); + this.tag.setBoolean("HasChip", true); + this.tag.setByte("ChipConfig", (byte) itemStack.getItemDamage()); + this.toBind.setTagCompound(this.tag); + this.Player.inventory.setInventorySlotContents(this.Player.inventory.currentItem, this.toBind); + if (!this.Player.isClientWorld()) + MainMod.BW_Network_instance.sendToServer(new CircuitProgrammerPacket(this.Player.worldObj.provider.dimensionId, this.Player.getEntityId(), true, (byte) itemStack.getItemDamage())); } else if (BW_Util.checkStackAndPrefix(itemStack) && GT_OreDictUnificator.getAssociation(itemStack).mPrefix.equals(OrePrefixes.circuit) && GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.equals(Materials.Basic)) { - Slot = GT_Utility.getIntegratedCircuit(0); - Slot.stackSize = 1; + this.Slot = GT_Utility.getIntegratedCircuit(0); + this.Slot.stackSize = 1; itemStack.stackSize--; - tag = toBind.getTagCompound(); - tag.setBoolean("HasChip", true); - tag.setByte("ChipConfig", (byte) 0); - toBind.setTagCompound(tag); - Player.inventory.setInventorySlotContents(Player.inventory.currentItem, toBind); - if (!Player.isClientWorld()) - MainMod.BW_Network_instance.sendToServer(new CircuitProgrammerPacket(Player.worldObj.provider.dimensionId, Player.getEntityId(), true, (byte) 0)); + this.tag = this.toBind.getTagCompound(); + this.tag.setBoolean("HasChip", true); + this.tag.setByte("ChipConfig", (byte) 0); + this.toBind.setTagCompound(this.tag); + this.Player.inventory.setInventorySlotContents(this.Player.inventory.currentItem, this.toBind); + if (!this.Player.isClientWorld()) + MainMod.BW_Network_instance.sendToServer(new CircuitProgrammerPacket(this.Player.worldObj.provider.dimensionId, this.Player.getEntityId(), true, (byte) 0)); }/* else if (GT_Utility.isStackValid(itemStack) && itemStack.getItem() instanceof Circuit_Programmer) { ForgeHooks.onPlayerTossEvent(Player, itemStack, false); this.closeInventory(); Player.closeScreen(); }*/ else { - ForgeHooks.onPlayerTossEvent(Player, itemStack, false); - tag = toBind.getTagCompound(); - tag.setBoolean("HasChip", false); - toBind.setTagCompound(tag); - Player.inventory.setInventorySlotContents(Player.inventory.currentItem, toBind); - if (!Player.isClientWorld()) - MainMod.BW_Network_instance.sendToServer(new CircuitProgrammerPacket(Player.worldObj.provider.dimensionId, Player.getEntityId(), false, (byte) 0)); + ForgeHooks.onPlayerTossEvent(this.Player, itemStack, false); + this.tag = this.toBind.getTagCompound(); + this.tag.setBoolean("HasChip", false); + this.toBind.setTagCompound(this.tag); + this.Player.inventory.setInventorySlotContents(this.Player.inventory.currentItem, this.toBind); + if (!this.Player.isClientWorld()) + MainMod.BW_Network_instance.sendToServer(new CircuitProgrammerPacket(this.Player.worldObj.provider.dimensionId, this.Player.getEntityId(), false, (byte) 0)); } } @@ -236,9 +235,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())) - return true; - return false; + return itemStack != null && itemStack.getItem().equals(GT_Utility.getIntegratedCircuit(0).getItem()); } } 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 b983ea27d7..6d3b86da1f 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 @@ -34,21 +34,21 @@ public class GT_Container_Item_Destructopack extends Container { public GT_Container_Item_Destructopack(InventoryPlayer inventory) { - addSlotToContainer(new BW_DelSlot()); + this.addSlotToContainer(new BW_DelSlot()); 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)); + this.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)); + this.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); + public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int aSlotIndex) { + Slot slotObject = (Slot) this.inventorySlots.get(aSlotIndex); slotObject.putStack(null); return null; } @@ -60,7 +60,7 @@ public class GT_Container_Item_Destructopack extends Container { @Override public void onCraftMatrixChanged(IInventory p_75130_1_) { - final Slot slotObject = (Slot) this.inventorySlots.get(0); + Slot slotObject = (Slot) this.inventorySlots.get(0); slotObject.decrStackSize(0); } }
\ No newline at end of file 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 index 22a3e8ea17..a1cd7505fe 100644 --- 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 @@ -40,7 +40,7 @@ public class GT_Container_RadioHatch extends GT_Container_1by1 { 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; + private long timer; public GT_Container_RadioHatch(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); @@ -49,49 +49,49 @@ public class GT_Container_RadioHatch extends GT_Container_1by1 { 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; + this.TE = (GT_MetaTileEntity_RadioHatch) this.mTileEntity.getMetaTileEntity(); + this.mass = this.TE.getMass(); + this.sievert = (short) this.TE.sievert; + short[] rgb = this.TE.getColorForGUI(); + this.r = rgb[0]; + this.g = rgb[1]; + this.b = rgb[2]; + this.sv = (short) this.TE.getSievert(); + this.teTimer = ByteBuffer.allocate(8).putLong(this.TE.getTimer()).array(); + ++this.timer; Iterator var2 = this.crafters.iterator(); - if (timer >= Long.MAX_VALUE - 1) - timer = 0; + if (this.timer >= Long.MAX_VALUE - 1) + this.timer = 0; while (true) { do { if (!var2.hasNext()) { - dmass = mass; - dsievert = sievert; - dr = r; - dg = g; - db = b; - dteTimer = teTimer; - dsv = sv; + this.dmass = this.mass; + this.dsievert = this.sievert; + this.dr = this.r; + this.dg = this.g; + this.db = this.b; + this.dteTimer = this.teTimer; + this.dsv = this.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.dmass != this.mass) + var1.sendProgressBarUpdate(this, 21, this.mass); + if (this.timer % 500 == 10 || this.dsievert != this.sievert) + var1.sendProgressBarUpdate(this, 22, (this.sievert - 100)); + if (this.timer % 500 == 10 || this.dr != this.r) + var1.sendProgressBarUpdate(this, 23, this.r); + if (this.timer % 500 == 10 || this.dg != this.g) + var1.sendProgressBarUpdate(this, 24, this.g); + if (this.timer % 500 == 10 || this.db != this.b) + var1.sendProgressBarUpdate(this, 25, this.b); + if (this.timer % 500 == 10 || this.dteTimer != this.teTimer) + for (int i = 0; i < this.teTimer.length; i++) { + var1.sendProgressBarUpdate(this, 26 + i, this.teTimer[i]); } - if (this.timer % 500 == 10 || this.dsv != sv) - var1.sendProgressBarUpdate(this, 34, sv); + if (this.timer % 500 == 10 || this.dsv != this.sv) + var1.sendProgressBarUpdate(this, 34, this.sv); } while (this.timer % 500 != 10 && this.dmass == this.mass); } @@ -104,46 +104,46 @@ public class GT_Container_RadioHatch extends GT_Container_1by1 { super.updateProgressBar(par1, par2); switch (par1) { case 21: - mass = (byte) par2; + this.mass = (byte) par2; break; case 22: - sievert = (short) (par2 + 100); + this.sievert = (short) (par2 + 100); break; case 23: - r = (short) par2; + this.r = (short) par2; break; case 24: - g = (short) par2; + this.g = (short) par2; break; case 25: - b = (short) par2; + this.b = (short) par2; break; case 26: - teTimer[0] = (byte) par2; + this.teTimer[0] = (byte) par2; break; case 27: - teTimer[1] = (byte) par2; + this.teTimer[1] = (byte) par2; break; case 28: - teTimer[2] = (byte) par2; + this.teTimer[2] = (byte) par2; break; case 29: - teTimer[3] = (byte) par2; + this.teTimer[3] = (byte) par2; break; case 30: - teTimer[4] = (byte) par2; + this.teTimer[4] = (byte) par2; break; case 31: - teTimer[5] = (byte) par2; + this.teTimer[5] = (byte) par2; break; case 32: - teTimer[6] = (byte) par2; + this.teTimer[6] = (byte) par2; break; case 33: - teTimer[7] = (byte) par2; + this.teTimer[7] = (byte) par2; break; case 34: - sv = (short) par2; + this.sv = (short) par2; break; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java index ba85a38e79..9e832e0820 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/log/DebugLog.java @@ -35,16 +35,16 @@ import java.util.logging.LogRecord; import java.util.logging.Logger; public class DebugLog { - private static boolean init = false; + private static boolean init; private static FileHandler fh; private static Logger utilLog; public DebugLog(FMLPreInitializationEvent event) throws IOException { - if (init) + if (DebugLog.init) return; - fh = new FileHandler(new File(new File(event.getModConfigurationDirectory().getParentFile(),"logs"),"BWLog.log").toString()); - utilLog = Logger.getLogger("DebugLog"); - utilLog.setUseParentHandlers(false); - utilLog.addHandler(fh); + DebugLog.fh = new FileHandler(new File(new File(event.getModConfigurationDirectory().getParentFile(),"logs"),"BWLog.log").toString()); + DebugLog.utilLog = Logger.getLogger("DebugLog"); + DebugLog.utilLog.setUseParentHandlers(false); + DebugLog.utilLog.addHandler(DebugLog.fh); Formatter formatter = new Formatter() { @Override public String format(LogRecord record) { @@ -56,13 +56,13 @@ public class DebugLog { + " " + record.getMessage() + "\n"; } }; - fh.setFormatter(formatter); - init = true; + DebugLog.fh.setFormatter(formatter); + DebugLog.init = true; } public static void log(String record){ - if (!init) + if (!DebugLog.init) return; - utilLog.info(record); + DebugLog.utilLog.info(record); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BWUnificationEnforcer.java index 97cc8e3c85..784459f25e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/CircuitImprintLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BWUnificationEnforcer.java @@ -20,24 +20,29 @@ * SOFTWARE. */ -package com.github.bartimaeusnek.bartworks.common.loaders; +package com.github.bartimaeusnek.bartworks.system.material; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.oredict.OreDictionary; import java.util.HashSet; -public class CircuitImprintLoader implements Runnable { +public class BWUnificationEnforcer { + private static boolean enabled; + private static final HashSet<String> UNIFICATION_TARGETS = new HashSet<>(); + public static boolean isEnabled() { + return BWUnificationEnforcer.enabled; + } - private static HashSet<NBTTagCompound> circuitTypes = new HashSet<>(); + public static HashSet<String> getUnificationTargets() { + return BWUnificationEnforcer.UNIFICATION_TARGETS; + } - @Override - public void run() { - for(String names : OreDictionary.getOreNames()){ - if (names.contains("circuit") || names.contains("Circuit")) - for (ItemStack itemStack : OreDictionary.getOres(names)) - CircuitImprintLoader.circuitTypes.add(itemStack.copy().splitStack(1).writeToNBT(new NBTTagCompound())); - } + public static void addUnificationTarget(String aOreDictName){ + if (aOreDictName == null || aOreDictName.isEmpty() || !OreDictionary.doesOreNameExist(aOreDictName)) + return; + BWUnificationEnforcer.UNIFICATION_TARGETS.add(aOreDictName); + BWUnificationEnforcer.enabled = true; } + + } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java index 4418d72dbd..1e671a1d29 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOreTE.java @@ -29,12 +29,10 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.ITexturedTileEntity; import gregtech.api.objects.GT_CopiedBlockTexture; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.common.blocks.GT_Block_Ores_Abstract; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.Packet; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; @@ -44,7 +42,7 @@ import static com.github.bartimaeusnek.bartworks.MainMod.BW_Network_instance; public class BW_MetaGeneratedOreTE extends TileEntity implements ITexturedTileEntity { - public short mMetaData = 0; + public short mMetaData; public static boolean placeOre(World aWorld, Coords coords, Werkstoff werkstoff) { short meta = werkstoff.getmID(); @@ -80,10 +78,9 @@ public class BW_MetaGeneratedOreTE extends TileEntity implements ITexturedTileEn return rList; } - public Packet getDescriptionPacket() { + public void sendPacket(){ if (!this.worldObj.isRemote) BW_Network_instance.sendPacketToAllPlayersInRange(this.worldObj, new OrePacket(this.xCoord, (short) this.yCoord, this.zCoord, this.mMetaData), this.xCoord, this.zCoord); - return null; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOre_Item.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOre_Item.java index 6aa0ab1671..f09bb6f33d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOre_Item.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGeneratedOre_Item.java @@ -46,7 +46,7 @@ public class BW_MetaGeneratedOre_Item extends BW_ItemBlocks { } public String getUnlocalizedName(ItemStack aStack) { - return this.field_150939_a.getUnlocalizedName() + "." + getDamage(aStack); + return this.field_150939_a.getUnlocalizedName() + "." + this.getDamage(aStack); } public String getItemStackDisplayName(ItemStack aStack) { @@ -64,7 +64,7 @@ public class BW_MetaGeneratedOre_Item extends BW_ItemBlocks { } public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, float hitX, float hitY, float hitZ, int aMeta) { - short tDamage = (short) getDamage(aStack); + short tDamage = (short) this.getDamage(aStack); if (tDamage > 0) { if (!aWorld.setBlock(aX, aY, aZ, this.field_150939_a, tDamage, 3)) { return false; diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java index 3cbd78ac89..d3bd73964b 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Items.java @@ -37,14 +37,12 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; import ic2.core.IC2Potion; -import ic2.core.item.armor.ItemArmorHazmat; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -74,11 +72,13 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa public BW_MetaGenerated_Items(OrePrefixes orePrefixes) { super("bwMetaGenerated" + orePrefixes.name(), (short) 32766, (short) 0); this.orePrefixes = orePrefixes; - this.setCreativeTab(metaTab); - for (int i = 0; i < aNumToGen; i++) { + this.setCreativeTab(BW_MetaGenerated_Items.metaTab); + for (int i = 0; i < this.aNumToGen; i++) { ItemStack tStack = new ItemStack(this, 1, i); Werkstoff w = werkstoffHashMap.get((short) i); - if (w == null || ((w.getGenerationFeatures().toGenerate & orePrefixes.mMaterialGenerationBits) == 0) || ((w.getGenerationFeatures().blacklist & orePrefixes.mMaterialGenerationBits) != 0) ) + if (w == null || ((w.getGenerationFeatures().blacklist & orePrefixes.mMaterialGenerationBits) != 0) ) + continue; + if ((w.getGenerationFeatures().toGenerate & orePrefixes.mMaterialGenerationBits) == 0 && orePrefixes.mMaterialGenerationBits != 0) continue; GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(tStack) + ".name", this.getDefaultLocalization(w)); GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(tStack) + ".tooltip", w.getToolTip()); @@ -90,7 +90,7 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa } public boolean onEntityItemUpdate(EntityItem aItemEntity) { - if (orePrefixes == OrePrefixes.dustImpure || orePrefixes == OrePrefixes.dustPure || orePrefixes == OrePrefixes.crushed) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure || this.orePrefixes == OrePrefixes.crushed) { int aDamage = aItemEntity.getEntityItem().getItemDamage(); if ((aDamage >= 0) && (!aItemEntity.worldObj.isRemote)) { Werkstoff aMaterial = werkstoffHashMap.get((short) aDamage); @@ -98,19 +98,19 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa int tX = MathHelper.floor_double(aItemEntity.posX); int tY = MathHelper.floor_double(aItemEntity.posY); int tZ = MathHelper.floor_double(aItemEntity.posZ); - if ((orePrefixes == OrePrefixes.dustImpure) || (orePrefixes == OrePrefixes.dustPure)) { + if ((this.orePrefixes == OrePrefixes.dustImpure) || (this.orePrefixes == OrePrefixes.dustPure)) { Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { - aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.dust, aMaterial, aItemEntity.getEntityItem().stackSize)); + aItemEntity.setEntityItemStack(WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dust, aMaterial, aItemEntity.getEntityItem().stackSize)); aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); return true; } - } else if (orePrefixes == OrePrefixes.crushed) { + } else if (this.orePrefixes == OrePrefixes.crushed) { Block tBlock = aItemEntity.worldObj.getBlock(tX, tY, tZ); byte tMetaData = (byte) aItemEntity.worldObj.getBlockMetadata(tX, tY, tZ); if ((tBlock == Blocks.cauldron) && (tMetaData > 0)) { - aItemEntity.setEntityItemStack(WerkstoffLoader.getCorresopndingItemStack(OrePrefixes.crushedPurified, aMaterial, aItemEntity.getEntityItem().stackSize)); + aItemEntity.setEntityItemStack(WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedPurified, aMaterial, aItemEntity.getEntityItem().stackSize)); aItemEntity.worldObj.setBlockMetadataWithNotify(tX, tY, tZ, tMetaData - 1, 3); return true; } @@ -126,16 +126,16 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa // String tooltip = GT_LanguageManager.getTranslation(this.getUnlocalizedName(aStack) + ".tooltip"); // if (!tooltip.isEmpty()) // aList.add(tooltip); - if (orePrefixes == OrePrefixes.dustImpure || orePrefixes == OrePrefixes.dustPure) { + if (this.orePrefixes == OrePrefixes.dustImpure || this.orePrefixes == OrePrefixes.dustPure) { aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.purify")); } - if (orePrefixes == OrePrefixes.crushed) + if (this.orePrefixes == OrePrefixes.crushed) aList.add(GT_LanguageManager.getTranslation("metaitem.01.tooltip.purify.2")); aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); } public String getDefaultLocalization(Werkstoff werkstoff) { - return werkstoff != null ? orePrefixes.mLocalizedMaterialPre + werkstoff.getDefaultName() + orePrefixes.mLocalizedMaterialPost : Werkstoff.default_null_Werkstoff.getDefaultName(); + return werkstoff != null ? this.orePrefixes.mLocalizedMaterialPre + werkstoff.getDefaultName() + this.orePrefixes.mLocalizedMaterialPost : Werkstoff.default_null_Werkstoff.getDefaultName(); } @Override @@ -145,15 +145,15 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa @Override public final IIconContainer getIconContainer(int aMetaData) { - return werkstoffHashMap.get((short) aMetaData) == null ? null : werkstoffHashMap.get((short) aMetaData).getTexSet().mTextures[orePrefixes.mTextureIndex]; + return werkstoffHashMap.get((short) aMetaData) == null ? null : this.orePrefixes.mTextureIndex == -1 ? null : werkstoffHashMap.get((short) aMetaData).getTexSet().mTextures[this.orePrefixes.mTextureIndex]; } @Override @SideOnly(Side.CLIENT) public final void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { - for (int i = 0; i < aNumToGen; i++) { + for (int i = 0; i < this.aNumToGen; i++) { Werkstoff werkstoff = werkstoffHashMap.get((short) i); - if (werkstoff != null && ((werkstoff.getGenerationFeatures().toGenerate & orePrefixes.mMaterialGenerationBits) != 0) && ((werkstoff.getGenerationFeatures().blacklist & orePrefixes.mMaterialGenerationBits) == 0)) { + if (werkstoff != null && ((werkstoff.getGenerationFeatures().toGenerate & this.orePrefixes.mMaterialGenerationBits) != 0) && ((werkstoff.getGenerationFeatures().blacklist & this.orePrefixes.mMaterialGenerationBits) == 0)) { ItemStack tStack = new ItemStack(this, 1, i); aList.add(tStack); } @@ -163,7 +163,7 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa @Override public short[] getRGBa(ItemStack aStack) { - Werkstoff werkstoff = werkstoffHashMap.get((short) getDamage(aStack)); + Werkstoff werkstoff = werkstoffHashMap.get((short) this.getDamage(aStack)); return werkstoff == null ? Materials._NULL.mRGBa : werkstoff.getRGBA(); } @@ -195,7 +195,7 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa Werkstoff tMaterial = werkstoffHashMap.get((short) aMetaData); if (tMaterial == null) return null; - IIconContainer tIcon = getIconContainer(aMetaData); + IIconContainer tIcon = this.getIconContainer(aMetaData); if (tIcon != null) return tIcon.getIcon(); return null; @@ -208,7 +208,7 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa @Override public int getRadiationLevel(ItemStack aStack) { - Werkstoff w = Werkstoff.werkstoffHashMap.get((short)aStack.getItemDamage()); + Werkstoff w = werkstoffHashMap.get((short)aStack.getItemDamage()); return w.getStats().isRadioactive() ? (int) w.getStats().protons : 0; } @@ -219,13 +219,18 @@ public class BW_MetaGenerated_Items extends GT_MetaGenerated_Item implements IRa @Override public short[] getColorForGUI(ItemStack aStack) { - Werkstoff w = Werkstoff.werkstoffHashMap.get((short)aStack.getItemDamage()); + Werkstoff w = werkstoffHashMap.get((short)aStack.getItemDamage()); return w.getRGBA(); } @Override public String getNameForGUI(ItemStack aStack) { - Werkstoff w = Werkstoff.werkstoffHashMap.get((short)aStack.getItemDamage()); + Werkstoff w = werkstoffHashMap.get((short)aStack.getItemDamage()); return w.getDefaultName(); } + + @Override + public int getCapacity(ItemStack aStack) { + return this.orePrefixes == OrePrefixes.cell || this.orePrefixes == OrePrefixes.cellPlasma ? 1000 : this.orePrefixes == WerkstoffLoader.cellMolten ? 144 : 0; + } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java index ba03007669..47e676e082 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Ores.java @@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.system.material; import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; import com.github.bartimaeusnek.bartworks.common.blocks.BW_TileEntityContainer; +import cpw.mods.fml.common.FMLCommonHandler; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; @@ -60,7 +61,7 @@ public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { if ((w.getGenerationFeatures().toGenerate & 0b1000) == 0 || ((w.getGenerationFeatures().blacklist & 0b1000) != 0)) continue; GT_ModHandler.addValuableOre(this, w.getmID(), 1); - GT_LanguageManager.addStringLocalization(getUnlocalizedName() + "." + w.getmID() + ".name", w.getDefaultName() + OrePrefixes.ore.mLocalizedMaterialPost); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName() + "." + w.getmID() + ".name", w.getDefaultName() + OrePrefixes.ore.mLocalizedMaterialPost); } } } @@ -91,7 +92,7 @@ public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { } public String getLocalizedName() { - return StatCollector.translateToLocal(getUnlocalizedName() + ".name"); + return StatCollector.translateToLocal(this.getUnlocalizedName() + ".name"); } @Override @@ -131,7 +132,7 @@ public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { public void breakBlock(World world, int x, int y, int z, Block block, int meta) { TileEntity tTileEntity = world.getTileEntity(x, y, z); if ((tTileEntity instanceof BW_MetaGeneratedOreTE)) { - mTemporaryTileEntity.set((BW_MetaGeneratedOreTE) tTileEntity); + BW_MetaGenerated_Ores.mTemporaryTileEntity.set((BW_MetaGeneratedOreTE) tTileEntity); } super.breakBlock(world, x, y, z, block, meta); } @@ -141,7 +142,7 @@ public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { if ((tTileEntity instanceof BW_MetaGeneratedOreTE)) { return ((BW_MetaGeneratedOreTE) tTileEntity).getDrops(WerkstoffLoader.BWOres); } - return mTemporaryTileEntity.get() == null ? new ArrayList() : ((BW_MetaGeneratedOreTE) mTemporaryTileEntity.get()).getDrops(WerkstoffLoader.BWOres); + return BW_MetaGenerated_Ores.mTemporaryTileEntity.get() == null ? new ArrayList() : BW_MetaGenerated_Ores.mTemporaryTileEntity.get().getDrops(WerkstoffLoader.BWOres); } public int getHarvestLevel(int metadata) { @@ -165,11 +166,27 @@ public class BW_MetaGenerated_Ores extends BW_TileEntityContainer { @Override public void onNeighborBlockChange(World aWorld, int aX, int aY, int aZ, Block p_149695_5_) { - aWorld.getTileEntity(aX, aY, aZ).getDescriptionPacket(); + if ((!aWorld.isRemote || this.checkForAir(aWorld,aX,aY,aZ)) && aWorld.getTileEntity(aX, aY, aZ) instanceof BW_MetaGeneratedOreTE) + ((BW_MetaGeneratedOreTE)aWorld.getTileEntity(aX, aY, aZ)).sendPacket(); } @Override public void onNeighborChange(IBlockAccess aWorld, int aX, int aY, int aZ, int tileX, int tileY, int tileZ) { - aWorld.getTileEntity(aX, aY, aZ).getDescriptionPacket(); + if ((FMLCommonHandler.instance().getEffectiveSide().isServer() || this.checkForAir(aWorld,aX,aY,aZ)) && aWorld.getTileEntity(aX, aY, aZ) instanceof BW_MetaGeneratedOreTE) + ((BW_MetaGeneratedOreTE)aWorld.getTileEntity(aX, aY, aZ)).sendPacket(); + } + + private boolean checkForAir(IBlockAccess aWorld, int aX, int aY, int aZ){ + for (int x = -1; x <= 1; x++) { + for (int y = -1; y <= 1; y++) { + for (int z = -1; z <= 1; z++) { + if (x == 0 && y == 0 && z == 0) + continue; + if (aWorld.getBlock(aX+x,aY+y,aZ+z).isAir(aWorld,aX+x,aY+y,aZ+z)) + return true; + } + } + } + return false; } -} +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.java new file mode 100644 index 0000000000..819d9f98bd --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_CircuitsLoader.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.system.material.CircuitGeneration; + +public class BW_CircuitsLoader { + private static final BW_Meta_Items NEW_CIRCUITS; + + public static BW_Meta_Items getNewCircuits() { + return BW_CircuitsLoader.NEW_CIRCUITS; + } + + static { + NEW_CIRCUITS = new BW_Meta_Items(); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(0,4, "Primitive Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(1,5, "Basic Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(2,6, "Good Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(3,7, "Advanced Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(4,8, "Data Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(5,9, "Elite Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(6,10, "Master Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(7,11, "Ultimate Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(8,12, "Superconductor Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(9,13, "Infinite Magneto Resonatic Circuit"); + BW_CircuitsLoader.NEW_CIRCUITS.addNewCircuit(10,14, "Bio Magneto Resonatic Circuit"); + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java new file mode 100644 index 0000000000..dfb48a7b50 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/BW_Meta_Items.java @@ -0,0 +1,319 @@ +/* + * 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.system.material.CircuitGeneration; + +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.system.oredict.OreDictAdder; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.bartworks.util.ChatColorHelper; +import com.github.bartimaeusnek.bartworks.util.Pair; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTech_API; +import gregtech.api.enums.*; +import gregtech.api.interfaces.IItemBehaviour; +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.items.GT_MetaBase_Item; +import gregtech.api.objects.ItemData; +import gregtech.api.util.*; +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.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraftforge.fluids.FluidStack; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.HashSet; +import java.util.List; + + +public class BW_Meta_Items { + + public static BW_Meta_Items.BW_GT_MetaGenCircuits getNEWCIRCUITS() { + return BW_Meta_Items.NEWCIRCUITS; + } + + private static final BW_Meta_Items.BW_GT_MetaGenCircuits NEWCIRCUITS = new BW_Meta_Items.BW_GT_MetaGenCircuits(); + + static{ + BW_Meta_Items.NEWCIRCUITS.addItem(0,"Circuit Imprint","",SubTag.NO_UNIFICATION,SubTag.NO_RECYCLING); + BW_Meta_Items.NEWCIRCUITS.addItem(1,"Sliced Circuit","",SubTag.NO_UNIFICATION,SubTag.NO_RECYCLING); + BW_Meta_Items.NEWCIRCUITS.addItem(2,"Raw Imprint supporting Board","A Raw Board needed for Circuit Imprints"); + BW_Meta_Items.NEWCIRCUITS.addItem(3,"Imprint supporting Board","A Board needed for Circuit Imprints"); + GT_Values.RA.addFormingPressRecipe(WerkstoffLoader.MagnetoResonaticDust.get(OrePrefixes.dust,1),WerkstoffLoader.ArInGaPhoBiBoTe.get(OrePrefixes.dust,4),BW_Meta_Items.NEWCIRCUITS.getStack(2),300,480); + GT_Recipe.GT_Recipe_Map.sAutoclaveRecipes.add(new BWRecipes.DynamicGTRecipe(false,new ItemStack[]{BW_Meta_Items.NEWCIRCUITS.getStack(2)},new ItemStack[]{BW_Meta_Items.NEWCIRCUITS.getStack(3)},null,new int[]{7500},new FluidStack[]{Materials.SolderingAlloy.getMolten(576)},null,300, BW_Util.getMachineVoltageFromTier(4), BW_Util.CLEANROOM)); + } + + public void addNewCircuit(int aTier, int aID, String aName){ + + String additionalOreDictData = ""; + String tooltip = ""; + String aOreDictPrefix = OrePrefixes.circuit.toString(); + switch (aTier){ + case 0: additionalOreDictData = Materials.Primitive.toString(); tooltip = Materials.Primitive.getToolTip(); break; + case 1: additionalOreDictData = Materials.Basic.toString(); tooltip = Materials.Basic.getToolTip(); break; + case 2: additionalOreDictData = Materials.Good.toString(); tooltip = Materials.Good.getToolTip(); break; + case 3: additionalOreDictData = Materials.Advanced.toString(); tooltip = Materials.Advanced.getToolTip(); break; + case 4: additionalOreDictData = Materials.Data.toString(); tooltip = Materials.Data.getToolTip(); break; + case 5: additionalOreDictData = Materials.Elite.toString(); tooltip = Materials.Elite.getToolTip(); break; + case 6: additionalOreDictData = Materials.Master.toString(); tooltip = Materials.Master.getToolTip(); break; + case 7: additionalOreDictData = Materials.Ultimate.toString(); tooltip = Materials.Ultimate.getToolTip(); break; + case 8: additionalOreDictData = Materials.Superconductor.toString(); tooltip = Materials.Superconductor.getToolTip(); break; + case 9: additionalOreDictData = "Infinite"; tooltip = "An Infinite Circuit"; break; + case 10: additionalOreDictData = "Bio"; tooltip = "A Bio Circuit"; break; + } + + ItemStack tStack = BW_Meta_Items.NEWCIRCUITS.addCircuit(aID,aName,tooltip,aTier); + + if (ConfigHandler.experimentalThreadedLoader) + OreDictAdder.addToMap(new Pair<>((aOreDictPrefix + additionalOreDictData).replaceAll(" ",""), tStack)); + else + GT_OreDictUnificator.registerOre((aOreDictPrefix + additionalOreDictData).replaceAll(" ",""), tStack); + } + + public static class BW_GT_MetaGenCircuits extends BW_Meta_Items.BW_GT_MetaGen_Item_Hook{ + + + public BW_GT_MetaGenCircuits() { + super("bwMetaGeneratedItem0"); + } + + public final ItemStack addCircuit(int aID, String aEnglish, String aToolTip, int tier){ + CircuitImprintLoader.bwCircuitTagMap.put(new CircuitData(BW_Util.getMachineVoltageFromTier(Math.min(1,(tier-2))),tier > 2 ? BW_Util.CLEANROOM : 0,(byte)tier), new ItemStack(BW_Meta_Items.NEWCIRCUITS,1,aID)); + return this.addItem(aID, aEnglish, aToolTip,SubTag.NO_UNIFICATION); + } + + public final ItemStack getStack(int... meta_amount){ + ItemStack ret = new ItemStack(this); + if (meta_amount.length <= 0 || meta_amount.length > 2) + return ret; + if (meta_amount.length == 1) { + ret.setItemDamage(meta_amount[0]); + return ret; + } + ret.setItemDamage(meta_amount[0]); + ret.stackSize=meta_amount[1]; + return ret; + } + + public final ItemStack getStackWithNBT(NBTTagCompound tag, int... meta_amount){ + ItemStack ret = this.getStack(meta_amount); + ret.setTagCompound(tag); + return ret; + } + + @Override + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + if (aCreativeTab == this.getCreativeTab()) + for (NBTTagCompound tag : CircuitImprintLoader.recipeTagMap.keySet()){ + ItemStack stack = new ItemStack(BW_Meta_Items.NEWCIRCUITS,1,0); + stack.setTagCompound(tag); + aList.add(stack); + } + super.getSubItems(var1, aCreativeTab, aList); + } + + @SideOnly(Side.CLIENT) + public final void registerIcons(IIconRegister aIconRegister) { + + for(short i = 0; i < CircuitImprintLoader.reverseIDs; ++i) { + if (this.mEnabledItems.get(i)) { + BW_Util.set2DCoordTo1DArray(i,0,2,aIconRegister.registerIcon("gregtech:" + (GT_Config.troll ? "troll" : this.getUnlocalizedName() + "/" + i)),this.mIconList); + } + } + + for (short i = CircuitImprintLoader.reverseIDs; i < Short.MAX_VALUE; i++) { + if (this.mEnabledItems.get(i)) { + BW_Util.set2DCoordTo1DArray(i,0,2,CircuitImprintLoader.circuitIIconRefs.get(i).get(1).getIconIndex(),this.mIconList); + BW_Util.set2DCoordTo1DArray(i,1,2,aIconRegister.registerIcon(MainMod.MOD_ID+":WrapOverlay"),this.mIconList); + //aIconRegister.registerIcon("gregtech:" + (GT_Config.troll ? "troll" : this.getUnlocalizedName() + "/" + i)); + } + } + + } + + @Override + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + if (aStack.getItemDamage() == 0 ) + if (aStack.getTagCompound() != null && CircuitImprintLoader.getStackFromTag(aStack.getTagCompound()) != null) + aList.add("An Imprint for: "+GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(CircuitImprintLoader.getStackFromTag(aStack.getTagCompound())))); + else + aList.add("An Imprint for a Circuit"); + else if (aStack.getItemDamage() == 1 ) + if (aStack.getTagCompound() != null && CircuitImprintLoader.getStackFromTag(aStack.getTagCompound()) != null) + aList.add("A Sliced "+GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(CircuitImprintLoader.getStackFromTag(aStack.getTagCompound())))); + else + aList.add("A Sliced Circuit"); + super.addAdditionalToolTips(aList, aStack, aPlayer); + } + } + + public static class BW_GT_MetaGen_Item_Hook extends GT_MetaBase_Item { + public static final HashSet<BW_Meta_Items.BW_GT_MetaGen_Item_Hook> sInstances = new HashSet<>(); + public final IIcon[] mIconList; + public final BitSet mEnabledItems; + { + this.mIconList = new IIcon[Short.MAX_VALUE*2]; + this.mEnabledItems = new BitSet(Short.MAX_VALUE); + } + + private BW_GT_MetaGen_Item_Hook(String aUnlocalized) { + super(aUnlocalized); + + this.setCreativeTab(new CreativeTabs("bw.MetaItems.0") { + @Override + public Item getTabIconItem() { + return ItemRegistry.TAB; + } + }); + this.setHasSubtypes(true); + this.setMaxDamage(0); + BW_Meta_Items.BW_GT_MetaGen_Item_Hook.sInstances.add(this); + } + + @Override + public Long[] getElectricStats(ItemStack itemStack) { + return null; + } + + @Override + public Long[] getFluidContainerStats(ItemStack itemStack) { + return null; + } + + public final ItemStack addItem(int aID, String aEnglish, String aToolTip, Object... aRandomData) { + if (aToolTip == null) { + aToolTip = ""; + } + ItemStack rStack = new ItemStack(this, 1, aID); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".name", aEnglish); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(rStack) + ".tooltip", aToolTip); + List<TC_Aspects.TC_AspectStack> tAspects = new ArrayList<>(); + this.mEnabledItems.set(aID); + Object[] var7 = aRandomData; + int var8 = aRandomData.length; + + int var9; + Object tRandomData; + for(var9 = 0; var9 < var8; ++var9) { + tRandomData = var7[var9]; + if (tRandomData instanceof SubTag) { + if (tRandomData == SubTag.NO_UNIFICATION) { + GT_OreDictUnificator.addToBlacklist(rStack); + } + } + } + + var7 = aRandomData; + var8 = aRandomData.length; + + for(var9 = 0; var9 < var8; ++var9) { + tRandomData = var7[var9]; + if (tRandomData != null) { + boolean tUseOreDict = true; + + if (tRandomData instanceof IItemBehaviour) { + this.addItemBehavior(aID, (IItemBehaviour) tRandomData); + tUseOreDict = false; + } + + if (tRandomData instanceof IItemContainer) { + ((IItemContainer)tRandomData).set(rStack); + tUseOreDict = false; + } + + if (!(tRandomData instanceof SubTag)) { + if (tRandomData instanceof TC_Aspects.TC_AspectStack) { + ((TC_Aspects.TC_AspectStack)tRandomData).addToAspectList(tAspects); + } else if (tRandomData instanceof ItemData) { + if (GT_Utility.isStringValid(tRandomData)) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } else { + GT_OreDictUnificator.addItemData(rStack, (ItemData)tRandomData); + } + } else if (tUseOreDict) { + GT_OreDictUnificator.registerOre(tRandomData, rStack); + } + } + } + } + + if (GregTech_API.sThaumcraftCompat != null) { + GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); + } + + return rStack; + } + + @SideOnly(Side.CLIENT) + public void getSubItems(Item var1, CreativeTabs aCreativeTab, List aList) { + int j = this.mEnabledItems.length(); + + for(int i = 0; i < j; ++i) { + if (this.mEnabledItems.get(i)) { + ItemStack tStack = new ItemStack(this, 1, i); + this.isItemStackUsable(tStack); + aList.add(tStack); + } + } + + } + + @Override + protected void addAdditionalToolTips(List aList, ItemStack aStack, EntityPlayer aPlayer) { + super.addAdditionalToolTips(aList, aStack, aPlayer); + aList.add(StatCollector.translateToLocal("tooltip.bw.0.name") + ChatColorHelper.DARKGREEN + " BartWorks"); + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return this.getUnlocalizedName() + "." + aStack.getItemDamage(); + } + + @Override + public IIcon getIconFromDamage(int i) { + if (this.mEnabledItems.get(i)) + return (IIcon) BW_Util.get2DCoordFrom1DArray(i,0,2,this.mIconList); + return null; + } + + @Override + public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { + return this.getIconFromDamage(stack.getItemDamage()); + } + + @Override + public IIcon getIcon(ItemStack stack, int pass) { + return this.getIconFromDamage(stack.getItemDamage()); + } + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java new file mode 100644 index 0000000000..2dfb4ad7c0 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitData.java @@ -0,0 +1,79 @@ +/* + * 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.system.material.CircuitGeneration; + +import com.github.bartimaeusnek.bartworks.util.MurmurHash3; + +import java.nio.ByteBuffer; + +public class CircuitData { + + private long aVoltage; + private int aSpecial; + private byte aTier; + + public CircuitData(long aVoltage, int aSpecial, byte aTier) { + this.aVoltage = aVoltage; + this.aSpecial = aSpecial; + this.aTier = aTier; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof CircuitData)) return false; + CircuitData that = (CircuitData) o; + if (this.getaVoltage() != that.getaVoltage()) return false; + if (this.getaSpecial() != that.getaSpecial()) return false; + return this.getaTier() == that.getaTier(); + } + + @Override + public int hashCode() { + return MurmurHash3.murmurhash3_x86_32(ByteBuffer.allocate(13).put(this.aTier).putInt(this.aSpecial).putLong(this.aVoltage).array(),0,13,31); + } + + public long getaVoltage() { + return this.aVoltage; + } + + public void setaVoltage(long aVoltage) { + this.aVoltage = aVoltage; + } + + public int getaSpecial() { + return this.aSpecial; + } + + public void setaSpecial(int aSpecial) { + this.aSpecial = aSpecial; + } + + public byte getaTier() { + return this.aTier; + } + + public void setaTier(byte aTier) { + this.aTier = aTier; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java new file mode 100644 index 0000000000..26f774b780 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java @@ -0,0 +1,222 @@ +/* + * 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.system.material.CircuitGeneration; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; +import cpw.mods.fml.common.registry.GameRegistry; +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_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashSet; +import java.util.Iterator; + +public class CircuitImprintLoader implements Runnable { + + public static final ArrayListMultimap<NBTTagCompound,GT_Recipe> recipeTagMap = ArrayListMultimap.create(); + static final HashBiMap<CircuitData,ItemStack> bwCircuitTagMap = HashBiMap.create(20); + static final HashSet<NBTTagCompound> refs = new HashSet<>(); + public static short reverseIDs = Short.MAX_VALUE-1; + public static HashBiMap<Short, ItemList> circuitIIconRefs = HashBiMap.create(20); + + public static NBTTagCompound getTagFromStack(ItemStack stack){ + if (GT_Utility.isStackValid(stack)) + return stack.copy().splitStack(1).writeToNBT(new NBTTagCompound()); + return new NBTTagCompound(); + } + + public static ItemStack getStackFromTag(NBTTagCompound tagCompound){ + return ItemStack.loadItemStackFromNBT(tagCompound); + } + + @Override + public void run() { + if (BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).mRecipeList.size() > 0) + return; + Iterator<GT_Recipe> it = GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.iterator(); + GT_Recipe circuitRecipe; + HashSet<GT_Recipe> toRem = new HashSet<>(); + HashSet<GT_Recipe> toAdd = new HashSet<>(); + while (it.hasNext()) { + circuitRecipe = it.next(); + ItemStack[] outputs = circuitRecipe.mOutputs; + if (outputs.length < 1) + continue; + int[] oreIDS = OreDictionary.getOreIDs(outputs[0]); + if (oreIDS.length < 1) + continue; + String name = OreDictionary.getOreName(oreIDS[0]); + if (name.contains("Circuit") || name.contains("circuit")) { + CircuitImprintLoader.recipeTagMap.put(CircuitImprintLoader.getTagFromStack(outputs[0]), circuitRecipe.copy()); + for (ItemStack s : circuitRecipe.mInputs) { + if (circuitRecipe.mFluidInputs[0].isFluidEqual(Materials.SolderingAlloy.getMolten(0))) + CircuitImprintLoader.refs.add(CircuitImprintLoader.getTagFromStack(s.copy().splitStack(1))); + } + if (circuitRecipe.mFluidInputs[0].isFluidEqual(Materials.SolderingAlloy.getMolten(0))) { + + GT_Recipe newRecipe = CircuitImprintLoader.reBuildRecipe(circuitRecipe); + if (newRecipe != null) + BWRecipes.instance.getMappingsFor(BWRecipes.CIRCUITASSEMBLYLINE).addRecipe(newRecipe); + if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) { + toRem.add(circuitRecipe); + toAdd.add(CircuitImprintLoader.makeMoreExpensive(circuitRecipe)); + } + } else { + if (circuitRecipe.mEUt > BW_Util.getTierVoltage(ConfigHandler.cutoffTier)) { + toRem.add(circuitRecipe); + } + } + + } + } + GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.addAll(toAdd); + GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.mRecipeList.removeAll(toRem); + this.makeCircuitImprints(); + } + + public static GT_Recipe makeMoreExpensive(GT_Recipe original){ + GT_Recipe newRecipe = original.copy(); + for (ItemStack is : newRecipe.mInputs){ + int[] oreIDs = OreDictionary.getOreIDs(is); + if(oreIDs == null || oreIDs.length < 1 || !OreDictionary.getOreName(oreIDs[0]).contains("circuit")) { + is.stackSize = 64; + } + } + newRecipe.mFluidInputs[0].amount *= 4; + newRecipe.mDuration *= 4; + return newRecipe; + } + + public static GT_Recipe reBuildRecipe(GT_Recipe original){ + ItemStack out = original.copy().getOutput(0); + out.stackSize *= 16; + ItemStack[] in = new ItemStack[6]; + BiMap<ItemList, Short> inversed = CircuitImprintLoader.circuitIIconRefs.inverse(); + for (int i = 0; i < 6; i++) { + try { + for (ItemList il : inversed.keySet()){ + if (GT_Utility.areStacksEqual(il.get(1), original.mInputs[i])) { + in[i] = BW_Meta_Items.getNEWCIRCUITS().getStack(inversed.get(il), original.mInputs[i].stackSize); + } + + } + if (original.mInputs[i] != null && in[i] == null){ + if (BW_Util.checkStackAndPrefix(original.mInputs[i]) && GT_OreDictUnificator.getAssociation(original.mInputs[i]).mPrefix == OrePrefixes.wireGt01){ + in[i] = GT_OreDictUnificator.get(OrePrefixes.wireGt16,GT_OreDictUnificator.getAssociation(original.mInputs[i]).mMaterial.mMaterial,original.mInputs[i].stackSize); + } + else if (BW_Util.checkStackAndPrefix(original.mInputs[i]) && GT_OreDictUnificator.getAssociation(original.mInputs[i]).mPrefix == OrePrefixes.wireFine){ + in[i] = GT_OreDictUnificator.get(OrePrefixes.wireGt04,GT_OreDictUnificator.getAssociation(original.mInputs[i]).mMaterial.mMaterial,original.mInputs[i].stackSize); + } + else { + in[i] = original.mInputs[i].copy(); + in[i].stackSize *= 16; + } +// if (in[i].stackSize > 64) +// return null; + } + } catch (ArrayIndexOutOfBoundsException e){ + break; + } catch (NullPointerException e){ + e.printStackTrace(); + } + } + if (CircuitImprintLoader.checkForBlacklistedComponents(in)){ + return null; + } + return new BWRecipes.DynamicGTRecipe(false,in,new ItemStack[]{out},BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(CircuitImprintLoader.getTagFromStack(original.mOutputs[0]),0,0),null, original.mFluidInputs,null,original.mDuration,original.mEUt,original.mSpecialValue); + } + + + public static final HashSet<ItemStack> blacklistSet = new HashSet<>(); + + private static boolean checkForBlacklistedComponents(ItemStack[] itemStacks){ + for (ItemStack is: itemStacks){ + for (ItemStack is2 : CircuitImprintLoader.blacklistSet){ + if (GT_Utility.areStacksEqual(is,is2)) + return true; + } + } + return false; + } + + private void makeCircuitImprints(){ + for (NBTTagCompound tag : CircuitImprintLoader.recipeTagMap.keySet()){ + ItemStack stack = CircuitImprintLoader.getStackFromTag(tag); + int eut = Integer.MAX_VALUE; + for (GT_Recipe recipe : CircuitImprintLoader.recipeTagMap.get(tag)) { + eut = Math.min(eut, recipe.mEUt); + } + eut = Math.min(eut, BW_Util.getMachineVoltageFromTier(BW_Util.getCircuitTierFromOreDictName(OreDictionary.getOreName(OreDictionary.getOreIDs(stack)[0])))); + GT_Recipe slicingRecipe = new BWRecipes.DynamicGTRecipe(true,new ItemStack[]{stack,ItemList.Shape_Slicer_Flat.get(0)},new ItemStack[]{BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1)},null,null,null,null,300,eut, BW_Util.CLEANROOM); + GT_Recipe.GT_Recipe_Map.sSlicerRecipes.add(slicingRecipe); + GameRegistry.addRecipe(new BWRecipes.BWNBTDependantCraftingRecipe(BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,0,1), + " X ", + "GPG", + " X ", + 'P', BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1), + 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), + 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3))); + GT_ModHandler.addCraftingRecipe(BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,0,1), GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS | GT_ModHandler.RecipeBits.KEEPNBT | GT_ModHandler.RecipeBits.BUFFERED, new Object[]{ + " X ", + "GPG", + " X ", + 'P', BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1), + 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), + 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3)}); + } +// for (ItemStack stack : CircuitImprintLoader.bwCircuitTagMap.values()){ +// NBTTagCompound tag = CircuitImprintLoader.getTagFromStack(stack); +// CircuitData data = CircuitImprintLoader.bwCircuitTagMap.inverse().get(stack); +// GT_Recipe slicingRecipe = new BWRecipes.DynamicGTRecipe(true,new ItemStack[]{stack,ItemList.Shape_Slicer_Flat.get(0)},new ItemStack[]{BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1)},null,null,null,null,300, Math.toIntExact(data.getaVoltage()),data.getaSpecial()); +// GT_Recipe.GT_Recipe_Map.sSlicerRecipes.add(slicingRecipe); +// GameRegistry.addRecipe(new BWRecipes.BWNBTDependantCraftingRecipe(BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,0,1), +// " X ", +// "GPG", +// " X ", +// 'P', BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1), +// 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), +// 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3))); +// GT_ModHandler.addCraftingRecipe(BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,0,1),GT_ModHandler.RecipeBits.KEEPNBT | GT_ModHandler.RecipeBits.BUFFERED | GT_ModHandler.RecipeBits.DO_NOT_CHECK_FOR_COLLISIONS ,new Object[]{ +// " X ", +// "GPG", +// " X ", +// 'P', BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(tag,1,1), +// 'G', WerkstoffLoader.Prasiolite.get(OrePrefixes.gemExquisite,1), +// 'X', BW_Meta_Items.getNEWCIRCUITS().getStack(3) +// }); +// } + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java new file mode 100644 index 0000000000..b6d1e83529 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java @@ -0,0 +1,100 @@ +/* + * 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.system.material.CircuitGeneration; + +import com.github.bartimaeusnek.bartworks.client.renderer.BW_GT_ItemRenderer; +import cpw.mods.fml.common.FMLCommonHandler; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.util.ArrayList; + +import static gregtech.api.enums.ItemList.*; + +public class CircuitPartLoader implements Runnable { + @Override + public void run() { + CircuitPartLoader.makeCircuitParts(); + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) + new BW_GT_ItemRenderer(); + } + + public static void makeCircuitParts() { + ItemList[] itemLists = values(); + for (ItemList single : itemLists) { + if (!single.hasBeenSet()) + continue; + if ( + single.toString().contains("Wafer") || + single.toString().contains("Circuit_Silicon_Ingot") || + single.toString().contains("Raw") || + single.toString().contains("raw") || + single.toString().contains("Glass_Tube") || + single == Circuit_Parts_GlassFiber || + single == Circuit_Parts_Advanced || + single == Circuit_Parts_Wiring_Advanced || + single == Circuit_Parts_Wiring_Elite || + single == Circuit_Parts_Wiring_Basic || + single == Circuit_Integrated || + single == Circuit_Parts_PetriDish || + single == Circuit_Parts_Vacuum_Tube || + single == Circuit_Integrated_Good || + single == Circuit_Parts_Capacitor || + single == Circuit_Parts_Diode || + single == Circuit_Parts_Resistor || + single == Circuit_Parts_Transistor + + ){ + CircuitImprintLoader.blacklistSet.add(single.get(1)); + continue; + } + ItemStack itemStack = single.get(1); + if (!GT_Utility.isStackValid(itemStack)) + continue; + int[] oreIDS = OreDictionary.getOreIDs(itemStack); + if (oreIDS.length > 1) + continue; + String name = null; + if (oreIDS.length == 1) + name = OreDictionary.getOreName(oreIDS[0]); + if ((name == null || name.isEmpty()) && (single.toString().contains("Circuit") || single.toString().contains("circuit") || single.toString().contains("board")) && single.getBlock() == Blocks.air) { + ArrayList<String> toolTip = new ArrayList<>(); + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) + single.getItem().addInformation(single.get(1).copy(), null, toolTip, true); + String tt = (toolTip.size() > 0 ? toolTip.get(0) : ""); + // tt += "Internal Name = "+single; + String localised = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(itemStack)); + BW_Meta_Items.getNEWCIRCUITS().addItem(CircuitImprintLoader.reverseIDs, "Wrap of " + localised+"s", tt); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{single.get(16).copy()}, Materials.Plastic.getMolten(72),BW_Meta_Items.getNEWCIRCUITS().getStack(CircuitImprintLoader.reverseIDs),600,30); + CircuitImprintLoader.circuitIIconRefs.put(CircuitImprintLoader.reverseIDs,single); + CircuitImprintLoader.reverseIDs--; + } + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/ThreadedLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/ThreadedLoader.java index bb3bea4915..e5467ea8c3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/ThreadedLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/ThreadedLoader.java @@ -39,17 +39,17 @@ public class ThreadedLoader implements Runnable { public synchronized void run() { MainMod.LOGGER.warn("EXPERIMENTAL THREADED-LOADER ENABLED!"); MainMod.LOGGER.info("Starting to register BartWorks Materials Recipes to Gregtech"); - threads.add(new AllRecipes()); - threads.forEach(Thread::start); + this.threads.add(new AllRecipes()); + this.threads.forEach(Thread::start); } public synchronized void runInit() { MainMod.LOGGER.warn("EXPERIMENTAL THREADED-LOADER ENABLED!"); MainMod.LOGGER.info("Starting the Material Generation Thread"); - threadsInit.add(new MaterialGen()); - threadsInit.forEach(Thread::start); - for (Thread thread : threadsInit) { + this.threadsInit.add(new MaterialGen()); + this.threadsInit.forEach(Thread::start); + for (Thread thread : this.threadsInit) { try { MainMod.LOGGER.info("Trying to join the Material Generation Thread"); thread.join(); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java index 754d07055f..5d73dba279 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/Werkstoff.java @@ -29,10 +29,9 @@ import com.github.bartimaeusnek.bartworks.util.Pair; import gregtech.api.enums.*; import gregtech.api.interfaces.IColorModulationContainer; import gregtech.api.interfaces.ISubTagContainer; -import gregtech.api.objects.GT_Fluid; import gregtech.api.util.GT_OreDictUnificator; import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; import java.nio.ByteBuffer; import java.util.*; @@ -53,8 +52,6 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { private byte[] rgb = new byte[3]; private final String defaultName; private String toolTip; - private Fluid fluid; - private Fluid gas; private Werkstoff.Stats stats; private final Werkstoff.Types type; @@ -99,7 +96,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { type = Werkstoff.Types.UNDEFINED; this.defaultName = defaultName; - + this.stats = stats; this.type = type; this.mID = (short) mID; this.generationFeatures = generationFeatures; @@ -108,41 +105,58 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { this.toolTip = ""; if (toolTip.isEmpty()) { for (Pair<ISubTagContainer, Integer> p : contents) { - if (p.getKey() instanceof Materials) { - this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + if (contents.length > 1) { + if (p.getKey() instanceof Materials) { + if (((Materials) p.getKey()).mMaterialList.size() > 1 && p.getValue() > 1) +// if (((Materials) p.getKey()).mChemicalFormula != null && Character.isDigit(((Materials) p.getKey()).mChemicalFormula.toCharArray()[((Materials) p.getKey()).mChemicalFormula.length()-1])) + this.toolTip += "(" + ((Materials) p.getKey()).mChemicalFormula + ")" + (BW_Util.subscriptNumber(p.getValue())); + else + this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } + if (p.getKey() instanceof Werkstoff) { + if (((Werkstoff) p.getKey()).contents.size() > 1 && p.getValue() > 1) +// if (((Werkstoff) p.getKey()).toolTip != null && Character.isDigit(((Werkstoff) p.getKey()).toolTip.toCharArray()[((Werkstoff) p.getKey()).toolTip.length()-1])) + this.toolTip += "(" + ((Werkstoff) p.getKey()).toolTip + ")" + (BW_Util.subscriptNumber(p.getValue())); + else + this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } + } else { + if (p.getKey() instanceof Materials) { + this.toolTip += ((Materials) p.getKey()).mChemicalFormula + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); + } else if (p.getKey() instanceof Werkstoff) + this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } - if (p.getKey() instanceof Werkstoff) - this.toolTip += ((Werkstoff) p.getKey()).toolTip + (p.getValue() > 1 ? BW_Util.subscriptNumber(p.getValue()) : ""); } } else this.toolTip = toolTip; - long tmpprotons = 0; - for (Pair<ISubTagContainer, Integer> p : contents) { - if (p.getKey() instanceof Materials) { - tmpprotons += ((Materials) p.getKey()).getProtons() * p.getValue(); - } else if (p.getKey() instanceof Werkstoff) { - tmpprotons += ((Werkstoff) p.getKey()).getStats().protons * p.getValue(); + if (this.stats.protons == 0) { + long tmpprotons = 0; + for (Pair<ISubTagContainer, Integer> p : contents) { + if (p.getKey() instanceof Materials) { + tmpprotons += ((Materials) p.getKey()).getProtons() * p.getValue(); + } else if (p.getKey() instanceof Werkstoff) { + tmpprotons += ((Werkstoff) p.getKey()).getStats().protons * p.getValue(); + } } + this.stats = stats.setProtons(tmpprotons); } - this.stats = stats.setProtons(tmpprotons); - - long tmpmass = 0; - for (Pair<ISubTagContainer, Integer> p : contents) { - if (p.getKey() instanceof Materials) { - tmpmass += ((Materials) p.getKey()).getMass() * p.getValue(); - } else if (p.getKey() instanceof Werkstoff) { - tmpprotons += ((Werkstoff) p.getKey()).getStats().mass * p.getValue(); + if (this.stats.mass == 0) { + long tmpmass = 0; + for (Pair<ISubTagContainer, Integer> p : contents) { + if (p.getKey() instanceof Materials) { + tmpmass += ((Materials) p.getKey()).getMass() * p.getValue(); + } else if (p.getKey() instanceof Werkstoff) { + tmpmass += ((Werkstoff) p.getKey()).getStats().mass * p.getValue(); + } } + this.stats = stats.setMass(tmpmass); } - this.stats = stats.setMass(tmpmass); - this.texSet = texSet; - if (this.getStats().meltingPoint > 0) { - this.fluid = new GT_Fluid("molten" + this.getDefaultName().replaceAll(" ", ""), "molten.autogenerated", this.getRGBA()); - this.getGenerationFeatures().toGenerate |= 16; + if (this.getGenerationFeatures().enforceUnification) { + for (OrePrefixes prefix : OrePrefixes.values()) + BWUnificationEnforcer.addUnificationTarget(prefix+this.getDefaultName()); } - Werkstoff.werkstoffHashSet.add(this); Werkstoff.werkstoffHashMap.put(this.mID, this); } @@ -225,7 +239,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { if (o == null||o.equals(Werkstoff.default_null_Werkstoff) || o.equals(Materials._NULL)) return this.get(prefixes); if (o instanceof Werkstoff) - return WerkstoffLoader.getCorresopndingItemStack(prefixes, (Werkstoff) o); + return WerkstoffLoader.getCorrespondingItemStack(prefixes, (Werkstoff) o); if (o instanceof Materials) return GT_OreDictUnificator.get(prefixes, o, 1L); return null; @@ -266,9 +280,10 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { @Override public boolean contains(SubTag subTag) { - for (Pair<ISubTagContainer, Integer> p : this.contents) - if (p.getKey().contains(subTag)) - return true; + if (!subTag.equals(WerkstoffLoader.NOBLE_GAS) && !subTag.equals(WerkstoffLoader.ANAEROBE_GAS)) + for (Pair<ISubTagContainer, Integer> p : this.contents) + if (p.getKey().contains(subTag)) + return true; return this.subtags.contains(subTag); } @@ -288,15 +303,23 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { } public ItemStack get(OrePrefixes prefixes) { - return WerkstoffLoader.getCorresopndingItemStack(prefixes, this); + return WerkstoffLoader.getCorrespondingItemStack(prefixes, this); + } + + public FluidStack getFluidOrGas(int fluidAmount) { + return new FluidStack(WerkstoffLoader.fluids.get(this),fluidAmount); + } + public FluidStack getMolten(int fluidAmount) { + return new FluidStack(WerkstoffLoader.molten.get(this),fluidAmount); } + public ItemStack get(OrePrefixes prefixes, int amount) { - return WerkstoffLoader.getCorresopndingItemStack(prefixes, this, amount); + return WerkstoffLoader.getCorrespondingItemStack(prefixes, this, amount); } public enum Types { - MATERIAL, COMPOUND, MIXTURE, BIOLOGICAL, ELEMENT, UNDEFINED; + MATERIAL, COMPOUND, MIXTURE, BIOLOGICAL, ELEMENT, ISOTOPE, UNDEFINED; public static Werkstoff.Stats getDefaultStatForType(Werkstoff.Types T) { switch (T) { @@ -319,10 +342,16 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { gem 100 ore 1000 cell 10000 + plasma 100000 + molten 1000000 */ public byte toGenerate = 0b0001001; + + //public byte toGenerateSecondary = 0b0000000; public byte blacklist; + public boolean enforceUnification; + /* * Auto add Chemical Recipes 1 * Auto add mixer Recipes 10 @@ -348,6 +377,11 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { return (this.toGenerate & 0b1000) != 0; } + public Werkstoff.GenerationFeatures enforceUnification(){ + this.enforceUnification = true; + return this; + } + public Werkstoff.GenerationFeatures removeGems(){ if (this.hasGems()) this.toGenerate = (byte) (this.toGenerate ^ 0b100); @@ -404,6 +438,23 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { this.toGenerate = (byte) (0); return this; } + public Werkstoff.GenerationFeatures addCells() { + this.toGenerate = (byte) (this.toGenerate | 0b10000); + return this; + } + + public boolean hasCells() { + return (this.toGenerate & 0b10000) != 0; + } + + public boolean hasMolten() { + return (this.toGenerate & 0b1000000) != 0; + } + + public Werkstoff.GenerationFeatures addMolten() { + this.toGenerate = (byte) (this.toGenerate | 0b1000000); + return this; + } public Werkstoff.GenerationFeatures addGems() { this.toGenerate = (byte) (this.toGenerate | 0x4); @@ -422,16 +473,24 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { return this.boilingPoint; } - public Stats setBoilingPoint(int boilingPoint) { + public Werkstoff.Stats setBoilingPoint(int boilingPoint) { this.boilingPoint = boilingPoint; return this; } + public long getMass() { + return this.mass; + } + + public long getProtons() { + return this.protons; + } + public int getMeltingPoint() { return this.meltingPoint; } - public Stats setMeltingPoint(int meltingPoint) { + public Werkstoff.Stats setMeltingPoint(int meltingPoint) { this.meltingPoint = meltingPoint; return this; } @@ -443,14 +502,14 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { long mass; private Pair<Object,Integer>[] mTC_Aspects; //logic gate shit - byte quality = ~0b111111; + byte quality = ~0b1111111; - public Stats setmTC_AspectsArray(Pair<Object, Integer>[] mTC_Aspects) { + public Werkstoff.Stats setmTC_AspectsArray(Pair<Object, Integer>[] mTC_Aspects) { this.mTC_Aspects = mTC_Aspects; return this; } - public Stats setmTC_AspectsVarArg(Pair<Object, Integer>... mTC_Aspects) { + public Werkstoff.Stats setmTC_AspectsVarArg(Pair<Object, Integer>... mTC_Aspects) { this.mTC_Aspects = mTC_Aspects; return this; } @@ -481,7 +540,7 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { } public Werkstoff.Stats setMass(long mass) { - this.mass = this.protons; + this.mass = mass; return this; } @@ -491,74 +550,86 @@ public class Werkstoff implements IColorModulationContainer, ISubTagContainer { } public boolean isSublimation() { - return (this.quality & 0b1) == 0b1; + return (this.quality & 0b1) != 0; } public Werkstoff.Stats setSublimation(boolean sublimation) { if (sublimation) this.quality = (byte) (this.quality | 0b000001); else - this.quality = (byte) (this.quality & 0b111110); + this.quality = (byte) (this.quality & 0b1111110); return this; } public boolean isToxic() { - return (this.quality >> 1 & 0b1) == 0b1; + return (this.quality & 0b10) != 0; } public Werkstoff.Stats setToxic(boolean toxic) { if (toxic) this.quality = (byte) (this.quality | 0b000010); else - this.quality = (byte) (this.quality & 0b111101); + this.quality = (byte) (this.quality & 0b1111101); return this; } public boolean isRadioactive() { - return (this.quality >> 2 & 0b1) == 0b1; + return (this.quality & 0b100) != 0; } public Werkstoff.Stats setRadioactive(boolean radioactive) { if (radioactive) this.quality = (byte) (this.quality | 0b000100); else - this.quality = (byte) (this.quality & 0b111011); + this.quality = (byte) (this.quality & 0b1111011); return this; } public boolean isBlastFurnace() { - return (this.quality >> 3 & 0b1) == 0b1; + return (this.quality & 0b1000) != 0; } public Werkstoff.Stats setBlastFurnace(boolean blastFurnace) { if (blastFurnace) this.quality = (byte) (this.quality | 0b001000); else - this.quality = (byte) (this.quality & 0b110111); + this.quality = (byte) (this.quality & 0b1110111); return this; } public boolean isElektrolysis() { - return (this.quality >> 4 & 0b1) == 0b1; + return (this.quality & 0x10) != 0; } public Werkstoff.Stats setElektrolysis(boolean elektrolysis) { if (elektrolysis) - this.quality = (byte) (this.quality | 0b010000); + this.quality = (byte) (this.quality | 0x10); else - this.quality = (byte) (this.quality & 0b101111); + this.quality = (byte) (this.quality & 0b1101111); return this; } public boolean isCentrifuge() { - return (this.quality >> 5 & 0b1) == 0b1; + return (this.quality & 0x20) != 0; } public Werkstoff.Stats setCentrifuge(boolean centrifuge) { if (centrifuge) - this.quality = (byte) (this.quality | 0b100000); + this.quality = (byte) (this.quality | 0x20); + else + this.quality = (byte) (this.quality & 0b1011111); + return this; + } + + public boolean isGas() { + return (this.quality & 0x40) != 0; + } + + public Werkstoff.Stats setGas(boolean gas) { + if (gas) + this.quality = (byte) (this.quality | 0x40); else - this.quality = (byte) (this.quality & 0b011111); + this.quality = (byte) (this.quality & 0b0111111); return this; } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java index 662cfbea5a..bf3ae4bb9e 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java @@ -27,9 +27,11 @@ import com.github.bartimaeusnek.bartworks.MainMod; import com.github.bartimaeusnek.bartworks.client.renderer.BW_Renderer_Block_Ores; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.bartworks.system.log.DebugLog; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_CircuitsLoader; import com.github.bartimaeusnek.bartworks.system.material.processingLoaders.AdditionalRecipes; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictAdder; import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_ColorUtil; import com.github.bartimaeusnek.bartworks.util.Pair; import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; @@ -42,21 +44,26 @@ import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.*; import gregtech.api.interfaces.ISubTagContainer; +import gregtech.api.objects.GT_Fluid; import gregtech.api.objects.GT_MultiTexture; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.ItemData; import gregtech.api.util.*; +import gregtech.common.items.behaviors.Behaviour_DataOrb; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputOreDict; import ic2.api.recipe.RecipeOutput; import ic2.api.recipe.Recipes; import net.minecraft.block.Block; import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.EnumHelper; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import java.lang.reflect.Field; import java.util.*; import static com.github.bartimaeusnek.bartworks.util.BW_Util.subscriptNumbers; @@ -68,7 +75,23 @@ public class WerkstoffLoader implements Runnable { private WerkstoffLoader() {} public static final WerkstoffLoader INSTANCE = new WerkstoffLoader(); + public static final SubTag NOBLE_GAS = SubTag.getNewSubTag("NobleGas"); + public static final SubTag ANAEROBE_GAS = SubTag.getNewSubTag("AnaerobeGas"); + public static final SubTag ANAEROBE_SMELTING = SubTag.getNewSubTag("AnaerobeSmelting"); + public static OrePrefixes cellMolten; + static { + for (OrePrefixes prefix : OrePrefixes.values()){ + if (prefix.toString().equals("cellMolten")) + WerkstoffLoader.cellMolten = prefix; + } + if (WerkstoffLoader.cellMolten == null) { + WerkstoffLoader.cellMolten = EnumHelper.addEnum(OrePrefixes.class,"cellMolten",new Class[]{String.class, String.class, String.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, boolean.class, int.class, long.class, int.class, int.class},new Object[]{"Cells of Molten stuff", "Molten ", " Cell", true, true, true, true, false, false, false, true, false, false, 0b1000000, 3628800L, 64, 31}); + // GT_LanguageManager.addStringLocalization(".name", this.getDefaultLocalization(w)); + } else { + WerkstoffLoader.cellMolten.mMaterialGenerationBits = 0b1000000; + } + } //TODO: FREE ID RANGE: 19-32766 public static final Werkstoff Bismutite = new Werkstoff( @@ -102,18 +125,18 @@ public class WerkstoffLoader implements Runnable { Werkstoff.Types.ELEMENT, new Werkstoff.GenerationFeatures().onlyDust(), 3, - TextureSet.SET_METALLIC, - Arrays.asList() + TextureSet.SET_METALLIC + //No Byproducts ); - public static final Werkstoff Zirconia = new Werkstoff( + public static final Werkstoff CubicZirconia = new Werkstoff( new short[]{255, 255, 255, 0}, "Cubic Zirconia", Werkstoff.Types.COMPOUND, new Werkstoff.GenerationFeatures().onlyDust().addGems(), 4, TextureSet.SET_DIAMOND, - Arrays.asList(Zirconium), - new Pair<>(Zirconium, 1), + Arrays.asList(WerkstoffLoader.Zirconium), + new Pair<>(WerkstoffLoader.Zirconium, 1), new Pair<>(Materials.Oxygen, 2) ); public static final Werkstoff FluorBuergerit = new Werkstoff( @@ -310,8 +333,8 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().addGems(), 19, TextureSet.SET_GEM_VERTICAL, - Arrays.asList(Zirconium,Materials.Silicon), - new Pair<>(Zirconium, 1), + Arrays.asList(WerkstoffLoader.Zirconium,Materials.Silicon), + new Pair<>(WerkstoffLoader.Zirconium, 1), new Pair<>(Materials.Silicon, 1), new Pair<>(Materials.Oxygen, 4) ); @@ -457,10 +480,11 @@ public class WerkstoffLoader implements Runnable { "Thorium 232", superscriptNumbers("Th232"), new Werkstoff.Stats().setRadioactive(true), - Werkstoff.Types.ELEMENT, + Werkstoff.Types.ISOTOPE, new Werkstoff.GenerationFeatures().disable().onlyDust(), 30, TextureSet.SET_METALLIC + //No Byproducts ); public static final Werkstoff BismuthTellurite = new Werkstoff( new short[]{32,72,32,0}, @@ -470,6 +494,7 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().disable().onlyDust().addChemicalRecipes(), 31, TextureSet.SET_METALLIC, + //No Byproducts new Pair<>(Materials.Bismuth, 2), new Pair<>(Materials.Tellurium, 3) ); @@ -478,9 +503,10 @@ public class WerkstoffLoader implements Runnable { "Tellurium", new Werkstoff.Stats(), Werkstoff.Types.ELEMENT, - new Werkstoff.GenerationFeatures().disable().addMetalItems(), + new Werkstoff.GenerationFeatures().addMetalItems().removeOres(), 32, TextureSet.SET_METALLIC, + //No Byproducts new Pair<>(Materials.Tellurium, 1) ); public static final Werkstoff BismuthHydroBorat = new Werkstoff( @@ -491,35 +517,176 @@ public class WerkstoffLoader implements Runnable { new Werkstoff.GenerationFeatures().disable().onlyDust().addChemicalRecipes(), 33, TextureSet.SET_METALLIC, + //No Byproducts new Pair<>(Materials.Bismuth, 2), new Pair<>(Materials.Boron, 1), new Pair<>(Materials.Hydrogen, 1) ); public static final Werkstoff ArInGaPhoBiBoTe = new Werkstoff( new short[]{36,36,36,0}, - "Circuit Compound MK1", + "Circuit Compound MK3", new Werkstoff.Stats().setCentrifuge(true), Werkstoff.Types.COMPOUND, new Werkstoff.GenerationFeatures().disable().onlyDust().addMixerRecipes(), 34, TextureSet.SET_METALLIC, + //No Byproducts new Pair<>(Materials.IndiumGalliumPhosphide, 1), new Pair<>(WerkstoffLoader.BismuthHydroBorat, 3), new Pair<>(WerkstoffLoader.BismuthTellurite, 2) ); + public static final Werkstoff Prasiolite = new Werkstoff( + new short[]{0xD0,0xDD,0x95,0}, + "Prasiolite", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems(), + 35, + TextureSet.SET_QUARTZ, + //No Byproducts + new Pair<>(Materials.Silicon,5), + new Pair<>(Materials.Oxygen,10), + new Pair<>(Materials.Iron,1) + ); + + public static final Werkstoff MagnetoResonaticDust = new Werkstoff( + new short[]{0xDD,0x77,0xDD,0}, + "Magneto Resonatic", + new Werkstoff.Stats().setElektrolysis(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().onlyDust().addMixerRecipes().addGems(), + 36, + TextureSet.SET_MAGNETIC, + //No Byproducts + new Pair<>(WerkstoffLoader.Prasiolite,3), + new Pair<>(WerkstoffLoader.BismuthTellurite,4), + new Pair<>(WerkstoffLoader.CubicZirconia,1), + new Pair<>(Materials.SteelMagnetic,1) + ); + public static final Werkstoff Xenon = new Werkstoff( + new short[]{0x14,0x39,0x7F,0}, + "Xenon", + "Xe", + new Werkstoff.Stats().setProtons(54).setMass(131).setGas(true), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable().addCells().enforceUnification(), + 37, + TextureSet.SET_FLUID + //No Byproducts + //No Ingredients + ); + public static final Werkstoff Oganesson = new Werkstoff( + new short[]{0x14,0x39,0x7F,0}, + "Oganesson", + "Og", + new Werkstoff.Stats().setProtons(118).setMass(294).setGas(true), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable().addCells(), + 38, + TextureSet.SET_FLUID + //No Byproducts + //No Ingredients + ); + public static final Werkstoff Californium = new Werkstoff( + new short[]{0xAA,0xAA,0xAA,0}, + "Californium", + "Cf", + new Werkstoff.Stats().setProtons(98).setMass(251).setBlastFurnace(true).setMeltingPoint(900), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable().onlyDust().addMetalItems().addMolten().enforceUnification(), + 39, + TextureSet.SET_METALLIC + //No Byproducts + //No Ingredients + ); + public static final Werkstoff Calcium = new Werkstoff( + Materials.Calcium.mRGBa, + "Calcium", + "Ca", + new Werkstoff.Stats().setProtons(Element.Ca.mProtons).setMass(Element.Ca.getMass()).setBlastFurnace(true).setMeltingPoint(1115).setBoilingPoint(1757), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable().onlyDust().addMetalItems().addMolten(), + 40, + Materials.Calcium.mIconSet + //No Byproducts + //No Ingredients + ); + public static final Werkstoff Neon = new Werkstoff( + new short[]{0xff,0x07,0x3a}, + "Neon", + "Ne", + new Werkstoff.Stats().setProtons(Element.Ne.mProtons).setMass(Element.Ne.getMass()).setGas(true), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable().addCells().enforceUnification(), + 41, + TextureSet.SET_FLUID + //No Byproducts + //No Ingredients + ); + public static final Werkstoff Krypton = new Werkstoff( + new short[]{0xb1,0xff,0x32}, + "Krypton", + "Kr", + new Werkstoff.Stats().setProtons(Element.Kr.mProtons).setMass(Element.Kr.getMass()).setGas(true), + Werkstoff.Types.ELEMENT, + new Werkstoff.GenerationFeatures().disable().addCells().enforceUnification(), + 42, + TextureSet.SET_FLUID + //No Byproducts + //No Ingredients + ); + public static final Werkstoff BArTiMaEuSNeK = new Werkstoff( + new short[]{0x00,0xff,0x00}, + "BArTiMaEuSNeK", + "Are you serious?", + new Werkstoff.Stats().setMeltingPoint(9001).setCentrifuge(true).setBlastFurnace(true), + Werkstoff.Types.COMPOUND, + new Werkstoff.GenerationFeatures().addGems().addMetalItems().addMolten(), + 43, + TextureSet.SET_DIAMOND, + Arrays.asList( + Materials.Boron, + Materials.Titanium, + Materials.Europium + ), + new Pair<>(Materials.Boron,1), + new Pair<>(Materials.Argon,1), + new Pair<>(Materials.Titanium,1), + new Pair<>(Materials.Magic,1), + new Pair<>(Materials.Europium,1), + new Pair<>(Materials.Sulfur,1), + new Pair<>(WerkstoffLoader.Neon,1), + new Pair<>(Materials.Potassium,1) + ); + public static HashMap<OrePrefixes, BW_MetaGenerated_Items> items = new HashMap<>(); + public static HashMap<Werkstoff, Fluid> fluids = new HashMap<>(); + public static HashMap<Werkstoff, Fluid> molten = new HashMap<>(); public static Block BWOres; public boolean registered; - public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { - return WerkstoffLoader.getCorresopndingItemStack(orePrefixes, werkstoff, 1); + public static Werkstoff getWerkstoff(String Name){ + try{ + Field f = WerkstoffLoader.class.getField(Name); + if (f != null) + return (Werkstoff) f.get(null); + } catch (IllegalAccessException | NoSuchFieldException | ClassCastException e) { + e.printStackTrace(); + } + return Werkstoff.default_null_Werkstoff; + } + + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff) { + return WerkstoffLoader.getCorrespondingItemStack(orePrefixes, werkstoff, 1); } - public static ItemStack getCorresopndingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { - ItemStack ret = OreDictHandler.getItemStack(werkstoff.getDefaultName(),orePrefixes,amount); + public static ItemStack getCorrespondingItemStack(OrePrefixes orePrefixes, Werkstoff werkstoff, int amount) { + if (!werkstoff.getGenerationFeatures().enforceUnification) { + ItemStack ret = OreDictHandler.getItemStack(werkstoff.getDefaultName(), orePrefixes, amount); if (ret != null) return ret; + } if (orePrefixes == ore) return new ItemStack(WerkstoffLoader.BWOres, amount, werkstoff.getmID()); return new ItemStack(WerkstoffLoader.items.get(orePrefixes), amount, werkstoff.getmID()).copy(); @@ -566,10 +733,16 @@ public class WerkstoffLoader implements Runnable { this.addOreRecipes(werkstoff); DebugLog.log("Loading Crushed Recipes"+" " +(System.nanoTime()-timepreone)); this.addCrushedRecipes(werkstoff); + DebugLog.log("Loading Cell Recipes"+" " +(System.nanoTime()-timepreone)); + this.addCellRecipes(werkstoff); + DebugLog.log("Loading Meltdown Recipes"+" " +(System.nanoTime()-timepreone)); + this.addMoltenRecipes(werkstoff); if (Loader.isModLoaded("Thaumcraft")) { DebugLog.log("Loading Aspects"+" " +(System.nanoTime()-timepreone)); ThaumcraftHandler.AspectAdder.addAspectToAll(werkstoff); } + DebugLog.log("Loading New Circuits"+" " +(System.nanoTime()-timepreone)); + new BW_CircuitsLoader(); DebugLog.log("Done"+" " +(System.nanoTime()-timepreone)); progressBar.step(werkstoff.getDefaultName()); } @@ -583,6 +756,21 @@ public class WerkstoffLoader implements Runnable { } private void addSubTags() { + Materials.Helium.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Neon.add(WerkstoffLoader.NOBLE_GAS); + Materials.Argon.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Krypton.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Xenon.add(WerkstoffLoader.NOBLE_GAS,WerkstoffLoader.ANAEROBE_GAS); + Materials.Radon.add(WerkstoffLoader.NOBLE_GAS); + WerkstoffLoader.Oganesson.add(WerkstoffLoader.NOBLE_GAS,WerkstoffLoader.ANAEROBE_GAS); + + Materials.Nitrogen.add(WerkstoffLoader.ANAEROBE_GAS); + + WerkstoffLoader.Calcium.add(WerkstoffLoader.ANAEROBE_SMELTING); + + //Calcium Smelting block + Materials.Calcium.mBlastFurnaceRequired=true; + for (Werkstoff W : Werkstoff.werkstoffHashMap.values()) { for (Pair<ISubTagContainer, Integer> pair : W.getContents().getValue().toArray(new Pair[0])) { @@ -604,28 +792,52 @@ public class WerkstoffLoader implements Runnable { } } - public static int toGenerateGlobal = 0b0000000; + public static int toGenerateGlobal; private void addItemsForGeneration() { for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { + if ((werkstoff.getGenerationFeatures().toGenerate & 0b10000) != 0){ + if (!FluidRegistry.isFluidRegistered(werkstoff.getDefaultName())) { + DebugLog.log("Adding new Fluid: " + werkstoff.getDefaultName()); + GT_Fluid fluid = (GT_Fluid) new GT_Fluid(werkstoff.getDefaultName(), "molten.autogenerated", werkstoff.getRGBA()).setGaseous(werkstoff.getStats().isGas()); + FluidRegistry.registerFluid(fluid); + WerkstoffLoader.fluids.put(werkstoff, fluid); + } else { + WerkstoffLoader.fluids.put(werkstoff, FluidRegistry.getFluid(werkstoff.getDefaultName())); + } + } + if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000000) != 0){ + if (!FluidRegistry.isFluidRegistered("molten."+werkstoff.getDefaultName())) { + DebugLog.log("Adding new Molten: " + werkstoff.getDefaultName()); + Fluid fluid = new GT_Fluid("molten." + werkstoff.getDefaultName(), "molten.autogenerated", werkstoff.getRGBA()); + if (werkstoff.getStats().meltingPoint > 0) + fluid = fluid.setTemperature(werkstoff.getStats().meltingPoint); + FluidRegistry.registerFluid(fluid); + //GT_LanguageManager.addStringLocalization("Molten." + werkstoff.getDefaultName(), "Molten "+ werkstoff.getDefaultName()); + GT_LanguageManager.addStringLocalization(fluid.getUnlocalizedName(), "Molten "+ werkstoff.getDefaultName()); + WerkstoffLoader.molten.put(werkstoff, fluid); + } else { + WerkstoffLoader.molten.put(werkstoff, FluidRegistry.getFluid(werkstoff.getDefaultName())); + } + } for (OrePrefixes p : values()) - if ((werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 && OreDictHandler.getItemStack(werkstoff.getDefaultName(),p,1) != null) { + if (!werkstoff.getGenerationFeatures().enforceUnification && (werkstoff.getGenerationFeatures().toGenerate & p.mMaterialGenerationBits) != 0 && OreDictHandler.getItemStack(werkstoff.getDefaultName(),p,1) != null) { MainMod.LOGGER.info("Found: "+(p+werkstoff.getDefaultName().replaceAll(" ",""))+" in oreDict, disable and reroute my Items to that, also add a Tooltip."); werkstoff.getGenerationFeatures().setBlacklist(p); } - toGenerateGlobal = (toGenerateGlobal | werkstoff.getGenerationFeatures().toGenerate); + WerkstoffLoader.toGenerateGlobal = (WerkstoffLoader.toGenerateGlobal | werkstoff.getGenerationFeatures().toGenerate); //System.out.println(werkstoff.getDefaultName()+": "+werkstoff.getGenerationFeatures().toGenerate); } - - if ((toGenerateGlobal & 0b1) != 0) { + DebugLog.log("GlobalGeneration: "+WerkstoffLoader.toGenerateGlobal); + if ((WerkstoffLoader.toGenerateGlobal & 0b1) != 0) { WerkstoffLoader.items.put(dust, new BW_MetaGenerated_Items(dust)); WerkstoffLoader.items.put(dustTiny, new BW_MetaGenerated_Items(dustTiny)); WerkstoffLoader.items.put(dustSmall, new BW_MetaGenerated_Items(dustSmall)); } - if ((toGenerateGlobal & 0b10) != 0) { + if ((WerkstoffLoader.toGenerateGlobal & 0b10) != 0) { WerkstoffLoader.items.put(ingot, new BW_MetaGenerated_Items(ingot)); WerkstoffLoader.items.put(nugget, new BW_MetaGenerated_Items(nugget)); } - if ((toGenerateGlobal & 0b100) != 0) { + if ((WerkstoffLoader.toGenerateGlobal & 0b100) != 0) { WerkstoffLoader.items.put(gem, new BW_MetaGenerated_Items(gem)); WerkstoffLoader.items.put(gemChipped, new BW_MetaGenerated_Items(gemChipped)); WerkstoffLoader.items.put(gemExquisite, new BW_MetaGenerated_Items(gemExquisite)); @@ -633,29 +845,37 @@ public class WerkstoffLoader implements Runnable { WerkstoffLoader.items.put(gemFlawless, new BW_MetaGenerated_Items(gemFlawless)); WerkstoffLoader.items.put(lens,new BW_MetaGenerated_Items(lens)); } - if ((toGenerateGlobal & 0b1000) != 0) { + if ((WerkstoffLoader.toGenerateGlobal & 0b1000) != 0) { if (!ConfigHandler.experimentalThreadedLoader) - gameRegistryHandler(); + this.gameRegistryHandler(); WerkstoffLoader.items.put(crushed, new BW_MetaGenerated_Items(crushed)); WerkstoffLoader.items.put(crushedPurified, new BW_MetaGenerated_Items(crushedPurified)); WerkstoffLoader.items.put(crushedCentrifuged, new BW_MetaGenerated_Items(crushedCentrifuged)); WerkstoffLoader.items.put(dustPure, new BW_MetaGenerated_Items(dustPure)); WerkstoffLoader.items.put(dustImpure, new BW_MetaGenerated_Items(dustImpure)); } - if ((toGenerateGlobal & 0b10000) != 0) { + if ((WerkstoffLoader.toGenerateGlobal & 0b10000) != 0) { WerkstoffLoader.items.put(cell, new BW_MetaGenerated_Items(cell)); - WerkstoffLoader.items.put(bottle, new BW_MetaGenerated_Items(bottle)); - WerkstoffLoader.items.put(capsule, new BW_MetaGenerated_Items(capsule)); + //WerkstoffLoader.items.put(bottle, new BW_MetaGenerated_Items(bottle)); + //WerkstoffLoader.items.put(capsule, new BW_MetaGenerated_Items(capsule)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b100000) != 0) { + WerkstoffLoader.items.put(cellPlasma, new BW_MetaGenerated_Items(cellPlasma)); + } + if ((WerkstoffLoader.toGenerateGlobal & 0b1000000) != 0) { + WerkstoffLoader.items.put(cellMolten, new BW_MetaGenerated_Items(cellMolten)); } } + + public void gameRegistryHandler(){ if (FMLCommonHandler.instance().getSide().isClient()) RenderingRegistry.registerBlockHandler(BW_Renderer_Block_Ores.INSTANCE); GameRegistry.registerTileEntity(BW_MetaGeneratedOreTE.class, "bw.blockoresTE"); WerkstoffLoader.BWOres = new BW_MetaGenerated_Ores(Material.rock, BW_MetaGeneratedOreTE.class, "bw.blockores"); GameRegistry.registerBlock(WerkstoffLoader.BWOres, BW_MetaGeneratedOre_Item.class, "bw.blockores.01"); - runGTItemDataRegistrator(); + WerkstoffLoader.runGTItemDataRegistrator(); } public static void runGTItemDataRegistrator(){ @@ -689,7 +909,7 @@ public class WerkstoffLoader implements Runnable { OreDictAdder.addToMap(new Pair<>("craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""), werkstoff.get(lens))); } - OreDictAdder.addToMap(new Pair<>("craftingIndustrialDiamond", WerkstoffLoader.Zirconia.get(gemExquisite))); + OreDictAdder.addToMap(new Pair<>("craftingIndustrialDiamond", WerkstoffLoader.CubicZirconia.get(gemExquisite))); } else { for (Werkstoff werkstoff : Werkstoff.werkstoffHashSet) { if (werkstoff.getGenerationFeatures().hasOres()) @@ -698,7 +918,7 @@ public class WerkstoffLoader implements Runnable { OreDictionary.registerOre("craftingLens" + BW_ColorUtil.getDyeFromColor(werkstoff.getRGBA()).mName.replace(" ", ""), werkstoff.get(lens)); } - GT_OreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.Zirconia.get(gemExquisite)); + GT_OreDictUnificator.registerOre("craftingIndustrialDiamond", WerkstoffLoader.CubicZirconia.get(gemExquisite)); } } @@ -707,14 +927,14 @@ public class WerkstoffLoader implements Runnable { if (werkstoff.getGenerationFeatures().hasSifterRecipes() || ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0 && (werkstoff.getGenerationFeatures().toGenerate & 0b1) != 0)) { GT_Values.RA.addSifterRecipe( - WerkstoffLoader.getCorresopndingItemStack(crushedPurified, werkstoff), + werkstoff.get(crushedPurified), new ItemStack[]{ - WerkstoffLoader.getCorresopndingItemStack(gemExquisite, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(gemFlawless, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(gem, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(gemFlawed, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(gemChipped, werkstoff), - WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + werkstoff.get(gemExquisite), + werkstoff.get(gemFlawless), + werkstoff.get(gem), + werkstoff.get(gemFlawed), + werkstoff.get(gemChipped), + werkstoff.get(dust) }, new int[]{ 200, 1000, 2500, 2000, 4000, 5000 @@ -727,8 +947,8 @@ public class WerkstoffLoader implements Runnable { GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemExquisite), werkstoff.get(dust, 4)); GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemFlawless), werkstoff.get(dust, 2)); GT_ModHandler.addPulverisationRecipe(werkstoff.get(gem), werkstoff.get(dust)); - GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemFlawed), werkstoff.get(dustSmall, 1)); - GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemChipped), werkstoff.get(dustTiny)); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemFlawed), werkstoff.get(dustSmall, 2)); + GT_ModHandler.addPulverisationRecipe(werkstoff.get(gemChipped), werkstoff.get(dustSmall)); GT_ModHandler.addCraftingRecipe(werkstoff.get(gemFlawless, 2), 0, new Object[]{"h ", "W ", 'W', werkstoff.get(gemExquisite)}); GT_ModHandler.addCraftingRecipe(werkstoff.get(gem, 2), 0, new Object[]{"h ", "W ", 'W', werkstoff.get(gemFlawless)}); @@ -768,7 +988,6 @@ public class WerkstoffLoader implements Runnable { private void addDustRecipes(Werkstoff werkstoff) { if ((werkstoff.getGenerationFeatures().toGenerate & 0b1) != 0) { - List<FluidStack> flOutputs = new ArrayList<>(); List<ItemStack> stOutputs = new ArrayList<>(); HashMap<ISubTagContainer, Pair<Integer, Integer>> tracker = new HashMap<>(); @@ -794,6 +1013,8 @@ public class WerkstoffLoader implements Runnable { cells += container.getValue(); } } else { + if (((Materials) container.getKey()).getDust(container.getValue()) == null ) + continue; if (!tracker.containsKey(container.getKey())) { stOutputs.add(((Materials) container.getKey()).getDust(container.getValue())); tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); @@ -803,9 +1024,25 @@ public class WerkstoffLoader implements Runnable { } } } else if (container.getKey() instanceof Werkstoff) { - if (((Werkstoff) container.getKey()).getTexSet() == TextureSet.SET_FLUID) { - //not yet implemented no fluids from me... + if (((Werkstoff) container.getKey()).getStats().isGas() || ((Werkstoff) container.getKey()).getGenerationFeatures().hasCells()) { + FluidStack tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + if (tmpFl == null || tmpFl.getFluid() == null) { + tmpFl = ((Werkstoff) container.getKey()).getFluidOrGas(1000 * container.getValue()); + } + flOutputs.add(tmpFl); + if (flOutputs.size() > 1) { + if (!tracker.containsKey(container.getKey())) { + stOutputs.add(((Werkstoff) container.getKey()).get(cell, container.getValue())); + tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); + } else { + stOutputs.add(((Werkstoff) container.getKey()).get(cell, tracker.get(container.getKey()).getKey() + container.getValue())); + stOutputs.remove(tracker.get(container.getKey()).getValue() + 1); + } + cells += container.getValue(); + } } else { + if (!((Werkstoff) container.getKey()).getGenerationFeatures().hasDusts()) + continue; if (!tracker.containsKey(container.getKey())) { stOutputs.add(((Werkstoff) container.getKey()).get(dust, container.getValue())); tracker.put(container.getKey(), new Pair<>(container.getValue(), stOutputs.size() - 1)); @@ -816,7 +1053,7 @@ public class WerkstoffLoader implements Runnable { } } } - ItemStack input = WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff); + ItemStack input = werkstoff.get(dust); input.stackSize = werkstoff.getContents().getKey(); if (werkstoff.getStats().isElektrolysis()) GT_Recipe.GT_Recipe_Map.sElectrolyzerRecipes.addRecipe(true, new ItemStack[]{input, cells > 0 ? Materials.Empty.getCells(cells) : null}, stOutputs.toArray(new ItemStack[0]), null, null, new FluidStack[]{null}, new FluidStack[]{flOutputs.size() > 0 ? flOutputs.get(0) : null}, (int) Math.max(1L, Math.abs(werkstoff.getStats().protons * werkstoff.getContents().getValue().size())), Math.min(4, werkstoff.getContents().getValue().size()) * 30, 0); @@ -834,35 +1071,80 @@ public class WerkstoffLoader implements Runnable { } } - GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), new Object[]{ + GT_ModHandler.addCraftingRecipe(werkstoff.get(dust), new Object[]{ "TTT","TTT","TTT",'T', - WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff) + werkstoff.get(dustTiny) }); - GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), new Object[]{ + GT_ModHandler.addCraftingRecipe(werkstoff.get(dust), new Object[]{ "TT ","TT ",'T', - WerkstoffLoader.getCorresopndingItemStack(dustSmall, werkstoff) + WerkstoffLoader.getCorrespondingItemStack(dustSmall, werkstoff) }); - GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustSmall, werkstoff, 4), new Object[]{ - " T ", 'T', WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorrespondingItemStack(dustSmall, werkstoff, 4), new Object[]{ + " T ", 'T', werkstoff.get(dust) }); - GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff, 9), new Object[]{ - "T ", 'T', WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff) + GT_ModHandler.addCraftingRecipe(WerkstoffLoader.getCorrespondingItemStack(dustTiny, werkstoff, 9), new Object[]{ + "T ", 'T', werkstoff.get(dust) }); if ((werkstoff.getGenerationFeatures().toGenerate & 0b10) != 0 && !werkstoff.getStats().isBlastFurnace()) { - GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(dust, werkstoff), WerkstoffLoader.getCorresopndingItemStack(ingot, werkstoff)); - GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(dustTiny, werkstoff), WerkstoffLoader.getCorresopndingItemStack(nugget, werkstoff)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(dust), werkstoff.get(ingot)); + GT_ModHandler.addSmeltingRecipe(werkstoff.get(dustTiny), werkstoff.get(nugget)); + } + else if ((werkstoff.getGenerationFeatures().toGenerate & 0b10) != 0 && werkstoff.getStats().isBlastFurnace() && werkstoff.getStats().meltingPoint != 0){ + if (werkstoff.contains(WerkstoffLoader.ANAEROBE_SMELTING)){ + GT_Values.RA.addBlastRecipe(werkstoff.get(dust),GT_Utility.getIntegratedCircuit(11),Materials.Nitrogen.getGas(1000),null,werkstoff.get(ingot),null,(int) Math.max(werkstoff.getStats().getMass() / 40L, 1L) * werkstoff.getStats().meltingPoint, 120, werkstoff.getStats().getMeltingPoint()); + } + else { + GT_Values.RA.addBlastRecipe(werkstoff.get(dust), GT_Utility.getIntegratedCircuit(1), null, null, werkstoff.get(ingot), null, (int) Math.max(werkstoff.getStats().getMass() / 40L, 1L) * werkstoff.getStats().meltingPoint, 120, werkstoff.getStats().getMeltingPoint()); + if (werkstoff.getStats().meltingPoint <= 1000) { + GT_Values.RA.addPrimitiveBlastRecipe(werkstoff.get(dust), null, 9, werkstoff.get(ingot), null, (int) Math.max(werkstoff.getStats().getMass() / 40L, 1L) * werkstoff.getStats().meltingPoint); + GT_ModHandler.addRCBlastFurnaceRecipe(werkstoff.get(ingot), werkstoff.get(dust), werkstoff.getStats().meltingPoint); + } + } } if ((werkstoff.getGenerationFeatures().toGenerate & 0b10) != 0){ GT_ModHandler.addPulverisationRecipe(werkstoff.get(ingot),werkstoff.get(dust)); GT_ModHandler.addPulverisationRecipe(werkstoff.get(nugget),werkstoff.get(dustTiny)); } + + if (werkstoff.getType().equals(Werkstoff.Types.ELEMENT)) { + Materials werkstoffBridgeMaterial = null; + boolean ElementSet = false; + for (Element e : Element.values()){ + if (e.toString().equals(werkstoff.getToolTip())){ + if (e.mLinkedMaterials.size() > 0) + break; + werkstoffBridgeMaterial = new Materials(-1,werkstoff.getTexSet(),0,0,0,false,werkstoff.getDefaultName(),werkstoff.getDefaultName()); + werkstoffBridgeMaterial.mElement = e; + e.mLinkedMaterials.add(werkstoffBridgeMaterial); + ElementSet = true; + break; + } + } + if (!ElementSet) + return; + + GT_OreDictUnificator.addAssociation(dust,werkstoffBridgeMaterial, werkstoff.get(dust),true); + try { + Field f = Materials.class.getDeclaredField("MATERIALS_MAP"); + f.setAccessible(true); + Map<String, Materials> MATERIALS_MAP = (Map<String, Materials>) f.get(null); + MATERIALS_MAP.remove(werkstoffBridgeMaterial.mName); + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) { + e.printStackTrace(); + } + ItemStack scannerOutput = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(scannerOutput,"Elemental-Scan"); + Behaviour_DataOrb.setDataName(scannerOutput,werkstoff.getToolTip()); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.add(new BWRecipes.DynamicGTRecipe(false, new ItemStack[]{werkstoff.get(dust)}, new ItemStack[]{scannerOutput}, ItemList.Tool_DataOrb.get(1L), null, null, null, (int) (werkstoffBridgeMaterial.getMass()* 8192L),30,0)); + GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes.add(new BWRecipes.DynamicGTRecipe(false, null,new ItemStack[]{werkstoff.get(dust)}, scannerOutput, null, new FluidStack[]{Materials.UUMatter.getFluid(werkstoffBridgeMaterial.getMass())}, null, (int) (werkstoffBridgeMaterial.getMass() * 512L),30,0)); + } } } private void addOreRecipes(Werkstoff werkstoff) { if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0 && (werkstoff.getGenerationFeatures().toGenerate & 0b10) != 0 &&!werkstoff.getStats().isBlastFurnace()) - GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorresopndingItemStack(ore, werkstoff), WerkstoffLoader.getCorresopndingItemStack(ingot, werkstoff)); + GT_ModHandler.addSmeltingRecipe(WerkstoffLoader.getCorrespondingItemStack(ore, werkstoff), werkstoff.get(ingot)); if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000) != 0) { GT_Values.RA.addForgeHammerRecipe(werkstoff.get(ore), werkstoff.getGenerationFeatures().hasGems() ? werkstoff.get(gem) : werkstoff.get(crushed), 16, 10); @@ -934,4 +1216,67 @@ public class WerkstoffLoader implements Runnable { GT_Values.RA.addElectromagneticSeparatorRecipe(werkstoff.get(dustPure), werkstoff.get(dust), GT_OreDictUnificator.get(dustSmall, Materials.Neodymium, 1L), GT_OreDictUnificator.get(nugget, Materials.Neodymium, 1L), new int[]{10000, 4000, 2000}, 400, 24); } + private void addCellRecipes(Werkstoff werkstoff){ + if ((werkstoff.getGenerationFeatures().toGenerate & 0b10000) == 0) + return; + + //Tank "Recipe" + GT_Utility.addFluidContainerData(new FluidContainerRegistry.FluidContainerData(new FluidStack(WerkstoffLoader.fluids.get(werkstoff), 1000),werkstoff.get(cell),Materials.Empty.getCells(1))); + + GT_Values.RA.addFluidCannerRecipe(Materials.Empty.getCells(1), werkstoff.get(cell), new FluidStack(fluids.get(werkstoff),1000), GT_Values.NF); + GT_Values.RA.addFluidCannerRecipe(werkstoff.get(cell), Materials.Empty.getCells(1), GT_Values.NF, new FluidStack(fluids.get(werkstoff),1000)); + + if (werkstoff.getType().equals(Werkstoff.Types.ELEMENT)) { + Materials werkstoffBridgeMaterial = null; + boolean ElementSet = false; + for (Element e : Element.values()){ + if (e.toString().equals(werkstoff.getToolTip())){ + werkstoffBridgeMaterial = new Materials(-1,werkstoff.getTexSet(),0,0,0,false,werkstoff.getDefaultName(),werkstoff.getDefaultName()); + werkstoffBridgeMaterial.mElement = e; + e.mLinkedMaterials.add(werkstoffBridgeMaterial); + ElementSet = true; + break; + } + } + if (!ElementSet) + return; + + GT_OreDictUnificator.addAssociation(cell,werkstoffBridgeMaterial, werkstoff.get(cell),true); + try { + Field f = Materials.class.getDeclaredField("MATERIALS_MAP"); + f.setAccessible(true); + Map<String, Materials> MATERIALS_MAP = (Map<String, Materials>) f.get(null); + MATERIALS_MAP.remove(werkstoffBridgeMaterial.mName); + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) { + e.printStackTrace(); + } + ItemStack scannerOutput = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(scannerOutput,"Elemental-Scan"); + Behaviour_DataOrb.setDataName(scannerOutput,werkstoff.getToolTip()); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.add(new BWRecipes.DynamicGTRecipe(false, new ItemStack[]{werkstoff.get(cell)}, new ItemStack[]{scannerOutput}, ItemList.Tool_DataOrb.get(1L), null, null, null, (int) (werkstoffBridgeMaterial.getMass()* 8192L),30,0)); + GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes.add(new BWRecipes.DynamicGTRecipe(false,new ItemStack[]{Materials.Empty.getCells(1)} ,new ItemStack[]{werkstoff.get(cell)}, scannerOutput, null, new FluidStack[]{Materials.UUMatter.getFluid(werkstoffBridgeMaterial.getMass())}, null, (int) (werkstoffBridgeMaterial.getMass() * 512L),30,0)); + } + } + private void addMoltenRecipes(Werkstoff werkstoff) { + if ((werkstoff.getGenerationFeatures().toGenerate & 0b1000000) == 0) + return; + + //Tank "Recipe" + FluidContainerRegistry.FluidContainerData data = new FluidContainerRegistry.FluidContainerData(new FluidStack(WerkstoffLoader.molten.get(werkstoff), 144),werkstoff.get(cellMolten),Materials.Empty.getCells(1)); + GT_Utility.addFluidContainerData(data); + GT_Values.RA.addFluidCannerRecipe(Materials.Empty.getCells(1), werkstoff.get(cellMolten), new FluidStack(molten.get(werkstoff),144), GT_Values.NF); + GT_Values.RA.addFluidCannerRecipe(werkstoff.get(cellMolten), Materials.Empty.getCells(1), GT_Values.NF, new FluidStack(molten.get(werkstoff),144)); + + if ((werkstoff.getGenerationFeatures().toGenerate & 0b10) != 0) { + GT_Values.RA.addFluidExtractionRecipe(werkstoff.get(ingot),null,werkstoff.getMolten(144),0,werkstoff.getStats().getMass() > 128 ? 64 : 30, (int) werkstoff.getStats().mass); + //GT_Values.RA.addFluidExtractionRecipe(werkstoff.get(stickLong),null,werkstoff.getMolten(144),0,werkstoff.getStats().getMass() > 128 ? 64 : 30, (int) werkstoff.getStats().mass); + //GT_Values.RA.addFluidExtractionRecipe(werkstoff.get(plate),null,werkstoff.getMolten(144),0,werkstoff.getStats().getMass() > 128 ? 64 : 30, (int) werkstoff.getStats().mass); + //GT_Values.RA.addFluidExtractionRecipe(werkstoff.get(stick),null,werkstoff.getMolten(72),0,werkstoff.getStats().getMass() > 128 ? 64 : 30, (int) werkstoff.getStats().mass); + GT_Values.RA.addFluidExtractionRecipe(werkstoff.get(nugget),null,werkstoff.getMolten(16),0,werkstoff.getStats().getMass() > 128 ? 64 : 30, (int) werkstoff.getStats().mass); + + GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Ingot.get(0), werkstoff.getMolten(144), werkstoff.get(ingot), werkstoff.getStats().getMass() > 128 ? 64 : 30, (int) werkstoff.getStats().mass); + //GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Block.get(0), werkstoff.getMolten(144), werkstoff.get(block), werkstoff.getStats().getMass() > 128 ? 64 : 30, (int) werkstoff.getStats().mass); + GT_Values.RA.addFluidSolidifierRecipe(ItemList.Shape_Mold_Nugget.get(0), werkstoff.getMolten(16), werkstoff.get(nugget), werkstoff.getStats().getMass() > 128 ? 64 : 30, (int) werkstoff.getStats().mass); + } + } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java index a6345c8736..0acd99df2d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/AdditionalRecipes.java @@ -23,29 +23,31 @@ package com.github.bartimaeusnek.bartworks.system.material.processingLoaders; import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry; +import com.github.bartimaeusnek.bartworks.system.material.CircuitGeneration.BW_Meta_Items; +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.BWRecipes; import com.github.bartimaeusnek.bartworks.util.BW_Util; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.ItemList; -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.*; 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.minecraftforge.fluids.FluidStack; +import java.lang.reflect.Field; +import java.util.Map; + +import static com.github.bartimaeusnek.bartworks.util.BW_Util.CLEANROOM; import static gregtech.api.enums.OrePrefixes.*; public class AdditionalRecipes implements Runnable { @Override public void run() { - //Cubic Circonia - GT_Values.RA.addChemicalRecipe(Materials.Yttrium.getDust(2), GT_Utility.getIntegratedCircuit(11),Materials.Oxygen.getGas(3000),null, WerkstoffLoader.YttriumOxide.get(dust,5),64, BW_Util.getMachineVoltageFromTier(4)); - GT_Recipe.GT_Recipe_Map.sBlastRecipes.addRecipe(false, new ItemStack[]{WerkstoffLoader.Zirconium.get(dust,10), WerkstoffLoader.YttriumOxide.get(dust)}, new ItemStack[]{WerkstoffLoader.YttriumOxide.get(dust), WerkstoffLoader.Zirconia.get(gemFlawed, 40)}, (Object) null, (int[]) null, new FluidStack[]{Materials.Oxygen.getGas(20000)}, null, 14400, BW_Util.getMachineVoltageFromTier(4), 2953); //Thorium/Yttrium Glas - GT_Values.RA.addBlastRecipe(WerkstoffLoader.YttriumOxide.get(dustSmall,2),WerkstoffLoader.Thorianit.get(dustSmall,2),Materials.Glass.getMolten(144),null,new ItemStack(ItemRegistry.bw_glasses[0],1,12),null,800,BW_Util.getMachineVoltageFromTier(5),3663); + GT_Values.RA.addBlastRecipe(WerkstoffLoader.YttriumOxide.get(dustSmall,2),WerkstoffLoader.Thorianit.get(dustSmall,2),Materials.Glass.getMolten(144),null,new ItemStack(ItemRegistry.bw_glasses[0],1,12),null,800, BW_Util.getMachineVoltageFromTier(5),3663); //Thorianit recipes GT_Values.RA.addSifterRecipe(WerkstoffLoader.Thorianit.get(crushedPurified), new ItemStack[]{ @@ -62,7 +64,88 @@ public class AdditionalRecipes implements Runnable { GT_Values.RA.addChemicalRecipe(WerkstoffLoader.Thorianit.get(dust),Materials.Aluminium.getDust(1),Materials.Thorium.getDust(1),1000); GT_Values.RA.addChemicalRecipe(WerkstoffLoader.Thorianit.get(dust),Materials.Magnesium.getDust(1),Materials.Thorium.getDust(1),1000); GT_Values.RA.addChemicalRecipe(WerkstoffLoader.Thorianit.get(crushed), ItemList.Crop_Drop_Thorium.get(9),Materials.Water.getFluid(1000),Materials.Thorium.getMolten(144),WerkstoffLoader.Thorianit.get(crushedPurified,4),96,24); + + //Prasiolite + GT_Values.RA.addBlastRecipe(GT_OreDictUnificator.get(dust,Materials.Quartzite,40L),Materials.Amethyst.getDust(10),GT_Values.NF,GT_Values.NF,WerkstoffLoader.Prasiolite.get(OrePrefixes.gemFlawed,20),GT_Values.NI,800, BW_Util.getMachineVoltageFromTier(2),500); + GT_Values.RA.addPrimitiveBlastRecipe(GT_OreDictUnificator.get(dust,Materials.Quartzite,40L),Materials.Amethyst.getDust(10),6,WerkstoffLoader.Prasiolite.get(OrePrefixes.gemFlawed,20),GT_Values.NI,800); + //Cubic Circonia + GT_Values.RA.addChemicalRecipe(Materials.Yttrium.getDust(2), GT_Utility.getIntegratedCircuit(11),Materials.Oxygen.getGas(3000),null, WerkstoffLoader.YttriumOxide.get(dust,5),64, BW_Util.getMachineVoltageFromTier(4)); + GT_Recipe.GT_Recipe_Map.sBlastRecipes.addRecipe(false, new ItemStack[]{WerkstoffLoader.Zirconium.get(dust,10), WerkstoffLoader.YttriumOxide.get(dust)}, new ItemStack[]{WerkstoffLoader.YttriumOxide.get(dust), WerkstoffLoader.CubicZirconia.get(gemFlawed, 40)}, null, null, new FluidStack[]{Materials.Oxygen.getGas(20000)}, null, 14400, BW_Util.getMachineVoltageFromTier(4), 2953); //Tellurium - GT_Values.RA.addBlastRecipe(GT_OreDictUnificator.get(crushed,Materials.Lead,10L),GT_Utility.getIntegratedCircuit(17),GT_Values.NF,GT_Values.NF,Materials.Lead.getIngots(10),Materials.Tellurium.getNuggets(20),800,BW_Util.getMachineVoltageFromTier(2),722); - } + GT_Values.RA.addBlastRecipe(GT_OreDictUnificator.get(crushed,Materials.Lead,10L),GT_Utility.getIntegratedCircuit(17),GT_Values.NF,GT_Values.NF,Materials.Lead.getIngots(10),Materials.Tellurium.getNuggets(20),800, BW_Util.getMachineVoltageFromTier(2),722); + GT_Values.RA.addFusionReactorRecipe(Materials.Plutonium.getMolten(16), Materials.Beryllium.getMolten(16), WerkstoffLoader.Californium.getMolten(16), 250,49152, 480000000); + GT_Values.RA.addFusionReactorRecipe(WerkstoffLoader.Californium.getMolten(16), WerkstoffLoader.Calcium.getMolten(16), WerkstoffLoader.Oganesson.getFluidOrGas(16), 500,49152, 600000000); + GT_Values.RA.addDistillationTowerRecipe(Materials.LiquidAir.getFluid(100000000),new FluidStack[]{Materials.Nitrogen.getGas(78084000),Materials.Oxygen.getGas(20946000),Materials.Argon.getGas(934000),Materials.CarbonDioxide.getGas(40700),WerkstoffLoader.Neon.getFluidOrGas(1818),Materials.Helium.getGas(524),Materials.Methane.getGas(180),WerkstoffLoader.Krypton.getFluidOrGas(114),Materials.Hydrogen.getGas(55),WerkstoffLoader.Xenon.getFluidOrGas(9)},null,7500, BW_Util.getMachineVoltageFromTier(4)); + GT_Values.RA.addAutoclaveRecipe(WerkstoffLoader.MagnetoResonaticDust.get(dust),WerkstoffLoader.Neon.getFluidOrGas(1000),WerkstoffLoader.MagnetoResonaticDust.get(gemChipped,9),9000,4500, BW_Util.getMachineVoltageFromTier(5)); + GT_Values.RA.addAutoclaveRecipe(WerkstoffLoader.MagnetoResonaticDust.get(dust),WerkstoffLoader.Krypton.getFluidOrGas(1000),WerkstoffLoader.MagnetoResonaticDust.get(gem),10000,4500, BW_Util.getMachineVoltageFromTier(5)); + + + for (int i = 0; i <= 6; i++) { + GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.add( + new BWRecipes.DynamicGTRecipe(false, + new ItemStack[]{ + BW_Meta_Items.getNEWCIRCUITS().getStack(3), + WerkstoffLoader.MagnetoResonaticDust.get(gem), + BW_Meta_Items.getNEWCIRCUITS().getStack(i+3), + ItemList.Circuit_Parts_DiodeSMD.get((i+1)*4), + ItemList.Circuit_Parts_CapacitorSMD.get((i+1)*4), + ItemList.Circuit_Parts_TransistorSMD.get((i+1)*4) + }, + new ItemStack[]{ + BW_Meta_Items.getNEWCIRCUITS().getStack(i+4) + },null,null, + new FluidStack[]{ + Materials.SolderingAlloy.getMolten((i+1)*36) + },null,(i+1)*750, BW_Util.getMachineVoltageFromTier((i+1)),CLEANROOM)); + } + for (int i = 7; i <= 10; i++) { + GT_Recipe.GT_Recipe_Map.sCircuitAssemblerRecipes.add( + new BWRecipes.DynamicGTRecipe(false, + new ItemStack[]{ + BW_Meta_Items.getNEWCIRCUITS().getStack(3), + WerkstoffLoader.MagnetoResonaticDust.get(gemExquisite,(2)), + BW_Meta_Items.getNEWCIRCUITS().getStack(i+3), + ItemList.Circuit_Parts_DiodeSMD.get((i+6)*4), + ItemList.Circuit_Parts_CapacitorSMD.get((i+6)*4), + ItemList.Circuit_Parts_TransistorSMD.get((i+6)*4) + }, + new ItemStack[]{ + BW_Meta_Items.getNEWCIRCUITS().getStack(i+4) + },null,null, + new FluidStack[]{ + Materials.SolderingAlloy.getMolten((i+1)*144) + },null,(i+1)*1500, BW_Util.getMachineVoltageFromTier(i+1),CLEANROOM)); + } + + //manual override for older GT + Werkstoff werkstoff = WerkstoffLoader.Oganesson; + Materials werkstoffBridgeMaterial = null; + boolean aElementSet = false; + for (Element e : Element.values()){ + if (e.toString().equals("Uuo")){ + werkstoffBridgeMaterial = new Materials(-1,werkstoff.getTexSet(),0,0,0,false,werkstoff.getDefaultName(),werkstoff.getDefaultName()); + werkstoffBridgeMaterial.mElement = e; + e.mLinkedMaterials.add(werkstoffBridgeMaterial); + aElementSet = true; + break; + } + } + if (!aElementSet) + return; + + GT_OreDictUnificator.addAssociation(cell,werkstoffBridgeMaterial, werkstoff.get(cell),true); + try { + Field f = Materials.class.getDeclaredField("MATERIALS_MAP"); + f.setAccessible(true); + Map<String, Materials> MATERIALS_MAP = (Map<String, Materials>) f.get(null); + MATERIALS_MAP.remove(werkstoffBridgeMaterial.mName); + } catch (NoSuchFieldException | IllegalAccessException | ClassCastException e) { + e.printStackTrace(); + } + ItemStack scannerOutput = ItemList.Tool_DataOrb.get(1L); + Behaviour_DataOrb.setDataTitle(scannerOutput,"Elemental-Scan"); + Behaviour_DataOrb.setDataName(scannerOutput, werkstoff.getToolTip()); + GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes.add(new BWRecipes.DynamicGTRecipe(false, new ItemStack[]{werkstoff.get(cell)}, new ItemStack[]{scannerOutput}, ItemList.Tool_DataOrb.get(1L), null, null, null, (int) (werkstoffBridgeMaterial.getMass()* 8192L),30,0)); + GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes.add(new BWRecipes.DynamicGTRecipe(false,new ItemStack[]{Materials.Empty.getCells(1)} ,new ItemStack[]{werkstoff.get(cell)}, scannerOutput, null, new FluidStack[]{Materials.UUMatter.getFluid(werkstoffBridgeMaterial.getMass())}, null, (int) (werkstoffBridgeMaterial.getMass() * 512L),30,0)); + } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java new file mode 100644 index 0000000000..1ed1cb0b83 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/processingLoaders/DownTierLoader.java @@ -0,0 +1,51 @@ +/* + * 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.system.material.processingLoaders; + +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import gregtech.api.util.GT_Recipe; + +import java.util.HashSet; +import java.util.Set; + +public class DownTierLoader implements Runnable { + @Override + public void run() { + for (GT_Recipe.GT_Recipe_Map map : GT_Recipe.GT_Recipe_Map.sMappings) { + if (map == GT_Recipe.GT_Recipe_Map.sScannerFakeRecipes || map == GT_Recipe.GT_Recipe_Map.sReplicatorFakeRecipes || map == GT_Recipe.GT_Recipe_Map.sMassFabFakeRecipes || map == GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes || map == GT_Recipe.GT_Recipe_Map.sFusionRecipes || map == GT_Recipe.GT_Recipe_Map.sRockBreakerFakeRecipes) + return; + Set<GT_Recipe> newRecipes = new HashSet<>(); + Set<GT_Recipe> toRem = new HashSet<>(); + for (GT_Recipe recipe : map.mRecipeList) { + if (recipe == null) + continue; + if (recipe.mEUt > 128) { + toRem.add(recipe); + newRecipes.add(BW_Util.copyAndSetTierToNewRecipe(recipe, (byte) 2)); + } + } + map.mRecipeList.removeAll(toRem); + map.mRecipeList.addAll(newRecipes); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictAdder.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictAdder.java index 25e3598df0..61a1d33d08 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictAdder.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictAdder.java @@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap; public class OreDictAdder { - private static ConcurrentHashMap<String, ItemStack> toAddMap = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap<String, ItemStack> toAddMap = new ConcurrentHashMap<>(); public static synchronized void addToMap(Pair<String, ItemStack> element){ OreDictAdder.toAddMap.put(element.getKey(),element.getValue()); @@ -43,7 +43,7 @@ public class OreDictAdder { } public static void addToOreDict(){ - for (Map.Entry<String, ItemStack> entry: toAddMap.entrySet()){ + for (Map.Entry<String, ItemStack> entry: OreDictAdder.toAddMap.entrySet()){ GT_OreDictUnificator.registerOre(entry.getKey(),entry.getValue()); } } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java index 77578b3c1c..6bc3627e7c 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oredict/OreDictHandler.java @@ -50,14 +50,14 @@ public class OreDictHandler { } public static void adaptCacheForWorld(){ - Set<String> used = new HashSet<>(cache.keySet()); + Set<String> used = new HashSet<>(OreDictHandler.cache.keySet()); OreDictHandler.cache.clear(); OreDictHandler.cacheNonBW.clear(); for (String s : used) { if (!OreDictionary.getOres(s).isEmpty()) { ItemStack tmpstack = OreDictionary.getOres(s).get(0).copy(); Pair<Integer, Short> p = new Pair<>(Item.getIdFromItem(tmpstack.getItem()), (short) tmpstack.getItemDamage()); - cache.put(s, p); + OreDictHandler.cache.put(s, p); for (ItemStack tmp : OreDictionary.getOres(s)) { Pair<Integer, Short> p2 = new Pair<>(Item.getIdFromItem(tmp.getItem()), (short) tmp.getItemDamage()); GameRegistry.UniqueIdentifier UI = GameRegistry.findUniqueIdentifierFor(tmp.getItem()); @@ -72,12 +72,12 @@ public class OreDictHandler { } public static ItemStack getItemStack(String elementName, OrePrefixes prefixes, int amount){ - if (cache.get(prefixes+elementName.replaceAll(" ","")) != null){ - Pair<Integer,Short> p = cache.get(prefixes+elementName.replaceAll(" ","")); + if (OreDictHandler.cache.get(prefixes+elementName.replaceAll(" ","")) != null){ + Pair<Integer,Short> p = OreDictHandler.cache.get(prefixes+elementName.replaceAll(" ","")); return new ItemStack(Item.getItemById(p.getKey()),amount,p.getValue()); } else if (!OreDictionary.getOres(prefixes+elementName.replaceAll(" ","")).isEmpty()){ ItemStack tmp = OreDictionary.getOres(prefixes+elementName.replaceAll(" ","")).get(0).copy(); - cache.put(prefixes+elementName.replaceAll(" ",""),new Pair<>(Item.getIdFromItem(tmp.getItem()), (short) tmp.getItemDamage())); + OreDictHandler.cache.put(prefixes+elementName.replaceAll(" ",""),new Pair<>(Item.getIdFromItem(tmp.getItem()), (short) tmp.getItemDamage())); tmp.stackSize=amount; return tmp; } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java index 7442a9a769..1dc9e080c4 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/oregen/BW_WorldGenRoss128b.java @@ -23,8 +23,6 @@ package com.github.bartimaeusnek.bartworks.system.oregen; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; -import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; -import gregtech.api.enums.Materials; import gregtech.api.interfaces.ISubTagContainer; import net.minecraft.block.Block; import net.minecraft.init.Blocks; @@ -32,9 +30,9 @@ import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; +import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.*; import static com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy.uo_dimensionList; import static gregtech.api.enums.Materials.*; -import static com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader.*; public class BW_WorldGenRoss128b extends BW_OreLayer { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java index 8254b44815..39a1ffa5bb 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/GT_WorldgenUtil.java @@ -31,9 +31,9 @@ public class GT_WorldgenUtil { private GT_WorldgenUtil() {} - public final static Block GT_TILES = GregTech_API.sBlockMachines; + public static final Block GT_TILES = GregTech_API.sBlockMachines; - public final static short[][] METAFORTIERS_ENERGY = { + public static final short[][] METAFORTIERS_ENERGY = { {100,101,102,105}, //ULV=HPSteam {1110,1115,1120,1127}, {1111,12726,1116,1121,1128}, @@ -41,7 +41,7 @@ public class GT_WorldgenUtil { {12728,1190,1130,12685}, {1191,1174,695,12686}, }; - public final static short[][] METAFORTIERS_BUFFER = { + public static final short[][] METAFORTIERS_BUFFER = { {5133,5123}, //ULV=HPSteam {161,171,181,191}, {162,172,182,192}, @@ -50,7 +50,7 @@ public class GT_WorldgenUtil { {165,175,185,195}, }; //ULV=HPSteam - public final static short[][] METAFORTIERS_CABLE = { + public static final short[][] METAFORTIERS_CABLE = { {5133,5123}, //ULV=HPSteam {1210,1230,1250,1270,1290}, {1310,1330,1350,1370,1390}, @@ -58,7 +58,7 @@ public class GT_WorldgenUtil { {1510,1530,1550,1570,1590}, {1650,1670,1690}, }; - public final static short[][] METAFORTIERS_MACHINE = { + public static final short[][] METAFORTIERS_MACHINE = { {103,104,106,107,109,110,112,113,115,116,118,119}, //ULV=HPSteam {201,211,221,231,241,251,261,271,281,291,301,311,321,331,341,351,361,371,381,391,401,411,421,431,441,451,461,471,481,491,501,511,521,531,541,551,561,571,581,591,601,611,621,631,641,651,661,671}, {}, @@ -67,39 +67,39 @@ public class GT_WorldgenUtil { {}, }; - private static boolean initialisized = false; + private static boolean initialisized; private static void init(){ for (int j = 1; j < 5; j++) { - METAFORTIERS_MACHINE[j+1]=new short[METAFORTIERS_MACHINE[1].length]; - for (int i = 0; i < METAFORTIERS_MACHINE[1].length; i++) { - METAFORTIERS_MACHINE[j+1][i]= (short) (METAFORTIERS_MACHINE[1][i]+j); + GT_WorldgenUtil.METAFORTIERS_MACHINE[j+1]=new short[GT_WorldgenUtil.METAFORTIERS_MACHINE[1].length]; + for (int i = 0; i < GT_WorldgenUtil.METAFORTIERS_MACHINE[1].length; i++) { + GT_WorldgenUtil.METAFORTIERS_MACHINE[j+1][i]= (short) (GT_WorldgenUtil.METAFORTIERS_MACHINE[1][i]+j); } } - initialisized=true; + GT_WorldgenUtil.initialisized =true; } public static short getGenerator(Random rand,int tier){ - short meta = METAFORTIERS_ENERGY[tier][rand.nextInt(METAFORTIERS_ENERGY[tier].length)]; - return GregTech_API.METATILEENTITIES[meta] != null ? meta : getGenerator(rand,tier); + short meta = GT_WorldgenUtil.METAFORTIERS_ENERGY[tier][rand.nextInt(GT_WorldgenUtil.METAFORTIERS_ENERGY[tier].length)]; + return GregTech_API.METATILEENTITIES[meta] != null ? meta : GT_WorldgenUtil.getGenerator(rand,tier); } public static short getBuffer(Random rand,int tier){ - short meta = METAFORTIERS_BUFFER[tier][rand.nextInt(METAFORTIERS_BUFFER[tier].length)]; - return GregTech_API.METATILEENTITIES[meta] != null ? meta : getBuffer(rand,tier); + short meta = GT_WorldgenUtil.METAFORTIERS_BUFFER[tier][rand.nextInt(GT_WorldgenUtil.METAFORTIERS_BUFFER[tier].length)]; + return GregTech_API.METATILEENTITIES[meta] != null ? meta : GT_WorldgenUtil.getBuffer(rand,tier); } public static short getCable(Random rand,int tier){ - short meta = METAFORTIERS_CABLE[tier][rand.nextInt(METAFORTIERS_CABLE[tier].length)]; - return GregTech_API.METATILEENTITIES[meta] != null ? meta : getCable(rand,tier); + short meta = GT_WorldgenUtil.METAFORTIERS_CABLE[tier][rand.nextInt(GT_WorldgenUtil.METAFORTIERS_CABLE[tier].length)]; + return GregTech_API.METATILEENTITIES[meta] != null ? meta : GT_WorldgenUtil.getCable(rand,tier); } public static short getMachine(Random rand,int tier){ - if (!initialisized) - init(); - short meta = METAFORTIERS_MACHINE[tier][rand.nextInt(METAFORTIERS_MACHINE[tier].length)]; - return GregTech_API.METATILEENTITIES[meta] != null ? meta : getMachine(rand,tier); + if (!GT_WorldgenUtil.initialisized) + GT_WorldgenUtil.init(); + short meta = GT_WorldgenUtil.METAFORTIERS_MACHINE[tier][rand.nextInt(GT_WorldgenUtil.METAFORTIERS_MACHINE[tier].length)]; + return GregTech_API.METATILEENTITIES[meta] != null ? meta : GT_WorldgenUtil.getMachine(rand,tier); } diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java index 841fe49b12..8c5db993b3 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/worldgen/MapGenRuins.java @@ -32,19 +32,14 @@ import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.inventory.IInventory; -import net.minecraft.tileentity.TileEntityChest; import net.minecraft.util.WeightedRandomChestContent; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; import net.minecraftforge.common.ChestGenHooks; -import net.minecraftforge.common.ForgeHooks; -import java.nio.ByteBuffer; import java.security.SecureRandom; import java.util.Random; -import static net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST; -import static net.minecraftforge.common.ChestGenHooks.PYRAMID_DESERT_CHEST; import static net.minecraftforge.common.ChestGenHooks.PYRAMID_JUNGLE_CHEST; public abstract class MapGenRuins extends WorldGenerator { @@ -57,30 +52,30 @@ public abstract class MapGenRuins extends WorldGenerator { } protected void setFloorBlocks(int[] metas, Block... blocks){ - ToBuildWith[0]=new Pair[metas.length]; + this.ToBuildWith[0]=new Pair[metas.length]; for (int i = 0; i < metas.length; i++) { - ToBuildWith[0][i]=new Pair<>(blocks[i%blocks.length],metas[i]); + this.ToBuildWith[0][i]=new Pair<>(blocks[i%blocks.length],metas[i]); } } protected void setWallBlocks(int[] metas,Block... blocks){ - ToBuildWith[1]=new Pair[metas.length]; + this.ToBuildWith[1]=new Pair[metas.length]; for (int i = 0; i < metas.length; i++) { - ToBuildWith[1][i]=new Pair<>(blocks[i%blocks.length],metas[i]); + this.ToBuildWith[1][i]=new Pair<>(blocks[i%blocks.length],metas[i]); } } protected void setRoofBlocks(int[] metas,Block... blocks){ - ToBuildWith[2]=new Pair[metas.length]; + this.ToBuildWith[2]=new Pair[metas.length]; for (int i = 0; i < metas.length; i++) { - ToBuildWith[2][i]=new Pair<>(blocks[i%blocks.length],metas[i]); + this.ToBuildWith[2][i]=new Pair<>(blocks[i%blocks.length],metas[i]); } } protected void setMiscBlocks(int[] metas,Block... blocks){ - ToBuildWith[3]=new Pair[metas.length]; + this.ToBuildWith[3]=new Pair[metas.length]; for (int i = 0; i < metas.length; i++) { - ToBuildWith[3][i]=new Pair<>(blocks[i%blocks.length],metas[i]); + this.ToBuildWith[3][i]=new Pair<>(blocks[i%blocks.length],metas[i]); } } @@ -88,9 +83,9 @@ public abstract class MapGenRuins extends WorldGenerator { protected void setRandomBlockWAirChance(World worldObj, int x, int y, int z, Random rand, int airchance, Pair<Block,Integer>... blocks){ if (rand.nextInt(100) > airchance) - setRandomBlock(worldObj,x,y,z,rand,blocks); + this.setRandomBlock(worldObj,x,y,z,rand,blocks); else - setBlock(worldObj,x,y,z,Blocks.air,0); + this.setBlock(worldObj,x,y,z,Blocks.air,0); } protected void setRandomBlock(World worldObj, int x, int y, int z, Random rand, Pair<Block,Integer>... blocks){ @@ -132,11 +127,11 @@ public abstract class MapGenRuins extends WorldGenerator { y--; } - setFloorBlocks(new int[]{0,0,0},Blocks.brick_block,Blocks.double_stone_slab,Blocks.stonebrick); - setWallBlocks(new int[]{0,1,2,1,1},Blocks.stonebrick); - setRoofBlocks(new int[]{9},Blocks.log); - setMiscBlocks(new int[]{1},Blocks.log); - statBlocks= new int[]{rand.nextInt(ToBuildWith[0].length)}; + this.setFloorBlocks(new int[]{0,0,0},Blocks.brick_block,Blocks.double_stone_slab,Blocks.stonebrick); + this.setWallBlocks(new int[]{0,1,2,1,1},Blocks.stonebrick); + this.setRoofBlocks(new int[]{9},Blocks.log); + this.setMiscBlocks(new int[]{1},Blocks.log); + this.statBlocks = new int[]{rand.nextInt(this.ToBuildWith[0].length)}; int colored=rand.nextInt(15); int tier = rand.nextInt(6); boolean useColor = rand.nextBoolean(); @@ -150,40 +145,40 @@ public abstract class MapGenRuins extends WorldGenerator { for (int dz = -6; dz <= 6; dz++) { this.setBlock(worldObj,x+dx,y+dy,z+dz,Blocks.air,0); if (dy == 0){ - Pair<Block,Integer> floor = ToBuildWith[0][statBlocks[0]]; - this.setBlock(worldObj,x+dx,y+dy,z+dz, floor.getKey(),floor.getValue()); + Pair<Block,Integer> floor = this.ToBuildWith[0][this.statBlocks[0]]; + this.setBlock(worldObj,x+dx,y+ 0,z+dz, floor.getKey(),floor.getValue()); } else if (dy > 0 && dy < 4){ if (Math.abs(dx) == 5 && Math.abs(dz) == 5){ - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,5, ToBuildWith[3][0]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,5, this.ToBuildWith[3][0]); } else if ((dx == 0) && dz == -5 && (dy == 1 || dy == 2)){ if (dy == 1) - this.setBlock(worldObj,x+dx,y+dy,z+dz, Blocks.iron_door,1); + this.setBlock(worldObj,x+dx,y+ 1,z+ -5, Blocks.iron_door,1); if (dy == 2) - this.setBlock(worldObj,x+dx,y+dy,z+dz, Blocks.iron_door,8); + this.setBlock(worldObj,x+dx,y+ 2,z+dz, Blocks.iron_door,8); } else if (Math.abs(dx)== 5 && Math.abs(dz) < 5 || Math.abs(dz)== 5 && Math.abs(dx) < 5){ - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[1]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25, this.ToBuildWith[1]); if (dy == 2) { if (rand.nextInt(100)<12) if (useColor) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,new Pair<>(Blocks.stained_glass_pane,colored)); + this.setRandomBlockWAirChance(worldObj,x+dx,y+ 2,z+dz,rand,25,new Pair<>(Blocks.stained_glass_pane,colored)); else - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,new Pair<>(Blocks.glass_pane,0)); + this.setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,new Pair<>(Blocks.glass_pane,0)); } } if (dy == 3 && Math.abs(dx)== 6){ - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[2]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+ 3,z+dz,rand,25, this.ToBuildWith[2]); } if (dy == 1){ if (dx == 3 && dz == -3){ - setBlock(worldObj,x + dx, y + dy, z + dz,Blocks.crafting_table,0); + this.setBlock(worldObj,x + 3, y + 1, z + dz,Blocks.crafting_table,0); } if (dx == -3 && (dz == -3 || dz == -2)){ - setBlock(worldObj,x + dx, y + dy, z + dz,Blocks.chest,5); + this.setBlock(worldObj,x + -3, y + dy, z + dz,Blocks.chest,5); IInventory chest = (IInventory)worldObj.getTileEntity(x + dx, y + dy, z + dz); if (chest != null) { WeightedRandomChestContent.generateChestContents(secureRandom, ChestGenHooks.getItems(PYRAMID_JUNGLE_CHEST, rand), chest, ChestGenHooks.getCount(PYRAMID_JUNGLE_CHEST, rand)); @@ -192,7 +187,7 @@ public abstract class MapGenRuins extends WorldGenerator { if (dx == 4 && dz==4) { short meta = GT_WorldgenUtil.getGenerator(secureRandom,tier); - setBlock(worldObj, x + dx, y + dy, z + dz, GT_WorldgenUtil.GT_TILES,GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); + this.setBlock(worldObj, x + 4, y + dy, z + dz, GT_WorldgenUtil.GT_TILES,GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); BaseMetaTileEntity BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x + dx, y + dy, z + dz); BTE.setInitialValuesAsNBT(null,meta); BTE.setOwnerName("Ancient Cultures"); @@ -202,28 +197,28 @@ public abstract class MapGenRuins extends WorldGenerator { else if (dx == 3 && dz==4) { if (tier>0) { short meta = GT_WorldgenUtil.getBuffer(secureRandom, tier); - setBlock(worldObj, x + dx, y + dy, z + dz, GT_WorldgenUtil.GT_TILES, GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); + this.setBlock(worldObj, x + 3, y + dy, z + dz, GT_WorldgenUtil.GT_TILES, GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); BaseMetaTileEntity BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x + dx, y + dy, z + dz); BTE.setInitialValuesAsNBT(null, meta); BTE.setOwnerName("Ancient Cultures"); BTE.setFrontFacing((byte) 4); }else{ short meta = cablemeta; - setRandomBlockWAirChance(worldObj, x + dx, y + dy, z + dz, rand, 33, new Pair<Block, Integer>(GT_WorldgenUtil.GT_TILES, (int) GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType())); + this.setRandomBlockWAirChance(worldObj, x + dx, y + dy, z + dz, rand, 33, new Pair<Block, Integer>(GT_WorldgenUtil.GT_TILES, (int) GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType())); BaseMetaPipeEntity BTE = (BaseMetaPipeEntity) worldObj.getTileEntity(x + dx, y + dy, z + dz); if (BTE != null) { BTE.setInitialValuesAsNBT(null, meta); BTE.setOwnerName("Ancient Cultures"); BTE.setFrontFacing((byte) 4); BTE.mConnections = (byte) (BTE.mConnections | 1 << (byte) 4); - BTE.mConnections = (byte) (BTE.mConnections | 1 << (byte) GT_Utility.getOppositeSide(4)); + BTE.mConnections = (byte) (BTE.mConnections | 1 << GT_Utility.getOppositeSide(4)); ((MetaPipeEntity) BTE.getMetaTileEntity()).mConnections = BTE.mConnections; } } } else if (dx < 3 && dx > -5 && dz == 4) { short meta = cablemeta; - setRandomBlockWAirChance(worldObj, x + dx, y + dy, z + dz, rand, 33, new Pair<Block, Integer>(GT_WorldgenUtil.GT_TILES, (int) GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType())); + this.setRandomBlockWAirChance(worldObj, x + dx, y + dy, z + 4, rand, 33, new Pair<Block, Integer>(GT_WorldgenUtil.GT_TILES, (int) GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType())); BaseMetaPipeEntity BTE = (BaseMetaPipeEntity) worldObj.getTileEntity(x + dx, y + dy, z + dz); if (BTE != null) { @@ -231,7 +226,7 @@ public abstract class MapGenRuins extends WorldGenerator { BTE.setOwnerName("Ancient Cultures"); BTE.setFrontFacing((byte) 4); BTE.mConnections = (byte)(BTE.mConnections | 1 << (byte)4); - BTE.mConnections = (byte)(BTE.mConnections | 1 << (byte) GT_Utility.getOppositeSide(4)); + BTE.mConnections = (byte)(BTE.mConnections | 1 << GT_Utility.getOppositeSide(4)); BaseMetaTileEntity BPE = (BaseMetaTileEntity) worldObj.getTileEntity(x + dx, y + dy, z + dz-1); if (BPE != null) { @@ -244,7 +239,7 @@ public abstract class MapGenRuins extends WorldGenerator { else if (dx < 3 && dx > -5 && dz == 3 && set < toSet){ if (!lastset || treeinaRow > 2) { short meta = GT_WorldgenUtil.getMachine(secureRandom, tier); - setBlock(worldObj, x + dx, y + dy, z + dz, GT_WorldgenUtil.GT_TILES, GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); + this.setBlock(worldObj, x + dx, y + dy, z + 3, GT_WorldgenUtil.GT_TILES, GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); BaseMetaTileEntity BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x + dx, y + dy, z + dz); BTE.setInitialValuesAsNBT(null, meta); BTE.setOwnerName("Ancient Cultures"); @@ -264,31 +259,31 @@ public abstract class MapGenRuins extends WorldGenerator { } else if(dy == 4){ if (Math.abs(dx)== 5) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[2]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+ 4,z+dz,rand,25, this.ToBuildWith[2]); else if (Math.abs(dz) == 5 && Math.abs(dx) < 5) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[1]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25, this.ToBuildWith[1]); } else if(dy == 5){ if (Math.abs(dx)== 4) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[2]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+ 5,z+dz,rand,25, this.ToBuildWith[2]); else if (Math.abs(dz) == 5 && Math.abs(dx) < 4) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[1]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25, this.ToBuildWith[1]); } else if(dy == 6){ if (Math.abs(dx)== 3) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[2]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+ 6,z+dz,rand,25, this.ToBuildWith[2]); else if (Math.abs(dz) == 5 && Math.abs(dx) < 3) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[1]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25, this.ToBuildWith[1]); } else if(dy == 7){ if (Math.abs(dx)== 2) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[2]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+ 7,z+dz,rand,25, this.ToBuildWith[2]); else if (Math.abs(dz) == 5 && Math.abs(dx) < 2) - setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25,ToBuildWith[1]); + this.setRandomBlockWAirChance(worldObj,x+dx,y+dy,z+dz,rand,25, this.ToBuildWith[1]); } else if(dy == 8) { if (Math.abs(dx) == 1 || Math.abs(dx) == 0) - setRandomBlockWAirChance(worldObj, x + dx, y + dy, z + dz, rand, 25, ToBuildWith[2]); + this.setRandomBlockWAirChance(worldObj, x + dx, y + 8, z + dz, rand, 25, this.ToBuildWith[2]); } } } @@ -301,7 +296,7 @@ public abstract class MapGenRuins extends WorldGenerator { if (set < toSet){ if (!lastset || treeinaRow > 2 && worldObj.getTileEntity(x + dx, y + dy, z + dz) == null) { short meta = GT_WorldgenUtil.getMachine(secureRandom, tier); - setBlock(worldObj, x + dx, y + dy, z + dz, GT_WorldgenUtil.GT_TILES, GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); + this.setBlock(worldObj, x + dx, y + dy, z + dz, GT_WorldgenUtil.GT_TILES, GregTech_API.METATILEENTITIES[meta].getTileEntityBaseType()); BaseMetaTileEntity BTE = (BaseMetaTileEntity) worldObj.getTileEntity(x + dx, y + dy, z + dz); BTE.setInitialValuesAsNBT(null, meta); BTE.setOwnerName("Ancient Cultures"); diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java index c380f3399b..16d306d05f 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java @@ -41,15 +41,17 @@ import gregtech.common.items.behaviors.Behaviour_DataOrb; import ic2.core.Ic2Items; import ic2.core.item.ItemFluidCell; import net.minecraft.init.Items; +import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.IRecipe; import net.minecraft.util.StatCollector; +import net.minecraft.world.World; 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 java.io.Serializable; +import java.util.*; import static com.github.bartimaeusnek.bartworks.util.BW_Util.calculateSv; import static com.github.bartimaeusnek.bartworks.util.BW_Util.specialToByte; @@ -60,6 +62,8 @@ public class BWRecipes { public static final byte BIOLABBYTE = 0; public static final byte BACTERIALVATBYTE = 1; public static final byte ACIDGENMAPBYTE = 2; + public static final byte CIRCUITASSEMBLYLINE = 3; + private final GT_Recipe.GT_Recipe_Map sBiolab = new GT_Recipe.GT_Recipe_Map( new HashSet<GT_Recipe>(150), "bw.recipe.biolab", @@ -87,6 +91,15 @@ public class BWRecipes { 1, 1, 1, 1, 1, "EU generated: ", 1000, "", false, true ); + private final BWRecipes.SpecialObjectSensitiveMap sCircuitAssemblyLineMap = new SpecialObjectSensitiveMap( + new HashSet<GT_Recipe>(60), + "bw.recipe.cal", + "Circuit Assembly Line", + null, + "gregtech:textures/gui/basicmachines/Default", + 6, 6, 1, 1, 1, + "", 1, "", true, true //special handler + ); public BWRecipes() { @@ -261,7 +274,7 @@ public class BWRecipes { ); //aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue sBiolab.addRecipe( - new BioLabRecipe( + new DynamicGTRecipe( false, new ItemStack[]{ BioItemList.getPetriDish(null), @@ -304,8 +317,7 @@ public class BWRecipes { /** - * @param machine 0 = biolab; 1 = BacterialVat; 2 = sAcidGenFuels - * @return + * @param machine 0 = biolab; 1 = BacterialVat; 2 = sAcidGenFuels; 3 = circuitAssemblyLine */ public GT_Recipe.GT_Recipe_Map getMappingsFor(byte machine) { switch (machine) { @@ -315,6 +327,8 @@ public class BWRecipes { return sBacteriaVat; case 2: return sAcidGenFuels; + case 3: + return sCircuitAssemblyLineMap; default: return null; } @@ -322,54 +336,54 @@ public class BWRecipes { } public boolean addBioLabRecipe(ItemStack[] aInputs, ItemStack aOutput, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - if (sBiolab.addRecipe(new BioLabRecipe(true, aInputs, new ItemStack[]{aOutput}, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(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) + if (sBiolab.addRecipe(new DynamicGTRecipe(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; } 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, new FluidStack[]{aFluidInputs}, new FluidStack[]{GT_Values.NF}, aDuration, aEUt, aSpecialValue)) != null) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, new ItemStack[]{BioItemList.getPetriDish(null), aInput}, new ItemStack[]{BioItemList.getPetriDish(aOutput)}, null, aChances, new FluidStack[]{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) + if (sBiolab.addRecipe(new DynamicGTRecipe(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) + if (sBiolab.addRecipe(new DynamicGTRecipe(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) + if (sBiolab.addRecipe(new DynamicGTRecipe(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) + if (sBiolab.addRecipe(new DynamicGTRecipe(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) + if (sBiolab.addRecipe(new DynamicGTRecipe(true, aInputs, new ItemStack[]{aOutput}, BioItemList.mBioLabParts[4], aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue)) != null) return true; return false; } @@ -483,7 +497,7 @@ public class BWRecipes { return false; } - public static class DynamicGTRecipe extends GT_Recipe { + public static class DynamicGTRecipe extends GT_Recipe implements Serializable { public DynamicGTRecipe(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); } @@ -515,14 +529,65 @@ public class BWRecipes { } } - public static class BacteriaVatRecipeMap extends GT_Recipe.GT_Recipe_Map { + public static class BacteriaVatRecipeMap extends BWRecipes.SpecialObjectSensitiveMap { 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); } + 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.areStacksEqualOrNull((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); + } + } + + public static class SpecialObjectSensitiveMap extends GT_Recipe.GT_Recipe_Map{ + + public SpecialObjectSensitiveMap(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. + * finds a Recipe matching the aFluid, aSpecial 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. @@ -530,7 +595,7 @@ public class BWRecipes { * @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 aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. Like this one. * @param aInputs the Item Inputs * @return the Recipe it has found or null for no matching Recipe */ @@ -592,56 +657,72 @@ public class BWRecipes { // 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); + public static class BWNBTDependantCraftingRecipe implements IRecipe { - if (aRecipe.mFluidInputs.length < this.mMinimalInputFluids && aRecipe.mInputs.length < this.mMinimalInputItems) { - return null; - } else { - return aCheckForCollisions && isthere != null && BW_Util.areStacksEqualOrNull((ItemStack) isthere.mSpecialItems, (ItemStack) aRecipe.mSpecialItems) ? null : this.add(aRecipe); + ItemStack result; + Map<Character, ItemStack> charToStackMap = new HashMap<>(9,1); + String[] shape; + + public BWNBTDependantCraftingRecipe(ItemStack result, Object... recipe) { + this.result = result; + this.shape = new String[3]; + System.arraycopy(recipe,0, this.shape,0,3); + this.charToStackMap.put(' ', null); + for (int i = 3; i < recipe.length; i+=2) { + this.charToStackMap.put((char)recipe[i],((ItemStack)recipe[i+1]).copy()); } } - public GT_Recipe addRecipe(GT_Recipe aRecipe, boolean VanillaGT) { - if (VanillaGT) - return addRecipe(aRecipe, true, false, false); - else - return addRecipe(aRecipe); + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof BWRecipes.BWNBTDependantCraftingRecipe)) return false; + + BWRecipes.BWNBTDependantCraftingRecipe that = (BWRecipes.BWNBTDependantCraftingRecipe) o; + + if (!Objects.equals(this.result, that.result)) return false; + if (!Objects.equals(this.charToStackMap, that.charToStackMap)) + return false; + // Probably incorrect - comparing Object[] arrays with Arrays.equals + return Arrays.equals(this.shape, that.shape); } - 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; + @Override + public int hashCode() { + int result1 = this.result != null ? this.result.hashCode() : 0; + result1 = 31 * result1 + (this.charToStackMap != null ? this.charToStackMap.hashCode() : 0); + result1 = 31 * result1 + Arrays.hashCode(this.shape); + return result1; + } + + @Override + public boolean matches(InventoryCrafting p_77569_1_, World p_77569_2_) { + for (int x = 0; x < 3; x++) { + for (int y = 0; y < 3; y++) { + ItemStack toCheck = p_77569_1_.getStackInRowAndColumn(y,x); + ItemStack ref = this.charToStackMap.get(this.shape[x].toCharArray()[y]); + if (!BW_Util.areStacksEqualOrNull(toCheck,ref)) + return false; } - while (this.findRecipe((IHasWorldObjectAndCoords) null, false, 9223372036854775807L, aRecipe.mFluidInputs, aRecipe.mInputs) != null); } - return this.addRecipe(aRecipe, false, false, false); + return true; } - } - class BioLabRecipe extends GT_Recipe { - protected BioLabRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, ItemStack aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) { - super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue); + @Override + public ItemStack getCraftingResult(InventoryCrafting p_77572_1_) { + return this.result.copy(); } + @Override + public int getRecipeSize() { + return 10; + } + + @Override + public ItemStack getRecipeOutput() { + return this.result; + } } } 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 index f7312eeab2..0ee22cbd7d 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BW_Util.java @@ -24,32 +24,71 @@ package com.github.bartimaeusnek.bartworks.util; import com.github.bartimaeusnek.bartworks.API.BioVatLogicAdder; import gregtech.api.enums.Materials; -import gregtech.api.interfaces.ISubTagContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import ic2.api.item.IElectricItem; import net.minecraft.block.Block; +import net.minecraft.init.Blocks; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import javax.annotation.Nonnegative; -import java.util.*; -import java.util.function.UnaryOperator; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; import static gregtech.api.enums.GT_Values.V; public class BW_Util { public static final int STANDART = 0; - public static final int CLEANROOM = -100; - public static final int LOWGRAVITY = -200; + public static final int LOWGRAVITY = -100; + public static final int CLEANROOM = -200; + + public static String translateGTItemStack(ItemStack itemStack){ + if (!GT_Utility.isStackValid(itemStack)) + return "Not a Valid ItemStack:"+itemStack; + String ret = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(itemStack)); + if (!ret.contains("%material")) + return ret; + String matname = ""; + if (BW_Util.checkStackAndPrefix(itemStack)) + matname = GT_OreDictUnificator.getAssociation(itemStack).mMaterial.mMaterial.mDefaultLocalName; + return ret.replace("%material", matname); + } + + public static void set2DCoordTo1DArray(int indexX, int indexY, int sizeY, Object value, Object[] array) { + int index = indexX * sizeY + indexY; + array[index] = value; + } + + public static Object get2DCoordFrom1DArray(int indexX, int indexY, int sizeY, Object[] array){ + int index = indexX * sizeY + indexY; + return array[index]; + } + + public static GT_Recipe copyAndSetTierToNewRecipe(GT_Recipe recipe, byte tier){ + byte oldTier = GT_Utility.getTier(recipe.mEUt); + int newTime = recipe.mDuration; + int newVoltage = recipe.mEUt; + if (tier < oldTier) { + newTime <<= (oldTier - tier); + newVoltage >>= 2 * (oldTier - tier); + } else { + newTime >>= (tier - oldTier); + newVoltage <<= 2 * (tier - oldTier); + } + return new BWRecipes.DynamicGTRecipe(false, recipe.mInputs, recipe.mOutputs, recipe.mSpecialItems, recipe.mChances, recipe.mFluidInputs, recipe.mFluidOutputs, newTime, newVoltage, recipe.mSpecialValue); + } public static String subscriptNumbers(String b){ char[] chars = b.toCharArray(); @@ -135,11 +174,11 @@ public class BW_Util { public static byte specialToByte(int aSpecialValue) { byte special = 0; - if (aSpecialValue == (CLEANROOM)) + if (aSpecialValue == (LOWGRAVITY)) special = 1; - else if (aSpecialValue == (LOWGRAVITY)) + else if (aSpecialValue == (CLEANROOM)) special = 2; - else if (aSpecialValue == (CLEANROOM | LOWGRAVITY)) { + else if (aSpecialValue == (LOWGRAVITY | CLEANROOM)) { special = 3; } return special; @@ -149,7 +188,7 @@ public class BW_Util { 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); + return block == Blocks.air ? aBaseMetaTileEntity.getAirOffset(xDir + x, y, zDir + z) : 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) { @@ -157,7 +196,7 @@ public class BW_Util { 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; + return block == Blocks.air ? aBaseMetaTileEntity.getAirOffset(xDir + x, y, zDir + z) : aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(block) && aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) == dmg; } public static int calculateSv(Materials materials) { @@ -203,6 +242,7 @@ public class BW_Util { ret = 4; break; case 2: + case 12: ret = 5; break; case 3: @@ -214,9 +254,6 @@ public class BW_Util { case 5: ret = 8; break; - case 12: - ret = 5; - break; default: ret = 3; } @@ -248,7 +285,7 @@ public class BW_Util { //Long EUt calculation long xEUt = aEUt; //Isnt too low EUt check? - long tempEUt = xEUt < V[1] ? V[1] : xEUt; + long tempEUt = Math.max(xEUt, V[1]); base.mMaxProgresstime = aDuration; @@ -256,8 +293,15 @@ public class BW_Util { tempEUt <<= 2;//this actually controls overclocking //xEUt *= 4;//this is effect of everclocking base.mMaxProgresstime >>= 1;//this is effect of overclocking - xEUt = base.mMaxProgresstime == 0 ? xEUt >> 1 : xEUt << 2;//U know, if the time is less than 1 tick make the machine use less power + xEUt = base.mMaxProgresstime <= 0 ? xEUt >> 1 : xEUt << 2;//U know, if the time is less than 1 tick make the machine use less power + } + + if (xEUt > maxInputVoltage){ + //downclock one notch, we have overshot. + xEUt >>=2; + base.mMaxProgresstime <<= 1; } + if (xEUt > Integer.MAX_VALUE - 1) { base.mEUt = Integer.MAX_VALUE - 1; base.mMaxProgresstime = Integer.MAX_VALUE - 1; @@ -265,7 +309,7 @@ public class BW_Util { base.mEUt = (int) xEUt; if (base.mEUt == 0) base.mEUt = 1; - if (base.mMaxProgresstime == 0) + if (base.mMaxProgresstime <= 0) base.mMaxProgresstime = 1;//set time to 1 tick } } @@ -293,14 +337,14 @@ public class BW_Util { for (GT_MetaTileEntity_Hatch_Input fip : aBaseMetaTileEntity.mInputHatches){ tmp.add(fip.getFluid()); } - return (FluidStack[]) tmp.toArray(); + return tmp.toArray(new FluidStack[0]); } public static ItemStack[] getItemsFromInputBusses(GT_MetaTileEntity_MultiBlockBase aBaseMetaTileEntity){ ArrayList<ItemStack> tmp = new ArrayList<>(); for (GT_MetaTileEntity_Hatch_InputBus fip : aBaseMetaTileEntity.mInputBusses){ tmp.addAll(Arrays.asList(fip.mInventory)); } - return (ItemStack[]) tmp.toArray(); + return tmp.toArray(new ItemStack[0]); } @@ -363,8 +407,9 @@ public class BW_Util { continue; if (controllerLayer && (xDir + x == 0 && zDir + z == 0)) continue; - if (insideCheck && (Math.abs(x) < radius && Math.abs(z) != radius)) { - if (!aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(inside) || (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) != dmginside && dmginside > (-1))) { + boolean b = Math.abs(x) < radius && Math.abs(z) != radius; + if (insideCheck && b) { + if (!aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(inside) && (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) != dmginside || dmginside > (-1))) { if (!(allowHatches && ( ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addDynamoToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), aBaseCasingIndex) || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addEnergyInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), aBaseCasingIndex) || @@ -377,7 +422,7 @@ public class BW_Util { } } } - if (((!(Math.abs(x) < radius && Math.abs(z) != radius))) && (!aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(block) || (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) != dmg && dmg > (-1)))) { + if (!b && !aBaseMetaTileEntity.getBlockOffset(xDir + x, y, zDir + z).equals(block) && (aBaseMetaTileEntity.getMetaIDOffset(xDir + x, y, zDir + z) != dmg || dmg > (-1))) { if (!(allowHatches && ( ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addDynamoToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), aBaseCasingIndex) || ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addEnergyInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + x, y, zDir + z), aBaseCasingIndex) || @@ -416,4 +461,21 @@ public class BW_Util { } return ret; } + + public static byte getCircuitTierFromOreDictName(String name) { + switch (name){ + case "circuitPrimitive": return 0; + case "circuitBasic": return 1; + case "circuitGood": return 2; + case "circuitAdvanced": return 3; + case "circuitData": return 4; + case "circuitElite": return 5; + case "circuitMaster": return 6; + case "circuitUltimate": return 7; + case "circuitSuperconductor": return 8; + case "circuitInfinite": return 9; + case "circuitBio": return 10; + default: return -1; + } + } } 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 1a0f189fd7..7e35affabf 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/ConnectedBlocksChecker.java @@ -29,7 +29,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.DimensionManager; import java.util.HashSet; -import java.util.LinkedHashSet; public class ConnectedBlocksChecker { 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 de262fd73d..d37f3f0661 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NEIbartworksConfig.java @@ -27,9 +27,12 @@ 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 com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; import cpw.mods.fml.common.Optional; +import gregtech.api.enums.OrePrefixes; import net.minecraft.item.ItemStack; + @Optional.Interface(iface = "codechicken.nei.api.API", modid = "NotEnoughItems") public class NEIbartworksConfig implements IConfigureNEI { @@ -51,5 +54,23 @@ public class NEIbartworksConfig implements IConfigureNEI { API.hideItem(new ItemStack(ItemRegistry.TAB)); API.hideItem(new ItemStack(FluidLoader.bioFluidBlock)); API.hideItem(new ItemStack(ItemRegistry.bw_fake_glasses)); + ItemStack[] prefixesToHide = { + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustTiny, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustSmall, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushed, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedPurified, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.crushedCentrifuged, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.nugget, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemChipped, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemFlawed, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemFlawless, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.gemExquisite, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustImpure, WerkstoffLoader.Bismutite).copy(), + WerkstoffLoader.getCorrespondingItemStack(OrePrefixes.dustPure, WerkstoffLoader.Bismutite).copy(), + }; + for (ItemStack stack : prefixesToHide) { + stack.setItemDamage(Short.MAX_VALUE); + API.hideItem(stack); + } } }
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java new file mode 100644 index 0000000000..d568baf22b --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/BartsNoise.java @@ -0,0 +1,232 @@ +/* + * 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.NoiseUtil; + +import com.github.bartimaeusnek.bartworks.API.INoiseGen; +import gregtech.api.objects.XSTR; + +import java.util.Random; + +public class BartsNoise implements INoiseGen { + public void setUsePhase(boolean usePhase) { + this.usePhase = usePhase; + } + + public void setRandom(Random random) { + this.random = random; + } + + boolean usePhase; + int octaves; + double frequency; + double amplitude; + long seed; + Random random; + + public enum NoiseColor{ + Red(-1),Pink(-0.5),White(0),Blue(0.5),Violet(1); + NoiseColor(double num) { + this.ampl=num; + } + double ampl; + public BartsNoise getColoredNoise(){ + BartsNoise noise = new BartsNoise(); + noise.setAmplitude(this.ampl); + return noise; + } + } + + public static double clamp(double input, double lowerBound, double upperBound){ + return Math.min(Math.max(input, lowerBound),upperBound); + } + public static double wrap(double input, double bound){ + return (((input % bound)+bound) % bound); + } + + public BartsNoise(int octaves, double frequency, double amplitude, long seed) { + this.octaves = octaves; + this.frequency = frequency; + this.amplitude = amplitude; + this.seed = seed; + this.random = new XSTR(seed); + } + + public BartsNoise() { + this.seed = new XSTR().nextLong(); + this.random = new XSTR(this.seed); + this.octaves = 1; + this.frequency = this.random.nextGaussian(); + this.amplitude = this.random.nextGaussian(); + } + + public BartsNoise(long seed) { + this.seed = seed; + this.random = new XSTR(seed); + this.octaves = 1; + this.frequency = this.random.nextGaussian(); + this.amplitude = this.random.nextGaussian(); + } + + public BartsNoise copy(){ + return new BartsNoise(this.octaves,this.frequency,this.amplitude,this.seed); + } + public BartsNoise copy(long seed){ + return new BartsNoise(this.octaves,this.frequency,this.amplitude,seed); + } +// public static void main(String[] args) throws IOException { +// +// BartsNoise noiseGen1 = new BartsNoise(2,0.005F,1D,System.nanoTime()); +//// BartsNoise noiseGen2 = new BartsNoise(1,0.002F,-1D,System.nanoTime()); +//// BartsNoise noiseGen3 = new BartsNoise(1,0.002F,-1D,System.nanoTime()); +// +// noiseGen1.setUsePhase(false); +//// noiseGen2.setUsePhase(false); +//// noiseGen3.setUsePhase(false); +// +// +// BufferedImage image = new BufferedImage(640, 640, BufferedImage.TYPE_INT_RGB); +// +// for (int chunkX = 0; chunkX < 40; chunkX++) { +// for (int chunkZ = 0; chunkZ < 40; chunkZ++) { +// for (int x = 0; x < 16; ++x) { +// for (int z = 0; z < 16; ++z) { +// double d = noiseGen1.getNoise(x + chunkX * 16, z + chunkZ * 16) * 2D; +//// double d2 = noiseGen2.getNoise(x + chunkX * 16, z + chunkZ * 16) * 2D; +//// double d3 = (noiseGen3.getNoise(x + chunkX * 16, z + chunkZ * 16) - 0.5D); +//// d3 *= 2; +// double yDev; +//// if (d3 < 0.0D) { +//// yDev = d; +//// } else if (d3 > 1.0D) { +//// yDev = d2; +//// } else { +// yDev = d*4; +//// } +// yDev=wrap(yDev,1); +// image.setRGB(x + chunkX * 16,z + chunkZ * 16,new Color((float)(1f*yDev),(float)(1f*yDev),(float)(1f*yDev)).getRGB()); +// } +// } +// } +// } +// File file = new File("myimage.png"); +// ImageIO.write(image, "png", file); +//// BartsNoise redNoise = NoiseColor.Blue.getColoredNoise(); +//// redNoise.setOctaves(1); +//// redNoise.setFrequency(0.05F); +//// for (int i = 40; i < 50; i++) { +//// String line = ""; +//// for (int j = 0; j < 10; j++) { +//// double num = (redNoise.getNoise(i,j)-0.5D); +//// line += num+","; +//// } +//// System.out.println(line); +//// } +// } + + public double getCosNoise(double x, double y){ + double pr = x * this.frequency; + double r1 = Math.cos(pr); + if (r1 < 0) + r1 = Math.abs(r1); + double result = Math.pow(r1, this.amplitude); + double pr2 = y * this.frequency; + double r2 = Math.cos(pr2); + if (r2 < 0) + r2 = Math.abs(r2); + double result2 = Math.pow(r2, this.amplitude); + result *= result2; + if (result == Double.POSITIVE_INFINITY) + result = Double.MAX_VALUE; + if (result == Double.NEGATIVE_INFINITY) + result = Double.MIN_VALUE; + return BartsNoise.wrap(result,1D); + } + + + double getNonOctavedNoise(double x, double y){ + double phase = SimplexNoise.noise( Math.pow(x*this.frequency,this.amplitude),Math.pow(y*this.frequency,this.amplitude)); + return BartsNoise.wrap(phase,1); + + } + + public double getNeighbouringNoise(int x, int y){ + return (this.getNoiseSingle(x-1,y-1)+ + this.getNoiseSingle(x,y-1) + + this.getNoiseSingle(x-1,y) + + this.getNoiseSingle(x+1,y) + + this.getNoiseSingle(x,y+1) + + this.getNoiseSingle(x+1,y+1) + + this.getNoiseSingle(x-1,y+1)+ + this.getNoiseSingle(x+1,y-1) + )/8; + } + + public double getNoiseSingle(int x, int y){ + double result = 0; + for (double i = 1; i <= this.octaves; i++) { + result += 1d/i * this.getNonOctavedNoise(i * x, i * y); + } + return result; + } + + @Override + public double getNoise(int x, int y) { + double result = 0; + for (double i = 1; i <= this.octaves; i++) { + result += 1d/i * this.getNonOctavedNoise(i * x, y); + } + //result = (this.getNeighbouringNoise(x,y)+result)/2; + return BartsNoise.wrap(result,1D); + } + + @Override + public double[][] getNoiseForRegion(int xStart, int zStart, int xEnd, int zEnd) { +// double[][] results = new double[Math.abs(xEnd)-Math.abs(xStart)][Math.abs(zEnd)-Math.abs(zStart)]; +// for (int i = xStart; i < xEnd; i++) { +// for (int j = zStart; j < zEnd; j++) { +// results +// } +// } + return new double[0][0]; + } + + @Override + public void setAmplitude(double amplitude) { + this.amplitude = amplitude; + } + + @Override + public void setOctaves(int octaves) { + this.octaves = octaves; + } + + @Override + public void setFrequency(double freq) { + this.frequency = freq; + } + + @Override + public void setSeed(long seed) { + this.seed=seed; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java new file mode 100644 index 0000000000..e494594bd2 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/NoiseUtil/SimplexNoise.java @@ -0,0 +1,357 @@ +package com.github.bartimaeusnek.bartworks.util.NoiseUtil; +/* + * A speed-improved simplex noise algorithm for 2D, 3D and 4D in Java. + * + * Based on example code by Stefan Gustavson (stegu@itn.liu.se). + * Optimisations by Peter Eastman (peastman@drizzle.stanford.edu). + * Better rank ordering method by Stefan Gustavson in 2012. + * + * This could be speeded up even further, but it's useful as it is. + * + * Version 2012-03-09 + * + * This code was placed in the public domain by its original author, + * Stefan Gustavson. You may use it as you see fit, but + * attribution is appreciated. + * + */ + +public class SimplexNoise { // Simplex noise in 2D, 3D and 4D + private static Grad grad3[] = {new Grad(1,1,0),new Grad(-1,1,0),new Grad(1,-1,0),new Grad(-1,-1,0), + new Grad(1,0,1),new Grad(-1,0,1),new Grad(1,0,-1),new Grad(-1,0,-1), + new Grad(0,1,1),new Grad(0,-1,1),new Grad(0,1,-1),new Grad(0,-1,-1)}; + + private static Grad grad4[]= {new Grad(0,1,1,1),new Grad(0,1,1,-1),new Grad(0,1,-1,1),new Grad(0,1,-1,-1), + new Grad(0,-1,1,1),new Grad(0,-1,1,-1),new Grad(0,-1,-1,1),new Grad(0,-1,-1,-1), + new Grad(1,0,1,1),new Grad(1,0,1,-1),new Grad(1,0,-1,1),new Grad(1,0,-1,-1), + new Grad(-1,0,1,1),new Grad(-1,0,1,-1),new Grad(-1,0,-1,1),new Grad(-1,0,-1,-1), + new Grad(1,1,0,1),new Grad(1,1,0,-1),new Grad(1,-1,0,1),new Grad(1,-1,0,-1), + new Grad(-1,1,0,1),new Grad(-1,1,0,-1),new Grad(-1,-1,0,1),new Grad(-1,-1,0,-1), + new Grad(1,1,1,0),new Grad(1,1,-1,0),new Grad(1,-1,1,0),new Grad(1,-1,-1,0), + new Grad(-1,1,1,0),new Grad(-1,1,-1,0),new Grad(-1,-1,1,0),new Grad(-1,-1,-1,0)}; + + private static short p[] = {151,160,137,91,90,15, + 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, + 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, + 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, + 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, + 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, + 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, + 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, + 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, + 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, + 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, + 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, + 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180}; + // To remove the need for index wrapping, double the permutation table length + private static short perm[] = new short[512]; + private static short permMod12[] = new short[512]; + static { + for(int i=0; i<512; i++) + { + perm[i]=p[i & 255]; + permMod12[i] = (short)(perm[i] % 12); + } + } + + // Skewing and unskewing factors for 2, 3, and 4 dimensions + private static final double F2 = 0.5*(Math.sqrt(3.0)-1.0); + private static final double G2 = (3.0-Math.sqrt(3.0))/6.0; + private static final double F3 = 1.0/3.0; + private static final double G3 = 1.0/6.0; + private static final double F4 = (Math.sqrt(5.0)-1.0)/4.0; + private static final double G4 = (5.0-Math.sqrt(5.0))/20.0; + + // This method is a *lot* faster than using (int)Math.floor(x) + private static int fastfloor(double x) { + int xi = (int)x; + return x<xi ? xi-1 : xi; + } + + private static double dot(Grad g, double x, double y) { + return g.x*x + g.y*y; } + + private static double dot(Grad g, double x, double y, double z) { + return g.x*x + g.y*y + g.z*z; } + + private static double dot(Grad g, double x, double y, double z, double w) { + return g.x*x + g.y*y + g.z*z + g.w*w; } + + + // 2D simplex noise + public static double noise(double xin, double yin) { + double n0, n1, n2; // Noise contributions from the three corners + // Skew the input space to determine which simplex cell we're in + double s = (xin+yin)*F2; // Hairy factor for 2D + int i = fastfloor(xin+s); + int j = fastfloor(yin+s); + double t = (i+j)*G2; + double X0 = i-t; // Unskew the cell origin back to (x,y) space + double Y0 = j-t; + double x0 = xin-X0; // The x,y distances from the cell origin + double y0 = yin-Y0; + // For the 2D case, the simplex shape is an equilateral triangle. + // Determine which simplex we are in. + int i1, j1; // Offsets for second (middle) corner of simplex in (i,j) coords + if(x0>y0) {i1=1; j1=0;} // lower triangle, XY order: (0,0)->(1,0)->(1,1) + else {i1=0; j1=1;} // upper triangle, YX order: (0,0)->(0,1)->(1,1) + // A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and + // a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where + // c = (3-sqrt(3))/6 + double x1 = x0 - i1 + G2; // Offsets for middle corner in (x,y) unskewed coords + double y1 = y0 - j1 + G2; + double x2 = x0 - 1.0 + 2.0 * G2; // Offsets for last corner in (x,y) unskewed coords + double y2 = y0 - 1.0 + 2.0 * G2; + // Work out the hashed gradient indices of the three simplex corners + int ii = i & 255; + int jj = j & 255; + int gi0 = permMod12[ii+perm[jj]]; + int gi1 = permMod12[ii+i1+perm[jj+j1]]; + int gi2 = permMod12[ii+1+perm[jj+1]]; + // Calculate the contribution from the three corners + double t0 = 0.5 - x0*x0-y0*y0; + if(t0<0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad3[gi0], x0, y0); // (x,y) of grad3 used for 2D gradient + } + double t1 = 0.5 - x1*x1-y1*y1; + if(t1<0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad3[gi1], x1, y1); + } + double t2 = 0.5 - x2*x2-y2*y2; + if(t2<0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad3[gi2], x2, y2); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to return values in the interval [-1,1]. + return 70.0 * (n0 + n1 + n2); + } + + + // 3D simplex noise + public static double noise(double xin, double yin, double zin) { + double n0, n1, n2, n3; // Noise contributions from the four corners + // Skew the input space to determine which simplex cell we're in + double s = (xin+yin+zin)*F3; // Very nice and simple skew factor for 3D + int i = fastfloor(xin+s); + int j = fastfloor(yin+s); + int k = fastfloor(zin+s); + double t = (i+j+k)*G3; + double X0 = i-t; // Unskew the cell origin back to (x,y,z) space + double Y0 = j-t; + double Z0 = k-t; + double x0 = xin-X0; // The x,y,z distances from the cell origin + double y0 = yin-Y0; + double z0 = zin-Z0; + // For the 3D case, the simplex shape is a slightly irregular tetrahedron. + // Determine which simplex we are in. + int i1, j1, k1; // Offsets for second corner of simplex in (i,j,k) coords + int i2, j2, k2; // Offsets for third corner of simplex in (i,j,k) coords + if(x0>=y0) { + if(y0>=z0) + { i1=1; j1=0; k1=0; i2=1; j2=1; k2=0; } // X Y Z order + else if(x0>=z0) { i1=1; j1=0; k1=0; i2=1; j2=0; k2=1; } // X Z Y order + else { i1=0; j1=0; k1=1; i2=1; j2=0; k2=1; } // Z X Y order + } + else { // x0<y0 + if(y0<z0) { i1=0; j1=0; k1=1; i2=0; j2=1; k2=1; } // Z Y X order + else if(x0<z0) { i1=0; j1=1; k1=0; i2=0; j2=1; k2=1; } // Y Z X order + else { i1=0; j1=1; k1=0; i2=1; j2=1; k2=0; } // Y X Z order + } + // A step of (1,0,0) in (i,j,k) means a step of (1-c,-c,-c) in (x,y,z), + // a step of (0,1,0) in (i,j,k) means a step of (-c,1-c,-c) in (x,y,z), and + // a step of (0,0,1) in (i,j,k) means a step of (-c,-c,1-c) in (x,y,z), where + // c = 1/6. + double x1 = x0 - i1 + G3; // Offsets for second corner in (x,y,z) coords + double y1 = y0 - j1 + G3; + double z1 = z0 - k1 + G3; + double x2 = x0 - i2 + 2.0*G3; // Offsets for third corner in (x,y,z) coords + double y2 = y0 - j2 + 2.0*G3; + double z2 = z0 - k2 + 2.0*G3; + double x3 = x0 - 1.0 + 3.0*G3; // Offsets for last corner in (x,y,z) coords + double y3 = y0 - 1.0 + 3.0*G3; + double z3 = z0 - 1.0 + 3.0*G3; + // Work out the hashed gradient indices of the four simplex corners + int ii = i & 255; + int jj = j & 255; + int kk = k & 255; + int gi0 = permMod12[ii+perm[jj+perm[kk]]]; + int gi1 = permMod12[ii+i1+perm[jj+j1+perm[kk+k1]]]; + int gi2 = permMod12[ii+i2+perm[jj+j2+perm[kk+k2]]]; + int gi3 = permMod12[ii+1+perm[jj+1+perm[kk+1]]]; + // Calculate the contribution from the four corners + double t0 = 0.6 - x0*x0 - y0*y0 - z0*z0; + if(t0<0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad3[gi0], x0, y0, z0); + } + double t1 = 0.6 - x1*x1 - y1*y1 - z1*z1; + if(t1<0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad3[gi1], x1, y1, z1); + } + double t2 = 0.6 - x2*x2 - y2*y2 - z2*z2; + if(t2<0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad3[gi2], x2, y2, z2); + } + double t3 = 0.6 - x3*x3 - y3*y3 - z3*z3; + if(t3<0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad3[gi3], x3, y3, z3); + } + // Add contributions from each corner to get the final noise value. + // The result is scaled to stay just inside [-1,1] + return 32.0*(n0 + n1 + n2 + n3); + } + + + // 4D simplex noise, better simplex rank ordering method 2012-03-09 + public static double noise(double x, double y, double z, double w) { + + double n0, n1, n2, n3, n4; // Noise contributions from the five corners + // Skew the (x,y,z,w) space to determine which cell of 24 simplices we're in + double s = (x + y + z + w) * F4; // Factor for 4D skewing + int i = fastfloor(x + s); + int j = fastfloor(y + s); + int k = fastfloor(z + s); + int l = fastfloor(w + s); + double t = (i + j + k + l) * G4; // Factor for 4D unskewing + double X0 = i - t; // Unskew the cell origin back to (x,y,z,w) space + double Y0 = j - t; + double Z0 = k - t; + double W0 = l - t; + double x0 = x - X0; // The x,y,z,w distances from the cell origin + double y0 = y - Y0; + double z0 = z - Z0; + double w0 = w - W0; + // For the 4D case, the simplex is a 4D shape I won't even try to describe. + // To find out which of the 24 possible simplices we're in, we need to + // determine the magnitude ordering of x0, y0, z0 and w0. + // Six pair-wise comparisons are performed between each possible pair + // of the four coordinates, and the results are used to rank the numbers. + int rankx = 0; + int ranky = 0; + int rankz = 0; + int rankw = 0; + if(x0 > y0) rankx++; else ranky++; + if(x0 > z0) rankx++; else rankz++; + if(x0 > w0) rankx++; else rankw++; + if(y0 > z0) ranky++; else rankz++; + if(y0 > w0) ranky++; else rankw++; + if(z0 > w0) rankz++; else rankw++; + int i1, j1, k1, l1; // The integer offsets for the second simplex corner + int i2, j2, k2, l2; // The integer offsets for the third simplex corner + int i3, j3, k3, l3; // The integer offsets for the fourth simplex corner + // simplex[c] is a 4-vector with the numbers 0, 1, 2 and 3 in some order. + // Many values of c will never occur, since e.g. x>y>z>w makes x<z, y<w and x<w + // impossible. Only the 24 indices which have non-zero entries make any sense. + // We use a thresholding to set the coordinates in turn from the largest magnitude. + // Rank 3 denotes the largest coordinate. + i1 = rankx >= 3 ? 1 : 0; + j1 = ranky >= 3 ? 1 : 0; + k1 = rankz >= 3 ? 1 : 0; + l1 = rankw >= 3 ? 1 : 0; + // Rank 2 denotes the second largest coordinate. + i2 = rankx >= 2 ? 1 : 0; + j2 = ranky >= 2 ? 1 : 0; + k2 = rankz >= 2 ? 1 : 0; + l2 = rankw >= 2 ? 1 : 0; + // Rank 1 denotes the second smallest coordinate. + i3 = rankx >= 1 ? 1 : 0; + j3 = ranky >= 1 ? 1 : 0; + k3 = rankz >= 1 ? 1 : 0; + l3 = rankw >= 1 ? 1 : 0; + // The fifth corner has all coordinate offsets = 1, so no need to compute that. + double x1 = x0 - i1 + G4; // Offsets for second corner in (x,y,z,w) coords + double y1 = y0 - j1 + G4; + double z1 = z0 - k1 + G4; + double w1 = w0 - l1 + G4; + double x2 = x0 - i2 + 2.0*G4; // Offsets for third corner in (x,y,z,w) coords + double y2 = y0 - j2 + 2.0*G4; + double z2 = z0 - k2 + 2.0*G4; + double w2 = w0 - l2 + 2.0*G4; + double x3 = x0 - i3 + 3.0*G4; // Offsets for fourth corner in (x,y,z,w) coords + double y3 = y0 - j3 + 3.0*G4; + double z3 = z0 - k3 + 3.0*G4; + double w3 = w0 - l3 + 3.0*G4; + double x4 = x0 - 1.0 + 4.0*G4; // Offsets for last corner in (x,y,z,w) coords + double y4 = y0 - 1.0 + 4.0*G4; + double z4 = z0 - 1.0 + 4.0*G4; + double w4 = w0 - 1.0 + 4.0*G4; + // Work out the hashed gradient indices of the five simplex corners + int ii = i & 255; + int jj = j & 255; + int kk = k & 255; + int ll = l & 255; + int gi0 = perm[ii+perm[jj+perm[kk+perm[ll]]]] % 32; + int gi1 = perm[ii+i1+perm[jj+j1+perm[kk+k1+perm[ll+l1]]]] % 32; + int gi2 = perm[ii+i2+perm[jj+j2+perm[kk+k2+perm[ll+l2]]]] % 32; + int gi3 = perm[ii+i3+perm[jj+j3+perm[kk+k3+perm[ll+l3]]]] % 32; + int gi4 = perm[ii+1+perm[jj+1+perm[kk+1+perm[ll+1]]]] % 32; + // Calculate the contribution from the five corners + double t0 = 0.6 - x0*x0 - y0*y0 - z0*z0 - w0*w0; + if(t0<0) n0 = 0.0; + else { + t0 *= t0; + n0 = t0 * t0 * dot(grad4[gi0], x0, y0, z0, w0); + } + double t1 = 0.6 - x1*x1 - y1*y1 - z1*z1 - w1*w1; + if(t1<0) n1 = 0.0; + else { + t1 *= t1; + n1 = t1 * t1 * dot(grad4[gi1], x1, y1, z1, w1); + } + double t2 = 0.6 - x2*x2 - y2*y2 - z2*z2 - w2*w2; + if(t2<0) n2 = 0.0; + else { + t2 *= t2; + n2 = t2 * t2 * dot(grad4[gi2], x2, y2, z2, w2); + } + double t3 = 0.6 - x3*x3 - y3*y3 - z3*z3 - w3*w3; + if(t3<0) n3 = 0.0; + else { + t3 *= t3; + n3 = t3 * t3 * dot(grad4[gi3], x3, y3, z3, w3); + } + double t4 = 0.6 - x4*x4 - y4*y4 - z4*z4 - w4*w4; + if(t4<0) n4 = 0.0; + else { + t4 *= t4; + n4 = t4 * t4 * dot(grad4[gi4], x4, y4, z4, w4); + } + // Sum up and scale the result to cover the range [-1,1] + return 27.0 * (n0 + n1 + n2 + n3 + n4); + } + + // Inner class to speed upp gradient computations + // (array access is a lot slower than member access) + private static class Grad + { + double x, y, z, w; + + Grad(double x, double y, double z) + { + this.x = x; + this.y = y; + this.z = z; + } + + Grad(double x, double y, double z, double w) + { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java index 5effb4a33e..9bbd454325 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/BartWorksCrossmod.java @@ -22,22 +22,24 @@ package com.github.bartimaeusnek.crossmod; +import com.github.bartimaeusnek.bartworks.MainMod; +import com.github.bartimaeusnek.bartworks.common.commands.ChangeConfig; import com.github.bartimaeusnek.bartworks.common.commands.SummonRuin; +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; import com.github.bartimaeusnek.crossmod.GTpp.loader.RadioHatchCompat; +import com.github.bartimaeusnek.crossmod.emt.recipe.TCRecipeHandler; import com.github.bartimaeusnek.crossmod.galacticraft.GalacticraftProxy; import com.github.bartimaeusnek.crossmod.thaumcraft.CustomAspects; import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.event.*; import net.minecraft.util.StringTranslate; import org.apache.commons.io.input.ReaderInputStream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.StringReader; +import java.lang.reflect.InvocationTargetException; @Mod( modid = BartWorksCrossmod.MOD_ID, name = BartWorksCrossmod.NAME, version = BartWorksCrossmod.VERSION, @@ -48,14 +50,15 @@ import java.io.StringReader; + "after:GalacticraftCore; " + "after:Micdoodlecore; " + "after:miscutils;" + + "after:EMT;" ) public class BartWorksCrossmod { public static final String NAME = "BartWorks Mod Additions"; public static final String VERSION = "0.0.1"; public static final String MOD_ID = "bartworkscrossmod"; - public static final Logger LOGGER = LogManager.getLogger(NAME); + public static final Logger LOGGER = LogManager.getLogger(BartWorksCrossmod.NAME); - @Mod.Instance(MOD_ID) + @Mod.Instance(BartWorksCrossmod.MOD_ID) public static BartWorksCrossmod instance; @Mod.EventHandler @@ -87,9 +90,23 @@ public class BartWorksCrossmod { // } // } + +// @Mod.EventHandler +// public void onServerStarted(FMLServerStartedEvent event) { +// if (Loader.isModLoaded("EMT")){ +// try { +// TCRecipeHandler.init(); +// } catch (IllegalAccessException | InvocationTargetException e) { +// e.printStackTrace(); +// } +// +// } +// } + @Mod.EventHandler public void onFMLServerStart(FMLServerStartingEvent event) { event.registerServerCommand(new SummonRuin()); + event.registerServerCommand(new ChangeConfig()); if (Loader.isModLoaded("miscutils")) for (Object s : RadioHatchCompat.TranslateSet){ StringTranslate.inject(new ReaderInputStream(new StringReader((String) s))); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java b/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java index 1c48eae294..e424b693d2 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/GTpp/loader/RadioHatchCompat.java @@ -61,7 +61,7 @@ public class RadioHatchCompat implements Runnable { private static Object rod; private static Object longRod; - public static HashSet TranslateSet = new HashSet(); + public static HashSet<String> TranslateSet = new HashSet<>(); static{ try { @@ -89,7 +89,7 @@ public class RadioHatchCompat implements Runnable { RadioHatchCompat.localizedName.setAccessible(true); RadioHatchCompat.unlocalizedName.setAccessible(true); - Object[] arr = enu.getEnumConstants(); + Object[] arr = RadioHatchCompat.enu.getEnumConstants(); for (Object o : arr){ if (RadioHatchCompat.rod != null && RadioHatchCompat.longRod != null) break; @@ -110,13 +110,13 @@ public class RadioHatchCompat implements Runnable { try { Class rodclass = Class.forName("gtPlusPlus.core.item.base.rods.BaseItemRod"); Class longrodclass = Class.forName("gtPlusPlus.core.item.base.rods.BaseItemRodLong"); - Constructor c1 = rodclass.getConstructor(RadioHatchCompat.materialClass); - Constructor c2 = longrodclass.getConstructor(RadioHatchCompat.materialClass); + Constructor<? extends Item> c1 = rodclass.getConstructor(RadioHatchCompat.materialClass); + Constructor<? extends Item> c2 = longrodclass.getConstructor(RadioHatchCompat.materialClass); Field cOwners = GameData.class.getDeclaredField("customOwners"); cOwners.setAccessible(true); Field map = RegistryNamespaced.class.getDeclaredField("field_148758_b"); map.setAccessible(true); - Map<Item,String> UniqueIdentifierMap = (Map) map.get(GameData.getItemRegistry()); + Map<Item,String> UniqueIdentifierMap = (Map<Item, String>) map.get(GameData.getItemRegistry()); Map<GameRegistry.UniqueIdentifier, ModContainer> ownerItems = (Map<GameRegistry.UniqueIdentifier, ModContainer>) cOwners.get(null); ModContainer gtpp = null; @@ -135,7 +135,7 @@ public class RadioHatchCompat implements Runnable { if (RadioHatchCompat.isRadioactive.getBoolean(mats)) { if (OreDictionary.getOres("stick" + RadioHatchCompat.unlocalizedName.get(mats)).isEmpty()) { - Item it = (Item) c1.newInstance(mats); + Item it = c1.newInstance(mats); UniqueIdentifierMap.replace(it,"miscutils:"+it.getUnlocalizedName()); GameRegistry.UniqueIdentifier ui = GameRegistry.findUniqueIdentifierFor(it); ownerItems.replace(ui,bartworks,gtpp); @@ -147,7 +147,7 @@ public class RadioHatchCompat implements Runnable { DebugLog.log("Generate: " + RadioHatchCompat.rod + RadioHatchCompat.unlocalizedName.get(mats)); } if (OreDictionary.getOres("stickLong" + RadioHatchCompat.unlocalizedName.get(mats)).isEmpty()) { - Item it2 = (Item) c2.newInstance(mats); + Item it2 = c2.newInstance(mats); UniqueIdentifierMap.replace(it2,"miscutils:"+it2.getUnlocalizedName()); GameRegistry.UniqueIdentifier ui2 = GameRegistry.findUniqueIdentifierFor(it2); ownerItems.replace(ui2,bartworks,gtpp); @@ -212,7 +212,7 @@ public class RadioHatchCompat implements Runnable { elements.add(RadioHatchCompat.stackMaterial.get(materialStack)); } while (!toCheck.isEmpty()){ - elements.addAll(getElemets(toCheck.poll())); + elements.addAll(GTPPRadAdapter.getElemets(toCheck.poll())); } return elements; } @@ -269,4 +269,4 @@ public class RadioHatchCompat implements Runnable { } } -} +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java new file mode 100644 index 0000000000..c36f63cd00 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/emt/recipe/TCRecipeHandler.java @@ -0,0 +1,286 @@ +/* + * 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.crossmod.emt.recipe; + +import com.github.bartimaeusnek.bartworks.util.BWRecipes; +import com.github.bartimaeusnek.bartworks.util.BW_Util; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.HashBiMap; +import gregtech.api.GregTech_API; +import gregtech.api.enums.GT_Values; +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 net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; + +import static com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler.AspectAdder; + +public class TCRecipeHandler { + public static final GT_Recipe.GT_Recipe_Map alchemicalConstructHandler = new TCRecipeHandler.TCRecipeMap(new HashSet<>(), + "bwcm.recipe.alchemicalConstruct", + "Industrical Alchemical Construct", + null, + "gregtech:textures/gui/basicmachines/Default", + 2, 1, 2, 0, 1, + "", 1, "", true, true + ); + static Class aCrucibleRecipeClass; + static Class aThaumcraftAPI; + static Field craftingRecipes; + static Field aCrucibleRecipeField; + static Field aCrucibleRecipeCatalyst; + static Field aspects; + static Field key; + + static { + try { + aCrucibleRecipeClass = Class.forName("thaumcraft.api.crafting.CrucibleRecipe"); + aThaumcraftAPI = Class.forName("thaumcraft.api.ThaumcraftApi"); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + try { + aspects = aCrucibleRecipeClass.getField("aspects"); + + key = aCrucibleRecipeClass.getField("key"); + + aCrucibleRecipeField = aCrucibleRecipeClass.getDeclaredField("recipeOutput"); + aCrucibleRecipeField.setAccessible(true); + + aCrucibleRecipeCatalyst = aCrucibleRecipeClass.getField("catalyst"); + + craftingRecipes = aThaumcraftAPI.getDeclaredField("craftingRecipes"); + craftingRecipes.setAccessible(true); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + } + + public static void init() throws IllegalAccessException, InvocationTargetException { + ArrayList tcCraftingList = (ArrayList) craftingRecipes.get(null); + HashSet crucibleRecipes = new HashSet(); + for (Object o : tcCraftingList) { + if (TCRecipeHandler.aCrucibleRecipeClass.isInstance(o)) + crucibleRecipes.add(o); + } + TCRecipeHandler.convertCrucibleRecipesToGTRecipes(crucibleRecipes); + } + + public static void convertCrucibleRecipesToGTRecipes(HashSet crucibleRecipes) throws IllegalAccessException, InvocationTargetException { + HashSet<GT_Recipe> ret = new HashSet<>(); + ArrayListMultimap<ItemStack,Integer> itemToCircuitConfigMap = ArrayListMultimap.create(); + ArrayListMultimap<ItemStack,Object> itemToAspectsMap = ArrayListMultimap.create(); + ArrayListMultimap<ItemStack,ItemStack> itemToOutputMap = ArrayListMultimap.create(); + ArrayListMultimap<ItemStack,String> itemToResearchMap = ArrayListMultimap.create(); + + for (Object o : crucibleRecipes) { + + String key = (String) TCRecipeHandler.key.get(o); + ItemStack out = (ItemStack) TCRecipeHandler.aCrucibleRecipeField.get(o); + Object aspects = TCRecipeHandler.aspects.get(o); + Object cat = TCRecipeHandler.aCrucibleRecipeCatalyst.get(o); + + if (cat instanceof ItemStack) { + itemToAspectsMap.put((ItemStack)cat,aspects); + itemToOutputMap.put((ItemStack)cat,out); + itemToResearchMap.put((ItemStack)cat,key); + } else if (cat instanceof String) { + for (ItemStack stack : OreDictionary.getOres((String) cat)) { + itemToAspectsMap.put(stack,aspects); + itemToOutputMap.put(stack,out); + itemToResearchMap.put(stack,key); + } + } else if (cat instanceof ArrayList && ((ArrayList) cat).size() > 0) { + for (ItemStack stack : ((ArrayList<ItemStack>) cat)) { + itemToAspectsMap.put(stack,aspects); + itemToOutputMap.put(stack,out); + itemToResearchMap.put(stack,key); + + } + } + } + for (ItemStack o : itemToAspectsMap.keySet()){ + for (int j = 1; j <= itemToAspectsMap.get(o).size() ; j++) { + itemToCircuitConfigMap.put(o,j); + } + + for (int j = 0; j < itemToAspectsMap.get(o).size() ; j++) { + ret.add(addRecipes(itemToResearchMap.get(o).get(j),itemToOutputMap.get(o).get(j),itemToAspectsMap.get(o).get(j),o,itemToCircuitConfigMap.get(o).get(j))); + } + } + + for (GT_Recipe recipe : ret){ + TCRecipeHandler.alchemicalConstructHandler.add(recipe); + } + + } + + public static GT_Recipe addRecipes(String key, ItemStack out, Object aspects, ItemStack cat, int config) throws InvocationTargetException, IllegalAccessException { + + NBTTagCompound toWrite = new NBTTagCompound(); + ThaumcraftHandler.AspectAdder.writeAspectListToNBT.invoke(aspects, toWrite); + ItemStack fake = new ItemStack(Items.feather); + fake.setTagCompound(toWrite); + fake.setStackDisplayName(key); + GT_Recipe recipe = new BWRecipes.DynamicGTRecipe( + false, + new ItemStack[]{cat, GT_Utility.getIntegratedCircuit(config)}, + new ItemStack[]{out}, + fake, + null, + null, + null, + 60, + 480, + 0 + ); + return recipe; + } + + static class TCRecipeMap extends GT_Recipe.GT_Recipe_Map { + public TCRecipeMap(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); + } + + @Override + 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 (this.mMinimalInputItems > 0) { + if (aInputs == null) + return null; + int tAmount = 0; + for (ItemStack aInput : aInputs) + if (aInput != null) + tAmount++; + if (tAmount < this.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)) { +// NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); +// NBTTagCompound givenNBT = ((ItemStack)aRecipe.mSpecialItems).getTagCompound(); +// Object aAspectListToCheck = null; +// Object aGivenAspectList = null; +// try { +// aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); +// aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); +// AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck,toCheckNBT); +// AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList,givenNBT); +// if (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck,aGivenAspectList)) +// return null; +// } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { +// e.printStackTrace(); +// return null; +// } +// 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 (this.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)) { + NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); + NBTTagCompound givenNBT = ((ItemStack)aRecipe.mSpecialItems).getTagCompound(); + Object aAspectListToCheck = null; + Object aGivenAspectList = null; + try { + aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); + aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); + AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck,toCheckNBT); + AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList,givenNBT); + if (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck,aGivenAspectList)) + continue; + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + 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.areStacksEqualOrNull((ItemStack) tRecipe.mSpecialItems, aSpecialSlot)) { + NBTTagCompound toCheckNBT = aSpecialSlot.getTagCompound(); + NBTTagCompound givenNBT = ((ItemStack)aRecipe.mSpecialItems).getTagCompound(); + Object aAspectListToCheck = null; + Object aGivenAspectList = null; + try { + aAspectListToCheck = AspectAdder.mAspectListClass.newInstance(); + aGivenAspectList = AspectAdder.mAspectListClass.newInstance(); + AspectAdder.readAspectListFromNBT.invoke(aAspectListToCheck,toCheckNBT); + AspectAdder.readAspectListFromNBT.invoke(aGivenAspectList,givenNBT); + if (!TCRecipeHandler.TCRecipeMap.containsAspects(aAspectListToCheck,aGivenAspectList)) + continue; + } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + return null; + } + return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + } + } + // And nothing has been found. + return null; + } + + + private static boolean containsAspects(Object aAspectListToCheck, Object aGivenAspectList) throws InvocationTargetException, IllegalAccessException { + Object[] aspects = (Object[]) ThaumcraftHandler.AspectAdder.getAspects.invoke(aGivenAspectList); + for (int i = 0; i < aspects.length; i++) { + if ((int) ThaumcraftHandler.AspectAdder.getAmount.invoke(aAspectListToCheck,aspects[i]) < (int) ThaumcraftHandler.AspectAdder.getAmount.invoke(aGivenAspectList,aspects[i])) + return false; + } + return true; + } + + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Furnace.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Furnace.java new file mode 100644 index 0000000000..fa9bf7cd37 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/emt/tileentities/multi/GT_Industrial_Alchemic_Furnace.java @@ -0,0 +1,150 @@ +/* + * 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.crossmod.emt.tileentities.multi; + +import com.github.bartimaeusnek.crossmod.emt.recipe.TCRecipeHandler; +import com.github.bartimaeusnek.crossmod.emt.util.EMTHandler; +import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +import static gregtech.api.enums.GT_Values.V; + +public class GT_Industrial_Alchemic_Furnace extends GT_MetaTileEntity_MultiBlockBase { + + List<Object> mEssentiaHatches = new ArrayList<>(); + + public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity.getClass().isInstance(EMTHandler.aEssentiaInputHatch)) + return this.addEssetiaHatchToList(aTileEntity, aBaseCasingIndex); + return super.addInputToMachineList(aTileEntity, aBaseCasingIndex); + } + + private boolean addEssetiaHatchToList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } else { + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } else if (aTileEntity.getClass().isInstance(EMTHandler.aEssentiaInputHatch)) { + ((GT_MetaTileEntity_Hatch)aMetaTileEntity).updateTexture(aBaseCasingIndex); + return this.mEssentiaHatches.add(aMetaTileEntity); + } else { + return false; + } + } + } + + public GT_Industrial_Alchemic_Furnace(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_Industrial_Alchemic_Furnace(String aName) { + super(aName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + @Override + public boolean checkRecipe(ItemStack itemStack) { + ItemStack stack = new ItemStack(Items.feather); + try { + String owner = this.getBaseMetaTileEntity().getOwnerName(); + Object allAspects = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); + for (Object o : this.mEssentiaHatches) { + Object aspectList = EMTHandler.aAspectField.get(o); + ThaumcraftHandler.AspectAdder.add.invoke(allAspects,aspectList); + } + NBTTagCompound toWrite = (NBTTagCompound)ThaumcraftHandler.AspectAdder.writeAspectListToNBT.invoke(allAspects,new NBTTagCompound()); + stack.setTagCompound(toWrite); + } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) { + e.printStackTrace(); + return false; + } + ItemStack[] tInputs = this.getStoredInputs().toArray(new ItemStack[0]); + ArrayList<ItemStack> outputItems = new ArrayList<ItemStack>(); + + long tVoltage = this.getMaxInputVoltage(); + byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); + GT_Recipe tRecipe = TCRecipeHandler.alchemicalConstructHandler.findRecipe(this.getBaseMetaTileEntity(),null,false, false, V[tTier], null, stack,tInputs); + + return false; + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return false; + } + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 0; + } + + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new GT_Industrial_Alchemic_Furnace(mName); + } + + @Override + public String[] getDescription() { + return new String[0]; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity iGregTechTileEntity, byte b, byte b1, byte b2, boolean b3, boolean b4) { + return new ITexture[0]; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.java new file mode 100644 index 0000000000..c720de1f07 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/emt/util/EMTHandler.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.crossmod.emt.util; + +import java.lang.reflect.Field; + +public class EMTHandler { + public static Class aEssentiaInputHatch; + public static Field aAspectField; + static { + try { + aEssentiaInputHatch = Class.forName("emt.gthandler.common.implementations.EssentiaHatch"); + aAspectField = aEssentiaInputHatch.getDeclaredField("current"); + aAspectField.setAccessible(true); + } catch (ClassNotFoundException | NoSuchFieldException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java index 2c126759b8..cca1bf94d4 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/GalacticraftProxy.java @@ -23,12 +23,14 @@ package com.github.bartimaeusnek.crossmod.galacticraft; import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import com.github.bartimaeusnek.crossmod.galacticraft.atmosphere.BWAtmosphereManager; import com.github.bartimaeusnek.crossmod.galacticraft.solarsystems.Ross128SolarSystem; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import gregtech.api.objects.GT_UO_DimensionList; +import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import java.io.File; @@ -74,6 +76,7 @@ public class GalacticraftProxy { if (GalacticraftProxy.gtConf.hasChanged()) GalacticraftProxy.gtConf.save(); init_OresRoss128(); + MinecraftForge.EVENT_BUS.register(BWAtmosphereManager.INSTANCE); } public static void init(FMLInitializationEvent e) { diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java new file mode 100644 index 0000000000..8eddf5eb04 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/PlanetsHelperClass.java @@ -0,0 +1,49 @@ +/* + * 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.crossmod.galacticraft; + +import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import micdoodle8.mods.galacticraft.core.entities.EntityLander; +import micdoodle8.mods.galacticraft.core.entities.EntityLanderBase; +import micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityEntryPod; +import micdoodle8.mods.galacticraft.planets.mars.entities.EntityLandingBalloons; +import net.minecraft.entity.player.EntityPlayerMP; + +public class PlanetsHelperClass { + + public static EntityLanderBase getLanderType(EntityPlayerMP player){ + EntityLanderBase elb; + switch (ConfigHandler.landerType){ + case 1: + elb = new EntityLander(player); + break; + case 2: + elb = new EntityLandingBalloons(player); + break; + default: + elb = new EntityEntryPod(player); + break; + } + return elb; + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java index c1e7e7a6c8..ddae0648b2 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/UniversalTeleportType.java @@ -22,14 +22,12 @@ package com.github.bartimaeusnek.crossmod.galacticraft; -import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler; +import cpw.mods.fml.common.Loader; import micdoodle8.mods.galacticraft.api.vector.Vector3; import micdoodle8.mods.galacticraft.api.world.ITeleportType; import micdoodle8.mods.galacticraft.core.entities.EntityLander; import micdoodle8.mods.galacticraft.core.entities.EntityLanderBase; import micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats; -import micdoodle8.mods.galacticraft.planets.asteroids.entities.EntityEntryPod; -import micdoodle8.mods.galacticraft.planets.mars.entities.EntityLandingBalloons; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.world.World; @@ -71,18 +69,10 @@ public class UniversalTeleportType implements ITeleportType { } EntityLanderBase elb; - - switch (ConfigHandler.landerType){ - case 1: - elb = new EntityLander(player); - break; - case 2: - elb = new EntityLandingBalloons(player); - break; - default: - elb = new EntityEntryPod(player); - break; - } + if (Loader.isModLoaded("GalacticraftMars")) + elb=PlanetsHelperClass.getLanderType(player); + else + elb = new EntityLander(player); if (!newWorld.isRemote) { newWorld.spawnEntityInWorld(elb); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java new file mode 100644 index 0000000000..0b835e382c --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/atmosphere/BWAtmosphereManager.java @@ -0,0 +1,113 @@ +/* + * 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.crossmod.galacticraft.atmosphere; + +import com.github.bartimaeusnek.bartworks.system.material.Werkstoff; +import com.github.bartimaeusnek.bartworks.system.material.WerkstoffLoader; +import com.github.bartimaeusnek.bartworks.util.Pair; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import com.google.common.collect.ArrayListMultimap; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.ISubTagContainer; +import micdoodle8.mods.galacticraft.api.galaxies.CelestialBody; +import micdoodle8.mods.galacticraft.api.galaxies.GalaxyRegistry; +import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; + +import java.util.*; + +public final class BWAtmosphereManager { + + private static final Map<Integer,Integer[]> COEFFICIENT_MAP = new HashMap<>(); + + private BWAtmosphereManager() { + BWAtmosphereManager.COEFFICIENT_MAP.put(1, new Integer[]{100}); + BWAtmosphereManager.COEFFICIENT_MAP.put(2,new Integer[]{70,30}); + BWAtmosphereManager.COEFFICIENT_MAP.put(3,new Integer[]{60,25,15}); + BWAtmosphereManager.COEFFICIENT_MAP.put(4,new Integer[]{50,25,15,10}); + BWAtmosphereManager.COEFFICIENT_MAP.put(5,new Integer[]{45,25,15,10,5}); + BWAtmosphereManager.COEFFICIENT_MAP.put(6,new Integer[]{45,20,15,10,5,5}); + BWAtmosphereManager.COEFFICIENT_MAP.put(7,new Integer[]{40,20,15,10,5,5,5}); + BWAtmosphereManager.COEFFICIENT_MAP.put(8,new Integer[]{35,20,15,10,5,5,5,5}); + BWAtmosphereManager.COEFFICIENT_MAP.put(9,new Integer[]{35,15,15,10,5,5,5,5,5}); + } + + public static final BWAtmosphereManager INSTANCE = new BWAtmosphereManager(); + + private static final ArrayListMultimap<Integer, Pair<ISubTagContainer,Integer>> gasConcentration = ArrayListMultimap.create(); + + public static List<Pair<ISubTagContainer,Integer>> getGasFromWorldID(int worldID){ + return BWAtmosphereManager.gasConcentration.get(worldID); + } + + public static void removeGasFromWorld(int worldID, ISubTagContainer gas){ + HashSet toRemSet = new HashSet(); + for (Pair<ISubTagContainer,Integer> pair : BWAtmosphereManager.gasConcentration.get(worldID)){ + if (pair.getKey().equals(gas)){ + BWAtmosphereManager.gasConcentration.get(worldID).remove(pair); + return; + } + } + } + + public static void addGasToWorld(int worldID, ISubTagContainer gas, int amount){ + Pair<ISubTagContainer,Integer> toadd = new Pair<ISubTagContainer,Integer>(gas,amount); + BWAtmosphereManager.gasConcentration.put(worldID,toadd); + } + + public static void addGasToWorld(int worldID, Pair<ISubTagContainer,Integer> toPut){ + BWAtmosphereManager.gasConcentration.put(worldID,toPut); + } + + public static void addGasToWorld(int worldID, Pair<ISubTagContainer,Integer>... toPut){ + for (Pair<ISubTagContainer,Integer> toadd : toPut) + BWAtmosphereManager.gasConcentration.put(worldID,toadd); + } + + private static boolean addGCGasToWorld(int worldID, IAtmosphericGas gas, int aNumber, int aMaxNumber){ + if (gas.equals(IAtmosphericGas.CO2)) { + BWAtmosphereManager.addGasToWorld(worldID, Materials.CarbonDioxide, BWAtmosphereManager.COEFFICIENT_MAP.get(aMaxNumber)[aNumber]); + return true; + } + String name = gas.toString(); + name = name.substring(0,1)+name.substring(1).toLowerCase(Locale.US); + ISubTagContainer mat = Materials.get(name); + if (mat == Materials._NULL){ + mat = WerkstoffLoader.getWerkstoff(name); + } + if (mat == Werkstoff.default_null_Werkstoff){ + return false; + } + BWAtmosphereManager.addGasToWorld(worldID, mat, BWAtmosphereManager.COEFFICIENT_MAP.get(aMaxNumber)[aNumber]); + return true; + } + + @SubscribeEvent + public void gcAutoRegister(GalaxyRegistry.PlanetRegisterEvent event){ + CelestialBody planet = GalaxyRegistry.getRegisteredPlanets().get(event.planetName); + for (int i = 0; i < planet.atmosphere.size(); i++) { + if (!BWAtmosphereManager.addGCGasToWorld(planet.getDimensionID(),planet.atmosphere.get(i),i,planet.atmosphere.size())) + BartWorksCrossmod.LOGGER.warn("Unidentified Fluid ("+planet.atmosphere.get(i)+") in the Atmosphere of: "+planet.getLocalizedName()); + } + } +} diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java index e3b8aaf3cf..d30d72bacd 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/creativetabs/SpaceTab.java @@ -35,7 +35,7 @@ public class SpaceTab extends CreativeTabs { } public static SpaceTab getInstance() { - return instance; + return SpaceTab.instance; } @Override diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java index 483b8f5cf7..34e96e6111 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128b/ChunkProviderRoss128b.java @@ -53,15 +53,15 @@ import static net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.Ev public class ChunkProviderRoss128b extends ChunkProviderGenerate { XSTR rand = new XSTR(); private BiomeGenBase[] biomesForGeneration; - private BW_WordGenerator BWOreGen = new BW_WordGenerator(); - private World worldObj; - private MapGenBase caveGenerator = new MapGenCaves(); - private MapGenBase ravineGenerator = new MapGenRavine(); - private MapGenRuins.RuinsBase ruinsBase = new MapGenRuins.RuinsBase(); + private final BW_WordGenerator BWOreGen = new BW_WordGenerator(); + private final World worldObj; + private final MapGenBase caveGenerator = new MapGenCaves(); + private final MapGenBase ravineGenerator = new MapGenRavine(); + private final MapGenRuins.RuinsBase ruinsBase = new MapGenRuins.RuinsBase(); public ChunkProviderRoss128b(World par1World, long seed, boolean mapFeaturesEnabled) { super(par1World, seed, mapFeaturesEnabled); - worldObj = par1World; + this.worldObj = par1World; } @Override @@ -75,8 +75,8 @@ public class ChunkProviderRoss128b extends ChunkProviderGenerate { byte[] abyte = new byte[65536]; this.func_147424_a(p_73154_1_, p_73154_2_, ablock); this.biomesForGeneration = this.worldObj.getWorldChunkManager().loadBlockGeneratorData(this.biomesForGeneration, p_73154_1_ * 16, p_73154_2_ * 16, 16, 16); - for (int i = 0; i < biomesForGeneration.length; i++) { - BiomeGenBase biomeGenBase = biomesForGeneration[i]; + for (int i = 0; i < this.biomesForGeneration.length; i++) { + BiomeGenBase biomeGenBase = this.biomesForGeneration[i]; if (biomeGenBase.biomeID == BiomeGenBase.mushroomIsland.biomeID) { this.biomesForGeneration[i] = BiomeGenBase.taiga; } else if (biomeGenBase.biomeID == BiomeGenBase.mushroomIslandShore.biomeID) { @@ -85,6 +85,8 @@ public class ChunkProviderRoss128b extends ChunkProviderGenerate { if (Loader.isModLoaded("Thaumcraft")) { if (ThaumcraftHandler.isTaintBiome(biomeGenBase.biomeID)) this.biomesForGeneration[i] = BiomeGenBase.taiga; + else if (ConfigHandler.disableMagicalForest && ThaumcraftHandler.isMagicalForestBiome(biomeGenBase.biomeID)) + this.biomesForGeneration[i] = BiomeGenBase.birchForest; } } this.replaceBlocksForBiome(p_73154_1_, p_73154_2_, ablock, abyte, this.biomesForGeneration); @@ -115,7 +117,7 @@ public class ChunkProviderRoss128b extends ChunkProviderGenerate { this.rand.setSeed((long) p_73153_2_ * i1 + (long) p_73153_3_ * j1 ^ this.worldObj.getSeed()); } - MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, false)); + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false)); int x1; int y1; @@ -126,11 +128,11 @@ public class ChunkProviderRoss128b extends ChunkProviderGenerate { x1 = k + this.rand.nextInt(16) + 3; y1 = this.rand.nextInt(256); z1 = l + this.rand.nextInt(16) + 3; - ruinsBase.generate(worldObj, rand, x1, y1, z1); + this.ruinsBase.generate(this.worldObj, this.rand, x1, y1, z1); } if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && this.rand.nextInt(4) == 0 - && TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, false, LAKE)) { + && TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, LAKE)) { x1 = k + this.rand.nextInt(16) + 8; y1 = this.rand.nextInt(256); z1 = l + this.rand.nextInt(16) + 8; @@ -142,7 +144,7 @@ public class ChunkProviderRoss128b extends ChunkProviderGenerate { k += 8; l += 8; - boolean doGen = TerrainGen.populate(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, false, ICE); + boolean doGen = TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, ICE); for (x1 = 0; doGen && x1 < 16; ++x1) { for (y1 = 0; y1 < 16; ++y1) { z1 = this.worldObj.getPrecipitationHeight(k + x1, l + y1); @@ -157,8 +159,8 @@ public class ChunkProviderRoss128b extends ChunkProviderGenerate { } } - BWOreGen.generate(rand, p_73153_2_, p_73153_3_, worldObj, this, this); - MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, worldObj, rand, p_73153_2_, p_73153_3_, false)); + this.BWOreGen.generate(this.rand, p_73153_2_, p_73153_3_, this.worldObj, this, this); + MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false)); BlockFalling.fallInstantly = false; } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java index 01bb163283..044737ac9c 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/planets/ross128ba/ChunkProviderRoss128ba.java @@ -22,8 +22,10 @@ package com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128ba; +import com.github.bartimaeusnek.bartworks.util.NoiseUtil.BartsNoise; import gregtech.api.objects.XSTR; import micdoodle8.mods.galacticraft.api.prefab.world.gen.MapGenBaseMeta; +import micdoodle8.mods.galacticraft.core.blocks.GCBlocks; import micdoodle8.mods.galacticraft.core.world.gen.BiomeGenBaseMoon; import micdoodle8.mods.galacticraft.core.world.gen.ChunkProviderMoon; import micdoodle8.mods.galacticraft.core.world.gen.MapGenCavesMoon; @@ -37,10 +39,10 @@ import java.util.Arrays; public class ChunkProviderRoss128ba extends ChunkProviderMoon { - private XSTR rand = new XSTR(); - private World worldObj; + private final XSTR rand = new XSTR(); + private final World worldObj; private BiomeGenBase[] biomesForGeneration; - private MapGenBaseMeta caveGenerator; + private final MapGenBaseMeta caveGenerator; public ChunkProviderRoss128ba(World world, long seed, boolean mapFeaturesEnabled) { super(world, seed, mapFeaturesEnabled); @@ -63,4 +65,34 @@ public class ChunkProviderRoss128ba extends ChunkProviderMoon { Chunk.generateSkylightMap(); return Chunk; } + + private int getIndex(int x, int y, int z) { + return (x * 16 + z) * 256 + y; + } + + final Block lowerBlockID = GCBlocks.blockMoon; + final BartsNoise noiseGen= new BartsNoise(2,0.008F,1D,System.nanoTime()); + final BartsNoise noiseGen2= new BartsNoise(2,0.01F,1D,System.nanoTime()); + final BartsNoise noiseGen3= new BartsNoise(2,0.002F,1D,System.nanoTime()); + + public void generateTerrain(int chunkX, int chunkZ, Block[] idArray, byte[] metaArray) { + for(int x = 0; x < 16; ++x) { + for(int z = 0; z < 16; ++z) { + double d = noiseGen.getNoise(x + chunkX * 16, z + chunkZ * 16); + double d2 = noiseGen2.getNoise(x + chunkX * 16, z + chunkZ * 16); + double d3 = noiseGen3.getCosNoise(x + chunkX * 16, z + chunkZ * 16); + + double yDev = d*4+d2*2+d3; + + for(int y = 0; y < 128; ++y) { + if ((double)y < 60.0D + yDev) { + idArray[this.getIndex(x, y, z)] = this.lowerBlockID; + int var10001 = this.getIndex(x, y, z); + metaArray[var10001] = 4; + } + } + } + } + + } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java index 1634ca0f75..359450c7f9 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/galacticraft/solarsystems/Ross128SolarSystem.java @@ -28,14 +28,12 @@ import com.github.bartimaeusnek.crossmod.galacticraft.UniversalTeleportType; import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128b.WorldProviderRoss128b; import com.github.bartimaeusnek.crossmod.galacticraft.planets.ross128ba.WorldProviderRoss128Ba; import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.registry.GameRegistry; import micdoodle8.mods.galacticraft.api.GalacticraftRegistry; import micdoodle8.mods.galacticraft.api.galaxies.*; import micdoodle8.mods.galacticraft.api.vector.Vector3; import micdoodle8.mods.galacticraft.api.world.IAtmosphericGas; import micdoodle8.mods.galacticraft.core.GalacticraftCore; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.DimensionManager; import java.util.Arrays; @@ -70,14 +68,14 @@ public class Ross128SolarSystem { Ross128SolarSystem.Ross128ba = new Moon("Ross128ba").setParentPlanet(Ross128SolarSystem.Ross128b); Ross128SolarSystem.Ross128ba.setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(10f, 15f)).setRelativeOrbitTime(1 / 0.01F); Ross128SolarSystem.Ross128ba.setBodyIcon(new ResourceLocation(BartWorksCrossmod.MOD_ID + ":galacticraft/Ross128b/MapObjs/Ross128ba.png")); -// Ross128SolarSystem.Ross128ba.setDimensionInfo(ConfigHandler.ross128BAID, WorldProviderRoss128Ba.class); - Ross128SolarSystem.Ross128ba.setTierRequired(Loader.isModLoaded("galaxyspace") ? 4 : 3); + Ross128SolarSystem.Ross128ba.setDimensionInfo(ConfigHandler.ross128BAID, WorldProviderRoss128Ba.class); + Ross128SolarSystem.Ross128ba.setTierRequired(Loader.isModLoaded("galaxyspace") ? Math.min(ConfigHandler.ross128btier + 1, 8) : 3); - Ross128SolarSystem.Ross128ba.setUnreachable(); + //Ross128SolarSystem.Ross128ba.setUnreachable(); - GalaxyRegistry.registerPlanet(Ross128SolarSystem.Ross128b); - GalaxyRegistry.registerMoon(Ross128SolarSystem.Ross128ba); GalaxyRegistry.registerSolarSystem(Ross128SolarSystem.Ross128System); + GalaxyRegistry.registerPlanet(Ross128SolarSystem.Ross128b); +// GalaxyRegistry.registerMoon(Ross128SolarSystem.Ross128ba); GalacticraftRegistry.registerRocketGui(WorldProviderRoss128b.class, new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/overworldRocketGui.png")); // GalacticraftRegistry.registerRocketGui(WorldProviderRoss128Ba.class, new ResourceLocation(GalacticraftCore.ASSET_PREFIX, "textures/gui/moonRocketGui.png")); GalacticraftRegistry.registerTeleportType(WorldProviderRoss128b.class, new UniversalTeleportType()); diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java index 4974a5725d..7db0ab7bb5 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/GT_NBT_DataBase.java @@ -22,13 +22,14 @@ package com.github.bartimaeusnek.crossmod.openComputers; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; import net.minecraft.nbt.NBTTagCompound; -import java.util.HashMap; - public class GT_NBT_DataBase { - private static HashMap<NBTTagCompound, Long> tagToIdMap = new HashMap<>(); + private static final BiMap<NBTTagCompound, Long> tagIdBiMap = HashBiMap.create(); + private static final BiMap<GT_NBT_DataBase, Long> GTNBTBIMAP = HashBiMap.create(); private static long maxID = Long.MIN_VALUE+1; @@ -43,12 +44,25 @@ public class GT_NBT_DataBase { this.mDataTitle = mDataTitle; this.tagCompound = tagCompound; this.id = GT_NBT_DataBase.maxID; - GT_NBT_DataBase.tagToIdMap.put(tagCompound,id); + GT_NBT_DataBase.tagIdBiMap.put(tagCompound, this.id); + GT_NBT_DataBase.GTNBTBIMAP.put(this,this.id); ++GT_NBT_DataBase.maxID; } + static GT_NBT_DataBase getGTTagFromId(Long id){ + return GT_NBT_DataBase.GTNBTBIMAP.inverse().get(id); + } + + static Long getIdFromGTTag(GT_NBT_DataBase tagCompound){ + return GT_NBT_DataBase.GTNBTBIMAP.get(tagCompound); + } + + static NBTTagCompound getTagFromId(Long id){ + return GT_NBT_DataBase.tagIdBiMap.inverse().get(id); + } + static Long getIdFromTag(NBTTagCompound tagCompound){ - return GT_NBT_DataBase.tagToIdMap.get(tagCompound); + return GT_NBT_DataBase.tagIdBiMap.get(tagCompound); } public NBTTagCompound getTagCompound() { diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java index 635ceb9fee..78251dac89 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/openComputers/TileEntity_GTDataServer.java @@ -25,41 +25,61 @@ package com.github.bartimaeusnek.crossmod.openComputers; import com.github.bartimaeusnek.bartworks.API.ITileAddsInformation; import com.github.bartimaeusnek.bartworks.API.ITileHasDifferentTextureSides; import com.github.bartimaeusnek.bartworks.API.ITileWithGUI; +import com.google.common.collect.BiMap; +import com.google.common.collect.HashBiMap; import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Optional; import gregtech.api.enums.ItemList; import gregtech.api.util.GT_Utility; import gregtech.common.items.behaviors.Behaviour_DataOrb; +import li.cil.oc.api.machine.Arguments; +import li.cil.oc.api.machine.Callback; +import li.cil.oc.api.machine.Context; +import li.cil.oc.api.network.SimpleComponent; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; -//@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers") -public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, ITileAddsInformation, ITileHasDifferentTextureSides/*, SimpleComponent*/ { +@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "OpenComputers") +public class TileEntity_GTDataServer extends TileEntity implements ISidedInventory, ITileWithGUI, ITileAddsInformation, ITileHasDifferentTextureSides, SimpleComponent { - private static HashMap<Long,GT_NBT_DataBase> OrbDataBase = new HashMap<>(); + private final BiMap<Long,GT_NBT_DataBase> OrbDataBase = HashBiMap.create(); private ItemStack[] mItems = new ItemStack[2]; - - - private byte TickTimer = 0; + private byte TickTimer; + @Optional.Method(modid = "OpenComputers") public String getComponentName() { return "GT-Data Server"; } -// @Callback -// @Optional.Method(modid = "OpenComputers") -// public Object[] listData(Context context, Arguments args) { -// return new String[] -// } + @Optional.Method(modid = "OpenComputers") + @Callback + public Object[] listData(Context context, Arguments args) { + Set<String> ret = new HashSet<>(); + for (Map.Entry<Long,GT_NBT_DataBase> entry : OrbDataBase.entrySet()){ + ret.add((entry.getValue().getId()+Long.MAX_VALUE)+". "+entry.getValue().getmDataTitle()); + } + return ret.toArray(new String[0]); + } + + @Optional.Method(modid = "OpenComputers") + @Callback + public Object[] imprintOrb(Context context, Arguments args) { + return new Object[]{false}; + } + private boolean isServerSide(){ return !this.worldObj.isRemote || FMLCommonHandler.instance().getSide().isServer(); } - - + @Override public void updateEntity() { if (this.TickTimer++ % 20 != 0) @@ -69,7 +89,7 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, if (GT_Utility.areStacksEqual(this.mItems[0],ItemList.Tool_DataOrb.get(1))) { if (this.mItems[0].hasTagCompound()) { if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { - TileEntity_GTDataServer.OrbDataBase.put( + this.OrbDataBase.put( GT_NBT_DataBase.getMaxID(), new GT_NBT_DataBase( Behaviour_DataOrb.getDataName(this.mItems[0]), @@ -77,6 +97,9 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, this.mItems[0].getTagCompound() ) ); + } else { + long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); + this.OrbDataBase.put(id,GT_NBT_DataBase.getGTTagFromId(id)); } } } @@ -91,7 +114,7 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, String title = data == 1 ? bookTitle : data == 2 ? punchcardData : data == 3 ? ""+mapID : "Custom Data"; String name = data == 1 ? "eBook" : data == 2 ? "Punch Card Data" : data == 3 ? "Map Data" : "Custom Data"; if (GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()) == null) { - TileEntity_GTDataServer.OrbDataBase.put( + this.OrbDataBase.put( GT_NBT_DataBase.getMaxID(), new GT_NBT_DataBase( name, @@ -99,6 +122,9 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, this.mItems[0].getTagCompound() ) ); + } else { + long id = GT_NBT_DataBase.getIdFromTag(this.mItems[0].getTagCompound()); + this.OrbDataBase.put(id,GT_NBT_DataBase.getGTTagFromId(id)); } } } @@ -119,4 +145,81 @@ public class TileEntity_GTDataServer extends TileEntity implements ITileWithGUI, public int getGUIID() { return 0; } + + @Override + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return new int[0]; + } + + @Override + public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return false; + } + + @Override + public boolean canExtractItem(int p_102008_1_, ItemStack p_102008_2_, int p_102008_3_) { + return false; + } + + @Override + public int getSizeInventory() { + return this.mItems.length; + } + + @Override + public ItemStack getStackInSlot(int p_70301_1_) { + return p_70301_1_ == 0 ? this.mItems[0] : this.mItems[1]; + } + + @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_) { + if (p_70299_1_ > 1 || p_70299_1_ < 0) + return; + this.mItems[p_70299_1_]=p_70299_2_; + } + + @Override + public String getInventoryName() { + return null; + } + + @Override + public boolean hasCustomInventoryName() { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer p_70300_1_) { + return true; + } + + @Override + public void openInventory() { + + } + + @Override + public void closeInventory() { + + } + + @Override + public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) { + return p_94041_1_ == 0; + } } diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/CustomAspects.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/CustomAspects.java index 542501ccce..267945116f 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/CustomAspects.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/CustomAspects.java @@ -22,15 +22,6 @@ package com.github.bartimaeusnek.crossmod.thaumcraft; -import com.github.bartimaeusnek.bartworks.MainMod; - -import com.github.bartimaeusnek.crossmod.thaumcraft.util.ThaumcraftHandler; -import net.minecraft.util.ResourceLocation; - -import java.lang.reflect.Array; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - public class CustomAspects { // static Constructor aspectConstructor; // static Object TRADE; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java index 3daa758a88..7911b0c9af 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/tile/GT_WandBuffer.java @@ -28,7 +28,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaBase_Item; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicBatteryBuffer; import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_Utility; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java index 3d984ed063..b753f61a4c 100644 --- a/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java +++ b/src/main/java/com/github/bartimaeusnek/crossmod/thaumcraft/util/ThaumcraftHandler.java @@ -29,6 +29,7 @@ import com.github.bartimaeusnek.bartworks.util.Pair; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TC_Aspects; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.biome.BiomeGenBase; import java.lang.reflect.InvocationTargetException; @@ -38,7 +39,7 @@ public class ThaumcraftHandler { private ThaumcraftHandler(){} private static Integer taintBiomeID; - + private static Integer magicalForestBiomeID; private static Class mWandInterface; static { @@ -57,6 +58,19 @@ public class ThaumcraftHandler { } } + public static boolean isMagicalForestBiome(int biomeID){ + if (ThaumcraftHandler.magicalForestBiomeID == null) { + try { + BiomeGenBase biome = (BiomeGenBase) Class.forName("thaumcraft.common.lib.world.ThaumcraftWorldGenerator").getField("biomeMagicalForest").get(null); + return biomeID == (ThaumcraftHandler.magicalForestBiomeID = biome.biomeID); + } catch (ClassCastException | ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) { + e.printStackTrace(); + return false; + } + } + return biomeID == ThaumcraftHandler.magicalForestBiomeID; + } + public static boolean isTaintBiome(int biomeID){ if (ThaumcraftHandler.taintBiomeID == null) { try { @@ -71,11 +85,16 @@ public class ThaumcraftHandler { } public static class AspectAdder { - private static Class mAspectListClass; + public static Class mAspectListClass; public static Class mAspectClass; - private static Method registerObjectTag; - private static Method addToList; - private static Method getName; + public static Method registerObjectTag; + public static Method addToList; + public static Method getName; + public static Method writeAspectListToNBT; + public static Method readAspectListFromNBT; + public static Method add; + public static Method getAmount; + public static Method getAspects; static { try { @@ -83,7 +102,12 @@ public class ThaumcraftHandler { ThaumcraftHandler.AspectAdder.mAspectClass = Class.forName("thaumcraft.api.aspects.Aspect"); ThaumcraftHandler.AspectAdder.addToList = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("add", ThaumcraftHandler.AspectAdder.mAspectClass,int.class); ThaumcraftHandler.AspectAdder.registerObjectTag = Class.forName("thaumcraft.api.ThaumcraftApi").getMethod("registerObjectTag",ItemStack.class, ThaumcraftHandler.AspectAdder.mAspectListClass); - ThaumcraftHandler.AspectAdder.getName = mAspectClass.getMethod("getName"); + ThaumcraftHandler.AspectAdder.getName = ThaumcraftHandler.AspectAdder.mAspectClass.getMethod("getName"); + ThaumcraftHandler.AspectAdder.writeAspectListToNBT = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("writeToNBT", NBTTagCompound.class); + ThaumcraftHandler.AspectAdder.add = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("add", ThaumcraftHandler.AspectAdder.mAspectListClass); + ThaumcraftHandler.AspectAdder.getAmount = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("getAmount", ThaumcraftHandler.AspectAdder.mAspectClass); + ThaumcraftHandler.AspectAdder.getAspects = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("getAspects"); + ThaumcraftHandler.AspectAdder.readAspectListFromNBT = ThaumcraftHandler.AspectAdder.mAspectListClass.getMethod("readFromNBT", NBTTagCompound.class); } catch (ClassNotFoundException | NoSuchMethodException e) { e.printStackTrace(); } @@ -96,7 +120,7 @@ public class ThaumcraftHandler { Object aspectList = ThaumcraftHandler.AspectAdder.mAspectListClass.newInstance(); for (Pair a : aspectPair) { if (ConfigHandler.debugLog) - DebugLog.log("Stack:"+ stack.getDisplayName() + " Damage:" +stack.getItemDamage() + " aspectPair: " + getName.invoke(a.getKey()) + " / " + a.getValue()); + DebugLog.log("Stack:"+ stack.getDisplayName() + " Damage:" +stack.getItemDamage() + " aspectPair: " + ThaumcraftHandler.AspectAdder.getName.invoke(a.getKey()) + " / " + a.getValue()); ThaumcraftHandler.AspectAdder.addToList.invoke(aspectList, a.getKey(), a.getValue()); } ThaumcraftHandler.AspectAdder.registerObjectTag.invoke(null, stack, aspectList); diff --git a/src/main/java/com/github/bartimaeusnek/preloader/PreLoaderMod.java b/src/main/java/com/github/bartimaeusnek/preloader/PreLoaderMod.java new file mode 100644 index 0000000000..b46a133df5 --- /dev/null +++ b/src/main/java/com/github/bartimaeusnek/preloader/PreLoaderMod.java @@ -0,0 +1,55 @@ +/* + * 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.preloader; + +import com.github.bartimaeusnek.bartworks.common.loaders.BeforeGTPreload; +import com.github.bartimaeusnek.crossmod.BartWorksCrossmod; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import gregtech.api.GregTech_API; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +@Mod( + modid = com.github.bartimaeusnek.preloader.PreLoaderMod.MOD_ID, name = com.github.bartimaeusnek.preloader.PreLoaderMod.NAME, version = com.github.bartimaeusnek.preloader.PreLoaderMod.VERSION, + dependencies = "required-before:IC2; " + + "required-before:gregtech; " + + "required-before:bartworks;" + + "before:GalacticraftMars; " + + "before:GalacticraftCore; " + + "before:miscutils;" + + "before:dreamcraft;" + + "before:EMT;" +) +public class PreLoaderMod { + public static final String NAME = "BartWorks Preloader Mod"; + public static final String VERSION = "0.0.1"; + public static final String MOD_ID = "bartworkspreloader"; + public static final Logger LOGGER = LogManager.getLogger(BartWorksCrossmod.NAME); + + + @Mod.EventHandler + public void preInit(FMLPreInitializationEvent preinit) { + GregTech_API.sBeforeGTPreload.add(new BeforeGTPreload()); + } +} diff --git a/src/main/resources/assets/bartworks/lang/en_US.lang b/src/main/resources/assets/bartworks/lang/en_US.lang index 0aac211cdf..b0b3c9b7b6 100644 --- a/src/main/resources/assets/bartworks/lang/en_US.lang +++ b/src/main/resources/assets/bartworks/lang/en_US.lang @@ -159,4 +159,6 @@ tooltip.tile.eic.0.name=Controller Block for the Electric Implosion Compressor;S planet.Ross128b=Ross128b moon.Ross128ba=Ross128ba star.Ross128=Ross128 -solarsystem.Ross128System=Ross128-System
\ No newline at end of file +solarsystem.Ross128System=Ross128-System + +itemGroup.bw.MetaItems.0=BartWorks Circuit Overhaul Items
\ No newline at end of file diff --git a/src/main/resources/assets/bartworks/textures/items/WrapOverlay.png b/src/main/resources/assets/bartworks/textures/items/WrapOverlay.png Binary files differnew file mode 100644 index 0000000000..f6d80e292e --- /dev/null +++ b/src/main/resources/assets/bartworks/textures/items/WrapOverlay.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/0.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/0.png Binary files differnew file mode 100644 index 0000000000..e16102588a --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/0.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/1.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/1.png Binary files differnew file mode 100644 index 0000000000..491164695b --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/1.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/10.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/10.png Binary files differnew file mode 100644 index 0000000000..38429ed78d --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/10.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/11.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/11.png Binary files differnew file mode 100644 index 0000000000..3901815927 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/11.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/12.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/12.png Binary files differnew file mode 100644 index 0000000000..c97ec3384c --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/12.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/13.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/13.png Binary files differnew file mode 100644 index 0000000000..40e5c92817 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/13.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/14.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/14.png Binary files differnew file mode 100644 index 0000000000..10c6f20de0 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/14.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/2.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/2.png Binary files differnew file mode 100644 index 0000000000..968e0745c9 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/2.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/3.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/3.png Binary files differnew file mode 100644 index 0000000000..9e22dd6726 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/3.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/4.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/4.png Binary files differnew file mode 100644 index 0000000000..86411e18bd --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/4.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/5.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/5.png Binary files differnew file mode 100644 index 0000000000..57a7c7a932 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/5.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/6.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/6.png Binary files differnew file mode 100644 index 0000000000..9f68371247 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/6.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/7.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/7.png Binary files differnew file mode 100644 index 0000000000..7a322b76c0 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/7.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/8.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/8.png Binary files differnew file mode 100644 index 0000000000..9fe039db81 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/8.png diff --git a/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/9.png b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/9.png Binary files differnew file mode 100644 index 0000000000..457a51b7a1 --- /dev/null +++ b/src/main/resources/assets/gregtech/textures/items/gt.bwMetaGeneratedItem0/9.png diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 82e2fed82f..ce4324d98d 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -8,7 +8,7 @@ "url": "https://github.com/bartimaeusnek/bartworks", "updateUrl": "", "authorList": ["bartimaeusnek"], - "credits": "Gregorius Techneticies for making gregtech and allowing me to port his old stuff. Austin Appleby and Yonik Seeley for creating and putting the MurmurHash3 into the public domain.", + "credits": "Gregorius Techneticies for making gregtech and allowing me to port his old stuff.\n Austin Appleby and Yonik Seeley for creating and putting the MurmurHash3 into the public domain.\n Spluff and EmeraldsEmerald for the Awesome Textures aswell.", "logoFile": "", "screenshots": [], "dependencies": [] |