diff options
32 files changed, 1392 insertions, 297 deletions
diff --git a/build.properties b/build.properties index d657940999..8264c7a661 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -tectech.version=1.0.0 +tectech.version=3.3.1 ic2.version=2.2.790-experimental nei.version=1.0.3.74 diff --git a/src/main/java/com/github/technus/tectech/CustomItemList.java b/src/main/java/com/github/technus/tectech/CustomItemList.java index 22e481be5b..65bdba09b7 100644 --- a/src/main/java/com/github/technus/tectech/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/CustomItemList.java @@ -28,8 +28,12 @@ public enum CustomItemList implements IItemContainer eM_in_UV,eM_in_UHV,eM_in_UEV,eM_in_UIV,eM_in_UMV,eM_in_UXV, eM_out_UV,eM_out_UHV,eM_out_UEV,eM_out_UIV,eM_out_UMV,eM_out_UXV, eM_muffler_UV,eM_muffler_UHV,eM_muffler_UEV,eM_muffler_UIV,eM_muffler_UMV,eM_muffler_UXV, - Parametrizer_Hatch,Uncertainty_Hatch,UncertaintyX_Hatch,eM_Casing,eM_Field,eM_Field_Casing,eM_Coil,eM_Tele,eM_TimeSpaceWarp,debugBlock, - Machine_Multi_BHG,Machine_Multi_EM,Machine_Multi_MatterToEM,Machine_Multi_EMToMatter,Machine_Multi_Collider,Machine_Multi_Wormhole,Machine_Multi_EMCrafter,Machine_Multi_EMjunction; + Parametrizer_Hatch,Uncertainty_Hatch,UncertaintyX_Hatch, + eM_Casing,eM_Field,eM_Field_Casing,eM_Coil,eM_Tele,eM_TimeSpaceWarp, + debugBlock, + Machine_Multi_MatterToEM,Machine_Multi_EMToMatter,Machine_Multi_EMjunction, + Machine_Multi_Transformer,Machine_Multi_Computer, + Machine_Multi_BHG,Machine_Multi_EMmachine,Machine_Multi_Collider,Machine_Multi_Wormhole,Machine_Multi_EMCrafter,Machine_Multi_Scanner; private ItemStack mStack = null; @@ -146,6 +150,4 @@ public enum CustomItemList implements IItemContainer for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, getWildcard(1)); return this; } - - }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/GT_CustomLoader.java b/src/main/java/com/github/technus/tectech/GT_CustomLoader.java index 82d97663c0..918725f759 100644 --- a/src/main/java/com/github/technus/tectech/GT_CustomLoader.java +++ b/src/main/java/com/github/technus/tectech/GT_CustomLoader.java @@ -1,22 +1,23 @@ package com.github.technus.tectech; -import com.github.technus.tectech.blocks.QuantumGlass; import com.github.technus.tectech.casing.GT_Loader_CasingsTT; -import cpw.mods.fml.common.registry.GameRegistry; public class GT_CustomLoader { + private GT_Loader_Machines ElementalLoader; + private GT_Loader_CasingsTT ElementalCasing; + private GT_Loader_Recipes ElementalRecipes; - - public GT_CustomLoader() { - ElementalCasing = new GT_Loader_CasingsTT(); - ElementalLoader = new GT_Loader_Elemental(); - } - - private GT_Loader_Elemental ElementalLoader = null; - private GT_Loader_CasingsTT ElementalCasing = null; + public GT_CustomLoader() {} public void run() { + ElementalCasing = new GT_Loader_CasingsTT(); + ElementalLoader = new GT_Loader_Machines(); ElementalCasing.run(); ElementalLoader.run(); } + + public void run2() { + ElementalRecipes = new GT_Loader_Recipes(); + ElementalRecipes.run(); + } } diff --git a/src/main/java/com/github/technus/tectech/GT_Loader_Elemental.java b/src/main/java/com/github/technus/tectech/GT_Loader_Machines.java index 73fd076604..f11bd7f3ff 100644 --- a/src/main/java/com/github/technus/tectech/GT_Loader_Elemental.java +++ b/src/main/java/com/github/technus/tectech/GT_Loader_Machines.java @@ -1,38 +1,12 @@ package com.github.technus.tectech; -import com.github.technus.tectech.elementalMatter.classes.cElementalPrimitive; -import com.github.technus.tectech.elementalMatter.definitions.*; import com.github.technus.tectech.elementalMatter.machine.*; /** * Created by danie_000 on 16.11.2016. */ -public class GT_Loader_Elemental implements Runnable { +public class GT_Loader_Machines implements Runnable { public void run() { - - // =================================================================================================== - // def init - // =================================================================================================== - - cElementalPrimitive.run(); - - cPrimitiveDefinition.run(); - - eQuarkDefinition.run(); - eLeptonDefinition.run(); - eNeutrinoDefinition.run(); - eBosonDefinition.run(); - - dHadronDefinition.run(); - - dAtomDefinition.run(); - - // =================================================================================================== - // Recipe init - // =================================================================================================== - - GT_MetaTileEntity_EMquantifier.recipeInit(); - // =================================================================================================== // eM IN // =================================================================================================== @@ -196,21 +170,24 @@ public class GT_Loader_Elemental implements Runnable { // MULTIBLOCKS EM // =================================================================================================== - CustomItemList.Machine_Multi_MatterToEM.set(new GT_MetaTileEntity_EMquantifier(12160,"multimachine.mattertoem","Matter Quantifier").getStackForm(1L)); - CustomItemList.Machine_Multi_EMToMatter.set(new GT_MetaTileEntity_EMdequantifier(12161,"multimachine.emtomatter","Matter De-quantifier").getStackForm(1L)); - CustomItemList.Machine_Multi_EMjunction.set(new GT_MetaTileEntity_EMjunction(12162,"multimachine.emjunction","Matter junction").getStackForm(1L)); - CustomItemList.Machine_Multi_EM.set(new GT_MetaTileEntity_EMmachine(12163,"multimachine.emprocessing","Quantum Processing Machine").getStackForm(1L)); - CustomItemList.Machine_Multi_EMCrafter.set(new GT_MetaTileEntity_EMcrafter(12164,"multimachine.emcrafter","Matter Assembler").getStackForm(1L)); - CustomItemList.Machine_Multi_Collider.set(new GT_MetaTileEntity_EMcollider(12165,"multimachine.emcollider","Matter Collider").getStackForm(1L)); - CustomItemList.Machine_Multi_BHG.set(new GT_MetaTileEntity_EMbhg(12166,"multimachine.blackholegenerator","Black Hole Generator").getStackForm(1L)); - CustomItemList.Machine_Multi_Wormhole.set(new GT_MetaTileEntity_EMwormhole(12167,"multimachine.emwormhole","Wormhole").getStackForm(1L)); + CustomItemList.Machine_Multi_Transformer.set(new GT_MetaTileEntity_EMtransformer(12160,"multimachine.em.transformer", "Active Transformer").getStackForm(1L)); + CustomItemList.Machine_Multi_MatterToEM.set(new GT_MetaTileEntity_EMquantifier(12161,"multimachine.em.mattertoem","Matter Quantifier").getStackForm(1L)); + CustomItemList.Machine_Multi_EMToMatter.set(new GT_MetaTileEntity_EMdequantifier(12162,"multimachine.em.emtomatter","Matter De-quantifier").getStackForm(1L)); + CustomItemList.Machine_Multi_EMjunction.set(new GT_MetaTileEntity_EMjunction(12163,"multimachine.em.junction","Matter junction").getStackForm(1L)); + CustomItemList.Machine_Multi_EMmachine.set(new GT_MetaTileEntity_EMmachine(12164,"multimachine.em.processing","Quantum Processing Machine").getStackForm(1L)); + CustomItemList.Machine_Multi_EMCrafter.set(new GT_MetaTileEntity_EMcrafter(12165,"multimachine.em.crafter","Matter Assembler").getStackForm(1L)); + CustomItemList.Machine_Multi_Collider.set(new GT_MetaTileEntity_EMcollider(12166,"multimachine.em.collider","Matter Collider").getStackForm(1L)); + CustomItemList.Machine_Multi_BHG.set(new GT_MetaTileEntity_EMbhg(12167,"multimachine.em.blackholegenerator","Black Hole Generator").getStackForm(1L)); + CustomItemList.Machine_Multi_Wormhole.set(new GT_MetaTileEntity_EMwormhole(12168,"multimachine.em.wormhole","Wormhole").getStackForm(1L)); + CustomItemList.Machine_Multi_Scanner.set(new GT_MetaTileEntity_EMscanner(12169,"multimachine.em.scanner","Elemental Scanner").getStackForm(1L)); + CustomItemList.Machine_Multi_Computer.set(new GT_MetaTileEntity_Computer(12170,"multimachine.em.computer","Quantum computer").getStackForm(1L)); // =================================================================================================== // Hatches EM // =================================================================================================== - CustomItemList.Parametrizer_Hatch.set(new GT_MetaTileEntity_Hatch_Param(12170,"hatch.param.tier.06","Parametrizer for machines",6).getStackForm(1L)); - CustomItemList.Uncertainty_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12171,"hatch.emcertain.tier.06","Uncertainty resolver",6).getStackForm(1L)); - CustomItemList.UncertaintyX_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12172,"hatch.emcertain.tier.10","Uncertainty resolver X",10).getStackForm(1L)); + CustomItemList.Parametrizer_Hatch.set(new GT_MetaTileEntity_Hatch_Param(12180,"hatch.param.tier.06","Parametrizer for machines",6).getStackForm(1L)); + CustomItemList.Uncertainty_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12181,"hatch.emcertain.tier.06","Uncertainty resolver",6).getStackForm(1L)); + CustomItemList.UncertaintyX_Hatch.set(new GT_MetaTileEntity_Hatch_Uncertainty(12182,"hatch.emcertain.tier.10","Uncertainty resolver X",10).getStackForm(1L)); // =================================================================================================== // EM pipe diff --git a/src/main/java/com/github/technus/tectech/GT_Loader_Recipes.java b/src/main/java/com/github/technus/tectech/GT_Loader_Recipes.java new file mode 100644 index 0000000000..2d26587d31 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/GT_Loader_Recipes.java @@ -0,0 +1,35 @@ +package com.github.technus.tectech; + +import com.github.technus.tectech.elementalMatter.classes.cElementalPrimitive; +import com.github.technus.tectech.elementalMatter.definitions.*; +import com.github.technus.tectech.elementalMatter.machine.GT_MetaTileEntity_EMquantifier; + +/** + * Created by danie_000 on 16.11.2016. + */ +public class GT_Loader_Recipes implements Runnable { + public void run() { + // =================================================================================================== + // def init + // =================================================================================================== + + cElementalPrimitive.run(); + + cPrimitiveDefinition.run(); + + eQuarkDefinition.run(); + eLeptonDefinition.run(); + eNeutrinoDefinition.run(); + eBosonDefinition.run(); + + dHadronDefinition.run(); + + dAtomDefinition.run(); + + // =================================================================================================== + // Recipe init + // =================================================================================================== + + GT_MetaTileEntity_EMquantifier.run(); + } +} diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 090b55604d..4c07e616c5 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -1,9 +1,9 @@ package com.github.technus.tectech; - import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.auxiliary.TecTechConfig; import com.github.technus.tectech.blocks.QuantumGlass; import com.github.technus.tectech.proxy.CommonProxy; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -13,13 +13,17 @@ 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.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import eu.usrv.yamcore.auxiliary.IngameErrorLog; import eu.usrv.yamcore.auxiliary.LogHelper; - -import java.util.Random; +import eu.usrv.yamcore.items.ModItemManager; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, dependencies = "required-after:Forge@[10.13.4.1614,);" - + "required-after:YAMCore@[0.5.73,);") + + "required-after:YAMCore@[0.5.73,);" + "required-after:gregtech;") public class TecTech { @SidedProxy(clientSide = Reference.CLIENTSIDE, serverSide = Reference.SERVERSIDE) @@ -28,12 +32,15 @@ public class TecTech { @Instance(Reference.MODID) public static TecTech instance; - //public static CreativeTabsManager TabManager = null; + //public static ModFluidManager FluidManager = null; + //public static ModBlockManager BlockManager = null; + public static ModItemManager ItemManager = null; public static IngameErrorLog Module_AdminErrorLogs = null; public static GT_CustomLoader GTCustomLoader = null; public static TecTechConfig ModConfig; - public static Random Rnd = null; + public static XSTR Rnd = null; public static LogHelper Logger = new LogHelper(Reference.MODID); + public static CreativeTabs mainTab=null; public static void AddLoginError(String pMessage) { if (Module_AdminErrorLogs != null) @@ -44,13 +51,16 @@ public class TecTech { public void PreLoad(FMLPreInitializationEvent PreEvent) { Logger.setDebugOutput(true); - Rnd = new Random(System.currentTimeMillis()); + Rnd = new XSTR(); + + //ItemManager = new ModItemManager(Refstrings.MODID); + //BlockManager = new ModBlockManager(Refstrings.MODID); + //FluidManager = new ModFluidManager(Refstrings.MODID); ModConfig = new TecTechConfig(PreEvent.getModConfigurationDirectory(), Reference.COLLECTIONNAME, Reference.MODID); if (!ModConfig.LoadConfig()) - Logger.error( - String.format("%s could not load its config file. Things are going to be weird!", Reference.MODID)); + Logger.error(Reference.MODID+" could not load its config file. Things are going to be weird!"); if (ModConfig.ModAdminErrorLogs_Enabled) { Logger.debug("Module_AdminErrorLogs is enabled"); @@ -68,6 +78,27 @@ public class TecTech { public void PostLoad(FMLPostInitializationEvent PostEvent) { GTCustomLoader = new GT_CustomLoader(); GTCustomLoader.run(); + GTCustomLoader.run2(); + + mainTab=new CreativeTabs("TecTech") { + @SideOnly(Side.CLIENT) + @Override + public Item getTabIconItem() { + return CustomItemList.eM_TimeSpaceWarp.getItem(); + } + + @SideOnly(Side.CLIENT) + @Override + public ItemStack getIconItemStack() { + return CustomItemList.eM_TimeSpaceWarp.getWithDamage(1,8); + } + }; + RegisterThingsInTabs(); + if(Loader.isModLoaded("dreamcraft"));//TODO init recipes for GTNH coremod + } + + public void RegisterThingsInTabs(){ + QuantumGlass.INSTANCE.setCreativeTab(mainTab);//TODO? COPY PASTE GT CLASSES TO ADD MY THINGS TO CREATIVE TAB } /** diff --git a/src/main/java/com/github/technus/tectech/XSTR.java b/src/main/java/com/github/technus/tectech/XSTR.java new file mode 100644 index 0000000000..e733e8cfb8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/XSTR.java @@ -0,0 +1,255 @@ +package com.github.technus.tectech; +/** + * A subclass of java.util.random that implements the Xorshift random number + * generator + * + * - it is 30% faster than the generator from Java's library - it produces + * random sequences of higher quality than java.util.Random - this class also + * provides a clone() function + * + * Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); + * //pull a random number + * + * To use the class in legacy code, you may also instantiate an XSRandom object + * and assign it to a java.util.Random object: java.util.Random rand = new + * XSRandom(); + * + * for an explanation of the algorithm, see + * http://demesos.blogspot.com/2011/09/pseudo-random-number-generators.html + * + * @author Wilfried Elmenreich University of Klagenfurt/Lakeside Labs + * http://www.elmenreich.tk + * + * This code is released under the GNU Lesser General Public License Version 3 + * http://www.gnu.org/licenses/lgpl-3.0.txt + */ + +import java.util.Random; +import java.util.concurrent.atomic.AtomicLong; + +/** + * XSTR - Xorshift ThermiteRandom + * Modified by Bogdan-G + * 03.06.2016 + * version 0.0.4 + */ +public class XSTR extends Random { + + private static final long serialVersionUID = 6208727693524452904L; + private long seed; + private long last; + private static final long GAMMA = 0x9e3779b97f4a7c15L; + private static final int PROBE_INCREMENT = 0x9e3779b9; + private static final long SEEDER_INCREMENT = 0xbb67ae8584caa73bL; + private static final double DOUBLE_UNIT = 0x1.0p-53; // 1.0 / (1L << 53) + private static final float FLOAT_UNIT = 0x1.0p-24f; // 1.0f / (1 << 24) + + /* + MODIFIED BY: Robotia + Modification: Implemented Random class seed generator + */ + /** + * Creates a new pseudo random number generator. The seed is initialized to + * the current time, as if by + * <code>setSeed(System.currentTimeMillis());</code>. + */ + public XSTR() { + this(seedUniquifier() ^ System.nanoTime()); + } + private static final AtomicLong seedUniquifier + = new AtomicLong(8682522807148012L); + + private static long seedUniquifier() { + // L'Ecuyer, "Tables of Linear Congruential Generators of + // Different Sizes and Good Lattice Structure", 1999 + for (;;) { + long current = seedUniquifier.get(); + long next = current * 181783497276652981L; + if (seedUniquifier.compareAndSet(current, next)) { + return next; + } + } + } + + /** + * Creates a new pseudo random number generator, starting with the specified + * seed, using <code>setSeed(seed);</code>. + * + * @param seed the initial seed + */ + public XSTR(long seed) { + this.seed = seed; + } + public boolean nextBoolean() { + return next(1) != 0; + } + + public double nextDouble() { + return (((long)(next(26)) << 27) + next(27)) * DOUBLE_UNIT; + } + /** + * Returns the current state of the seed, can be used to clone the object + * + * @return the current seed + */ + public synchronized long getSeed() { + return seed; + } + + /** + * Sets the seed for this pseudo random number generator. As described + * above, two instances of the same random class, starting with the same + * seed, produce the same results, if the same methods are called. + * + * @param seed the new seed + */ + public synchronized void setSeed(long seed) { + this.seed = seed; + } + + /** + * @return Returns an XSRandom object with the same state as the original + */ + @Override + public gregtech.api.objects.XSTR clone() { + return new gregtech.api.objects.XSTR(getSeed()); + } + + /** + * Implementation of George Marsaglia's elegant Xorshift random generator + * 30% faster and better quality than the built-in java.util.random see also + * see http://www.javamex.com/tutorials/random_numbers/xorshift.shtml + * + * @param nbits + * @return + */ + public int next(int nbits) { + long x = seed; + x ^= (x << 21); + x ^= (x >>> 35); + x ^= (x << 4); + seed = x; + x &= ((1L << nbits) - 1); + return (int) x; + } + boolean haveNextNextGaussian = false; + double nextNextGaussian = 0; + synchronized public double nextGaussian() { + // See Knuth, ACP, Section 3.4.1 Algorithm C. + if (haveNextNextGaussian) { + haveNextNextGaussian = false; + return nextNextGaussian; + } else { + double v1, v2, s; + do { + v1 = 2 * nextDouble() - 1; // between -1 and 1 + v2 = 2 * nextDouble() - 1; // between -1 and 1 + s = v1 * v1 + v2 * v2; + } while (s >= 1 || s == 0); + double multiplier = StrictMath.sqrt(-2 * StrictMath.log(s)/s); + nextNextGaussian = v2 * multiplier; + haveNextNextGaussian = true; + return v1 * multiplier; + } + } + /** + * Returns a pseudorandom, uniformly distributed {@code int} value between 0 + * (inclusive) and the specified value (exclusive), drawn from this random + * number generator's sequence. The general contract of {@code nextInt} is + * that one {@code int} value in the specified range is pseudorandomly + * generated and returned. All {@code bound} possible {@code int} values are + * produced with (approximately) equal probability. The method + * {@code nextInt(int bound)} is implemented by class {@code Random} as if + * by: + * <pre> {@code + * public int nextInt(int bound) { + * if (bound <= 0) + * throw new IllegalArgumentException("bound must be positive"); + * + * if ((bound & -bound) == bound) // i.e., bound is a power of 2 + * return (int)((bound * (long)next(31)) >> 31); + * + * int bits, val; + * do { + * bits = next(31); + * val = bits % bound; + * } while (bits - val + (bound-1) < 0); + * return val; + * }}</pre> + * + * <p>The hedge "approx + * imately" is used in the foregoing description only because the next + * method is only approximately an unbiased source of independently chosen + * bits. If it were a perfect source of randomly chosen bits, then the + * algorithm shown would choose {@code int} values from the stated range + * with perfect uniformity. + * <p> + * The algorithm is slightly tricky. It rejects values that would result in + * an uneven distribution (due to the fact that 2^31 is not divisible by n). + * The probability of a value being rejected depends on n. The worst case is + * n=2^30+1, for which the probability of a reject is 1/2, and the expected + * number of iterations before the loop terminates is 2. + * <p> + * The algorithm treats the case where n is a power of two specially: it + * returns the correct number of high-order bits from the underlying + * pseudo-random number generator. In the absence of special treatment, the + * correct number of <i>low-order</i> bits would be returned. Linear + * congruential pseudo-random number generators such as the one implemented + * by this class are known to have short periods in the sequence of values + * of their low-order bits. Thus, this special case greatly increases the + * length of the sequence of values returned by successive calls to this + * method if n is a small power of two. + * + * @param bound the upper bound (exclusive). Must be positive. + * @return the next pseudorandom, uniformly distributed {@code int} value + * between zero (inclusive) and {@code bound} (exclusive) from this random + * number generator's sequence + * @throws IllegalArgumentException if bound is not positive + * @since 1.2 + */ + public int nextInt(int bound) { + //if (bound <= 0) { + //throw new RuntimeException("BadBound"); + //} + + /*int r = next(31); + int m = bound - 1; + if ((bound & m) == 0) // i.e., bound is a power of 2 + { + r = (int) ((bound * (long) r) >> 31); + } else { + for (int u = r; + u - (r = u % bound) + m < 0; + u = next(31)) + ; + } + return r;*/ + //speedup, new nextInt ~+40% + last = seed ^ (seed << 21); + last ^= (last >>> 35); + last ^= (last << 4); + seed = last; + int out = (int) last % bound; + return (out < 0) ? -out : out; + } + public int nextInt() { + return next(32); + } + + public float nextFloat() { + return next(24) * FLOAT_UNIT; + } + + public long nextLong() { + // it's okay that the bottom word remains signed. + return ((long)(next(32)) << 32) + next(32); + } + + public void nextBytes(byte[] bytes_arr) { + for (int iba = 0, lenba = bytes_arr.length; iba < lenba; ) + for (int rndba = nextInt(), + nba = Math.min(lenba - iba, Integer.SIZE/Byte.SIZE); + nba-- > 0; rndba >>= Byte.SIZE) + bytes_arr[iba++] = (byte)rndba; + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/auxiliary/TecTechConfig.java b/src/main/java/com/github/technus/tectech/auxiliary/TecTechConfig.java index 0eb8a90d8f..4613bc193f 100644 --- a/src/main/java/com/github/technus/tectech/auxiliary/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/auxiliary/TecTechConfig.java @@ -7,20 +7,28 @@ import java.io.File; public class TecTechConfig extends ConfigManager { public TecTechConfig(File pConfigBaseDirectory, String pModCollectionDirectory, String pModID) { super(pConfigBaseDirectory, pModCollectionDirectory, pModID); - } public boolean ModAdminErrorLogs_Enabled; + public boolean DEBUG_MODE; + public boolean BOOM_ENABLE; + @Override protected void PreInit() { ModAdminErrorLogs_Enabled = false; + DEBUG_MODE=false; + BOOM_ENABLE=true; } @Override protected void Init() { ModAdminErrorLogs_Enabled = _mainConfig.getBoolean("AdminErrorLog", "Modules", ModAdminErrorLogs_Enabled, "If set to true, every op/admin will receive all errors occoured during the startup phase as ingame message on join"); + DEBUG_MODE=_mainConfig.getBoolean("DebugPrint", "Debug", DEBUG_MODE, + "Enables logging into System.out"); + BOOM_ENABLE=_mainConfig.getBoolean("BoomEnable","Features", BOOM_ENABLE, + "Set to false to disable explosions on everything bad that you can do (this will not be available after release)"); } @Override diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/Behaviour_elementalMatterContainer.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/Behaviour_elementalMatterContainer.java index dcef8a8d7a..6b28e3ba0a 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/Behaviour_elementalMatterContainer.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/Behaviour_elementalMatterContainer.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.elementalMatter.classes; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.commonValues; import com.github.technus.tectech.elementalMatter.interfaces.iElementalInstanceContainer; import gregtech.api.interfaces.IItemBehaviour; @@ -19,8 +20,6 @@ import net.minecraft.world.World; import java.util.Collections; import java.util.List; -import static com.github.technus.tectech.elementalMatter.commonValues.DEBUGMODE; - /** * Created by danie_000 on 11.12.2016. * used in custom GT build! debug purposes @@ -42,7 +41,7 @@ public final class Behaviour_elementalMatterContainer extends Behaviour_None { try { content.putUnifyAll(cElementalInstanceStackTree.fromNBT(tNBT.getCompoundTag("content"))); }catch (tElementalException e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return true; } ((iElementalInstanceContainer) metaTE).purgeOverflow(); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinition.java index 807d6991ae..827df7e684 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinition.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.elementalMatter.classes; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; import com.github.technus.tectech.elementalMatter.interfaces.iHasElementalDefinition; import net.minecraft.nbt.NBTTagCompound; @@ -7,7 +8,6 @@ import net.minecraft.nbt.NBTTagCompound; import java.lang.reflect.Method; import java.util.TreeMap; -import static com.github.technus.tectech.elementalMatter.commonValues.DEBUGMODE; import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveDefinition.debug__; /** @@ -28,7 +28,7 @@ public abstract class cElementalDefinition implements iElementalDefinition { try { return (iElementalDefinition) nbtCreationBind.get(nbt.getByte("t")).invoke(null, nbt); }catch(Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return debug__; } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStack.java index 8c752ea5c5..8698463bca 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStack.java @@ -1,8 +1,8 @@ package com.github.technus.tectech.elementalMatter.classes; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; import com.github.technus.tectech.elementalMatter.interfaces.iHasElementalDefinition; -import gregtech.api.objects.XSTR; import net.minecraft.nbt.NBTTagCompound; import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveDefinition.null__; @@ -11,8 +11,6 @@ import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveD * Created by danie_000 on 22.10.2016. */ public final class cElementalInstanceStack implements iHasElementalDefinition { - private static final XSTR xstr = new XSTR(); - public final iElementalDefinition definition; //energy - if positive then particle should try to decay public int energy; @@ -41,7 +39,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { if (color < (byte) 0) {//transforms colorable??? into proper color this.color = color; } else { - this.color = (byte) (xstr.nextInt(3)); + this.color = (byte) (TecTech.Rnd.nextInt(3)); } this.lifeTimeMult = lifeTimeMult; this.lifeTime = definition.getRawLifeTime() * this.lifeTimeMult; @@ -84,7 +82,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { public byte nextColor() { if (this.color < (byte) 0) return this.color; - this.color = (byte) (xstr.nextInt(3)); + this.color = (byte) (TecTech.Rnd.nextInt(3)); return this.color; } @@ -177,7 +175,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } for (int i = 0; i < amountRemaining; i++) { - double rand = (double) (xstr.nextFloat()); + double rand = (double) (TecTech.Rnd.nextFloat()); for (int j = 0; j < differentDecays; j++) {//looking for the thing it decayed into rand -= (double) (decays[j].probability); if (rand <= 0D) { diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalPrimitive.java index 89efa0cc71..eb7375555b 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalPrimitive.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.elementalMatter.classes; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; import net.minecraft.client.Minecraft; import net.minecraft.crash.CrashReport; @@ -9,8 +10,6 @@ import net.minecraftforge.fluids.FluidStack; import java.util.TreeMap; -import static com.github.technus.tectech.elementalMatter.commonValues.DEBUGMODE; - /** * Created by danie_000 on 22.10.2016. * EXTEND THIS TO ADD NEW PRIMITIVES, WATCH OUT FOR ID'S!!! (-1 to 32 can be assumed as used) @@ -167,7 +166,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { try { cElementalDefinition.addCreatorFromNBT(nbtType, cElementalPrimitive.class.getMethod("fromNBT", NBTTagCompound.class)); } catch (Exception e) { - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); } } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/commonValues.java b/src/main/java/com/github/technus/tectech/elementalMatter/commonValues.java index 1a1ff56aca..8f71e93c23 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/commonValues.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/commonValues.java @@ -19,6 +19,4 @@ public final class commonValues { // - in case some hatches are not in multiblock structure public final static byte multiCheckAt = 12;// multiblock checks it's state public final static byte disperseAt = 14;// overflow hatches perform disperse - - public final static boolean DEBUGMODE = true; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dAtomDefinition.java index a07509adf5..55048c9547 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dAtomDefinition.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.elementalMatter.definitions; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.classes.*; import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; import gregtech.api.objects.XSTR; @@ -7,12 +8,9 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.TreeSet; +import java.util.*; import static com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStackTree.stackUpTree; -import static com.github.technus.tectech.elementalMatter.commonValues.DEBUGMODE; import static com.github.technus.tectech.elementalMatter.definitions.eBosonDefinition.boson_Y__; import static com.github.technus.tectech.elementalMatter.definitions.eBosonDefinition.deadEnd; @@ -21,8 +19,11 @@ import static com.github.technus.tectech.elementalMatter.definitions.eBosonDefin */ public final class dAtomDefinition extends cElementalDefinition { private static final byte nbtType=(byte)'a'; - private static final XSTR xstr = new XSTR(); - private static final HashMap<Integer,TreeSet<Integer>> stableIsotopes=new HashMap<>(); + private static final Random xstr = new XSTR();//NEEDS SEPARATE! + private static HashMap<Integer,TreeSet<Integer>> stableIsotopes=new HashMap<>(); + private static final TreeMap<Integer,dAtomDefinition> stableAtoms=new TreeMap<>(); + private static HashMap<Integer,TreeMap<Float,Integer>> mostStableUnstableIsotopes=new HashMap<>(); + private static final TreeMap<Integer,dAtomDefinition> unstableAtoms=new TreeMap<>(); private static cElementalDefinitionStack alfa; //float-mass in eV/c^2 @@ -240,7 +241,7 @@ public final class dAtomDefinition extends cElementalDefinition { if(type!=1) return (negative?"~? ":"? ") +nomenclature.Name[element]; return negative?"~"+ nomenclature.Name[element]:nomenclature.Name[element]; }catch(Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return (negative?"Element: ~":"Element: ") + element; } } @@ -252,12 +253,12 @@ public final class dAtomDefinition extends cElementalDefinition { try{ return (negative?"~":"") + nomenclature.Symbol[element]+" N:"+isotope+" I:"+getIonization(); }catch(Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); try { int s100 = element / 100, s1 = (element/10) % 10, s10 = (element) % 10; return (negative?"~":"") + nomenclature.SymbolIUPAC[10+s100]+nomenclature.SymbolIUPAC[s10]+nomenclature.SymbolIUPAC[s1]+ " N:" + isotope + " I:" + getIonization(); }catch (Exception E){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return (negative?"~":"") + "? N:" + isotope + " I:" + getIonization(); } } @@ -294,7 +295,7 @@ public final class dAtomDefinition extends cElementalDefinition { deadEnd }; }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); } } return getNaturalDecayInstant(); @@ -310,7 +311,7 @@ public final class dAtomDefinition extends cElementalDefinition { deadEnd }; }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); } } return getNaturalDecayInstant(); @@ -327,7 +328,7 @@ public final class dAtomDefinition extends cElementalDefinition { deadEnd }; }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); } } return getNaturalDecayInstant(); @@ -344,7 +345,7 @@ public final class dAtomDefinition extends cElementalDefinition { deadEnd }; }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); } } return getNaturalDecayInstant(); @@ -370,7 +371,7 @@ public final class dAtomDefinition extends cElementalDefinition { decaysInto.add(new cElementalDefinitionStack(new dAtomDefinition(newAtom.toArray(new cElementalDefinitionStack[newAtom.size()])),1)); return new cElementalDecay[]{new cElementalDecay(0.95F, decaysInto.toArray(new cElementalDefinitionStack[decaysInto.size()])), eBosonDefinition.deadEnd}; }catch(tElementalException e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); for(cElementalDefinitionStack things:newAtom){ decaysInto.add(things); } @@ -404,18 +405,20 @@ public final class dAtomDefinition extends cElementalDefinition { try { return new dAtomDefinition(false, antiElements); } catch (tElementalException e) { - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return null; } } @Override public FluidStack materializesIntoFluid() { + return null; } @Override public ItemStack materializesIntoItem() { + return null; } @@ -443,7 +446,7 @@ public final class dAtomDefinition extends cElementalDefinition { try { return new dAtomDefinition(stacks); }catch (tElementalException e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return null; } } @@ -452,11 +455,12 @@ public final class dAtomDefinition extends cElementalDefinition { try { cElementalDefinition.addCreatorFromNBT(nbtType, dAtomDefinition.class.getMethod("fromNBT", NBTTagCompound.class)); }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); } //populate stable isotopes - for(int element=0;element<180;element++) - for(int isotope=0;isotope<180;isotope++){ + el: + for(int element=1;element<84;element++) + for(int isotope=0;isotope<130;isotope++){ xstr.setSeed((long) (element+1)*(isotope+100)); //stability curve final int StableIsotope = stableIzoCurve(element); @@ -465,33 +469,57 @@ public final class dAtomDefinition extends cElementalDefinition { final float rawLifeTime= calculateLifeTime(izoDiff,izoDiffAbs,element,isotope,false); if(isStable(rawLifeTime)){ TreeSet<Integer> isotopes=stableIsotopes.get(element); - if(isotopes==null) - stableIsotopes.put(element,isotopes=new TreeSet<>()); + if(isotopes==null) stableIsotopes.put(element,isotopes=new TreeSet<>()); isotopes.add(isotope); } } + + for(int element=84;element<150;element++) + for(int isotope=0;isotope<180;isotope++){ + xstr.setSeed((long) (element+1)*(isotope+100)); + //stability curve + final int Isotope = stableIzoCurve(element); + final int izoDiff =isotope-Isotope; + final int izoDiffAbs = Math.abs(izoDiff); + final float rawLifeTime= calculateLifeTime(izoDiff,izoDiffAbs,element,isotope,false); + TreeMap<Float,Integer> isotopes=mostStableUnstableIsotopes.get(element); + if(isotopes==null) mostStableUnstableIsotopes.put(element,isotopes=new TreeMap<>()); + isotopes.put(rawLifeTime,isotope); + } + try { + for(int key:stableIsotopes.keySet()){ + stableAtoms.put(key,new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p,key), + new cElementalDefinitionStack(dHadronDefinition.hadron_n,stableIsotopes.get(key).first()), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e,key))); + if(TecTech.ModConfig.DEBUG_MODE) + System.out.println("Added Stable Atom:"+key+" "+stableIsotopes.get(key).first()+" "+stableAtoms.get(key).getMass()); + } + for(int key:mostStableUnstableIsotopes.keySet()){ + unstableAtoms.put(key,new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p,key), + new cElementalDefinitionStack(dHadronDefinition.hadron_n,mostStableUnstableIsotopes.get(key).lastEntry().getValue()), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e,key))); + if(TecTech.ModConfig.DEBUG_MODE) + System.out.println("Added Unstable Atom:"+key+" "+mostStableUnstableIsotopes.get(key).lastEntry().getValue()+" "+unstableAtoms.get(key).getMass()); + } alfa = new cElementalDefinitionStack( new dAtomDefinition( new cElementalDefinitionStack(dHadronDefinition.hadron_p, 2), new cElementalDefinitionStack(dHadronDefinition.hadron_n, 2)) ,1); }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); } } public static dAtomDefinition getFirstStableIsotope(int element){ - try { - int isotope=stableIsotopes.get(element).first(); - return new dAtomDefinition( - new cElementalDefinitionStack(dHadronDefinition.hadron_n,isotope), - new cElementalDefinitionStack(dHadronDefinition.hadron_p,element), - new cElementalDefinitionStack(eLeptonDefinition.lepton_e,element)); - }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); - return null; - } + return stableAtoms.get(element); + } + + public static dAtomDefinition getBestUnstableIsotope(int element){ + return unstableAtoms.get(element); } @Override diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dHadronDefinition.java index 9b615168bd..f0a021d80d 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dHadronDefinition.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.elementalMatter.definitions; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.classes.*; import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; import net.minecraft.item.ItemStack; @@ -9,7 +10,6 @@ import net.minecraftforge.fluids.FluidStack; import java.util.ArrayList; import static com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStackTree.stackUpTree; -import static com.github.technus.tectech.elementalMatter.commonValues.DEBUGMODE; import static com.github.technus.tectech.elementalMatter.definitions.eBosonDefinition.boson_Y__; /** @@ -217,7 +217,7 @@ public final class dHadronDefinition extends cElementalDefinition { new cElementalDecay(0.001F, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1], boson_Y__), eBosonDefinition.deadEnd}; //decay into quarks } catch (tElementalException e) { - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return new cElementalDecay[]{eBosonDefinition.deadEnd}; } } @@ -251,7 +251,7 @@ public final class dHadronDefinition extends cElementalDefinition { try { return new dHadronDefinition(anti); }catch (tElementalException e) { - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return null; } } @@ -284,7 +284,7 @@ public final class dHadronDefinition extends cElementalDefinition { try { return new dHadronDefinition(stacks); }catch (tElementalException e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); return null; } } @@ -302,7 +302,7 @@ public final class dHadronDefinition extends cElementalDefinition { hadron_n = new dHadronDefinition(false, eQuarkDefinition.quark_u, eQuarkDefinition.quark_d, eQuarkDefinition.quark_d); hadron_n_ = (dHadronDefinition) (hadron_n.getAnti()); } catch (tElementalException e) { - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); protonMass = -1; neutronMass = -1; } @@ -313,7 +313,7 @@ public final class dHadronDefinition extends cElementalDefinition { try { cElementalDefinition.addCreatorFromNBT(nbtType, dHadronDefinition.class.getMethod("fromNBT", NBTTagCompound.class)); }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_MultiMachineEM.java index be1594d065..9200f5d02a 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_MultiMachineEM.java @@ -2,7 +2,6 @@ package com.github.technus.tectech.elementalMatter.gui; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.XSTR; import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_Uncertainty.java b/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_Uncertainty.java index 35f21b93c0..c9184ff184 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_Uncertainty.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_Uncertainty.java @@ -1,8 +1,8 @@ package com.github.technus.tectech.elementalMatter.gui; +import com.github.technus.tectech.TecTech; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.XSTR; import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; @@ -10,8 +10,6 @@ import static com.github.technus.tectech.TecTech.proxy; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; public class GT_GUIContainer_Uncertainty extends GT_GUIContainerMetaTile_Machine { - private static final XSTR ran= new XSTR(); - public GT_GUIContainer_Uncertainty(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(new GT_Container_Uncertainty(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Uncertainty.png"); } @@ -95,7 +93,7 @@ public class GT_GUIContainer_Uncertainty extends GT_GUIContainerMetaTile_Machine } x-=6;y-=6; for(int i=0;i<16;i++) - if(ran.nextInt(1000)<((GT_Container_Uncertainty) this.mContainer).matrix[i]) + if(TecTech.Rnd.nextInt(1000)<((GT_Container_Uncertainty) this.mContainer).matrix[i]) drawTexturedModalRect(x + 12*(i/4), y + 12*(i%4), fU + 12*(i/4), V + 12*(i%4), 10, 10); if(((GT_Container_Uncertainty) this.mContainer).selection>-1) { diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_UncertaintyAdv.java b/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_UncertaintyAdv.java index 4bae824207..13ebf2e198 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_UncertaintyAdv.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/gui/GT_GUIContainer_UncertaintyAdv.java @@ -2,7 +2,6 @@ package com.github.technus.tectech.elementalMatter.gui; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.objects.XSTR; import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; @@ -11,7 +10,6 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; import static org.lwjgl.opengl.GL11.*; public final class GT_GUIContainer_UncertaintyAdv extends GT_GUIContainerMetaTile_Machine { - protected static final XSTR ran= new XSTR(); protected static final short sX=52,sY=33,bU=0,rU=70,fU=192,V=210,Vs=216; public GT_GUIContainer_UncertaintyAdv(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Computer.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Computer.java new file mode 100644 index 0000000000..c3ecc12a0f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Computer.java @@ -0,0 +1,50 @@ +package com.github.technus.tectech.elementalMatter.machine; + +import com.github.technus.tectech.elementalMatter.commonValues; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_Computer extends GT_MetaTileEntity_MultiblockBase_Elemental { + private static final String[][] shape=new String[][]{ + {"",//left to right top + "", + "" },//front + {},//behind front + {} //behind + }; + private static final int[] casingRequirements=new int[]{}; + private static final Block[] blockType=new Block[]{}; + private static final byte[] blockMeta=new byte[]{}; + + public GT_MetaTileEntity_Computer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_Computer(String aName) { + super(aName); + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_Computer(this.mName); + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return false; + } + + @Override + public String[] getDescription() { + return new String[]{ + commonValues.tecMark, + "Processing quantum matter since...", + EnumChatFormatting.AQUA.toString()+EnumChatFormatting.BOLD+"the time u started using it." + }; + } +} diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMbhg.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMbhg.java index 4c2946171a..0b4543e371 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMbhg.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMbhg.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.elementalMatter.machine; -import com.github.technus.tectech.casing.GT_Container_CasingsTT; import com.github.technus.tectech.blocks.QuantumGlass; +import com.github.technus.tectech.casing.GT_Container_CasingsTT; import com.github.technus.tectech.elementalMatter.commonValues; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMdequantifier.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMdequantifier.java index 8eb0ea2ede..aaa982e1d9 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMdequantifier.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMdequantifier.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.elementalMatter.machine; -import com.github.technus.tectech.casing.GT_Container_CasingsTT; import com.github.technus.tectech.blocks.QuantumGlass; +import com.github.technus.tectech.casing.GT_Container_CasingsTT; import com.github.technus.tectech.elementalMatter.commonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -59,8 +59,8 @@ public class GT_MetaTileEntity_EMdequantifier extends GT_MetaTileEntity_Multiblo public String[] getDescription() { return new String[]{ commonValues.tecMark, - "Conveniently convert regular stuff into quantum form.", - EnumChatFormatting.AQUA.toString()+EnumChatFormatting.BOLD+"To make it more inconvenient." + "Transform quantum form back to regular one...", + EnumChatFormatting.AQUA.toString()+EnumChatFormatting.BOLD+"but why?" }; } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMjunction.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMjunction.java index f379f5140a..a413648483 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMjunction.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMjunction.java @@ -1,7 +1,7 @@ package com.github.technus.tectech.elementalMatter.machine; -import com.github.technus.tectech.casing.GT_Container_CasingsTT; import com.github.technus.tectech.blocks.QuantumGlass; +import com.github.technus.tectech.casing.GT_Container_CasingsTT; import com.github.technus.tectech.elementalMatter.commonValues; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -17,12 +17,10 @@ import static gregtech.api.enums.GT_Values.V; public class GT_MetaTileEntity_EMjunction extends GT_MetaTileEntity_MultiblockBase_Elemental { public GT_MetaTileEntity_EMjunction(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - mEUt=-(int)V[9]; } public GT_MetaTileEntity_EMjunction(String aName) { super(aName); - mEUt=-(int)V[9]; } public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -55,7 +53,7 @@ public class GT_MetaTileEntity_EMjunction extends GT_MetaTileEntity_MultiblockBa } } } - return eInputHatches.size() <= 9; + return true; } @Override @@ -91,11 +89,14 @@ public class GT_MetaTileEntity_EMjunction extends GT_MetaTileEntity_MultiblockBa public boolean EM_checkRecipe(ItemStack itemStack) { for(GT_MetaTileEntity_Hatch_InputElemental in: eInputHatches) if(in.getContainerHandler().hasStacks()) { - ampereRating=1+((eInputHatches.size()+eOutputHatches.size())>>1); + mEUt=-(int)V[9]; + eAmpereRating =1+((eInputHatches.size()+eOutputHatches.size())>>1); mMaxProgresstime=20; + mEfficiencyIncrease=10000; return true; } mMaxProgresstime=0; + mEfficiencyIncrease=0; return false; } @@ -103,8 +104,8 @@ public class GT_MetaTileEntity_EMjunction extends GT_MetaTileEntity_MultiblockBa public void EM_outputFunction() { for(int i=0;i<10;i++){ final int inIndex=(int)(eParamsIn[i])-1; - final int outIndex=(int)(eParamsIn[i+10])-1; if(inIndex<0 || inIndex>eInputHatches.size()) continue; + final int outIndex=(int)(eParamsIn[i+10])-1; GT_MetaTileEntity_Hatch_InputElemental in=eInputHatches.get(inIndex); if(outIndex==-1){ cleanHatchContent(in); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMquantifier.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMquantifier.java index 2ee43d46b5..be96250b3f 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMquantifier.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMquantifier.java @@ -1,31 +1,41 @@ package com.github.technus.tectech.elementalMatter.machine; -import com.github.technus.tectech.casing.GT_Container_CasingsTT; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.blocks.QuantumGlass; +import com.github.technus.tectech.casing.GT_Container_CasingsTT; import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; +import com.github.technus.tectech.elementalMatter.classes.tElementalException; import com.github.technus.tectech.elementalMatter.commonValues; +import com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition; import com.github.technus.tectech.elementalMatter.definitions.dHadronDefinition; +import com.github.technus.tectech.elementalMatter.definitions.eLeptonDefinition; +import gregtech.api.GregTech_API; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.init.Items; -import net.minecraft.item.Item; +import gregtech.api.util.GT_OreDictUnificator; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; import java.util.HashMap; -import static com.github.technus.tectech.elementalMatter.commonValues.DEBUGMODE; +import static com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition.getBestUnstableIsotope; +import static com.github.technus.tectech.elementalMatter.definitions.dAtomDefinition.getFirstStableIsotope; +import static gregtech.api.enums.GT_Values.V; /** * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_EMquantifier extends GT_MetaTileEntity_MultiblockBase_Elemental { - public static HashMap<Item,cElementalDefinitionStack> itemBinds=new HashMap<>(200); - public static HashMap<Fluid,cElementalDefinitionStack> fluidBind=new HashMap<>(200); + public static HashMap<String,cElementalDefinitionStack> itemBinds=new HashMap<>(32); + public static HashMap<Fluid,cElementalDefinitionStack> fluidBind=new HashMap<>(8); + private static float refMass,refUnstableMass; public GT_MetaTileEntity_EMquantifier(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -72,38 +82,306 @@ public class GT_MetaTileEntity_EMquantifier extends GT_MetaTileEntity_Multiblock public String[] getDescription() { return new String[]{ commonValues.tecMark, - "Transform quantum form back to regular one...", - EnumChatFormatting.AQUA.toString()+EnumChatFormatting.BOLD+"but why?" + "Conveniently convert regular stuff into quantum form.", + EnumChatFormatting.AQUA.toString()+EnumChatFormatting.BOLD+"To make it more inconvenient." }; } @Override public boolean EM_checkRecipe(ItemStack itemStack) { - if(itemStack.getItem()==Items.iron_ingot){ - mEUt=-1; - mMaxProgresstime=20; - - outputEM=new cElementalInstanceStackTree[1]; - outputEM[0]=new cElementalInstanceStackTree(); - outputEM[0].putReplace(new cElementalInstanceStack(dHadronDefinition.hadron_p,1000)); - - return true; + if(GregTech_API.sPostloadFinished) { + ItemStack[] inI =getStoredInputs().toArray(new ItemStack[0]); + if (inI.length > 0) { + for (ItemStack is : inI) { + if(TecTech.ModConfig.DEBUG_MODE) + System.out.println(is.getItem().getUnlocalizedName()+"."+is.getItemDamage()); + cElementalDefinitionStack into = itemBinds.get(is.getItem().getUnlocalizedName()+"."+is.getItemDamage()); + if (into != null && isInputEqual(true, false, + nothingF, new ItemStack[]{new ItemStack(is.getItem(),1,is.getItemDamage())}, null, inI)) { + mMaxProgresstime = 20; + mEfficiencyIncrease=10000; + float mass = into.getMass(); + float euMult = mass / refMass; + eAmpereRating = (int) Math.ceil(euMult); + if (mass > refUnstableMass) { + mEUt = (int) -V[9]; + } else { + mEUt = (int) -V[8]; + } + outputEM = new cElementalInstanceStackTree[1]; + outputEM[0] = new cElementalInstanceStackTree(new cElementalInstanceStack(into)); + return true; + } + } + } + FluidStack[] inF=getStoredFluids().toArray(new FluidStack[0]); + if (inF.length > 0) { + for (FluidStack fs : inF) { + cElementalDefinitionStack into = fluidBind.get(fs.getFluid()); + if (into != null && fs.amount >= 144 && isInputEqual(true, false, + new FluidStack[]{new FluidStack(fs.getFluid(), 144)}, nothingI, inF, (ItemStack[]) null)) { + mMaxProgresstime = 20; + mEfficiencyIncrease=10000; + float mass = into.getMass(); + float euMult = mass / refMass; + eAmpereRating = (int) Math.ceil(euMult); + if (mass > refUnstableMass) { + mEUt = (int) -V[9]; + } else { + mEUt = (int) -V[8]; + } + outputEM = new cElementalInstanceStackTree[1]; + outputEM[0] = new cElementalInstanceStackTree(new cElementalInstanceStack(into)); + return true; + } + } + } } + mEfficiencyIncrease=0; + mMaxProgresstime = 0; return false; } @Override public void EM_outputFunction() { - try{ - for(GT_MetaTileEntity_Hatch_OutputElemental hatch:eOutputHatches) - hatch.getContainerHandler().putUnifyAll(outputEM[0]); - //TODO FIX NPEs - }catch (Exception e){ - if(DEBUGMODE)e.printStackTrace(); + if(eOutputHatches.size()<1){ + stopMachine(); + return; } + eOutputHatches.get(0).getContainerHandler().putUnifyAll(outputEM[0]); } - public static void recipeInit(){ - itemBinds.put(Items.iron_ingot,new cElementalDefinitionStack(dHadronDefinition.hadron_p,1)); + private static String getItem(OrePrefixes prefix, Materials material){ + if(TecTech.ModConfig.DEBUG_MODE) + System.out.println(material.name()+" "+GT_OreDictUnificator.get(prefix, material, 1L).getUnlocalizedName()); + return GT_OreDictUnificator.get(prefix, material, 1L).getUnlocalizedName(); + } + + public static void run(){ + refMass=getFirstStableIsotope(1).getMass()*144F; + fluidBind.put(Materials.Hydrogen.mGas,new cElementalDefinitionStack(getFirstStableIsotope(1),144)); + fluidBind.put(Materials.Helium.mGas,new cElementalDefinitionStack(getFirstStableIsotope(2),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Lithium), + new cElementalDefinitionStack(getFirstStableIsotope(3),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Beryllium), + new cElementalDefinitionStack(getFirstStableIsotope(4),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Boron), + new cElementalDefinitionStack(getFirstStableIsotope(5),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Carbon), + new cElementalDefinitionStack(getFirstStableIsotope(6),144)); + fluidBind.put(Materials.Nitrogen.mGas,new cElementalDefinitionStack(getFirstStableIsotope(7),144)); + fluidBind.put(Materials.Oxygen.mGas,new cElementalDefinitionStack(getFirstStableIsotope(8),144)); + fluidBind.put(Materials.Fluorine.mFluid,new cElementalDefinitionStack(getFirstStableIsotope(9),144)); + //fluidBind.put(Materials.Neon.mGas,new cElementalDefinitionStack(getFirstStableIsotope(10),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Sodium), + new cElementalDefinitionStack(getFirstStableIsotope(11),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Magnesium), + new cElementalDefinitionStack(getFirstStableIsotope(12),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Aluminium), + new cElementalDefinitionStack(getFirstStableIsotope(13),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Silicon), + new cElementalDefinitionStack(getFirstStableIsotope(14),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Phosphorus), + new cElementalDefinitionStack(getFirstStableIsotope(15),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Sulfur), + new cElementalDefinitionStack(getFirstStableIsotope(16),144)); + fluidBind.put(Materials.Chlorine.mFluid,new cElementalDefinitionStack(getFirstStableIsotope(17),144)); + fluidBind.put(Materials.Argon.mGas,new cElementalDefinitionStack(getFirstStableIsotope(18),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Potassium), + new cElementalDefinitionStack(getFirstStableIsotope(19),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Calcium), + new cElementalDefinitionStack(getFirstStableIsotope(20),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Scandium), + new cElementalDefinitionStack(getFirstStableIsotope(21),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Titanium), + new cElementalDefinitionStack(getFirstStableIsotope(22),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Vanadium), + new cElementalDefinitionStack(getFirstStableIsotope(23),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Chrome), + new cElementalDefinitionStack(getFirstStableIsotope(24),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Manganese), + new cElementalDefinitionStack(getFirstStableIsotope(25),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Iron), + new cElementalDefinitionStack(getFirstStableIsotope(26),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.IronMagnetic), + new cElementalDefinitionStack(getFirstStableIsotope(26),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Cobalt), + new cElementalDefinitionStack(getFirstStableIsotope(27),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Nickel), + new cElementalDefinitionStack(getFirstStableIsotope(28),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Copper), + new cElementalDefinitionStack(getFirstStableIsotope(29),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Zinc), + new cElementalDefinitionStack(getFirstStableIsotope(30),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Gallium), + new cElementalDefinitionStack(getFirstStableIsotope(31),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Germanium), + // new cElementalDefinitionStack(getFirstStableIsotope(32),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Arsenic), + new cElementalDefinitionStack(getFirstStableIsotope(33),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Selenium), + // new cElementalDefinitionStack(getFirstStableIsotope(34),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Bromine), + // new cElementalDefinitionStack(getFirstStableIsotope(35),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Krypton), + // new cElementalDefinitionStack(getFirstStableIsotope(36),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Rubidium), + new cElementalDefinitionStack(getFirstStableIsotope(37),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Strontium), + new cElementalDefinitionStack(getFirstStableIsotope(38),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Yttrium), + new cElementalDefinitionStack(getFirstStableIsotope(39),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Zirconium), + // new cElementalDefinitionStack(getFirstStableIsotope(40),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Niobium), + new cElementalDefinitionStack(getFirstStableIsotope(41),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Molybdenum), + new cElementalDefinitionStack(getFirstStableIsotope(42),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Technetium), + // new cElementalDefinitionStack(getFirstStableIsotope(43),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Ruthenium), + // new cElementalDefinitionStack(getFirstStableIsotope(44),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Rhodium), + // new cElementalDefinitionStack(getFirstStableIsotope(45),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Palladium), + new cElementalDefinitionStack(getFirstStableIsotope(46),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Silver), + new cElementalDefinitionStack(getFirstStableIsotope(47),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Cadmium), + new cElementalDefinitionStack(getFirstStableIsotope(48),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Indium), + new cElementalDefinitionStack(getFirstStableIsotope(49),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Tin), + new cElementalDefinitionStack(getFirstStableIsotope(50),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Antimony), + new cElementalDefinitionStack(getFirstStableIsotope(51),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Tellurium), + new cElementalDefinitionStack(getFirstStableIsotope(52),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Iodine), + // new cElementalDefinitionStack(getFirstStableIsotope(53),144)); + //fluidBind.put(Materials.Xenon.mGas,new cElementalDefinitionStack(getFirstStableIsotope(54),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Caesium), + new cElementalDefinitionStack(getFirstStableIsotope(55),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Barium), + new cElementalDefinitionStack(getFirstStableIsotope(56),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Lanthanum), + new cElementalDefinitionStack(getFirstStableIsotope(57),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Cerium), + new cElementalDefinitionStack(getFirstStableIsotope(58),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Praseodymium), + new cElementalDefinitionStack(getFirstStableIsotope(59),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Neodymium), + new cElementalDefinitionStack(getFirstStableIsotope(60),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.NeodymiumMagnetic), + new cElementalDefinitionStack(getFirstStableIsotope(60),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Promethium), + new cElementalDefinitionStack(getFirstStableIsotope(61),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Samarium), + new cElementalDefinitionStack(getFirstStableIsotope(62),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.SamariumMagnetic), + // new cElementalDefinitionStack(getFirstStableIsotope(62),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Europium), + new cElementalDefinitionStack(getFirstStableIsotope(63),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Gadolinium), + new cElementalDefinitionStack(getFirstStableIsotope(64),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Terbium), + new cElementalDefinitionStack(getFirstStableIsotope(65),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Dysprosium), + new cElementalDefinitionStack(getFirstStableIsotope(66),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Holmium), + new cElementalDefinitionStack(getFirstStableIsotope(67),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Erbium), + new cElementalDefinitionStack(getFirstStableIsotope(68),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Thulium), + new cElementalDefinitionStack(getFirstStableIsotope(69),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Ytterbium), + new cElementalDefinitionStack(getFirstStableIsotope(70),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Lutetium), + new cElementalDefinitionStack(getFirstStableIsotope(71),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Hafnum), + // new cElementalDefinitionStack(getFirstStableIsotope(72),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Tantalum), + new cElementalDefinitionStack(getFirstStableIsotope(73),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Tungsten), + new cElementalDefinitionStack(getFirstStableIsotope(74),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Rhenium), + // new cElementalDefinitionStack(getFirstStableIsotope(75),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Osmium), + new cElementalDefinitionStack(getFirstStableIsotope(76),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Iridium), + new cElementalDefinitionStack(getFirstStableIsotope(77),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Platinum), + new cElementalDefinitionStack(getFirstStableIsotope(78),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Gold), + new cElementalDefinitionStack(getFirstStableIsotope(79),144)); + fluidBind.put(Materials.Mercury.mFluid,new cElementalDefinitionStack(getFirstStableIsotope(80),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Thalium), + // new cElementalDefinitionStack(getFirstStableIsotope(81),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Lead), + new cElementalDefinitionStack(getFirstStableIsotope(82),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Bismuth), + new cElementalDefinitionStack(getFirstStableIsotope(83),144)); + //UNSTABLE ATOMS + refUnstableMass=getFirstStableIsotope(83).getMass()*144F; + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Polonium), + // new cElementalDefinitionStack(getBestUnstableIsotope(84),144)); + //fluidBind.put(Materials.Astatine.mPlasma,new cElementalDefinitionStack(getBestUnstableIsotope(85),144)); + fluidBind.put(Materials.Radon.mGas,new cElementalDefinitionStack(getBestUnstableIsotope(86),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Francium), + // new cElementalDefinitionStack(getBestUnstableIsotope(87),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Radium), + // new cElementalDefinitionStack(getBestUnstableIsotope(88),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Actinium), + // new cElementalDefinitionStack(getBestUnstableIsotope(89),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Thorium), + new cElementalDefinitionStack(getBestUnstableIsotope(90),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Protactinium), + // new cElementalDefinitionStack(getBestUnstableIsotope(91),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Uranium), + new cElementalDefinitionStack(getBestUnstableIsotope(92),144)); + //itemBinds.put(getItem(OrePrefixes.dust, Materials.Neptunium), + // new cElementalDefinitionStack(getBestUnstableIsotope(93),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Plutonium), + new cElementalDefinitionStack(getBestUnstableIsotope(94),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Americium), + new cElementalDefinitionStack(getBestUnstableIsotope(95),144)); + /* ... */ + itemBinds.put(getItem(OrePrefixes.ingotHot, Materials.Neutronium), + new cElementalDefinitionStack(dHadronDefinition.hadron_n,100000)); + + try{ + fluidBind.put(Materials.Deuterium.mGas, new cElementalDefinitionStack( + new dAtomDefinition( + eLeptonDefinition.lepton_e1, + dHadronDefinition.hadron_p1, + dHadronDefinition.hadron_n1 + ),144)); + fluidBind.put(Materials.Tritium.mGas, new cElementalDefinitionStack( + new dAtomDefinition( + eLeptonDefinition.lepton_e1, + dHadronDefinition.hadron_p1, + dHadronDefinition.hadron_n2 + ),144)); + fluidBind.put(Materials.Helium_3.mGas, new cElementalDefinitionStack( + new dAtomDefinition( + new cElementalDefinitionStack(eLeptonDefinition.lepton_e,2), + dHadronDefinition.hadron_p2, + new cElementalDefinitionStack(dHadronDefinition.hadron_n,3) + ),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Uranium235), + new cElementalDefinitionStack(new dAtomDefinition( + new cElementalDefinitionStack(eLeptonDefinition.lepton_e,92), + new cElementalDefinitionStack(dHadronDefinition.hadron_p,92), + new cElementalDefinitionStack(dHadronDefinition.hadron_n,143) + ),144)); + itemBinds.put(getItem(OrePrefixes.dust, Materials.Plutonium241), + new cElementalDefinitionStack(new dAtomDefinition( + new cElementalDefinitionStack(eLeptonDefinition.lepton_e,94), + new cElementalDefinitionStack(dHadronDefinition.hadron_p,94), + new cElementalDefinitionStack(dHadronDefinition.hadron_n,149) + ),144)); + }catch (tElementalException e){ + if(TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + } } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMtransformer.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMtransformer.java new file mode 100644 index 0000000000..34f5af0bbb --- /dev/null +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_EMtransformer.java @@ -0,0 +1,102 @@ +package com.github.technus.tectech.elementalMatter.machine; + +import com.github.technus.tectech.elementalMatter.commonValues; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import static com.github.technus.tectech.casing.GT_Container_CasingsTT.sBlockCasingsTT; +import static com.github.technus.tectech.elementalMatter.commonValues.multiCheckAt; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EMtransformer extends GT_MetaTileEntity_MultiblockBase_Elemental { + public GT_MetaTileEntity_EMtransformer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } + + public GT_MetaTileEntity_EMtransformer(String aName) { + super(aName); + mWrench = true; + mScrewdriver = true; + mSoftHammer = true; + mHardHammer = true; + mSolderingTool = true; + mCrowbar = true; + } + + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EMtransformer(this.mName); + } + + @Override + public boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ; + if (iGregTechTileEntity.getBlockOffset(xDir, 0, zDir)!=sBlockCasingsTT || iGregTechTileEntity.getMetaIDOffset(xDir, 0, zDir)!=6) return false; + for (int i = -1; i < 2; i++) { + for (int j = -1; j < 2; j++) { + for (int h = -1; h < 2; h++) { + if ((h != 0) || (((xDir + i != 0) || (zDir + j != 0)) && ((i != 0) || (j != 0)))) { + IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); + if (!addEnergyIOToMachineList(tTileEntity, 99)) { + if ( iGregTechTileEntity.getBlockOffset(xDir + i, h, zDir + j) != sBlockCasingsTT || + iGregTechTileEntity.getMetaIDOffset(xDir + i, h, zDir + j) != 3) { + return false; + } + } + } + } + } + } + return true; + } + + @Override + public String[] getDescription() { + return new String[]{ + commonValues.tecMark, + "Power substation", + EnumChatFormatting.AQUA.toString()+EnumChatFormatting.BOLD+"All the transformation!", + EnumChatFormatting.AQUA+"SafeVoid button = Soft Hammer!", + EnumChatFormatting.BLUE+"Only 0.78125% power loss, HAYO!", + }; + } + + @Override + public boolean EM_checkRecipe(ItemStack itemStack) { + if(ePowerPass){ + mEfficiencyIncrease=10000; + mMaxProgresstime=20; + }else { + mEfficiencyIncrease=0; + mMaxProgresstime=0; + } + eAmpereRating=0; + mEUt=0; + eDismatleBoom=ePowerPass; + return ePowerPass; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if((aTick%20)==multiCheckAt) { + if(eSafeVoid){ + eSafeVoid=false; + if(aBaseMetaTileEntity.isAllowedToWork()) + aBaseMetaTileEntity.disableWorking(); + else aBaseMetaTileEntity.enableWorking(); + } + ePowerPass = aBaseMetaTileEntity.isAllowedToWork(); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_DynamoMulti.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_DynamoMulti.java index fa86cf5871..3d5b96e459 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_DynamoMulti.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_DynamoMulti.java @@ -79,7 +79,7 @@ public class GT_MetaTileEntity_Hatch_DynamoMulti extends GT_MetaTileEntity_Hatch @Override public long maxEUStore() { - return 512L + V[mTier] * 8L * Amperes; + return 512L + V[mTier] * 4L * Amperes; } @Override diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_ElementalContainer.java index 23cb442c3d..c2650d49f8 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_ElementalContainer.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.elementalMatter.machine; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; import com.github.technus.tectech.elementalMatter.classes.tElementalException; import com.github.technus.tectech.elementalMatter.commonValues; @@ -82,7 +83,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta try { content = cElementalInstanceStackTree.fromNBT(aNBT.getCompoundTag("eM_Stacks")); }catch (tElementalException e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); if(content==null) content=new cElementalInstanceStackTree(); } } @@ -97,24 +98,30 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta purgeOverflow(); } else if (overflowAt == Tick) { if(overflowMatter<=0) { - deathDelay=2; + deathDelay=3; }else { - IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()); - if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) - tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 0); - if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) - tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 1); - if (tGTTileEntity != null && (tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) { - GT_MetaTileEntity_Hatch_MufflerElemental aMetaTileEntity = (GT_MetaTileEntity_Hatch_MufflerElemental) tGTTileEntity.getMetaTileEntity(); - aMetaTileEntity.overflowMatter += overflowMatter; - if (aMetaTileEntity.overflowMatter > aMetaTileEntity.overflowMax) { - tGTTileEntity.doExplosion(V[15]); - } else overflowMatter = 0; - } else { - if(deathDelay==1) aBaseMetaTileEntity.setOnFire(); - else if(deathDelay<1) getBaseMetaTileEntity().doExplosion(V[15]); - deathDelay--; + if(deathDelay==2) { + if (TecTech.ModConfig.BOOM_ENABLE && TecTech.Rnd.nextInt(10)==0) aBaseMetaTileEntity.setOnFire(); + else System.out.println("FIRE! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + }else if(deathDelay==1) { + IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()); + if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) + tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 0); + if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) + tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 1); + if (tGTTileEntity != null && (tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) { + GT_MetaTileEntity_Hatch_MufflerElemental aMetaTileEntity = (GT_MetaTileEntity_Hatch_MufflerElemental) tGTTileEntity.getMetaTileEntity(); + aMetaTileEntity.overflowMatter += overflowMatter; + if (aMetaTileEntity.overflowMatter > aMetaTileEntity.overflowMax) { + if(TecTech.ModConfig.BOOM_ENABLE)tGTTileEntity.doExplosion(V[14]); + else System.out.println("BOOM! "+getBaseMetaTileEntity().getXCoord()+" "+getBaseMetaTileEntity().getYCoord()+" "+getBaseMetaTileEntity().getZCoord()); + } else overflowMatter = 0F; + } + }else if(deathDelay<1) { + if (TecTech.ModConfig.BOOM_ENABLE) getBaseMetaTileEntity().doExplosion(V[14]); + else System.out.println("BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); } + deathDelay--; } } else if (moveAt==Tick){ moveAround(aBaseMetaTileEntity); @@ -226,6 +233,8 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta @Override public void onRemoval() { - if(isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) getBaseMetaTileEntity().doExplosion(V[15]); + if(isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) + if(TecTech.ModConfig.BOOM_ENABLE)getBaseMetaTileEntity().doExplosion(V[15]); + else System.out.println("BOOM! "+getBaseMetaTileEntity().getXCoord()+" "+getBaseMetaTileEntity().getYCoord()+" "+getBaseMetaTileEntity().getZCoord()); } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_EnergyMulti.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_EnergyMulti.java index 9f6cdbf020..c0c4f0602c 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_EnergyMulti.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_EnergyMulti.java @@ -80,7 +80,7 @@ public class GT_MetaTileEntity_Hatch_EnergyMulti extends GT_MetaTileEntity_Hatch @Override public long maxEUStore() { - return 512L + V[mTier] * 8L * Amperes; + return 512L + V[mTier] * 4L * Amperes; } @Override diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_MufflerElemental.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_MufflerElemental.java index 430a19f4f9..7eaa69f628 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_MufflerElemental.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_MufflerElemental.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.elementalMatter.machine; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.commonValues; import gregtech.api.enums.Dyes; import gregtech.api.enums.Textures; @@ -8,7 +9,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.XSTR; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityExplodeFX; import net.minecraft.client.particle.EntityFX; @@ -152,8 +152,6 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ //DOES NOT CHECK FOR TOO MUCH, it is done only while putting stuff in (OPTIMIZATION!!!) } - private static XSTR floatGen=new XSTR(); - public void particles(World aWorld){//CUTE! IGregTechTileEntity aMuffler=this.getBaseMetaTileEntity(); ForgeDirection aDir=ForgeDirection.getOrientation(aMuffler.getFrontFacing()); @@ -165,8 +163,8 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ //aDir.offsetY*0.1F+0.2F+0.1F*floatGen.nextFloat(); float xSpd=0; float zSpd=0; - EntityFX particle=new EntityExplodeFX(aWorld, xPos + floatGen.nextFloat()*0.5F, yPos + floatGen.nextFloat()*0.5F, zPos + floatGen.nextFloat()*0.5F, xSpd, ySpd, zSpd); - particle.setRBGColorF(0,0.6F*floatGen.nextFloat(),0.8f); + EntityFX particle=new EntityExplodeFX(aWorld, xPos + TecTech.Rnd.nextFloat()*0.5F, yPos + TecTech.Rnd.nextFloat()*0.5F, zPos + TecTech.Rnd.nextFloat()*0.5F, xSpd, ySpd, zSpd); + particle.setRBGColorF(0,0.6F*TecTech.Rnd.nextFloat(),0.8f); Minecraft.getMinecraft().effectRenderer.addEffect(particle); } @@ -187,6 +185,8 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ @Override public void onRemoval() { - if(isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) getBaseMetaTileEntity().doExplosion(V[15]); + if(isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) + if(TecTech.ModConfig.BOOM_ENABLE)getBaseMetaTileEntity().doExplosion(V[15]); + else System.out.println("BOOM! "+getBaseMetaTileEntity().getXCoord()+" "+getBaseMetaTileEntity().getYCoord()+" "+getBaseMetaTileEntity().getZCoord()); } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_Uncertainty.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_Uncertainty.java index 341c9701e8..97605cabd0 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_Uncertainty.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_Hatch_Uncertainty.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.elementalMatter.machine; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.commonValues; import com.github.technus.tectech.elementalMatter.gui.GT_Container_Uncertainty; import com.github.technus.tectech.elementalMatter.gui.GT_GUIContainer_Uncertainty; @@ -10,7 +11,6 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.objects.GT_RenderedTexture; -import gregtech.api.objects.XSTR; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; @@ -28,7 +28,6 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch private static float errorMargin=0.05f; public short[] matrix=new short[]{500,500,500,500,500,500,500,500,500,500,500,500,500,500,500,500}; public byte selection=-1,mode=0,status=-128; - private static final XSTR ran=new XSTR(); public GT_MetaTileEntity_Hatch_Uncertainty(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, "Feeling certain, or not?"); @@ -187,7 +186,7 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch public void regenerate(){ for(int i=0;i<matrix.length;i++) - matrix[i]=(short)ran.nextInt(1000); + matrix[i]=(short)TecTech.Rnd.nextInt(1000); } public byte compute(){ @@ -259,8 +258,8 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch return status=(byte)result; } - private void shift(){ - final int i=ran.nextInt(16),j=ran.nextInt(2); + private void shift(){//TODO MAKE IT MORE EVIL + final int i=TecTech.Rnd.nextInt(16),j=TecTech.Rnd.nextInt(2); matrix[i]+=(((matrix[i]&1)==0)?2:-2)*j; switch(matrix[i]){ case 1002: matrix[i]-=3; break; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_MultiblockBase_Elemental.java b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_MultiblockBase_Elemental.java index 683b4f39af..6fe2affcf0 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_MultiblockBase_Elemental.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/machine/GT_MetaTileEntity_MultiblockBase_Elemental.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.elementalMatter.machine; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.classes.cElementalInstanceStackTree; @@ -7,6 +8,7 @@ import com.github.technus.tectech.elementalMatter.classes.tElementalException; import com.github.technus.tectech.elementalMatter.commonValues; import com.github.technus.tectech.elementalMatter.gui.GT_Container_MultiMachineEM; import com.github.technus.tectech.elementalMatter.gui.GT_GUIContainer_MultiMachineEM; +import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -14,6 +16,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.*; import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; @@ -36,6 +39,10 @@ import static gregtech.api.enums.GT_Values.V; */ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_MetaTileEntity_MultiBlockBase { protected cElementalInstanceStackTree[] outputEM=new cElementalInstanceStackTree[0]; + + final static ItemStack[] nothingI=new ItemStack[0]; + final static FluidStack[] nothingF=new FluidStack[0]; + private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; @@ -51,17 +58,19 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta public final float[] eParamsOut=new float[20]; public final byte[] eParamsInStatus =new byte[20]; public final byte[] eParamsOutStatus=new byte[20]; - protected final byte PARAM_UNUSED=0, PARAM_OK=1, PARAM_TOO_LOW=2, PARAM_LOW=3, PARAM_TOO_HIGH=4, PARAM_HIGH=5, PARAM_WRONG=6; + protected final static byte PARAM_UNUSED=0, PARAM_OK=1, PARAM_TOO_LOW=2, PARAM_LOW=3, PARAM_TOO_HIGH=4, PARAM_HIGH=5, PARAM_WRONG=6; //TO ENABLE this change value in <init> to false and/or other than 0, can also be added in recipe check or whatever - public boolean eParameters=true,ePowerPass=false,eSafeVoid=false; - public byte eCertainMode=0,eCertainStatus=0; + public boolean eParameters=true,ePowerPass=false,eSafeVoid=false,eDismatleBoom=false; + public byte eCertainMode=0,eCertainStatus=0,minRepairStatus=3; + private int maxAmps=0; - public int ampereRating=1,minRepairStatus=2; + private long maxEUinputMin=0,maxEUinputMax=0; + public int eAmpereRating =1; //init param states in constructor, or implement it in checkrecipe/outputfunction - //METHODS TO OVERRIDE + //METHODS TO OVERRIDE - this 3 below + checkMachine //if you want to add checks that run periodically when machine works then make onRunningTick better //if you want to add checks that run periodically when machine is built then use check params @@ -69,17 +78,18 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta public boolean EM_checkRecipe(ItemStack itemStack){ return false; } + //My code handles AMPS, if you want overclocking just modify mEUt and mMaxProgressTime, leave amps as usual! - public void EM_checkParams(){ - }//update status of parameters in guis and "machine state" + public void EM_checkParams(){} + //update status of parameters in guis and "machine state" - public void EM_outputFunction(){ - //it can also be here to do the last param check. - } + public void EM_outputFunction(){} // based on "machine state" do output, - // this must move to output EM things and can also modify output items/fluids + // this must move to output EM things and can also modify output items/fluids/EM, remaining EM is NOT overflowed. + //(Well it can be overflowed if machine didn't finished, soft-hammered/disabled/not enough EU) + + //RATHER LEAVE ALONE Section - //RATHER LEAVE ALONE public GT_MetaTileEntity_MultiblockBase_Elemental(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -127,12 +137,17 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta if(mOutputFluids!=null) aNBT.setInteger("eFluidsOut",mOutputFluids.length); - aNBT.setInteger("eRating",ampereRating); + aNBT.setLong("eMaxEUmin", maxEUinputMin); + aNBT.setLong("eMaxEUmax", maxEUinputMax); + aNBT.setInteger("eRating", eAmpereRating); + aNBT.setInteger("eMaxA",maxAmps); aNBT.setByte("eCertainM",eCertainMode); aNBT.setByte("eCertainS",eCertainStatus); - aNBT.setBoolean("eParam",!eParameters); + aNBT.setByte("eMinRepair",minRepairStatus); + aNBT.setBoolean("eParam",eParameters); aNBT.setBoolean("ePass",ePowerPass); aNBT.setBoolean("eVoid",eSafeVoid); + aNBT.setBoolean("eBoom", eDismatleBoom); if (outputEM!=null) { aNBT.setInteger("outputStackCount", outputEM.length); @@ -170,12 +185,17 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - ampereRating=aNBT.getInteger("eRating"); + maxEUinputMin =aNBT.getLong("eMaxEUmin"); + maxEUinputMax =aNBT.getLong("eMaxEUmax"); + eAmpereRating =aNBT.getInteger("eRating"); + maxAmps=aNBT.getInteger("eMaxA"); eCertainMode=aNBT.getByte("eCertainM"); eCertainStatus=aNBT.getByte("eCertainS"); - eParameters=!aNBT.getBoolean("eParam"); + minRepairStatus=aNBT.getByte("eMinRepair"); + eParameters=aNBT.getBoolean("eParam"); ePowerPass=aNBT.getBoolean("ePass"); eSafeVoid=aNBT.getBoolean("eVoid"); + eDismatleBoom =aNBT.getBoolean("eBoom"); //Fix supermethod shit. mOutputItems = new ItemStack[aNBT.getInteger("eItemsOut")]; @@ -193,7 +213,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta outputEM[i] = cElementalInstanceStackTree.fromNBT( aNBT.getCompoundTag("outputEM").getCompoundTag(Integer.toString(i))); }catch (tElementalException e){ - if(DEBUGMODE)e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE)e.printStackTrace(); outputEM[i] = new cElementalInstanceStackTree(); } }else outputEM=new cElementalInstanceStackTree[0]; @@ -217,7 +237,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta @Override public final long maxEUStore() { - return getMaxInputVoltage()*maxAmps<<3; + return (maxEUinputMin*maxAmps)<<3; } @Override @@ -256,13 +276,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta mMaintenanceHatches.clear(); for(GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental:eOutputHatches) - hatch_elemental.id=-1; + if(isValidMetaTileEntity(hatch_elemental))hatch_elemental.id=-1; for(GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental:eInputHatches) - hatch_elemental.id=-1; + if(isValidMetaTileEntity(hatch_elemental))hatch_elemental.id=-1; for(GT_MetaTileEntity_Hatch_Uncertainty hatch:eUncertainHatches) - hatch.getBaseMetaTileEntity().setActive(false); + if(isValidMetaTileEntity(hatch))hatch.getBaseMetaTileEntity().setActive(false); for(GT_MetaTileEntity_Hatch_Param hatch:eParamHatches) - hatch.getBaseMetaTileEntity().setActive(false); + if(isValidMetaTileEntity(hatch))hatch.getBaseMetaTileEntity().setActive(false); eUncertainHatches.clear(); eEnergyMulti.clear(); @@ -273,26 +293,58 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta eDynamoMulti.clear(); mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + + if(!mMachine) + if(eDismatleBoom) explodeMultiblock(); + else if(outputEM!=null) + for(cElementalInstanceStackTree tree:outputEM) + if(tree.hasStacks()) explodeMultiblock(); + if(eUncertainHatches.size()>1) mMachine=false; if(mMachine) { short id=1; for(GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental:eOutputHatches) - hatch_elemental.id=id++; + if(isValidMetaTileEntity(hatch_elemental))hatch_elemental.id=id++; id=1; for(GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental:eInputHatches) - hatch_elemental.id=id++; - - maxAmps=mEnergyHatches.size(); - for(GT_MetaTileEntity_Hatch_EnergyMulti hatch:eEnergyMulti) - maxAmps+=hatch.Amperes; + if(isValidMetaTileEntity(hatch_elemental))hatch_elemental.id=id++; + + if(mEnergyHatches.size()>0 || eEnergyMulti.size()>0) { + maxEUinputMin =V[15]; + maxEUinputMax=V[0]; + for(GT_MetaTileEntity_Hatch_Energy hatch:mEnergyHatches) + if(isValidMetaTileEntity(hatch)){ + if (hatch.maxEUInput() < maxEUinputMin) maxEUinputMin = hatch.maxEUInput(); + if (hatch.maxEUInput() > maxEUinputMax) maxEUinputMax = hatch.maxEUInput(); + } + for(GT_MetaTileEntity_Hatch_EnergyMulti hatch:eEnergyMulti) + if(isValidMetaTileEntity(hatch)){ + if (hatch.maxEUInput() < maxEUinputMin) maxEUinputMin = hatch.maxEUInput(); + if (hatch.maxEUInput() > maxEUinputMax) maxEUinputMax = hatch.maxEUInput(); + } + maxAmps=0; + for(GT_MetaTileEntity_Hatch_Energy hatch:mEnergyHatches) + if(isValidMetaTileEntity(hatch))maxAmps+=hatch.maxEUInput()/ maxEUinputMin; + for(GT_MetaTileEntity_Hatch_EnergyMulti hatch:eEnergyMulti) + if(isValidMetaTileEntity(hatch))maxAmps+=(hatch.maxEUInput()/ maxEUinputMin)*hatch.Amperes; + if(this.getEUVar()>maxEUStore())this.setEUVar(this.maxEUStore()); + } else { + maxEUinputMin=0; + maxEUinputMax=0; + maxAmps=0; + this.setEUVar(0); + } for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) - hatch.getBaseMetaTileEntity().setActive(true); + if(isValidMetaTileEntity(hatch))hatch.getBaseMetaTileEntity().setActive(true); for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) - hatch.getBaseMetaTileEntity().setActive(true); + if(isValidMetaTileEntity(hatch))hatch.getBaseMetaTileEntity().setActive(true); }else{ + maxEUinputMin=0; + maxEUinputMax=0; maxAmps=0; + this.setEUVar(0); } } @@ -358,30 +410,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta } } - if(ePowerPass && (mDynamoHatches.size()>0 || eDynamoMulti.size()>0)){ - IGregTechTileEntity base=this.getBaseMetaTileEntity(); - for(GT_MetaTileEntity_Hatch_Energy tHatch:mEnergyHatches){ - if(this.getEUVar()>this.getMinimumStoredEU()) break; - if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(tHatch.maxEUInput(),false)) - this.setEUVar(this.getEUVar()+tHatch.maxEUInput()); - } - for(GT_MetaTileEntity_Hatch_EnergyMulti tHatch:eEnergyMulti){ - if(this.getEUVar()>this.getMinimumStoredEU()) break; - if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(tHatch.maxEUInput()*tHatch.Amperes,false)) - this.setEUVar(this.getEUVar()+tHatch.maxEUInput()*tHatch.Amperes); - } - for(GT_MetaTileEntity_Hatch_Dynamo tHatch:mDynamoHatches) - if( isValidMetaTileEntity(tHatch) && - tHatch.getBaseMetaTileEntity().getStoredEU()<=(tHatch.maxEUStore()-tHatch.maxEUOutput()) && - base.decreaseStoredEnergyUnits(tHatch.maxEUOutput(),false)) - tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU()+tHatch.maxEUOutput()); - for(GT_MetaTileEntity_Hatch_DynamoMulti tHatch:eDynamoMulti) - if(isValidMetaTileEntity(tHatch) && - tHatch.getBaseMetaTileEntity().getStoredEU()<=(tHatch.maxEUStore()-tHatch.maxEUOutput()*tHatch.Amperes) && - base.decreaseStoredEnergyUnits(tHatch.maxEUOutput()*tHatch.Amperes,false)) - tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU()+tHatch.maxEUOutput()*tHatch.Amperes); - } - if (getRepairStatus() >= minRepairStatus) {//S if (multiCheckAt==Tick) paramsUpdate(); @@ -394,8 +422,6 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime && recipeAt==Tick ) {//progress increase and done paramsUpdate(); EM_outputFunction(); - purgeAll(); - if (mOutputItems != null) for (ItemStack tStack : mOutputItems) if (tStack != null) addOutput(tStack); @@ -406,21 +432,67 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta addOutput(tStack); else if (mOutputFluids != null && mOutputFluids.length > 1) addFluidOutputs(mOutputFluids); - - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + updateSlots(); mOutputItems = null; mOutputFluids = null; - outputEM=null; + outputEM=new cElementalInstanceStackTree[0]; mProgresstime = 0; mMaxProgresstime = 0; mEfficiencyIncrease = 0; - if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); + if (aBaseMetaTileEntity.isAllowedToWork()) { + if(checkRecipe(mInventory[1])) { + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + } + updateSlots(); + } } } } else { - if (recipeAt==Tick) { - if (aBaseMetaTileEntity.isAllowedToWork()) checkRecipe(mInventory[1]); - if (mMaxProgresstime <= 0) mEfficiency = Math.max(0, mEfficiency - 1000); + if (recipeAt==Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + if(checkRecipe(mInventory[1])) { + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + } + updateSlots(); + } + } + } + + {//DO ONCE + long euVar; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (this.getEUVar() > this.getMinimumStoredEU()) break; + if (isValidMetaTileEntity(tHatch)){ + euVar=tHatch.maxEUInput(); + if(tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) + this.setEUVar(this.getEUVar() + euVar); + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { + if (this.getEUVar() > this.getMinimumStoredEU()) break; + if (isValidMetaTileEntity(tHatch)){ + euVar=tHatch.maxEUInput()*tHatch.Amperes; + if(tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) + this.setEUVar(this.getEUVar() + euVar); + } + } + if (ePowerPass) { + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + euVar = tHatch.maxEUOutput(); + if( tHatch.getBaseMetaTileEntity().getStoredEU() <= (tHatch.maxEUStore() - euVar) && + aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + (euVar >> 7), false)) + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + } + } + for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) { + if (isValidMetaTileEntity(tHatch)){ + euVar = tHatch.maxEUOutput()*tHatch.Amperes; + if( tHatch.getBaseMetaTileEntity().getStoredEU() <= tHatch.maxEUStore() - euVar && + aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + (euVar >> 7), false)) + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + } + } } } } else {//not repaired @@ -447,7 +519,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta private void addFluidOutputs(FluidStack[] mOutputFluids2) { for(int i = 0; i < mOutputFluids2.length; ++i) { if(this.mOutputHatches.size() > i && this.mOutputHatches.get(i) != null && mOutputFluids2[i] != null && isValidMetaTileEntity((MetaTileEntity)this.mOutputHatches.get(i))) { - ((GT_MetaTileEntity_Hatch_Output)this.mOutputHatches.get(i)).fill(mOutputFluids2[i], true); + this.mOutputHatches.get(i).fill(mOutputFluids2[i], true); } } } @@ -459,7 +531,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta @Override public int getIdealStatus() { - return 8; + return super.getIdealStatus()+2; } @Override @@ -469,59 +541,146 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta @Override public boolean onRunningTick(ItemStack aStack) { - if(ampereRating<=0) return true; - else if(this.mEUt > 0) { - this.addEnergyOutput((long)this.mEUt * (long) ampereRating * (long)this.mEfficiency / getMaxEfficiency(aStack)); + if(this.mEUt > 0) { + this.EMaddEnergyOutput((long)mEUt * (long)mEfficiency / getMaxEfficiency(aStack),eAmpereRating); return true; - } else if(this.mEUt < 0 && !this.drainEnergyInput((long)(-this.mEUt) * (long) ampereRating * getMaxEfficiency(aStack) / (long)Math.max(1000, this.mEfficiency))) { + } else if(this.mEUt < 0 && !this.EMdrainEnergyInput((long)(-this.mEUt) * getMaxEfficiency(aStack) / (long)Math.max(1000, this.mEfficiency),eAmpereRating)) { this.stopMachine(); return false; } else return true; } + @Deprecated @Override - public final boolean addEnergyOutput(long aEU) { - if(aEU <= 0L) { - return true; - } else { - for(GT_MetaTileEntity_Hatch tHatch:eDynamoMulti) - if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU,false)) - return true; - for(GT_MetaTileEntity_Hatch tHatch:mDynamoHatches) - if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(aEU,false)) - return true; - return false; + public final boolean addEnergyOutput(long EU) { + if(EU <= 0L) return true; + for(GT_MetaTileEntity_Hatch tHatch:eDynamoMulti) + if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU,false)) + return true; + for(GT_MetaTileEntity_Hatch tHatch:mDynamoHatches) + if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU,false)) + return true; + return false; + } + + //new method + public final boolean EMaddEnergyOutput(long EU, int Amperes) { + if(EU <= 0L || Amperes<=0) return true; + long euVar=EU*Amperes; + long diff; + for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { + if (isValidMetaTileEntity(tHatch)) { + if(tHatch.maxEUOutput()<EU) explodeMultiblock(); + diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity().getStoredEU(); + if (diff > 0) { + if (euVar > diff) { + tHatch.setEUVar(tHatch.maxEUStore()); + euVar -= diff; + } else if (euVar <= diff) { + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + return true; + } + } + } } + for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) { + if (isValidMetaTileEntity(tHatch)) { + if(tHatch.maxEUOutput()<EU) explodeMultiblock(); + diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity().getStoredEU(); + if (diff > 0) { + if (euVar > diff) { + tHatch.setEUVar(tHatch.maxEUStore()); + euVar -= diff; + } else if (euVar <= diff) { + tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + return true; + } + } + } + } + return false; } + @Deprecated @Override - public final boolean drainEnergyInput(long aEU) { - if(aEU <= 0L) { + public final boolean drainEnergyInput(long EU) { + if(EU <= 0L) return true; + for(GT_MetaTileEntity_Hatch tHatch:eEnergyMulti) + if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU,false)) + return true; + for(GT_MetaTileEntity_Hatch tHatch:mEnergyHatches) + if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU,false)) + return true; + return false; + } + + //new method + public final boolean EMdrainEnergyInput(long EU, int Amperes) { + if(EU <= 0L || Amperes<=0) return true; + long euVar=EU*Amperes; + if( getEUVar() < euVar || + EU>maxEUinputMax || + (euVar+maxEUinputMin-1)/maxEUinputMin>maxAmps)return false; + //sub eu + setEUVar(getEUVar()-euVar); + return true; + } + + //new method + public final boolean EMoverclockAndPutValuesIn(long EU,int time){ + if(EU==0){ + mEUt=0; + mMaxProgresstime=time; return true; - } else { - for(GT_MetaTileEntity_Hatch tHatch:eEnergyMulti) - if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU,false)) - return true; - for(GT_MetaTileEntity_Hatch tHatch:mEnergyHatches) - if(isValidMetaTileEntity(tHatch) && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(aEU,false)) - return true; + } + long tempEUt = EU<V[1] ? V[1] : EU; + long tempTier=maxEUinputMax>>2; + while(tempEUt<tempTier){ + tempEUt<<=2; + time>>=1; + EU = time==0 ? EU>>1 : EU<<2;//U know, if the time is less than 1 tick make the machine use less power + } + if(EU> Integer.MAX_VALUE || EU< Integer.MIN_VALUE){ + mEUt= Integer.MAX_VALUE-1; + mMaxProgresstime= Integer.MAX_VALUE-1; return false; } - } + mEUt=(int)EU; + mMaxProgresstime=time==0?1:time; + return true; + }//Use in EM check recipe return statement if you want overclocking @Override public final long getMaxInputVoltage() { long rVoltage = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.maxEUInput(); for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) - if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.getBaseMetaTileEntity().getInputVoltage(); + if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.maxEUInput(); return rVoltage; } + //new Method + public final int getMaxEnergyInputTier(){ + return GT_Utility.getTier(maxEUinputMax); + } + + //new Method + public final int getMinEnergyInputTier(){ + return GT_Utility.getTier(maxEUinputMin); + } + @Override public final void stopMachine() { - super.stopMachine(); + mOutputItems = null; + mOutputFluids = null; + //mEUt = 0; + mEfficiency = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + getBaseMetaTileEntity().disableWorking(); + float mass=0; if(outputEM==null) return; for(cElementalInstanceStackTree tree:outputEM) @@ -542,6 +701,12 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta return null; } + @Override + public void updateSlots() { + super.updateSlots(); + purgeAll(); + } + private void purgeAll(){ float mass=0; for(GT_MetaTileEntity_Hatch_InputElemental tHatch: eInputHatches) { @@ -555,7 +720,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta tHatch.overflowMatter=0; } if(mass>0) { - if (eMufflerHatches.size()<1) explodeMultiblock(); + if (eMufflerHatches.size()<1) { + explodeMultiblock(); + return; + } mass /= eMufflerHatches.size(); for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) { dump.overflowMatter += mass; @@ -614,6 +782,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta @Override public void explodeMultiblock() {//BEST METHOD EVER!!! + if(!TecTech.ModConfig.BOOM_ENABLE) { + System.out.println("BOOM! "+getBaseMetaTileEntity().getXCoord()+" "+getBaseMetaTileEntity().getYCoord()+" "+getBaseMetaTileEntity().getZCoord()); + return; + } GT_Pollution.addPollution(new ChunkPosition(this.getBaseMetaTileEntity().getXCoord(), this.getBaseMetaTileEntity().getYCoord(), this.getBaseMetaTileEntity().getZCoord()), 600000); mInventory[1] = null; for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); @@ -932,16 +1104,15 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta "Stored Energy:", EnumChatFormatting.GREEN + Long.toString(storedEnergy) + EnumChatFormatting.RESET +" EU / "+ EnumChatFormatting.YELLOW + Long.toString(maxEnergy) + EnumChatFormatting.RESET +" EU", - "Probably uses: "+ - EnumChatFormatting.RED + Integer.toString(-mEUt) + EnumChatFormatting.RESET + " EU/t", - "Maximum total power (to all Energy Hatches, not single ones): ", - EnumChatFormatting.YELLOW+Long.toString(getMaxInputVoltage())+EnumChatFormatting.RESET+ " EU/t * 2A", - "Problems: "+ - EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ - " Efficiency: "+ - EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %", - "PowerPass(tm): "+EnumChatFormatting.BLUE+ePowerPass, - "SafeVoid(tm): "+EnumChatFormatting.BLUE+eSafeVoid + (mEUt<=0?"Probably uses: ":"Probably makes: ")+ + EnumChatFormatting.RED + Integer.toString(Math.abs(mEUt)) + EnumChatFormatting.RESET + " EU/t at "+ + EnumChatFormatting.RED + Integer.toString(eAmpereRating)+ EnumChatFormatting.RESET +" A", + "Tier Rating: "+EnumChatFormatting.YELLOW+getMaxEnergyInputTier()+EnumChatFormatting.RESET+" / "+EnumChatFormatting.GREEN+getMinEnergyInputTier()+EnumChatFormatting.RESET+ + " Amp Rating: "+EnumChatFormatting.GREEN+maxAmps+EnumChatFormatting.RESET + " A", + "Problems: "+EnumChatFormatting.RED+ (getIdealStatus() - getRepairStatus())+EnumChatFormatting.RESET+ + " Efficiency: "+EnumChatFormatting.YELLOW+Float.toString(mEfficiency / 100.0F)+EnumChatFormatting.RESET + " %", + "PowerPass: "+EnumChatFormatting.BLUE+ePowerPass+EnumChatFormatting.RESET+ + " SafeVoid: "+EnumChatFormatting.BLUE+eSafeVoid }; } @@ -1030,13 +1201,171 @@ public abstract class GT_MetaTileEntity_MultiblockBase_Elemental extends GT_Meta if(outputEM!=null) { for (cElementalInstanceStackTree output : outputEM) { if (output.hasStacks()) { - getBaseMetaTileEntity().doExplosion(V[15]); + explodeMultiblock(); return; } } } }catch (Exception e){ - if(DEBUGMODE) e.printStackTrace(); + if(TecTech.ModConfig.DEBUG_MODE) e.printStackTrace(); + } + } + + protected boolean isInputEqual(boolean aDecreaseStacksizeBySuccess, boolean aDontCheckStackSizes, FluidStack[] requiredFluidInputs, ItemStack[] requiredInputs, FluidStack[] givenFluidInputs, ItemStack... givenInputs) { + if(!GregTech_API.sPostloadFinished)return false; + if (requiredFluidInputs.length > 0 && givenFluidInputs == null) return false; + int amt; + for (FluidStack tFluid : requiredFluidInputs) + if (tFluid != null) { + boolean temp = true; + amt = tFluid.amount; + for (FluidStack aFluid : givenFluidInputs) + if (aFluid != null && aFluid.isFluidEqual(tFluid)){ + if (aDontCheckStackSizes ){ + temp = false; + break; + } + amt -= aFluid.amount; + if (amt<1){ + temp = false; + break; + } + } + if (temp) return false; + } + + if (requiredInputs.length > 0 && givenInputs == null) return false; + for (ItemStack tStack : requiredInputs) { + if (tStack != null) { + amt = tStack.stackSize; + boolean temp = true; + for (ItemStack aStack : givenInputs) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if (aDontCheckStackSizes) { + temp = false; + break; + } + amt -= aStack.stackSize; + if (amt < 1) { + temp = false; + break; + } + } + } + if (temp) return false; + } } + + if (aDecreaseStacksizeBySuccess) { + if (givenFluidInputs != null) { + for (FluidStack tFluid : requiredFluidInputs) { + if (tFluid != null) { + amt = tFluid.amount; + for (FluidStack aFluid : givenFluidInputs) { + if (aFluid != null && aFluid.isFluidEqual(tFluid)) { + if (aDontCheckStackSizes) { + aFluid.amount -= amt; + break; + } + if (aFluid.amount < amt) { + amt -= aFluid.amount; + aFluid.amount = 0; + } else { + aFluid.amount -= amt; + amt = 0; + break; + } + } + } + } + } + } + + if (givenInputs != null) { + for (ItemStack tStack : requiredInputs) { + if (tStack != null) { + amt = tStack.stackSize; + for (ItemStack aStack : givenInputs) { + if ((GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true))) { + if (aDontCheckStackSizes){ + aStack.stackSize -= amt; + break; + } + if (aStack.stackSize < amt){ + amt -= aStack.stackSize; + aStack.stackSize = 0; + }else{ + aStack.stackSize -= amt; + amt = 0; + break; + } + } + } + } + } + } + } + + return true; } + + /** + * finds a Recipe matching the aFluid and ItemStack Inputs. + * + * @param aNotUnificated if this is T the Recipe searcher will unificate the ItemStack Inputs + * @param aVoltage Voltage of the Machine or Long.MAX_VALUE if it has no Voltage + * @param aFluids the Fluid Inputs + * @param aSpecialSlot the content of the Special Slot, the regular Manager doesn't do anything with this, but some custom ones do. + * @param aInputs the Item Inputs + * @return the Recipe it has found or null for no matching Recipe + */ + + //protected static GT_Recipe findRecipe(boolean aNotUnificated, long aVoltage, FluidStack[] aFluids, ItemStack aSpecialSlot, ItemStack... aInputs) { + // // Some Recipe Classes require a certain amount of Inputs of certain kinds. Like "at least 1 Fluid + 1 Stack" or "at least 2 Stacks" before they start searching for Recipes. + // // This improves Performance massively, especially if people leave things like Circuits, Molds or Shapes in their Machines to select Sub Recipes. + // if (GregTech_API.sPostloadFinished) { + // if (mMinimalInputFluids > 0) { + // if (aFluids == null) return null; + // int tAmount = 0; + // for (FluidStack aFluid : aFluids) if (aFluid != null) tAmount++; + // if (tAmount < mMinimalInputFluids) return null; + // } + // if (mMinimalInputItems > 0) { + // if (aInputs == null) return null; + // int tAmount = 0; + // for (ItemStack aInput : aInputs) if (aInput != null) tAmount++; + // if (tAmount < mMinimalInputItems) return null; + // } + // } + // // Unification happens here in case the Input isn't already unificated. + // if (aNotUnificated) aInputs = GT_OreDictUnificator.getStackArray(true, (Object[]) aInputs); + // // Check the Recipe which has been used last time in order to not have to search for it again, if possible. + // if (aRecipe != null) + // if (!aRecipe.mFakeRecipe && aRecipe.mCanBeBuffered && aRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) + // return aRecipe.mEnabled && aVoltage * mAmperage >= aRecipe.mEUt ? aRecipe : null; + // // Now look for the Recipes inside the Item HashMaps, but only when the Recipes usually have Items. + // if (mUsualInputCount > 0 && aInputs != null) for (ItemStack tStack : aInputs) + // if (tStack != null) { + // Collection<GT_Recipe> + // tRecipes = mRecipeItemMap.get(new GT_ItemStack(tStack)); + // if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) + // if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) + // return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + // tRecipes = mRecipeItemMap.get(new GT_ItemStack(GT_Utility.copyMetaData(W, tStack))); + // if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) + // if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) + // return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + // } + // // If the minimal Amount of Items for the Recipe is 0, then it could be a Fluid-Only Recipe, so check that Map too. + // if (mMinimalInputItems == 0 && aFluids != null) for (FluidStack aFluid : aFluids) + // if (aFluid != null) { + // Collection<GT_Recipe> + // tRecipes = mRecipeFluidMap.get(aFluid.getFluid()); + // if (tRecipes != null) for (GT_Recipe tRecipe : tRecipes) + // if (!tRecipe.mFakeRecipe && tRecipe.isRecipeInputEqual(false, true, aFluids, aInputs)) + // return tRecipe.mEnabled && aVoltage * mAmperage >= tRecipe.mEUt ? tRecipe : null; + // } + // // And nothing has been found. + // return null; + //} } diff --git a/src/main/resources/assets/gregtech/textures/blocks/iconsets/PARAM_ACTIVE.png b/src/main/resources/assets/gregtech/textures/blocks/iconsets/PARAM_ACTIVE.png Binary files differindex 3d80f25c0e..43e88d959c 100644 --- a/src/main/resources/assets/gregtech/textures/blocks/iconsets/PARAM_ACTIVE.png +++ b/src/main/resources/assets/gregtech/textures/blocks/iconsets/PARAM_ACTIVE.png diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 26459ea81b..11257a8f6d 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1 +1,2 @@ -tile.QuantumGlass.name=Quantum Glass
\ No newline at end of file +itemGroup.TecTech=TecTech Interdimensional +tile.QuantumGlass.name=Quantum Glass |