diff options
author | Bass <tudurap.com@gmail.com> | 2018-02-03 12:39:19 +0000 |
---|---|---|
committer | Bass <tudurap.com@gmail.com> | 2018-02-03 12:39:19 +0000 |
commit | 2bac2961fc8371664ab3d75641edd1f7ae78fa83 (patch) | |
tree | ddcc56758ebdbdb7117b5de287cbf93830112ddb /src | |
parent | 4da1b57533dbfcd564c9a216dd2796664e65c36c (diff) | |
parent | 9b72b13fde8cfb7908cfd1569ad0399a4a10635e (diff) | |
download | GT5-Unofficial-2bac2961fc8371664ab3d75641edd1f7ae78fa83.tar.gz GT5-Unofficial-2bac2961fc8371664ab3d75641edd1f7ae78fa83.tar.bz2 GT5-Unofficial-2bac2961fc8371664ab3d75641edd1f7ae78fa83.zip |
Merge remote-tracking branch 'origin/master' into bassAdditions
Diffstat (limited to 'src')
170 files changed, 6709 insertions, 3134 deletions
diff --git a/src/main/java/com/github/technus/tectech/CommonValues.java b/src/main/java/com/github/technus/tectech/CommonValues.java index cc6957cf56..81c7dc3450 100644 --- a/src/main/java/com/github/technus/tectech/CommonValues.java +++ b/src/main/java/com/github/technus/tectech/CommonValues.java @@ -6,26 +6,28 @@ import net.minecraft.util.EnumChatFormatting; * Created by danie_000 on 11.01.2017. */ public final class CommonValues { - public final static String TEC_MARK_GENERAL = + public static final String TEC_MARK_GENERAL = EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.BLUE + ": Interdimensional"; - public final static String TEC_MARK_EM = + public static final String TEC_MARK_EM = EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.BLUE + ": Elemental Matter"; - public final static String BASS_MARK = - EnumChatFormatting.BLUE + "Bass" + + public static final String BASS_MARK = + EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.BLUE + ": Theta Movement"; - public final static byte DECAY_AT = 0;// hatches compute decays - public final static byte MULTI_PURGE_1_AT = 2;// multiblocks clean their hatches 1 - public final static byte MOVE_AT = 4;// move stuff around - public final static byte RECIPE_AT = 6;// move stuff around - public final static byte MULTI_PURGE_2_AT = 8;// multiblocks clean their hatches 2 - public final static byte OVERFLOW_AT = 10;// then hatches clean themselves + public static final byte DECAY_AT = 0;// hatches compute decays + public static final byte MULTI_PURGE_1_AT = 2;// multiblocks clean their hatches 1 + public static final byte MOVE_AT = 4;// move stuff around + public static final byte RECIPE_AT = 6;// move stuff around + public static final byte MULTI_PURGE_2_AT = 8;// multiblocks clean their hatches 2 + public static final byte OVERFLOW_AT = 10;// then hatches clean themselves // - in case some hatches are not in multiblock structure - public final static byte MULTI_CHECK_AT = 12;// multiblock checks it's state - public final static byte DISPERSE_AT = 14;// overflow hatches perform disperse + public static final byte MULTI_CHECK_AT = 12;// multiblock checks it's state + public static final byte DISPERSE_AT = 14;// overflow hatches perform disperse + + private CommonValues() {} } diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index df45b6585a..9a4e803f67 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -2,14 +2,16 @@ package com.github.technus.tectech; import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.auxiliary.TecTechConfig; +import com.github.technus.tectech.elementalMatter.core.commands.ListEM; +import com.github.technus.tectech.elementalMatter.core.commands.GiveEM; import com.github.technus.tectech.loader.MainLoader; +import com.github.technus.tectech.loader.ModGuiHandler; 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; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.*; +import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameData; import cpw.mods.fml.common.registry.GameRegistry; import eu.usrv.yamcore.auxiliary.IngameErrorLog; @@ -33,99 +35,115 @@ public class TecTech { @SidedProxy(clientSide = Reference.CLIENTSIDE, serverSide = Reference.SERVERSIDE) public static CommonProxy proxy; - @Instance(Reference.MODID) + @Mod.Instance(Reference.MODID) public static TecTech instance; public static final XSTR Rnd = XSTR.XSTR_INSTANCE; public static final LogHelper Logger = new LogHelper(Reference.MODID); - private static IngameErrorLog Module_AdminErrorLogs = null; - public static MainLoader GTCustomLoader = null; + private static IngameErrorLog Module_AdminErrorLogs; + public static MainLoader GTCustomLoader; public static TecTechConfig ModConfig; - public static CreativeTabs mainTab = null; + public static CreativeTabs mainTab; public static boolean hasCOFH = false, hasThaumcraft = false; public static final byte tectechTexturePage1=8; public static void AddLoginError(String pMessage) { - if (Module_AdminErrorLogs != null) + if (Module_AdminErrorLogs != null) { Module_AdminErrorLogs.AddErrorLogOnAdminJoin(pMessage); + } } - @EventHandler + @Mod.EventHandler public void PreLoad(FMLPreInitializationEvent PreEvent) { Logger.setDebugOutput(true); ModConfig = new TecTechConfig(PreEvent.getModConfigurationDirectory(), Reference.COLLECTIONNAME, Reference.MODID); - if (!ModConfig.LoadConfig()) + if (!ModConfig.LoadConfig()) { 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"); Module_AdminErrorLogs = new IngameErrorLog(); } - proxy.addTexturePage(tectechTexturePage1); - GTCustomLoader = new MainLoader(); - TecTech.Logger.info("Added Atom Overrider"); + Logger.info("Added Atom Overrider"); } - @EventHandler + @Mod.EventHandler public void Load(FMLInitializationEvent event) { hasCOFH = Loader.isModLoaded(Reference.COFHCORE); hasThaumcraft = Loader.isModLoaded(Reference.THAUMCRAFT); GTCustomLoader.load(); + + NetworkRegistry.INSTANCE.registerGuiHandler(instance, new ModGuiHandler()); proxy.registerRenderInfo(); } - @EventHandler + @Mod.EventHandler public void PostLoad(FMLPostInitializationEvent PostEvent) { GTCustomLoader.postLoad(); - if (ModConfig.NERF_FUSION) FixBrokenFusionRecipes(); + if (ModConfig.NERF_FUSION) { + FixBrokenFusionRecipes(); + } fixBlocks(); } - @EventHandler + @Mod.EventHandler public void serverLoad(FMLServerStartingEvent pEvent) { + if(DEBUG_MODE) { + pEvent.registerServerCommand(new GiveEM()); + pEvent.registerServerCommand(new ListEM()); + } } - @EventHandler + @Mod.EventHandler public void onServerAboutToStart(FMLServerAboutToStartEvent ev) { } private void FixBrokenFusionRecipes() { HashMap<Fluid, Fluid> binds = new HashMap<>(); - for (Materials m : Materials.values()) { - FluidStack p = m.getPlasma(1); + for (Materials material : Materials.values()) { + FluidStack p = material.getPlasma(1); if (p != null) { - if (DEBUG_MODE) - TecTech.Logger.info("Found Plasma of " + m.mName); - if (m.mElement != null && - (m.mElement.mProtons >= Materials.Iron.mElement.mProtons || - -m.mElement.mProtons >= Materials.Iron.mElement.mProtons || - m.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons || - -m.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons)) { - if (DEBUG_MODE) - TecTech.Logger.info("Attempting to bind " + m.mName); - if (m.getMolten(1) != null) binds.put(p.getFluid(), m.getMolten(1).getFluid()); - else if (m.getGas(1) != null) binds.put(p.getFluid(), m.getGas(1).getFluid()); - else if (m.getFluid(1) != null) binds.put(p.getFluid(), m.getFluid(1).getFluid()); - else binds.put(p.getFluid(), Materials.Iron.getMolten(1).getFluid()); + if (DEBUG_MODE) { + Logger.info("Found Plasma of " + material.mName); + } + if (material.mElement != null && + (material.mElement.mProtons >= Materials.Iron.mElement.mProtons || + -material.mElement.mProtons >= Materials.Iron.mElement.mProtons || + material.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons || + -material.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons)) { + if (DEBUG_MODE) { + Logger.info("Attempting to bind " + material.mName); + } + if (material.getMolten(1) != null) { + binds.put(p.getFluid(), material.getMolten(1).getFluid()); + } else if (material.getGas(1) != null) { + binds.put(p.getFluid(), material.getGas(1).getFluid()); + } else if (material.getFluid(1) != null) { + binds.put(p.getFluid(), material.getFluid(1).getFluid()); + } else { + binds.put(p.getFluid(), Materials.Iron.getMolten(1).getFluid()); + } } } } for (GT_Recipe r : GT_Recipe.GT_Recipe_Map.sFusionRecipes.mRecipeList) { - Fluid f = binds.get(r.mFluidOutputs[0].getFluid()); - if (f != null) { - if (DEBUG_MODE) - TecTech.Logger.info("Nerfing Recipe " + r.mFluidOutputs[0].getUnlocalizedName()); - r.mFluidOutputs[0] = new FluidStack(f, r.mFluidInputs[0].amount); + Fluid fluid = binds.get(r.mFluidOutputs[0].getFluid()); + if (fluid != null) { + if (DEBUG_MODE) { + Logger.info("Nerfing Recipe " + r.mFluidOutputs[0].getUnlocalizedName()); + } + r.mFluidOutputs[0] = new FluidStack(fluid, r.mFluidInputs[0].amount); } } } @@ -167,9 +185,10 @@ public class TecTech { modId = GameRegistry.findUniqueIdentifierFor(block).modId; if (modIDs.contains(modId)) {//Full Whitelisted Mods continue; - } else if (modId.equals("OpenBlocks")) { - if (GameRegistry.findUniqueIdentifierFor(block).name.equals("grave")) + } else if ("OpenBlocks".equals(modId)) { + if ("grave".equals(GameRegistry.findUniqueIdentifierFor(block).name)) { continue; + } } block.setResistance(6); } diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index aa3f8eee1d..25327e1369 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -10,6 +10,8 @@ import gregtech.api.util.GT_Utility; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -30,16 +32,19 @@ import static gregtech.api.enums.GT_Values.E; /** * Created by Tec on 21.03.2017. */ -public class Util { +public final class Util { + private Util() {} + public static String intBitsToString(int number) { - StringBuilder result = new StringBuilder(); + StringBuilder result = new StringBuilder(16); for (int i = 31; i >= 0; i--) { int mask = 1 << i; result.append((number & mask) != 0 ? "1" : "0"); - if (i % 8 == 0) - result.append(" "); + if (i % 8 == 0) { + result.append(' '); + } } result.replace(result.length() - 1, result.length(), ""); @@ -47,14 +52,15 @@ public class Util { } public static String intBitsToShortString(int number) { - StringBuilder result = new StringBuilder(); + StringBuilder result = new StringBuilder(16); for (int i = 31; i >= 0; i--) { int mask = 1 << i; result.append((number & mask) != 0 ? ":" : "."); - if (i % 8 == 0) - result.append("|"); + if (i % 8 == 0) { + result.append('|'); + } } result.replace(result.length() - 1, result.length(), ""); @@ -70,12 +76,14 @@ public class Util { IGregTechTileEntity aBaseMetaTileEntity, boolean forceCheck) { World world = aBaseMetaTileEntity.getWorld(); - if (world.isRemote) return false; + if (world.isRemote) { + return false; + } //TE Rotation byte facing = aBaseMetaTileEntity.getFrontFacing(); int x, y, z, a, b, c, pointer; - final int + int baseX=aBaseMetaTileEntity.getXCoord(), baseZ=aBaseMetaTileEntity.getZCoord(), baseY=aBaseMetaTileEntity.getYCoord(); @@ -94,12 +102,14 @@ public class Util { b -= block; break; } if (block > '@')//characters allow to skip check a-1 skip, b-2 skips etc. + { a += block - '@'; - else if (block < '+')//used to mark THINGS + } else if (block < '+')//used to mark THINGS + { a++; - else if (block=='.') + } else if (block=='.') { a++; - else { + } else { //get x y z from rotation switch (facing) {//translation case 4: @@ -138,34 +148,42 @@ public class Util { } //that must be here since in some cases other axis (b,c) controls y - if (y < 0 || y >= 256) return false; + if (y < 0 || y >= 256) { + return false; + } //Check block if (world.blockExists(x, y, z)) {//this actually checks if the chunk is loaded at this pos switch (block) { case '-'://must be air - if (world.getBlock(x, y, z).getMaterial() != Material.air) + if (world.getBlock(x, y, z).getMaterial() != Material.air) { return false; + } break; case '+'://must not be air - if (world.getBlock(x, y, z).getMaterial() == Material.air) + if (world.getBlock(x, y, z).getMaterial() == Material.air) { return false; + } break; default: //check for block (countable) pointer = block - '0'; //countable air -> net.minecraft.block.BlockAir if (world.getBlock(x, y, z) != blockType[pointer]) { - if (DEBUG_MODE) - TecTech.Logger.info("Struct-block-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + " " + blockType[pointer].getUnlocalizedName()); + if (DEBUG_MODE) { + TecTech.Logger.info("Struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + blockType[pointer].getUnlocalizedName()); + } return false; } if (world.getBlockMetadata(x, y, z) != blockMeta[pointer]) { - if (DEBUG_MODE) - TecTech.Logger.info("Struct-meta-id-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlockMetadata(x, y, z) + " " + blockMeta[pointer]); + if (DEBUG_MODE) { + TecTech.Logger.info("Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMeta[pointer]); + } return false; } } - } else if (forceCheck) return false; + } else if (forceCheck) { + return false; + } a++;//block in horizontal layer } } @@ -191,7 +209,9 @@ public class Util { IGregTechTileEntity aBaseMetaTileEntity, boolean forceCheck) { World world = aBaseMetaTileEntity.getWorld(); - if (world.isRemote) return false; + if (world.isRemote) { + return false; + } //TE Rotation byte facing = aBaseMetaTileEntity.getFrontFacing(); @@ -199,7 +219,7 @@ public class Util { IMetaTileEntity imt = aBaseMetaTileEntity.getMetaTileEntity(); int x, y, z, a, b, c, pointer; - final int + int baseX=aBaseMetaTileEntity.getXCoord(), baseZ=aBaseMetaTileEntity.getZCoord(), baseY=aBaseMetaTileEntity.getYCoord(); @@ -217,13 +237,14 @@ public class Util { if (block < ' ') {//Control chars allow skipping b -= block; break; - } else if (block > '@') //characters allow to skip check a-1 skip, b-2 skips etc. + } else if (block > '@') //characters allow to skip check A-1 skip, B-2 skips etc. + { a += block - '@'; - //else if (block < '+')//used to mark THINGS + }//else if (block < '+')//used to mark THINGS // a++; - else if (block=='.') + else if (block=='.') { a++; - else { + } else { //get x y z from rotation switch (facing) {//translation case 4: @@ -262,30 +283,36 @@ public class Util { } //that must be here since in some cases other axis (b,c) controls y - if (y < 0 || y >= 256) return false; + if (y < 0 || y >= 256) { + return false; + } //Check block if (world.blockExists(x, y, z)) {//this actually checks if the chunk is loaded at this pos switch (block) { case '-'://must be air - if (world.getBlock(x, y, z).getMaterial() != Material.air) + if (world.getBlock(x, y, z).getMaterial() != Material.air) { return false; + } break; case '+'://must not be air - if (world.getBlock(x, y, z).getMaterial() == Material.air) + if (world.getBlock(x, y, z).getMaterial() == Material.air) { return false; + } break; default://check for block (countable) if ((pointer = block - '0') >= 0) { //countable air -> net.minecraft.block.BlockAir if (world.getBlock(x, y, z) != blockType[pointer]) { - if (DEBUG_MODE) - TecTech.Logger.info("Struct-block-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + " " + blockType[pointer].getUnlocalizedName()); + if (DEBUG_MODE) { + TecTech.Logger.info("Struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + blockType[pointer].getUnlocalizedName()); + } return false; } if (world.getBlockMetadata(x, y, z) != blockMeta[pointer]) { - if (DEBUG_MODE) - TecTech.Logger.info("Struct-meta-id-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlockMetadata(x, y, z) + " " + blockMeta[pointer]); + if (DEBUG_MODE) { + TecTech.Logger.info("Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMeta[pointer]); + } return false; } } else if ((pointer = block - ' ') >= 0) { @@ -293,23 +320,29 @@ public class Util { try { if (igt == null || !(boolean) adder.invoke(imt, addingMethods[pointer], igt, casingTextures[pointer])) { if (world.getBlock(x, y, z) != blockTypeFallback[pointer]) { - if (DEBUG_MODE) - TecTech.Logger.info("Fallback-struct-block-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + " " + blockTypeFallback[pointer].getUnlocalizedName()); + if (DEBUG_MODE) { + TecTech.Logger.info("Fallback-struct-block-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + ' ' + blockTypeFallback[pointer].getUnlocalizedName()); + } return false; } if (world.getBlockMetadata(x, y, z) != blockMetaFallback[pointer]) { - if (DEBUG_MODE) - TecTech.Logger.info("Fallback-Struct-meta-id-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlockMetadata(x, y, z) + " " + blockMetaFallback[pointer]); + if (DEBUG_MODE) { + TecTech.Logger.info("Fallback-Struct-meta-id-error " + x + ' ' + y + ' ' + z + " / " + a + ' ' + b + ' ' + c + " / " + world.getBlockMetadata(x, y, z) + ' ' + blockMetaFallback[pointer]); + } return false; } } } catch (InvocationTargetException | IllegalAccessException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return false; } } } - } else if (forceCheck) return false; + } else if (forceCheck) { + return false; + } a++;//block in horizontal layer } } @@ -337,14 +370,18 @@ public class Util { byte[] blockMeta,//use numbers 0-9 for casing types int horizontalOffset, int verticalOffset, int depthOffset, TileEntity tileEntity, int facing, boolean hintsOnly) { - if(!tileEntity.hasWorldObj()) return false; + if(!tileEntity.hasWorldObj()) { + return false; + } World world = tileEntity.getWorldObj(); - if (!world.isRemote && hintsOnly) return false; + if (!world.isRemote && hintsOnly) { + return false; + } //TE Rotation int x, y, z, a, b, c, pointer; - final int + int baseX=tileEntity.xCoord, baseZ=tileEntity.zCoord, baseY=tileEntity.yCoord; @@ -362,12 +399,14 @@ public class Util { b -= block; break; } if (block > '@')//characters allow to skip check a-1 skip, b-2 skips etc. + { a += block - '@'; - //else if (block < '+')//used to mark THINGS + }//else if (block < '+')//used to mark THINGS // a++; else if (block=='.')// this TE + { a++; - else { + } else { //get x y z from rotation switch (facing) {//translation case 4: @@ -406,7 +445,9 @@ public class Util { } //that must be here since in some cases other axis (b,c) controls y - if (y < 0 || y >= 256) return false; + if (y < 0 || y >= 256) { + return false; + } //Check block if (world.blockExists(x, y, z)) {//this actually checks if the chunk is loaded @@ -420,15 +461,18 @@ public class Util { break; default: //check for block if ((pointer = block - '0') >= 0) { - if(world.getBlock(x,y,z)!=blockType[pointer] || world.getBlockMetadata(x,y,z)!=blockMeta[pointer]) - TecTech.proxy.hint_particle(world,x, y, z, blockType[pointer], blockMeta[pointer]); + if(world.getBlock(x,y,z)!=blockType[pointer] || world.getBlockMetadata(x,y,z)!=blockMeta[pointer]) { + TecTech.proxy.hint_particle(world, x, y, z, blockType[pointer], blockMeta[pointer]); + } } else if ((pointer = block - ' ') >= 0) { - switch(pointer){ - case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: - TecTech.proxy.hint_particle(world,x, y, z, TT_Container_Casings.sHintCasingsTT, pointer); break; - default:TecTech.proxy.hint_particle(world,x, y, z, TT_Container_Casings.sHintCasingsTT, 12); + if(pointer>=0 && pointer<12) { + TecTech.proxy.hint_particle(world, x, y, z, TT_Container_Casings.sHintCasingsTT, pointer); + } else { + TecTech.proxy.hint_particle(world, x, y, z, TT_Container_Casings.sHintCasingsTT, 12); } - } else TecTech.proxy.hint_particle(world,x, y, z, TT_Container_Casings.sHintCasingsTT, 15); + } else { + TecTech.proxy.hint_particle(world, x, y, z, TT_Container_Casings.sHintCasingsTT, 15); + } } }else{ switch (block) { @@ -441,13 +485,15 @@ public class Util { default: //check for block if ((pointer = block - '0') >= 0) { world.setBlock(x, y, z, blockType[pointer], blockMeta[pointer], 2); - } else if ((pointer = block - ' ') >= 0) { + } else if (block - ' ' < 0) { + world.setBlock(x, y, z, TT_Container_Casings.sHintCasingsTT, 15, 2); + } //else { //switch(pointer){ // case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: // world.setBlock(x, y, z, TT_Container_Casings.sHintCasingsTT, pointer, 2); break; // default:world.setBlock(x, y, z, TT_Container_Casings.sHintCasingsTT, 12, 2); //} - } else world.setBlock(x, y, z, TT_Container_Casings.sHintCasingsTT, 15,2); + //} } } } @@ -467,12 +513,14 @@ public class Util { //TE Rotation byte facing = aBaseMetaTileEntity.getFrontFacing(); World world = aBaseMetaTileEntity.getWorld(); - if (world.isRemote) return new String[]{"Not at Client m8"}; + if (world.isRemote) { + return new String[]{"Not at Client m8"}; + } ItemStack[] array = new ItemStack[10]; int x, y, z, a, b, c; - final int + int baseX=aBaseMetaTileEntity.getXCoord(), baseZ=aBaseMetaTileEntity.getZCoord(), baseY=aBaseMetaTileEntity.getYCoord(); @@ -525,7 +573,9 @@ public class Util { } //that must be here since in some cases other axis (b,c) controls y - if (y < 0 || y >= 256) return new String[]{"Invalid position"}; + if (y < 0 || y >= 256) { + return new String[]{"Invalid position"}; + } //Check block Block block = world.getBlock(x, y, z); @@ -533,7 +583,7 @@ public class Util { if (!block.hasTileEntity(meta) && block.getMaterial() != Material.air) { boolean err = true; - final ItemStack is = new ItemStack(block, 1, meta); + ItemStack is = new ItemStack(block, 1, meta); for (int i = 0; i < array.length; i++) { if (array[i] == null) { array[i] = is; @@ -544,7 +594,9 @@ public class Util { break; } } - if (err) return new String[]{"Too much different blocks"}; + if (err) { + return new String[]{"Too much different blocks"}; + } } a++;//block in horizontal layer @@ -556,8 +608,8 @@ public class Util { List<String> output = new ArrayList<>(); - output.add("Offsets: " + horizontalOffset + " " + verticalOffset + " " + depthOffset); - output.add("Sizes: " + horizontalSize + " " + verticalSize + " " + depthSize); + output.add("Offsets: " + horizontalOffset + ' ' + verticalOffset + ' ' + depthOffset); + output.add("Sizes: " + horizontalSize + ' ' + verticalSize + ' ' + depthSize); output.add(""); output.add("ID[]: Name[]"); @@ -572,7 +624,7 @@ public class Util { output.add(""); for (int i = 0; i < array.length; i++) { if (array[i] != null) { - output.add(i + ": " + array[i].getItem().getUnlocalizedName() + " " + array[i].getItemDamage()); + output.add(i + ": " + array[i].getItem().getUnlocalizedName() + ' ' + array[i].getItemDamage()); } } output.add(""); @@ -582,10 +634,10 @@ public class Util { c = -depthOffset; for (int cz = 0; cz < depthSize; cz++) {//front to back b = verticalOffset; - String addMe = "{"; + StringBuilder addMe = new StringBuilder().append('{'); for (int by = 0; by < verticalSize; by++) {//top to bottom a = -horizontalOffset; - String line = ""; + StringBuilder line = new StringBuilder(); for (int az = 0; az < horizontalSize; az++) {//left to right //get x y z from rotation switch (facing) {//translation @@ -629,11 +681,11 @@ public class Util { int meta = world.getBlockMetadata(x, y, z); if (a == 0 && b == 0 && c == 0) { - line += '.'; + line.append('.'); } else if (block.getMaterial() == Material.air) { - line += '-'; + line.append('-'); } else if (block.hasTileEntity(meta)) { - line += '*'; + line.append('*'); } else { ItemStack stack = new ItemStack(block, 1, meta); String str = "?";//OH YEAH NPEs @@ -643,73 +695,81 @@ public class Util { break; } } - line += str; + line.append(str); } a++;//block in horizontal layer } if (ignoreAir) { - String l = ""; + StringBuilder builder = new StringBuilder(); char temp = '@'; - for (char ch : line.toCharArray()) { + for (char ch : line.toString().toCharArray()){ if (ch == '-') { temp += 1; if (temp == '~') { - l += '~'; + builder.append('~'); temp = '@'; } } else { if (temp > '@') { - l += temp; + builder.append(temp); temp = '@'; } - l += ch; + builder.append(ch); } } - while (l.length() > 0 && l.toCharArray()[l.length() - 1] == '~') - l = l.substring(0, l.length() - 1); - if (l.length() == 0) - l = "E,"; - else { - l = "\"" + l + "\","; + while (builder.length()>0 && builder.charAt(builder.length() - 1) == '~') { + builder.deleteCharAt(builder.length() - 1); + } + if (builder.length()==0) { + builder.append("E,"); + } else { + builder.insert(0,'"'); + builder.append('"').append(','); } - addMe += l; + addMe.append(builder); } else { - if (line.length() == 0) - line = "E,"; - else { - line = "\"" + line + "\","; + if (line.length()==0) { + line.append("E,"); + } else { + line.insert(0,'"'); + line.append('"').append(','); } - addMe += line; + addMe.append(line); } b--;//horizontal layer } //region less verbose - addMe=(addMe + "},").replaceAll("(E,)+(?=})",E/*Remove Empty strings at end*/); - Matcher m = matchE_.matcher(addMe); - while (m.find()) { - byte lenEE = (byte)(m.group(1).length()>>1); - addMe=addMe.replaceFirst("E,(E,)+","\"\\\\u00"+String.format("%02X", lenEE-1)+"\","); - //addMe=addMe.replaceFirst("E,(E,)+\"","\"\\\\u00"+String.format("%02X", lenEE)); + addMe.append('}').append(','); + String builtStr=addMe.toString().replaceAll("(E,)+(?=})",E/*Remove Empty strings at end*/); + Matcher matcher = matchE_.matcher(builtStr); + while (matcher.find()) { + byte lenEE = (byte)(matcher.group(1).length()>>1); + builtStr=builtStr.replaceFirst("E,(E,)+","\"\\\\u00"+String.format("%02X", lenEE-1)+"\","); + //builtStr=builtStr.replaceFirst("E,(E,)+\"","\"\\\\u00"+String.format("%02X", lenEE)); } //endregion - output.add(addMe); + output.add(builtStr); c++;//depth } output.add("}"); - return output.toArray(new String[0]); + return output.toArray(new String[output.size()]); } private static final Pattern matchE_ = Pattern.compile("(E,(E,)+)"); public static 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; + if (!GregTech_API.sPostloadFinished) { + return false; + } + if (requiredFluidInputs.length > 0 && givenFluidInputs == null) { + return false; + } int amt; - for (FluidStack tFluid : requiredFluidInputs) + for (FluidStack tFluid : requiredFluidInputs) { if (tFluid != null) { boolean temp = true; amt = tFluid.amount; - for (FluidStack aFluid : givenFluidInputs) + for (FluidStack aFluid : givenFluidInputs) { if (aFluid != null && aFluid.isFluidEqual(tFluid)) { if (aDontCheckStackSizes) { temp = false; @@ -721,16 +781,22 @@ public class Util { break; } } - if (temp) return false; + } + if (temp) { + return false; + } } + } - if (requiredInputs.length > 0 && givenInputs == null) 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 (GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) { if (aDontCheckStackSizes) { temp = false; break; @@ -742,7 +808,9 @@ public class Util { } } } - if (temp) return false; + if (temp) { + return false; + } } } @@ -762,7 +830,6 @@ public class Util { aFluid.amount = 0; } else { aFluid.amount -= amt; - amt = 0; break; } } @@ -776,7 +843,7 @@ public class Util { 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 (GT_Utility.areUnificationsEqual(aStack, tStack, true) || GT_Utility.areUnificationsEqual(GT_OreDictUnificator.get(false, aStack), tStack, true)) { if (aDontCheckStackSizes) { aStack.stackSize -= amt; break; @@ -786,7 +853,6 @@ public class Util { aStack.stackSize = 0; } else { aStack.stackSize -= amt; - amt = 0; break; } } @@ -800,7 +866,7 @@ public class Util { } public static String getUniqueIdentifier(ItemStack is) { - return GameRegistry.findUniqueIdentifierFor(is.getItem()).modId + ":" + is.getUnlocalizedName(); + return GameRegistry.findUniqueIdentifierFor(is.getItem()).modId + ':' + is.getUnlocalizedName(); } @@ -808,16 +874,16 @@ public class Util { public static final long[] V = new long[]{8L, 32L, 128L, 512L, 2048L, 8192L, 32768L, 131072L, 524288L, 2097152L, 8388608L, 33554432L, 134217728L, 536870912L, 1073741824L, Integer.MAX_VALUE-7}; public static byte getTier(long l) { - byte i = -1; + byte b = -1; do { - ++i; - if (i >= V.length) { - return i; + ++b; + if (b >= V.length) { + return b; } - } while(l > V[i]); + } while(l > V[b]); - return i; + return b; } public static String[] splitButDifferent(String string,String delimiter){ @@ -833,13 +899,68 @@ public class Util { } public static String[] infoFromNBT(NBTTagCompound nbt) { - final String[] strings = new String[nbt.getInteger("i")]; - for (int i = 0; i < strings.length; i++) + String[] strings = new String[nbt.getInteger("i")]; + for (int i = 0; i < strings.length; i++) { strings[i] = nbt.getString(Integer.toString(i)); + } return strings; } public static boolean areBitsSet(int setBits,int testedValue){ return (testedValue&setBits)==setBits; } + + public static class TT_ItemStack implements Comparable<TT_ItemStack>{ + public final Item mItem; + public final int mStackSize; + public final int mMetaData; + + public TT_ItemStack(Item aItem, long aStackSize, long aMetaData) { + this.mItem = aItem; + this.mStackSize = (byte)((int)aStackSize); + this.mMetaData = (short)((int)aMetaData); + } + + public TT_ItemStack(ItemStack aStack) { + if(aStack==null){ + mItem=null; + mStackSize=mMetaData=0; + }else{ + mItem=aStack.getItem(); + mStackSize=aStack.stackSize; + mMetaData=Items.feather.getDamage(aStack); + } + } + + @Override + public int compareTo(TT_ItemStack o) { + if(mMetaData>o.mMetaData) return 1; + if(mMetaData<o.mMetaData) return -1; + if(mStackSize>o.mStackSize) return 1; + if(mStackSize<o.mStackSize) return -1; + if(mItem!=null && o.mItem!=null) return mItem.getUnlocalizedName().compareTo(o.mItem.getUnlocalizedName()); + if(mItem==null && o.mItem==null) return 0; + if(mItem!=null) return 1; + return -1; + } + + @Override + public boolean equals(Object aStack) { + return aStack == this || + (aStack instanceof TT_ItemStack && + ((mItem==((TT_ItemStack) aStack).mItem) || ((TT_ItemStack) aStack).mItem.getUnlocalizedName().equals(this.mItem.getUnlocalizedName())) && + ((TT_ItemStack) aStack).mStackSize == this.mStackSize && + ((TT_ItemStack) aStack).mMetaData == this.mMetaData); + } + + @Override + public int hashCode() { + return (mItem!=null?mItem.getUnlocalizedName().hashCode():0) ^ (mMetaData << 16) ^ (mStackSize<<24); + } + + @Override + public String toString() { + return Integer.toString(hashCode())+' '+(mItem==null?"null":mItem.getUnlocalizedName())+' '+mMetaData+' '+mStackSize; + } + } } diff --git a/src/main/java/com/github/technus/tectech/Vec3pos.java b/src/main/java/com/github/technus/tectech/Vec3pos.java index b38a76ded5..eb694813da 100644 --- a/src/main/java/com/github/technus/tectech/Vec3pos.java +++ b/src/main/java/com/github/technus/tectech/Vec3pos.java @@ -16,17 +16,21 @@ public class Vec3pos implements Comparable<Vec3pos> { } public Vec3pos(IGregTechTileEntity te) { - this.x = te.getXCoord(); - this.y = te.getYCoord(); - this.z = te.getZCoord(); + x = te.getXCoord(); + y = te.getYCoord(); + z = te.getZCoord(); } @Override public int compareTo(Vec3pos o) { int tmp=y-o.y; - if (tmp!=0) return tmp; + if (tmp!=0) { + return tmp; + } tmp=x-o.x; - if (tmp!=0) return tmp; + if (tmp!=0) { + return tmp; + } return z-o.z; } diff --git a/src/main/java/com/github/technus/tectech/XSTR.java b/src/main/java/com/github/technus/tectech/XSTR.java index cb19449d85..f5ff457fe1 100644 --- a/src/main/java/com/github/technus/tectech/XSTR.java +++ b/src/main/java/com/github/technus/tectech/XSTR.java @@ -1,23 +1,23 @@ package com.github.technus.tectech; -/** - * A subclass of java.util.random that implements the Xorshift random number - * generator - * <p> - * - 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 - * <p> - * Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); - * //pull a random number - * <p> - * 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(); - * <p> - * 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 +/* + A subclass of java.util.random that implements the Xorshift random number + generator + <p> + - 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 + <p> + Usage: XSRandom rand = new XSRandom(); //Instantiation x = rand.nextInt(); + //pull a random number + <p> + 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(); + <p> + 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 * <p> * This code is released under the GNU Lesser General Public License Version 3 @@ -37,18 +37,18 @@ 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) private static final AtomicLong seedUniquifier = new AtomicLong(8682522807148012L); - public final static XSTR XSTR_INSTANCE=new XSTR(){ + public static final XSTR XSTR_INSTANCE=new XSTR(){ @Override public synchronized void setSeed(long seed) { - if(!Thread.currentThread().getStackTrace()[2].getClassName().equals(Random.class.getName())) + if(!Thread.currentThread().getStackTrace()[2].getClassName().equals(Random.class.getName())) { throw new NoSuchMethodError("This is meant to be shared!, leave seed state alone!"); + } } }; @@ -69,7 +69,7 @@ public class XSTR extends Random { private static long seedUniquifier() { // L'Ecuyer, "Tables of Linear Congruential Generators of // Different Sizes and Good Lattice Structure", 1999 - for (; ; ) { + while (true) { long current = seedUniquifier.get(); long next = current * 181783497276652981L; if (seedUniquifier.compareAndSet(current, next)) { @@ -88,12 +88,14 @@ public class XSTR extends Random { this.seed = seed; } + @Override public boolean nextBoolean() { return next(1) != 0; } + @Override public double nextDouble() { - return (((long) (next(26)) << 27) + next(27)) * DOUBLE_UNIT; + return (((long) next(26) << 27) + next(27)) * DOUBLE_UNIT; } /** @@ -112,6 +114,7 @@ public class XSTR extends Random { * * @param seed the new seed */ + @Override public synchronized void setSeed(long seed) { this.seed = seed; } @@ -129,35 +132,37 @@ public class XSTR extends Random { * 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 + * @param nbits will shift nbits bits + * @return next seed */ + @Override public int next(int nbits) { long x = seed; - x ^= (x << 21); - x ^= (x >>> 35); - x ^= (x << 4); + x ^= x << 21; + x ^= x >>> 35; + x ^= x << 4; seed = x; - x &= ((1L << nbits) - 1); + x &= (1L << nbits) - 1; return (int) x; } private boolean haveNextNextGaussian = false; private double nextNextGaussian = 0; - synchronized public double nextGaussian() { + @Override + public synchronized double nextGaussian() { // See Knuth, ACP, Section 3.4.1 Algorithm C. if (haveNextNextGaussian) { haveNextNextGaussian = false; return nextNextGaussian; } else { - double v1, v2, s; + double v1, v2, vs; 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); + vs = v1 * v1 + v2 * v2; + } while (vs >= 1 || vs == 0); + double multiplier = StrictMath.sqrt(-2 * StrictMath.log(vs) / vs); nextNextGaussian = v2 * multiplier; haveNextNextGaussian = true; return v1 * multiplier; @@ -219,6 +224,7 @@ public class XSTR extends Random { * @throws IllegalArgumentException if bound is not positive * @since 1.2 */ + @Override public int nextInt(int bound) { //if (bound <= 0) { //throw new RuntimeException("BadBound"); @@ -237,32 +243,36 @@ public class XSTR extends Random { } return r;*/ //speedup, new nextInt ~+40% - last = seed ^ (seed << 21); - last ^= (last >>> 35); - last ^= (last << 4); + long last = seed ^ seed << 21; + last ^= last >>> 35; + last ^= last << 4; seed = last; int out = (int) last % bound; - return (out < 0) ? -out : out; + return out < 0 ? -out : out; } + @Override public int nextInt() { return next(32); } + @Override public float nextFloat() { return next(24) * FLOAT_UNIT; } + @Override public long nextLong() { // it's okay that the bottom word remains signed. - return ((long) (next(32)) << 32) + next(32); + return ((long) next(32) << 32) + next(32); } + @Override 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) + 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/Reference.java b/src/main/java/com/github/technus/tectech/auxiliary/Reference.java index cc5202636a..828974af05 100644 --- a/src/main/java/com/github/technus/tectech/auxiliary/Reference.java +++ b/src/main/java/com/github/technus/tectech/auxiliary/Reference.java @@ -9,4 +9,6 @@ public final class Reference { public static final String SERVERSIDE = "com.github.technus.tectech.proxy.CommonProxy"; public static final String COFHCORE = "CoFHCore"; public static final String THAUMCRAFT = "Thaumcraft"; + + private Reference() {} } diff --git a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java index 7bf0b43cb6..6cb1b669e9 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/compatibility/dreamcraft/DreamCraftRecipeLoader.java @@ -4,6 +4,9 @@ import com.github.technus.tectech.recipe.TT_recipeAdder; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.item.ConstructableTriggerItem; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_Centrifuge; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_ElectromagneticSeparator; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine; import gregtech.api.enums.*; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; @@ -18,11 +21,9 @@ import net.minecraftforge.fluids.FluidStack; public class DreamCraftRecipeLoader implements Runnable { @Override public void run() { - Object[] o = new Object[0]; - //Quantum Glass GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Containment.get(1, o), + CustomItemList.eM_Containment.get(1), GT_ModHandler.getIC2Item("reinforcedGlass", 1L) }, Materials.Trinium.getMolten(576), new ItemStack(QuantumGlassBlock.INSTANCE, 1), 200, 500000); @@ -35,9 +36,9 @@ public class DreamCraftRecipeLoader implements Runnable { //Data GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - ItemList.Circuit_Parts_GlassFiber.get(8, o), + ItemList.Circuit_Parts_GlassFiber.get(8), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silver, 8) - }, Materials.Polytetrafluoroethylene.getMolten(144), CustomItemList.DATApipe.get(1, o), 200, 30720, true); + }, Materials.Polytetrafluoroethylene.getMolten(144), CustomItemList.DATApipe.get(1), 200, 30720, true); //endregion @@ -52,42 +53,42 @@ public class DreamCraftRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 16), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Copper, 16), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NiobiumTitanium, 2) - }, Materials.TungstenSteel.getMolten(576), CustomItemList.eM_Power.get(1, o), 100, 30720); + }, Materials.TungstenSteel.getMolten(576), CustomItemList.eM_Power.get(1), 100, 30720); //Computer Casing GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Power.get(1, o), + CustomItemList.eM_Power.get(1), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 8), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NiobiumTitanium, 2) - }, Materials.Aluminium.getMolten(1296), CustomItemList.eM_Computer_Casing.get(1, o), 200, 122880); + }, Materials.Aluminium.getMolten(1296), CustomItemList.eM_Computer_Casing.get(1), 200, 122880); //Computer Vent Casing GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.StainlessSteel, 1), - ItemList.Electric_Motor_IV.get(2, o), + ItemList.Electric_Motor_IV.get(2), GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.StainlessSteel, 2), GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.StainlessSteel, 16), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Copper, 16), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 1) - }, Materials.SolderingAlloy.getMolten(1296), CustomItemList.eM_Computer_Vent.get(1, o), 100, 1920); + }, Materials.SolderingAlloy.getMolten(1296), CustomItemList.eM_Computer_Vent.get(1), 100, 1920); //Advanced Computer Casing GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), + CustomItemList.eM_Computer_Casing.get(1), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 64), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Electrum, 64), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Superconductor, 4) - }, Materials.Iridium.getMolten(1296), CustomItemList.eM_Computer_Bus.get(1, o), 200, 122880, true); + }, Materials.Iridium.getMolten(1296), CustomItemList.eM_Computer_Bus.get(1), 200, 122880, true); //Molecular Casing GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Power.get(1, o), + CustomItemList.eM_Power.get(1), GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Osmiridium, 6), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Trinium, 12), GT_OreDictUnificator.get(OrePrefixes.screw, Materials.TungstenSteel, 24), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.TungstenSteel, 24), - ItemList.Field_Generator_IV.get(1, o) - }, Materials.Osmium.getMolten(1296), CustomItemList.eM_Containment.get(1, o), 800, 500000); + ItemList.Field_Generator_IV.get(1) + }, Materials.Osmium.getMolten(1296), CustomItemList.eM_Containment.get(1), 800, 500000); //Hollow Casing TT_recipeAdder.addResearchableAssemblylineRecipe(CustomItemList.eM_Containment.get(1), @@ -126,73 +127,73 @@ public class DreamCraftRecipeLoader implements Runnable { //region hatches //Dynamo Hatches UV-UIV - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2)}, Materials.Silver.getMolten(1000), CustomItemList.eM_dynamomulti4_UV.get(1, o), 100, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Transformer_MAX_UV.get(1, o), CustomItemList.eM_dynamomulti4_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4)}, Materials.Electrum.getMolten(1000), CustomItemList.eM_dynamomulti16_UV.get(1, o), 200, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UHV_UV.get(1, o), CustomItemList.eM_dynamomulti16_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6)}, Materials.Tungsten.getMolten(1000), CustomItemList.eM_dynamomulti64_UV.get(1, o), 400, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2)}, Materials.Silver.getMolten(1000), CustomItemList.eM_dynamomulti4_UV.get(1), 100, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Transformer_MAX_UV.get(1), CustomItemList.eM_dynamomulti4_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4)}, Materials.Electrum.getMolten(1000), CustomItemList.eM_dynamomulti16_UV.get(1), 200, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UHV_UV.get(1), CustomItemList.eM_dynamomulti16_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6)}, Materials.Tungsten.getMolten(1000), CustomItemList.eM_dynamomulti64_UV.get(1), 400, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_MAX.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2)}, Materials.Silver.getMolten(2000), CustomItemList.eM_dynamomulti4_UHV.get(1, o), 100, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UEV_UHV.get(1, o), CustomItemList.eM_dynamomulti4_UHV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4)}, Materials.Electrum.getMolten(2000), CustomItemList.eM_dynamomulti16_UHV.get(1, o), 200, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UEV_UHV.get(1, o), CustomItemList.eM_dynamomulti16_UHV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6)}, Materials.Tungsten.getMolten(2000), CustomItemList.eM_dynamomulti64_UHV.get(1, o), 400, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2)}, Materials.Silver.getMolten(2000), CustomItemList.eM_dynamomulti4_UHV.get(1), 100, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UEV_UHV.get(1), CustomItemList.eM_dynamomulti4_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4)}, Materials.Electrum.getMolten(2000), CustomItemList.eM_dynamomulti16_UHV.get(1), 200, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UEV_UHV.get(1), CustomItemList.eM_dynamomulti16_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6)}, Materials.Tungsten.getMolten(2000), CustomItemList.eM_dynamomulti64_UHV.get(1), 400, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Hatch_Dynamo_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 2)}, Materials.Silver.getMolten(4000), CustomItemList.eM_dynamomulti4_UEV.get(1, o), 100, 2000000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UIV_UEV.get(1, o), CustomItemList.eM_dynamomulti4_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 4)}, Materials.Electrum.getMolten(4000), CustomItemList.eM_dynamomulti16_UEV.get(1, o), 200, 2000000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UIV_UEV.get(1, o), CustomItemList.eM_dynamomulti16_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 6)}, Materials.Tungsten.getMolten(4000), CustomItemList.eM_dynamomulti64_UEV.get(1, o), 400, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Hatch_Dynamo_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 2)}, Materials.Silver.getMolten(4000), CustomItemList.eM_dynamomulti4_UEV.get(1), 100, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UIV_UEV.get(1), CustomItemList.eM_dynamomulti4_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 4)}, Materials.Electrum.getMolten(4000), CustomItemList.eM_dynamomulti16_UEV.get(1), 200, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UIV_UEV.get(1), CustomItemList.eM_dynamomulti16_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 6)}, Materials.Tungsten.getMolten(4000), CustomItemList.eM_dynamomulti64_UEV.get(1), 400, 2000000); - //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Hatch_Dynamo_UIV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 2)}, Materials.Silver.getMolten(8000), CustomItemList.eM_dynamomulti4_UIV.get(1, o), 100, 8000000); - //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UMV_UIV.get(1, o), CustomItemList.eM_dynamomulti4_UIV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 4)}, Materials.Electrum.getMolten(8000), CustomItemList.eM_dynamomulti16_UIV.get(1, o), 200, 8000000); - //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UMV_UIV.get(1, o), CustomItemList.eM_dynamomulti16_UIV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 6)}, Materials.Tungsten.getMolten(8000), CustomItemList.eM_dynamomulti64_UIV.get(1, o), 400, 8000000); + //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Hatch_Dynamo_UIV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 2)}, Materials.Silver.getMolten(8000), CustomItemList.eM_dynamomulti4_UIV.get(1), 100, 8000000); + //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UMV_UIV.get(1), CustomItemList.eM_dynamomulti4_UIV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 4)}, Materials.Electrum.getMolten(8000), CustomItemList.eM_dynamomulti16_UIV.get(1), 200, 8000000); + //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UMV_UIV.get(1), CustomItemList.eM_dynamomulti16_UIV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 6)}, Materials.Tungsten.getMolten(8000), CustomItemList.eM_dynamomulti64_UIV.get(1), 400, 8000000); //Energy Hatches UV-UIV - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2)}, Materials.Silver.getMolten(1000), CustomItemList.eM_energymulti4_UV.get(1, o), 100, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Transformer_MAX_UV.get(1, o), CustomItemList.eM_energymulti4_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4)}, Materials.Electrum.getMolten(1000), CustomItemList.eM_energymulti16_UV.get(1, o), 200, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UHV_UV.get(1, o), CustomItemList.eM_energymulti16_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6)}, Materials.Tungsten.getMolten(1000), CustomItemList.eM_energymulti64_UV.get(1, o), 400, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2)}, Materials.Silver.getMolten(1000), CustomItemList.eM_energymulti4_UV.get(1), 100, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Transformer_MAX_UV.get(1), CustomItemList.eM_energymulti4_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4)}, Materials.Electrum.getMolten(1000), CustomItemList.eM_energymulti16_UV.get(1), 200, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UHV_UV.get(1), CustomItemList.eM_energymulti16_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6)}, Materials.Tungsten.getMolten(1000), CustomItemList.eM_energymulti64_UV.get(1), 400, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_MAX.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2)}, Materials.Silver.getMolten(2000), CustomItemList.eM_energymulti4_UHV.get(1, o), 100, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UEV_UHV.get(1, o), CustomItemList.eM_energymulti4_UHV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4)}, Materials.Electrum.getMolten(2000), CustomItemList.eM_energymulti16_UHV.get(1, o), 200, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UEV_UHV.get(1, o), CustomItemList.eM_energymulti16_UHV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6)}, Materials.Tungsten.getMolten(2000), CustomItemList.eM_energymulti64_UHV.get(1, o), 400, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2)}, Materials.Silver.getMolten(2000), CustomItemList.eM_energymulti4_UHV.get(1), 100, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UEV_UHV.get(1), CustomItemList.eM_energymulti4_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4)}, Materials.Electrum.getMolten(2000), CustomItemList.eM_energymulti16_UHV.get(1), 200, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UEV_UHV.get(1), CustomItemList.eM_energymulti16_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6)}, Materials.Tungsten.getMolten(2000), CustomItemList.eM_energymulti64_UHV.get(1), 400, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Hatch_Energy_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 2)}, Materials.Silver.getMolten(4000), CustomItemList.eM_energymulti4_UEV.get(1, o), 100, 2000000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UIV_UEV.get(1, o), CustomItemList.eM_energymulti4_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 4)}, Materials.Electrum.getMolten(4000), CustomItemList.eM_energymulti16_UEV.get(1, o), 200, 2000000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UIV_UEV.get(1, o), CustomItemList.eM_energymulti16_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 6)}, Materials.Tungsten.getMolten(4000), CustomItemList.eM_energymulti64_UEV.get(1, o), 400, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Hatch_Energy_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 2)}, Materials.Silver.getMolten(4000), CustomItemList.eM_energymulti4_UEV.get(1), 100, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UIV_UEV.get(1), CustomItemList.eM_energymulti4_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 4)}, Materials.Electrum.getMolten(4000), CustomItemList.eM_energymulti16_UEV.get(1), 200, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UIV_UEV.get(1), CustomItemList.eM_energymulti16_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Draconium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Bedrockium, 6)}, Materials.Tungsten.getMolten(4000), CustomItemList.eM_energymulti64_UEV.get(1), 400, 2000000); - //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Hatch_Energy_UIV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 2)}, Materials.Silver.getMolten(8000), CustomItemList.eM_energymulti4_UIV.get(1, o), 100, 8000000); - //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UMV_UIV.get(1, o), CustomItemList.eM_energymulti4_UIV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 4)}, Materials.Electrum.getMolten(8000), CustomItemList.eM_energymulti16_UIV.get(1, o), 200, 8000000); - //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UMV_UIV.get(1, o), CustomItemList.eM_energymulti16_UIV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 6)}, Materials.Tungsten.getMolten(8000), CustomItemList.eM_energymulti64_UIV.get(1, o), 400, 8000000); + //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Hatch_Energy_UIV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 2)}, Materials.Silver.getMolten(8000), CustomItemList.eM_energymulti4_UIV.get(1), 100, 8000000); + //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.Transformer_UMV_UIV.get(1), CustomItemList.eM_energymulti4_UIV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 4)}, Materials.Electrum.getMolten(8000), CustomItemList.eM_energymulti16_UIV.get(1), 200, 8000000); + //GT_Values.RA.addAssemblerRecipe(new ItemStack[]{com.dreammaster.gthandler.CustomItemList.WetTransformer_UMV_UIV.get(1), CustomItemList.eM_energymulti16_UIV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NetherStar, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.BlackPlutonium, 6)}, Materials.Tungsten.getMolten(8000), CustomItemList.eM_energymulti64_UIV.get(1), 400, 8000000); //Data Input GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), - ItemList.Hatch_Input_Bus_LuV.get(1, o), - ItemList.Circuit_Crystalcomputer.get(1, o), - CustomItemList.DATApipe.get(2, o) - }, Materials.Iridium.getMolten(1296), CustomItemList.dataIn_Hatch.get(1, o), 200, 122880, true); + CustomItemList.eM_Computer_Casing.get(1), + ItemList.Hatch_Input_Bus_LuV.get(1), + ItemList.Circuit_Crystalcomputer.get(1), + CustomItemList.DATApipe.get(2) + }, Materials.Iridium.getMolten(1296), CustomItemList.dataIn_Hatch.get(1), 200, 122880, true); //Data Output GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), - ItemList.Hatch_Output_Bus_LuV.get(1, o), - ItemList.Circuit_Crystalcomputer.get(1, o), - CustomItemList.DATApipe.get(2, o) - }, Materials.Iridium.getMolten(1296), CustomItemList.dataOut_Hatch.get(1, o), 200, 122880, true); + CustomItemList.eM_Computer_Casing.get(1), + ItemList.Hatch_Output_Bus_LuV.get(1), + ItemList.Circuit_Crystalcomputer.get(1), + CustomItemList.DATApipe.get(2) + }, Materials.Iridium.getMolten(1296), CustomItemList.dataOut_Hatch.get(1), 200, 122880, true); //Rack GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Bus.get(1, o), - ItemList.Hatch_Input_Bus_ZPM.get(1, o), - ItemList.Circuit_Crystalcomputer.get(2, o), - CustomItemList.DATApipe.get(4, o) - }, Materials.Iridium.getMolten(1296), CustomItemList.rack_Hatch.get(1, o), 800, 122880, true); + CustomItemList.eM_Computer_Bus.get(1), + ItemList.Hatch_Input_Bus_ZPM.get(1), + ItemList.Circuit_Crystalcomputer.get(2), + CustomItemList.DATApipe.get(4) + }, Materials.Iridium.getMolten(1296), CustomItemList.rack_Hatch.get(1), 800, 122880, true); //Object Holder GT_Values.RA.addAssemblylineRecipe(ItemList.Hatch_Input_Bus_ZPM.get(1), 10000, new ItemStack[]{ ItemList.Hatch_Input_Bus_ZPM.get(1), - CustomItemList.eM_Computer_Bus.get(1, o), + CustomItemList.eM_Computer_Bus.get(1), ItemList.Emitter_ZPM.get(8), ItemList.Robot_Arm_ZPM.get(1), ItemList.Electric_Motor_ZPM.get(2), ItemList.Circuit_Crystalmainframe.get(1), GT_OreDictUnificator.get(OrePrefixes.cableGt02, Materials.Naquadah, 2), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Naquadah, 16), - CustomItemList.DATApipe.get(2, o), + CustomItemList.DATApipe.get(2), }, new FluidStack[]{ Materials.UUMatter.getFluid(500), Materials.Iridium.getMolten(1000), @@ -201,42 +202,42 @@ public class DreamCraftRecipeLoader implements Runnable { //Parameterizer GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), - ItemList.Circuit_Masterquantumcomputer.get(1, o), - CustomItemList.DATApipe.get(4, o), - ItemList.Cover_Screen.get(1, o ), + CustomItemList.eM_Computer_Casing.get(1), + ItemList.Circuit_Masterquantumcomputer.get(1), + CustomItemList.DATApipe.get(4), + ItemList.Cover_Screen.get(1 ), new ItemStack(Blocks.stone_button, 16), - }, Materials.Iridium.getMolten(2592), CustomItemList.Parametrizer_Hatch.get(1, o), 800, 122880); + }, Materials.Iridium.getMolten(2592), CustomItemList.Parametrizer_Hatch.get(1), 800, 122880); //Uncertainty GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), - ItemList.Circuit_Ultimatecrystalcomputer.get(1, o), - CustomItemList.DATApipe.get(16, o), - ItemList.Cover_Screen.get(1, o ), + CustomItemList.eM_Computer_Casing.get(1), + ItemList.Circuit_Ultimatecrystalcomputer.get(1), + CustomItemList.DATApipe.get(16), + ItemList.Cover_Screen.get(1 ), new ItemStack(Blocks.stone_button, 16), - }, Materials.Iridium.getMolten(2592), CustomItemList.Uncertainty_Hatch.get(1, o), 1200, 122880, true); + }, Materials.Iridium.getMolten(2592), CustomItemList.Uncertainty_Hatch.get(1), 1200, 122880, true); //Elemental Input GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Containment.get(1, o), - ItemList.Hatch_Input_UV.get(1, o), + CustomItemList.eM_Containment.get(1), + ItemList.Hatch_Input_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Naquadah, 2), - ItemList.Sensor_UV.get(1, o) - }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_in_UV.get(1, o), 800, 500000, true); + ItemList.Sensor_UV.get(1) + }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_in_UV.get(1), 800, 500000, true); //Elemental Output GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Containment.get(1, o), - ItemList.Hatch_Output_UV.get(1, o), + CustomItemList.eM_Containment.get(1), + ItemList.Hatch_Output_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Naquadah, 2), - ItemList.Emitter_UV.get(1, o) - }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_out_UV.get(1, o), 800, 500000, true); + ItemList.Emitter_UV.get(1) + }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_out_UV.get(1), 800, 500000, true); //Overflow GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Containment.get(1, o), - ItemList.Hatch_Muffler_UV.get(1, o), + CustomItemList.eM_Containment.get(1), + ItemList.Hatch_Muffler_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Naquadah, 1), - ItemList.Field_Generator_UV.get(1, o) - }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_muffler_UV.get(1, o), 800, 500000, true); + ItemList.Field_Generator_UV.get(1) + }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_muffler_UV.get(1), 800, 500000, true); //endregion @@ -245,38 +246,38 @@ public class DreamCraftRecipeLoader implements Runnable { //Microwave Grinder GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - ItemList.Machine_HV_Microwave.get(1,o), + ItemList.Machine_HV_Microwave.get(1), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 4), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 4), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.AnnealedCopper, 16), - ItemList.Upgrade_Overclocker.get(4, o), - }, Materials.Copper.getMolten(576), CustomItemList.Machine_Multi_Microwave.get(1, o), 800, 480); + ItemList.Upgrade_Overclocker.get(4), + }, Materials.Copper.getMolten(576), CustomItemList.Machine_Multi_Microwave.get(1), 800, 480); //Active Transformer GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - com.dreammaster.gthandler.CustomItemList.WetTransformer_ZPM_LuV.get(1, o), - com.dreammaster.gthandler.CustomItemList.HighEnergyFlowCircuit.get(1, o), + com.dreammaster.gthandler.CustomItemList.WetTransformer_ZPM_LuV.get(1), + com.dreammaster.gthandler.CustomItemList.HighEnergyFlowCircuit.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 16), - ItemList.Circuit_Chip_UHPIC.get(2, o), - }, Materials.TungstenSteel.getMolten(576), CustomItemList.Machine_Multi_Transformer.get(1, o), 400, 30720); + ItemList.Circuit_Chip_UHPIC.get(2), + }, Materials.TungstenSteel.getMolten(576), CustomItemList.Machine_Multi_Transformer.get(1), 400, 30720); //Network Switch GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.Machine_Multi_Transformer.get(1, o), - ItemList.Circuit_Ultimatecrystalcomputer.get(1, o), + CustomItemList.Machine_Multi_Transformer.get(1), + ItemList.Circuit_Ultimatecrystalcomputer.get(1), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 64), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Copper, 64), - CustomItemList.DATApipe.get(4, o), - }, Materials.Iridium.getMolten(1296), CustomItemList.Machine_Multi_Switch.get(1, o), 800, 122880); + CustomItemList.DATApipe.get(4), + }, Materials.Iridium.getMolten(1296), CustomItemList.Machine_Multi_Switch.get(1), 800, 122880); //Quantum Computer GT_Values.RA.addAssemblylineRecipe(ItemList.Tool_DataOrb.get(1), 20000, new ItemStack[]{ CustomItemList.Machine_Multi_Switch.get(1), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Superconductor, 2), ItemList.Tool_DataOrb.get(1), - ItemList.Cover_Screen.get(1, o), + ItemList.Cover_Screen.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Superconductor, 8), - CustomItemList.DATApipe.get(8, o), + CustomItemList.DATApipe.get(8), }, new FluidStack[]{ Materials.UUMatter.getFluid(1000), Materials.Iridium.getMolten(1296), @@ -293,7 +294,7 @@ public class DreamCraftRecipeLoader implements Runnable { ItemList.Electric_Motor_ZPM.get(2), GT_OreDictUnificator.get(OrePrefixes.cableGt02, Materials.Naquadah, 4), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Naquadah, 32), - CustomItemList.DATApipe.get(16, o), + CustomItemList.DATApipe.get(16), }, new FluidStack[]{ Materials.UUMatter.getFluid(1000), Materials.Iridium.getMolten(1296), @@ -407,5 +408,27 @@ public class DreamCraftRecipeLoader implements Runnable { new FluidStack(FluidRegistry.getFluid("ic2coolant"), 2000), }, CustomItemList.Machine_Multi_Infuser.get(1), 8000, 2000000); //endregion + + register_machine_EM_behaviours(); + } + + private void register_machine_EM_behaviours(){ + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(5),ItemList.Machine_IV_Centrifuge.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(6),com.dreammaster.gthandler.CustomItemList.CentrifugeLuV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),com.dreammaster.gthandler.CustomItemList.CentrifugeZPM.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),com.dreammaster.gthandler.CustomItemList.CentrifugeUV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),com.dreammaster.gthandler.CustomItemList.CentrifugeUHV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),com.dreammaster.gthandler.CustomItemList.CentrifugeUEV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),com.dreammaster.gthandler.CustomItemList.CentrifugeUIV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),com.dreammaster.gthandler.CustomItemList.CentrifugeUMV.get(1)); + + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(5),ItemList.Machine_IV_ElectromagneticSeparator.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(6),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorLuV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorZPM.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUHV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUEV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUIV.get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),com.dreammaster.gthandler.CustomItemList.ElectromagneticSeparatorUMV.get(1)); } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompatEnabled.java index a66f51ff2d..15efa593eb 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompatEnabled.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/EssentiaCompatEnabled.java @@ -25,20 +25,22 @@ public class EssentiaCompatEnabled extends EssentiaCompat { @Override public boolean check(GT_MetaTileEntity_MultiblockBase_EM meta) { TileEntity tile =meta.getBaseMetaTileEntity().getTileEntityAtSide(meta.getBaseMetaTileEntity().getBackFacing()); - return tile!=null && (tile instanceof TileEssentiaReservoir) || (tile instanceof TileJarFillable); + return tile instanceof TileEssentiaReservoir || tile instanceof TileJarFillable; } @Override public TileEntity getContainer(GT_MetaTileEntity_MultiblockBase_EM meta) { TileEntity tile =meta.getBaseMetaTileEntity().getTileEntityAtSide(meta.getBaseMetaTileEntity().getBackFacing()); - return tile!=null && !tile.isInvalid() && (tile instanceof TileEssentiaReservoir) || (tile instanceof TileJarFillable)?tile:null; + return tile!=null && !tile.isInvalid() && tile instanceof TileEssentiaReservoir || tile instanceof TileJarFillable ?tile:null; } @Override public boolean putElementalInstanceStack(TileEntity container,cElementalInstanceStack stack){ - if(container==null || container.isInvalid())return false; - if((container instanceof IAspectContainer) && (stack.definition instanceof iElementalAspect)){ - Aspect aspect=(Aspect)(((iElementalAspect) stack.definition).materializeIntoAspect()); + if(container==null || container.isInvalid()) { + return false; + } + if(container instanceof IAspectContainer && stack.definition instanceof iElementalAspect){ + Aspect aspect=(Aspect) ((iElementalAspect) stack.definition).materializeIntoAspect(); if(aspect!=null){ ((IAspectContainer) container).addToContainer(aspect,1); return true; @@ -49,7 +51,9 @@ public class EssentiaCompatEnabled extends EssentiaCompat { @Override public cElementalInstanceStack getFromContainer(TileEntity container){ - if(container==null || container.isInvalid())return null; + if(container==null || container.isInvalid()) { + return null; + } if(container instanceof IAspectContainer){ AspectList aspects=((IAspectContainer) container).getAspects(); if(aspects!=null){ diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/AspectDefinitionCompatEnabled.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/AspectDefinitionCompatEnabled.java index 210b88cb9e..9038e4fe26 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/AspectDefinitionCompatEnabled.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/AspectDefinitionCompatEnabled.java @@ -13,45 +13,42 @@ import static com.github.technus.tectech.compatibility.thaumcraft.definitions.eP * Created by Tec on 21.05.2017. */ public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat { + @Override public void run(){ - defToAspect.put(magic_air,"aer"); - defToAspect.put(magic_earth,"terra"); - defToAspect.put(magic_fire,"ignis"); - defToAspect.put(magic_water,"aqua"); - defToAspect.put(magic_order,"ordo"); - defToAspect.put(magic_entropy,"perditio"); + AspectDefinitionCompat.defToAspect.put(magic_air,"aer"); + AspectDefinitionCompat.defToAspect.put(magic_earth,"terra"); + AspectDefinitionCompat.defToAspect.put(magic_fire,"ignis"); + AspectDefinitionCompat.defToAspect.put(magic_water,"aqua"); + AspectDefinitionCompat.defToAspect.put(magic_order,"ordo"); + AspectDefinitionCompat.defToAspect.put(magic_entropy,"perditio"); - aspectToDef.put("aer",magic_air); - aspectToDef.put("terra",magic_earth); - aspectToDef.put("ignis",magic_fire); - aspectToDef.put("aqua",magic_water); - aspectToDef.put("ordo",magic_order); - aspectToDef.put("perditio",magic_entropy); + AspectDefinitionCompat.aspectToDef.put("aer",magic_air); + AspectDefinitionCompat.aspectToDef.put("terra",magic_earth); + AspectDefinitionCompat.aspectToDef.put("ignis",magic_fire); + AspectDefinitionCompat.aspectToDef.put("aqua",magic_water); + AspectDefinitionCompat.aspectToDef.put("ordo",magic_order); + AspectDefinitionCompat.aspectToDef.put("perditio",magic_entropy); ArrayList<Aspect> list=Aspect.getCompoundAspects(); - Aspect[] array=list.toArray(new Aspect[0]); - while (list.size()>0) { + Aspect[] array= list.toArray(new Aspect[list.size()]); + while (!list.isEmpty()) { for (Aspect aspect : array) { if (list.contains(aspect)) { Aspect[] content = aspect.getComponents(); if (content.length != 2) { list.remove(aspect); - }else if(aspectToDef.containsKey(content[0].getTag()) && - aspectToDef.containsKey(content[1].getTag())){ + }else if(AspectDefinitionCompat.aspectToDef.containsKey(content[0].getTag()) && AspectDefinitionCompat.aspectToDef.containsKey(content[1].getTag())){ try { dComplexAspectDefinition newAspect; if(content[0].getTag().equals(content[1].getTag())){ - newAspect = new dComplexAspectDefinition( - aspectToDef.get(content[0].getTag()).getStackForm(2) + newAspect = new dComplexAspectDefinition(AspectDefinitionCompat.aspectToDef.get(content[0].getTag()).getStackForm(2) ); }else{ - newAspect = new dComplexAspectDefinition( - aspectToDef.get(content[0].getTag()).getStackForm(1), - aspectToDef.get(content[1].getTag()).getStackForm(1) + newAspect = new dComplexAspectDefinition(AspectDefinitionCompat.aspectToDef.get(content[0].getTag()).getStackForm(1), AspectDefinitionCompat.aspectToDef.get(content[1].getTag()).getStackForm(1) ); } - aspectToDef.put(aspect.getTag(),newAspect); - defToAspect.put(newAspect,aspect.getTag()); + AspectDefinitionCompat.aspectToDef.put(aspect.getTag(),newAspect); + AspectDefinitionCompat.defToAspect.put(newAspect,aspect.getTag()); }catch (tElementalException e) { /**/ }finally { @@ -65,17 +62,17 @@ public final class AspectDefinitionCompatEnabled extends AspectDefinitionCompat @Override Aspect getAspect(cElementalDefinition definition) { - return Aspect.getAspect(defToAspect.get(definition)); + return Aspect.getAspect(AspectDefinitionCompat.defToAspect.get(definition)); } @Override String getAspectTag(cElementalDefinition definition) { - return defToAspect.get(definition); + return AspectDefinitionCompat.defToAspect.get(definition); } @Override iElementalDefinition getDefinition(String aspect) { - return aspectToDef.get(aspect); + return AspectDefinitionCompat.aspectToDef.get(aspect); } } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java index 7eed0b309e..3d29927a6c 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/dComplexAspectDefinition.java @@ -55,8 +55,10 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme } private dComplexAspectDefinition(boolean check, cElementalDefinitionStackMap aspects) throws tElementalException { - if (check && !canTheyBeTogether(aspects)) throw new tElementalException("Hadron Definition error"); - this.aspectStacks = aspects; + if (check && !canTheyBeTogether(aspects)) { + throw new tElementalException("Hadron Definition error"); + } + aspectStacks = aspects; float mass=0; for(cElementalDefinitionStack stack:aspects.values()){ mass+=stack.getMass(); @@ -69,8 +71,9 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { long amount = 0; for (cElementalDefinitionStack aspects : stacks.values()) { - if (!(aspects.definition instanceof dComplexAspectDefinition) && !(aspects.definition instanceof ePrimalAspectDefinition)) + if (!(aspects.definition instanceof dComplexAspectDefinition) && !(aspects.definition instanceof ePrimalAspectDefinition)) { return false; + } amount += aspects.amount; } return amount==2; @@ -89,21 +92,21 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme @Override public String getSymbol() { - String symbol = ""; + StringBuilder symbol = new StringBuilder(8); for (cElementalDefinitionStack aspect : aspectStacks.values()) { if (aspect.definition instanceof ePrimalAspectDefinition) { for (int i = 0; i < aspect.amount; i++) { - symbol += aspect.definition.getSymbol(); + symbol.append(aspect.definition.getSymbol()); } } else { - symbol+="("; + symbol.append('('); for (int i = 0; i < aspect.amount; i++) { - symbol += aspect.definition.getSymbol(); + symbol.append(aspect.definition.getSymbol()); } - symbol+=")"; + symbol.append(')'); } } - return symbol; + return symbol.toString(); } @Override @@ -112,19 +115,23 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme nbt.setByte("t", nbtType); cElementalDefinitionStack[] quarkStacksValues = aspectStacks.values(); nbt.setInteger("i", quarkStacksValues.length); - for (int i = 0; i < quarkStacksValues.length; i++) + for (int i = 0; i < quarkStacksValues.length; i++) { nbt.setTag(Integer.toString(i), quarkStacksValues[i].toNBT()); + } return nbt; } - public static iElementalDefinition fromNBT(NBTTagCompound nbt) { + public static dComplexAspectDefinition fromNBT(NBTTagCompound nbt) { cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) + for (int i = 0; i < stacks.length; i++) { stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); + } try { return new dComplexAspectDefinition(stacks); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return null; } } @@ -166,7 +173,7 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme @Override public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { - return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); } @Override @@ -204,6 +211,7 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme return null; } + @Override public Object materializeIntoAspect() { return aspectDefinitionCompat.getAspect(this); } @@ -217,10 +225,13 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme try { cElementalDefinition.addCreatorFromNBT(nbtType, dComplexAspectDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-96); } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + if(DEBUG_MODE) { + TecTech.Logger.info("Registered Elemental Matter Class: ComplexAspect " + nbtType + ' ' + -96); } - if(DEBUG_MODE) - TecTech.Logger.info("Registered Elemental Matter Class: ComplexAspect "+nbtType+" "+(-96)); } @Override @@ -233,22 +244,24 @@ public final class dComplexAspectDefinition extends cElementalDefinition impleme return hash; } - - @Override public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) - lines.add("CLASS = "+nbtType+" "+getClassType()); + if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + lines.add("CLASS = " + nbtType + ' ' + getClassType()); + } if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS, capabilities)) { lines.add("NAME = "+getName()); //lines.add("SYMBOL = "+getSymbol()); } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) - lines.add("CHARGE = "+getCharge()/3f+" eV"); - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) - lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) - lines.add("MASS = "+getMass()+" eV/c\u00b2"); + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { + lines.add("CHARGE = " + getCharge() / 3f + " e"); + } + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { + lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); + } + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + lines.add("MASS = " + getMass() + " eV/c\u00b2"); + } if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ lines.add("LIFE TIME = "+getRawTimeSpan(energyLevel)+ " s"); lines.add(" "+"At current energy level"); diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/ePrimalAspectDefinition.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/ePrimalAspectDefinition.java index 6205055967..64c1b7ea19 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/ePrimalAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/definitions/ePrimalAspectDefinition.java @@ -35,6 +35,7 @@ public final class ePrimalAspectDefinition extends cElementalPrimitive implement return "Primal: " + name; } + @Override public Object materializeIntoAspect() { return aspectDefinitionCompat.getAspect(this); } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java index 2162f81ab5..9c0008ab07 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java @@ -8,7 +8,10 @@ import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstance import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; @@ -16,6 +19,7 @@ import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; import static com.github.technus.tectech.Util.StructureBuilder; @@ -29,7 +33,6 @@ import static gregtech.api.enums.GT_Values.E; * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - private TileEntity container; //region Structure //use multi A energy inputs, use less power the longer it runs @@ -63,8 +66,15 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_essentiaDequantizer(this.mName); + return new GT_MetaTileEntity_EM_essentiaDequantizer(mName); + } + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return GT_MetaTileEntity_EM_quantizer.activitySound; } @Override @@ -85,12 +95,9 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ iGregTechTileEntity.getZCoord()+zDir, TT_Container_Casings.sHintCasingsTT,12); } else{ - if(iGregTechTileEntity.getBlockOffset(xDir,0,zDir).getMaterial() == Material.air) - iGregTechTileEntity.getWorld().setBlock( - iGregTechTileEntity.getXCoord()+xDir, - iGregTechTileEntity.getYCoord()+yDir, - iGregTechTileEntity.getZCoord()+zDir, - TT_Container_Casings.sHintCasingsTT,12,2); + if(iGregTechTileEntity.getBlockOffset(xDir,0,zDir).getMaterial() == Material.air) { + iGregTechTileEntity.getWorld().setBlock(iGregTechTileEntity.getXCoord() + xDir, iGregTechTileEntity.getYCoord() + yDir, iGregTechTileEntity.getZCoord() + zDir, TT_Container_Casings.sHintCasingsTT, 12, 2); + } } StructureBuilder(shape, blockType, blockMeta,1, 1, 0, iGregTechTileEntity,hintsOnly); } @@ -101,9 +108,9 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { - container=essentiaContainerCompat.getContainer(this); - if (eInputHatches.size() < 1 || container==null) { + public boolean checkRecipe_EM(ItemStack itemStack) { + TileEntity container = essentiaContainerCompat.getContainer(this); + if (eInputHatches.size() < 1 || container ==null) { stopMachine(); return false; } @@ -111,8 +118,9 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ if(inputHatchContainer.hasStacks()){ cElementalInstanceStack stack = inputHatchContainer.getFirst(); inputHatchContainer.removeAmount(false,new cElementalInstanceStack(stack.definition,1)); - if(!essentiaContainerCompat.putElementalInstanceStack(container,stack)) + if(!essentiaContainerCompat.putElementalInstanceStack(container,stack)) { cleanStackEM_EM(stack); + } mMaxProgresstime = 20; mEfficiencyIncrease = 10000; eAmpereFlow=1; @@ -123,8 +131,6 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ } return true; } - mEfficiencyIncrease = 0; - mMaxProgresstime = 0; return false; } diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java index 350b918ba8..085884b80a 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java @@ -8,7 +8,10 @@ import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstance import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; @@ -16,6 +19,7 @@ import net.minecraft.block.material.Material; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; import static com.github.technus.tectech.Util.StructureBuilder; @@ -29,7 +33,6 @@ import static gregtech.api.enums.GT_Values.E; * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - private TileEntity container; //region Structure //use multi A energy inputs, use less power the longer it runs @@ -63,8 +66,15 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu super(aName); } + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return GT_MetaTileEntity_EM_quantizer.activitySound; + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_essentiaQuantizer(this.mName); + return new GT_MetaTileEntity_EM_essentiaQuantizer(mName); } @Override @@ -85,12 +95,9 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu iGregTechTileEntity.getZCoord()+zDir, TT_Container_Casings.sHintCasingsTT,12); } else{ - if(iGregTechTileEntity.getBlockOffset(xDir,0,zDir).getMaterial() == Material.air) - iGregTechTileEntity.getWorld().setBlock( - iGregTechTileEntity.getXCoord()+xDir, - iGregTechTileEntity.getYCoord()+yDir, - iGregTechTileEntity.getZCoord()+zDir, - TT_Container_Casings.sHintCasingsTT,12,2); + if(iGregTechTileEntity.getBlockOffset(xDir,0,zDir).getMaterial() == Material.air) { + iGregTechTileEntity.getWorld().setBlock(iGregTechTileEntity.getXCoord() + xDir, iGregTechTileEntity.getYCoord() + yDir, iGregTechTileEntity.getZCoord() + zDir, TT_Container_Casings.sHintCasingsTT, 12, 2); + } } StructureBuilder(shape, blockType, blockMeta,1, 1, 0, iGregTechTileEntity,hintsOnly); } @@ -110,8 +117,8 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { - container=essentiaContainerCompat.getContainer(this); + public boolean checkRecipe_EM(ItemStack itemStack) { + TileEntity container = essentiaContainerCompat.getContainer(this); cElementalInstanceStack newStack=essentiaContainerCompat.getFromContainer(container); if(newStack!=null){ mMaxProgresstime = 20; @@ -127,8 +134,6 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu } return true; } - mEfficiencyIncrease = 0; - mMaxProgresstime = 0; return false; } diff --git a/src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java b/src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java index 8f40dfb09d..56733d0b1d 100644 --- a/src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java +++ b/src/main/java/com/github/technus/tectech/dataFramework/QuantumDataPacket.java @@ -70,7 +70,9 @@ public class QuantumDataPacket { } public long computationIfNotContained(Vec3pos pos) { - if (trace.contains(pos)) return 0; + if (trace.contains(pos)) { + return 0; + } return computation; } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalDecay.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalDecay.java index d80a2b4ccd..609f92b1a1 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalDecay.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalDecay.java @@ -26,7 +26,7 @@ public final class cElementalDecay { for (int i = 0; i < outArr.length; i++) { outArr[i] = new cElementalDefinitionStack(outSafe[i], 1); } - this.outputStacks = new cElementalDefinitionStackMap(outArr); + outputStacks = new cElementalDefinitionStackMap(outArr); this.probability = probability; } @@ -35,7 +35,7 @@ public final class cElementalDecay { } public cElementalDecay(float probability, cElementalDefinitionStack... out) { - this.outputStacks = new cElementalDefinitionStackMap(out); + outputStacks = new cElementalDefinitionStackMap(out); this.probability = probability; } @@ -44,17 +44,23 @@ public final class cElementalDecay { } public cElementalDecay(float probability, cElementalDefinitionStackMap tree) { - this.outputStacks = tree; + outputStacks = tree; this.probability = probability; } public cElementalInstanceStackMap getResults(float lifeMult, long age, long energy, long amountDecaying) { cElementalInstanceStackMap decayResult = new cElementalInstanceStackMap(); - if (outputStacks == null) return decayResult;//This is to prevent null pointer exceptions. + if (outputStacks == null) { + return decayResult;//This is to prevent null pointer exceptions. + } //Deny decay code is in instance! long qtty = 0; - for (cElementalDefinitionStack stack : outputStacks.values()) qtty += stack.amount; - if (qtty <= 0) return decayResult; + for (cElementalDefinitionStack stack : outputStacks.values()) { + qtty += stack.amount; + } + if (qtty <= 0) { + return decayResult; + } //energy /= qtty; //lifeMult /= (float) qtty; for (cElementalDefinitionStack stack : outputStacks.values()) { diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalDefinitionStackMap.java index b3c66e42ce..e6ba0e6be8 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalDefinitionStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalDefinitionStackMap.java @@ -38,7 +38,7 @@ public final class cElementalDefinitionStackMap/*IMMUTABLE*/ extends cElementalS //IMMUTABLE DON'T NEED IT @Override - public final cElementalDefinitionStackMap clone() { + public cElementalDefinitionStackMap clone() { return this; } @@ -53,11 +53,12 @@ public final class cElementalDefinitionStackMap/*IMMUTABLE*/ extends cElementalS } public static cElementalDefinitionStackMap fromNBT(NBTTagCompound nbt) throws tElementalException { - final cElementalDefinitionStack[] defStacks = new cElementalDefinitionStack[nbt.getInteger("i")]; + cElementalDefinitionStack[] defStacks = new cElementalDefinitionStack[nbt.getInteger("i")]; for (int i = 0; i < defStacks.length; i++) { defStacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - if (defStacks[i].definition.equals(nbtE__)) + if (defStacks[i].definition.equals(nbtE__)) { throw new tElementalException("Something went Wrong"); + } } return new cElementalDefinitionStackMap(defStacks); } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java index ee8a81dbd1..b360a5a997 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalInstanceStackMap.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.elementalMatter.core; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; @@ -8,8 +8,9 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import java.util.ArrayList; -import java.util.Iterator; +import java.util.Collection; import java.util.Map; +import java.util.Set; import java.util.TreeMap; import static com.github.technus.tectech.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; @@ -33,8 +34,9 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn map = new TreeMap<>(); if (clone) { cElementalInstanceStack[] stacks=new cElementalInstanceStack[in.length]; - for(int i=0;i<stacks.length;i++) - stacks[i]=in[i].clone(); + for(int i=0;i<stacks.length;i++) { + stacks[i] = in[i].clone(); + } putUnifyAll(stacks); } else { putUnifyAll(in); @@ -50,8 +52,9 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn private cElementalInstanceStackMap(boolean clone, TreeMap<iElementalDefinition, cElementalInstanceStack> in) { if (clone) { map = new TreeMap<>(); - for(cElementalInstanceStack stack:in.values()) + for(cElementalInstanceStack stack:in.values()) { putUnify(stack.clone()); + } } else { map = in; } @@ -66,11 +69,11 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } @Override - public final cElementalInstanceStackMap clone() { + public cElementalInstanceStackMap clone() { return new cElementalInstanceStackMap(map); } - public final cElementalStackMap toDefinitionMapForComparison() { + public cElementalMutableDefinitionStackMap toDefinitionMapForComparison() { cElementalDefinitionStack[] list = new cElementalDefinitionStack[map.size()]; int i = 0; for (cElementalInstanceStack stack : map.values()) { @@ -79,15 +82,17 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn return new cElementalMutableDefinitionStackMap(list); } - @Deprecated - public final cElementalStackMap toDefinitionMap(boolean mutable) { - TreeMap<iElementalDefinition, cElementalDefinitionStack> newMap = new TreeMap<>(); - for (cElementalInstanceStack stack : map.values()) { - newMap.put(stack.definition, new cElementalDefinitionStack(stack.definition, stack.amount)); - } - if (mutable) return new cElementalMutableDefinitionStackMap(newMap); - return new cElementalDefinitionStackMap(newMap); - } + //@Deprecated + //public cElementalStackMap toDefinitionMap(boolean mutable) { + // TreeMap<iElementalDefinition, cElementalDefinitionStack> newMap = new TreeMap<>(); + // for (cElementalInstanceStack stack : map.values()) { + // newMap.put(stack.definition, new cElementalDefinitionStack(stack.definition, stack.amount)); + // } + // if (mutable) { + // return new cElementalMutableDefinitionStackMap(newMap); + // } + // return new cElementalDefinitionStackMap(newMap); + //} @Deprecated public Map<iElementalDefinition, cElementalInstanceStack> getRawMap() { @@ -109,25 +114,28 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public void removeAll(iElementalDefinition... definitions) { - for (iElementalDefinition def : definitions) + for (iElementalDefinition def : definitions) { map.remove(def); + } } @Deprecated - private void removeAll(iHasElementalDefinition... hasElementals) { - for (iHasElementalDefinition has : hasElementals) + private void removeAll(iHasElementalDefinition... hasElementalDefinition) { + for (iHasElementalDefinition has : hasElementalDefinition) { map.remove(has.getDefinition()); + } } //Remove amounts public boolean removeAmount(boolean testOnly, cElementalInstanceStack instance) { - final cElementalInstanceStack target = map.get(instance.definition); - if (target == null) + cElementalInstanceStack target = map.get(instance.definition); + if (target == null) { return false; - if (testOnly) + } + if (testOnly) { return target.amount >= instance.amount; - else { - final long diff = target.amount - instance.amount; + } else { + long diff = target.amount - instance.amount; if (diff > 0) { target.amount = diff; return true; @@ -140,13 +148,14 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public boolean removeAmount(boolean testOnly, iHasElementalDefinition stack) { - final cElementalInstanceStack target = map.get(stack.getDefinition()); - if (target == null) + cElementalInstanceStack target = map.get(stack.getDefinition()); + if (target == null) { return false; - if (testOnly) + } + if (testOnly) { return target.amount >= stack.getAmount(); - else { - final long diff = target.amount - stack.getAmount(); + } else { + long diff = target.amount - stack.getAmount(); if (diff > 0) { target.amount = diff; return true; @@ -165,41 +174,50 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStack... instances) { boolean test = true; - for (cElementalInstanceStack stack : instances) + for (cElementalInstanceStack stack : instances) { test &= removeAmount(true, stack); - if (testOnly || !test) return test; - for (cElementalInstanceStack stack : instances) + } + if (testOnly || !test) { + return test; + } + for (cElementalInstanceStack stack : instances) { removeAmount(false, stack); + } return true; } public boolean removeAllAmounts(boolean testOnly, iHasElementalDefinition... stacks) { boolean test = true; - for (iHasElementalDefinition stack : stacks) + for (iHasElementalDefinition stack : stacks) { test &= removeAmount(true, stack); - if (testOnly || !test) return test; - for (iHasElementalDefinition stack : stacks) + } + if (testOnly || !test) { + return test; + } + for (iHasElementalDefinition stack : stacks) { removeAmount(false, stack); + } return true; } @Deprecated public boolean removeAllAmounts(boolean testOnly, iElementalDefinition... definitions) { - final cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[definitions.length]; - for (int i = 0; i < stacks.length; i++) + cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[definitions.length]; + for (int i = 0; i < stacks.length; i++) { stacks[i] = new cElementalDefinitionStack(definitions[i], 1); + } return removeAllAmounts(testOnly, stacks); } public boolean removeAllAmounts(boolean testOnly, cElementalStackMap container) { boolean test=true; - for (Iterator<Map.Entry<iElementalDefinition, cElementalDefinitionStack>> entries = container.map.entrySet().iterator(); entries.hasNext(); ) { - Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry = entries.next(); + for (Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry : container.map.entrySet()) { test &= removeAmount(true, entry.getValue()); } - if (testOnly || !test) return test; - for (Iterator<Map.Entry<iElementalDefinition, cElementalDefinitionStack>> entries = container.map.entrySet().iterator(); entries.hasNext(); ) { - Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry = entries.next(); + if (testOnly || !test) { + return test; + } + for (Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry : container.map.entrySet()) { removeAmount(false, entry.getValue()); } return true; @@ -207,13 +225,13 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStackMap container) { boolean test=true; - for (Iterator<Map.Entry<iElementalDefinition, cElementalInstanceStack>> entries = container.map.entrySet().iterator(); entries.hasNext(); ) { - Map.Entry<iElementalDefinition, cElementalInstanceStack> entry = entries.next(); + for (Map.Entry<iElementalDefinition, cElementalInstanceStack> entry : container.map.entrySet()) { test &= removeAmount(true, entry.getValue()); } - if (testOnly || !test) return test; - for (Iterator<Map.Entry<iElementalDefinition, cElementalInstanceStack>> entries = container.map.entrySet().iterator(); entries.hasNext(); ) { - Map.Entry<iElementalDefinition, cElementalInstanceStack> entry = entries.next(); + if (testOnly || !test) { + return test; + } + for (Map.Entry<iElementalDefinition, cElementalInstanceStack> entry : container.map.entrySet()) { test &= removeAmount(false, entry.getValue()); } return true; @@ -224,18 +242,19 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn float massRemoved = 0; if (map.size() > stacksCount) { - iElementalDefinition[] keys = this.keys(); + iElementalDefinition[] keys = keys(); for (int i = stacksCount; i < keys.length; i++) { massRemoved += map.get(keys[i]).getDefinitionStack().getMass(); map.remove(keys[i]); } } - for (cElementalInstanceStack instance : this.values()) + for (cElementalInstanceStack instance : values()) { if (instance.amount > stackCapacity) { massRemoved += instance.definition.getMass() * (instance.amount - stackCapacity); instance.amount = stackCapacity; } + } return massRemoved; } @@ -245,12 +264,13 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public void putReplaceAll(cElementalInstanceStack... instances) { - for (cElementalInstanceStack instance : instances) - this.map.put(instance.definition, instance); + for (cElementalInstanceStack instance : instances) { + map.put(instance.definition, instance); + } } private void putReplaceAll(Map<iElementalDefinition, cElementalInstanceStack> inTreeUnsafe) { - this.map.putAll(inTreeUnsafe); + map.putAll(inTreeUnsafe); } public void putReplaceAll(cElementalInstanceStackMap inContainerUnsafe) { @@ -260,18 +280,22 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn //Put unify public cElementalInstanceStack putUnify(cElementalInstanceStack instance) { cElementalInstanceStack stack=map.get(instance.definition); - if(stack==null) return map.put(instance.definition,instance); + if(stack==null) { + return map.put(instance.definition, instance); + } return map.put(instance.definition, stack.unifyIntoThis(instance)); } public void putUnifyAll(cElementalInstanceStack... instances) { - for (cElementalInstanceStack instance : instances) + for (cElementalInstanceStack instance : instances) { putUnify(instance); + } } private void putUnifyAll(Map<iElementalDefinition, cElementalInstanceStack> inTreeUnsafe) { - for (cElementalInstanceStack in : inTreeUnsafe.values()) + for (cElementalInstanceStack in : inTreeUnsafe.values()) { putUnify(in); + } } public void putUnifyAll(cElementalInstanceStackMap containerUnsafe) { @@ -292,11 +316,12 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public cElementalInstanceStack get(int i){ - return map.values().toArray(new cElementalInstanceStack[0])[i]; + Collection<cElementalInstanceStack> var = map.values(); + return var.toArray(new cElementalInstanceStack[var.size()])[i]; } public String[] getElementalInfo() { - final String[] info = new String[map.size() * 4]; + String[] info = new String[map.size() * 4]; int i = 0; for (cElementalInstanceStack instance : map.values()) { info[i] = EnumChatFormatting.BLUE + instance.definition.getName(); @@ -317,11 +342,13 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public cElementalInstanceStack[] values() { - return map.values().toArray(new cElementalInstanceStack[0]); + Collection<cElementalInstanceStack> var = map.values(); + return var.toArray(new cElementalInstanceStack[var.size()]); } public iElementalDefinition[] keys() { - return map.keySet().toArray(new iElementalDefinition[0]); + Set<iElementalDefinition> var = map.keySet(); + return var.toArray(new iElementalDefinition[var.size()]); } public float getMass() { @@ -332,6 +359,22 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn return mass; } + public long getCharge() { + long charge = 0; + for (cElementalInstanceStack stack : map.values()) { + charge += stack.getCharge(); + } + return charge; + } + + public long getCountOfAllAmounts(){ + long sum=0; + for(cElementalInstanceStack stack:map.values()){ + sum+=stack.amount; + } + return sum; + } + //Tests public boolean containsDefinition(iElementalDefinition def) { return map.containsKey(def); @@ -346,7 +389,11 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public boolean hasStacks() { - return map.size() > 0; + return !map.isEmpty(); + } + + public boolean isEmpty(){ + return map.isEmpty(); } //Tick Content @@ -355,7 +402,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } public void tickContent(float lifeTimeMult, int postEnergize, int seconds){ - for (cElementalInstanceStack instance : this.values()) { + for (cElementalInstanceStack instance : values()) { cElementalInstanceStackMap newInstances = instance.decay(lifeTimeMult, instance.age += seconds, postEnergize); if (newInstances == null) { instance.nextColor(); @@ -371,75 +418,85 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn //NBT public NBTTagCompound getInfoNBT() { - final NBTTagCompound nbt = new NBTTagCompound(); - final String[] info = getElementalInfo(); + NBTTagCompound nbt = new NBTTagCompound(); + String[] info = getElementalInfo(); nbt.setInteger("i", info.length); - for (int i = 0; i < info.length; i++) + for (int i = 0; i < info.length; i++) { nbt.setString(Integer.toString(i), info[i]); + } return nbt; } public NBTTagCompound getScanInfoNBT(int[] capabilities) { - final NBTTagCompound nbt = new NBTTagCompound(); - final ArrayList<String> info = getScanInfo(capabilities); + NBTTagCompound nbt = new NBTTagCompound(); + ArrayList<String> info = getScanInfo(capabilities); nbt.setInteger("i", info.size()); - for (int i = 0; i < info.size(); i++) + for (int i = 0; i < info.size(); i++) { nbt.setString(Integer.toString(i), info.get(i)); + } return nbt; } public NBTTagCompound toNBT() { - final NBTTagCompound nbt = new NBTTagCompound(); + NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("i", map.size()); int i = 0; - for (cElementalInstanceStack instance : map.values()) + for (cElementalInstanceStack instance : map.values()) { nbt.setTag(Integer.toString(i++), instance.toNBT()); + } return nbt; } public static cElementalInstanceStackMap fromNBT(NBTTagCompound nbt) throws tElementalException { - final cElementalInstanceStack[] instances = new cElementalInstanceStack[nbt.getInteger("i")]; + cElementalInstanceStack[] instances = new cElementalInstanceStack[nbt.getInteger("i")]; for (int i = 0; i < instances.length; i++) { instances[i] = cElementalInstanceStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - if (instances[i].definition.equals(nbtE__)) + if (instances[i].definition.equals(nbtE__)) { throw new tElementalException("Something went Wrong"); + } } return new cElementalInstanceStackMap(false, instances); } //stackUp public static cElementalInstanceStack[] stackUp(cElementalInstanceStack... in) { - final cElementalInstanceStackMap inTree = new cElementalInstanceStackMap(); + cElementalInstanceStackMap inTree = new cElementalInstanceStackMap(); inTree.putUnifyAll(in); return inTree.values(); } @Override public int compareTo(cElementalInstanceStackMap o) { - final int sizeDiff = map.size() - o.map.size(); - if (sizeDiff != 0) return sizeDiff; + int sizeDiff = map.size() - o.map.size(); + if (sizeDiff != 0) { + return sizeDiff; + } cElementalInstanceStack[] ofThis = values(), ofThat = o.values(); for (int i = 0; i < ofThat.length; i++) { int result = ofThis[i].compareTo(ofThat[i]); - if (result != 0) return result; + if (result != 0) { + return result; + } } return 0; } @Override public boolean equals(Object obj) { - if (obj instanceof cElementalInstanceStackMap) + if (obj instanceof cElementalInstanceStackMap) { return compareTo((cElementalInstanceStackMap) obj) == 0; - if (obj instanceof cElementalStackMap) + } + if (obj instanceof cElementalStackMap) { return toDefinitionMapForComparison().compareTo((cElementalStackMap) obj) == 0; + } return false; } @Override public int hashCode() {//Hash only definitions to compare contents not amounts or data int hash = -(map.size() << 4); - for (cElementalInstanceStack s : map.values()) { - hash += s.definition.hashCode(); + for (cElementalInstanceStack stack : map.values()) { + hash += stack.definition.hashCode(); } return hash; } @@ -453,9 +510,17 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn return build.toString(); } + public cElementalInstanceStackMap takeAllToNewMap(){ + TreeMap<iElementalDefinition, cElementalInstanceStack> map=this.map; + this.map=new TreeMap<>(); + return new cElementalInstanceStackMap(map); + } + public void cleanUp(){ for(Map.Entry<iElementalDefinition, cElementalInstanceStack> entry:map.entrySet()){ - if(entry.getValue().amount<=0) map.remove(entry.getKey()); + if(entry.getValue().amount<=0) { + map.remove(entry.getKey()); + } } } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalMutableDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalMutableDefinitionStackMap.java index 49823d4088..9f7e14a154 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalMutableDefinitionStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalMutableDefinitionStackMap.java @@ -1,12 +1,11 @@ package com.github.technus.tectech.elementalMatter.core; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; import net.minecraft.nbt.NBTTagCompound; -import java.util.Iterator; import java.util.Map; import java.util.TreeMap; @@ -80,25 +79,28 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa } public void removeAll(iElementalDefinition... definitions) { - for (iElementalDefinition def : definitions) + for (iElementalDefinition def : definitions) { map.remove(def); + } } @Deprecated - public void removeAll(iHasElementalDefinition... hasElementals) { - for (iHasElementalDefinition has : hasElementals) + public void removeAll(iHasElementalDefinition... hasElementalDefinition) { + for (iHasElementalDefinition has : hasElementalDefinition) { map.remove(has.getDefinition()); + } } //Remove amounts public boolean removeAmount(boolean testOnly, cElementalInstanceStack instance) { - final cElementalDefinitionStack target = map.get(instance.definition); - if (target == null) + cElementalDefinitionStack target = map.get(instance.definition); + if (target == null) { return false; - if (testOnly) + } + if (testOnly) { return target.amount >= instance.amount; - else { - final long diff = target.amount - instance.amount; + } else { + long diff = target.amount - instance.amount; if (diff > 0) { map.put(target.definition, new cElementalDefinitionStack(target.definition, diff)); return true; @@ -111,13 +113,14 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa } public boolean removeAmount(boolean testOnly, iHasElementalDefinition stack) { - final cElementalDefinitionStack target = map.get(stack.getDefinition()); - if (target == null) + cElementalDefinitionStack target = map.get(stack.getDefinition()); + if (target == null) { return false; - if (testOnly) + } + if (testOnly) { return target.amount >= stack.getAmount(); - else { - final long diff = target.amount - stack.getAmount(); + } else { + long diff = target.amount - stack.getAmount(); if (diff > 0) { map.put(target.definition, new cElementalDefinitionStack(target.definition, diff)); return true; @@ -136,41 +139,50 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStack... instances) { boolean test = true; - for (cElementalInstanceStack stack : instances) + for (cElementalInstanceStack stack : instances) { test &= removeAmount(true, stack); - if (testOnly || !test) return test; - for (cElementalInstanceStack stack : instances) + } + if (testOnly || !test) { + return test; + } + for (cElementalInstanceStack stack : instances) { removeAmount(false, stack); + } return true; } public boolean removeAllAmounts(boolean testOnly, iHasElementalDefinition... stacks) { boolean test = true; - for (iHasElementalDefinition stack : stacks) + for (iHasElementalDefinition stack : stacks) { test &= removeAmount(true, stack); - if (testOnly || !test) return test; - for (iHasElementalDefinition stack : stacks) + } + if (testOnly || !test) { + return test; + } + for (iHasElementalDefinition stack : stacks) { removeAmount(false, stack); + } return true; } @Deprecated public boolean removeAllAmounts(boolean testOnly, iElementalDefinition... definitions) { - final cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[definitions.length]; - for (int i = 0; i < stacks.length; i++) + cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[definitions.length]; + for (int i = 0; i < stacks.length; i++) { stacks[i] = new cElementalDefinitionStack(definitions[i], 1); + } return removeAllAmounts(testOnly, stacks); } public boolean removeAllAmounts(boolean testOnly, cElementalStackMap container) { boolean test=true; - for (Iterator<Map.Entry<iElementalDefinition, cElementalDefinitionStack>> entries = container.map.entrySet().iterator(); entries.hasNext(); ) { - Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry = entries.next(); + for (Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry : container.map.entrySet()) { test &= removeAmount(true, entry.getValue()); } - if (testOnly || !test) return test; - for (Iterator<Map.Entry<iElementalDefinition, cElementalDefinitionStack>> entries = container.map.entrySet().iterator(); entries.hasNext(); ) { - Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry = entries.next(); + if (testOnly || !test) { + return test; + } + for (Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry : container.map.entrySet()) { removeAmount(false, entry.getValue()); } return true; @@ -178,13 +190,13 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa public boolean removeAllAmounts(boolean testOnly, cElementalInstanceStackMap container) { boolean test=true; - for (Iterator<Map.Entry<iElementalDefinition, cElementalInstanceStack>> entries = container.map.entrySet().iterator(); entries.hasNext(); ) { - Map.Entry<iElementalDefinition, cElementalInstanceStack> entry = entries.next(); + for (Map.Entry<iElementalDefinition, cElementalInstanceStack> entry : container.map.entrySet()) { test &= removeAmount(true, entry.getValue()); } - if (testOnly || !test) return test; - for (Iterator<Map.Entry<iElementalDefinition, cElementalInstanceStack>> entries = container.map.entrySet().iterator(); entries.hasNext(); ) { - Map.Entry<iElementalDefinition, cElementalInstanceStack> entry = entries.next(); + if (testOnly || !test) { + return test; + } + for (Map.Entry<iElementalDefinition, cElementalInstanceStack> entry : container.map.entrySet()) { test &= removeAmount(false, entry.getValue()); } return true; @@ -196,18 +208,21 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa } public void putReplaceAll(cElementalDefinitionStack... defStacks) { - for (cElementalDefinitionStack defStack : defStacks) - this.map.put(defStack.definition, defStack); + for (cElementalDefinitionStack defStack : defStacks) { + map.put(defStack.definition, defStack); + } } public void putReplaceAll(cElementalStackMap inContainerUnsafe) { - this.map.putAll(inContainerUnsafe.map); + map.putAll(inContainerUnsafe.map); } //Put unify public cElementalDefinitionStack putUnify(cElementalDefinitionStack def) { - final cElementalDefinitionStack stack=map.get(def.definition); - if(stack==null) return map.put(def.definition,def); + cElementalDefinitionStack stack=map.get(def.definition); + if(stack==null) { + return map.put(def.definition, def); + } return map.put(def.definition, stack.addAmountIntoNewInstance(def.amount)); } @@ -217,39 +232,46 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa } public void putUnifyAll(cElementalDefinitionStack... defs) { - for (cElementalDefinitionStack def : defs) + for (cElementalDefinitionStack def : defs) { putUnify(def); + } } @Deprecated public void putUnifyAll(iElementalDefinition... defs) { - for (iElementalDefinition def : defs) + for (iElementalDefinition def : defs) { putUnify(def); + } } private void putUnifyAll(Map<iElementalDefinition, cElementalDefinitionStack> inTreeUnsafe) { - for (cElementalDefinitionStack in : inTreeUnsafe.values()) + for (cElementalDefinitionStack in : inTreeUnsafe.values()) { putUnify(in); + } } public void putUnifyAll(cElementalStackMap containerUnsafe) { - for (cElementalDefinitionStack in : containerUnsafe.map.values()) + for (cElementalDefinitionStack in : containerUnsafe.map.values()) { putUnify(in); + } } public static cElementalMutableDefinitionStackMap fromNBT(NBTTagCompound nbt) throws tElementalException { - final cElementalDefinitionStack[] defStacks = new cElementalDefinitionStack[nbt.getInteger("i")]; + cElementalDefinitionStack[] defStacks = new cElementalDefinitionStack[nbt.getInteger("i")]; for (int i = 0; i < defStacks.length; i++) { defStacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); - if (defStacks[i].definition.equals(nbtE__)) + if (defStacks[i].definition.equals(nbtE__)) { throw new tElementalException("Something went Wrong"); + } } return new cElementalMutableDefinitionStackMap(defStacks); } public void cleanUp(){ for(Map.Entry<iElementalDefinition, cElementalDefinitionStack> entry:map.entrySet()){ - if(entry.getValue().amount<=0) map.remove(entry.getKey()); + if(entry.getValue().amount<=0) { + map.remove(entry.getKey()); + } } } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java index a5139bc254..676bdeff02 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/cElementalStackMap.java @@ -1,10 +1,13 @@ package com.github.technus.tectech.elementalMatter.core; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; +import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import java.util.Collection; +import java.util.Set; import java.util.TreeMap; /** @@ -33,7 +36,7 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { } public final String[] getElementalInfo() { - final String[] info = new String[map.size() * 3]; + String[] info = new String[map.size() * 3]; int i = 0; for (cElementalDefinitionStack defStack : map.values()) { info[i] = EnumChatFormatting.BLUE + defStack.definition.getName(); @@ -45,11 +48,21 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { } public final cElementalDefinitionStack[] values() { - return map.values().toArray(new cElementalDefinitionStack[0]); + Collection<cElementalDefinitionStack> var = map.values(); + return var.toArray(new cElementalDefinitionStack[var.size()]); } public final iElementalDefinition[] keys() { - return map.keySet().toArray(new iElementalDefinition[0]); + Set<iElementalDefinition> var = map.keySet(); + return var.toArray(new iElementalDefinition[var.size()]); + } + + public long getCountOfAllAmounts(){ + long sum=0; + for(cElementalDefinitionStack stack:map.values()){ + sum+=stack.amount; + } + return sum; } //Tests @@ -66,54 +79,66 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { } public final boolean hasStacks() { - return map.size() > 0; + return !map.isEmpty(); + } + + public final boolean isEmpty(){ + return map.isEmpty(); } //NBT public final NBTTagCompound getInfoNBT() { - final NBTTagCompound nbt = new NBTTagCompound(); - final String[] info = getElementalInfo(); + NBTTagCompound nbt = new NBTTagCompound(); + String[] info = getElementalInfo(); nbt.setInteger("i", info.length); - for (int i = 0; i < info.length; i++) + for (int i = 0; i < info.length; i++) { nbt.setString(Integer.toString(i), info[i]); + } return nbt; } public final NBTTagCompound toNBT() { - final NBTTagCompound nbt = new NBTTagCompound(); + NBTTagCompound nbt = new NBTTagCompound(); nbt.setInteger("i", map.size()); int i = 0; - for (cElementalDefinitionStack defStack : map.values()) + for (cElementalDefinitionStack defStack : map.values()) { nbt.setTag(Integer.toString(i++), defStack.toNBT()); + } return nbt; } @Override public final int compareTo(cElementalStackMap o) {//this actually compares rest - final int sizeDiff = map.size() - o.map.size(); - if (sizeDiff != 0) return sizeDiff; + int sizeDiff = map.size() - o.map.size(); + if (sizeDiff != 0) { + return sizeDiff; + } cElementalDefinitionStack[] ofThis = values(), ofO = o.values(); for (int i = 0; i < ofO.length; i++) { int result = ofThis[i].compareTo(ofO[i]); - if (result != 0) return result; + if (result != 0) { + return result; + } } return 0; } @Override public boolean equals(Object obj) { - if (obj instanceof cElementalStackMap) + if (obj instanceof cElementalStackMap) { return compareTo((cElementalStackMap) obj) == 0; - if (obj instanceof cElementalInstanceStackMap) + } + if (obj instanceof cElementalInstanceStackMap) { return compareTo(((cElementalInstanceStackMap) obj).toDefinitionMapForComparison()) == 0; + } return false; } @Override public final int hashCode() {//Hash only definitions to compare contents not amounts or data int hash = -(map.size() << 4); - for (cElementalDefinitionStack s : map.values()) { - hash += s.definition.hashCode(); + for (cElementalDefinitionStack stack : map.values()) { + hash += stack.definition.hashCode(); } return hash; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/commands/GiveEM.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/commands/GiveEM.java new file mode 100644 index 0000000000..36a41ca323 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/commands/GiveEM.java @@ -0,0 +1,159 @@ +package com.github.technus.tectech.elementalMatter.core.commands; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.elementalMatter.core.cElementalMutableDefinitionStackMap; +import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; +import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.elementalMatter.core.templates.cElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.templates.cElementalPrimitive; +import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; +import com.github.technus.tectech.thing.item.DebugElementalInstanceContainer_EM; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ChatComponentText; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; + +/** + * Created by danie_000 on 30.12.2017. + */ +public class GiveEM implements ICommand { + ArrayList<String> aliases=new ArrayList<>(); + + public GiveEM(){ + aliases.add("em_give"); + aliases.add("give_em"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (sender instanceof EntityPlayerMP && !sender.getEntityWorld().isRemote) { + if(args.length < 3) { + sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); + }else{ + TecTech.Logger.info("Spawninig EM for "+((EntityPlayerMP) sender).getDisplayName()+" - "+Arrays.toString(args)); + + ArrayList<String> list=new ArrayList<>(); + list.addAll(Arrays.asList(args)); + String energy=list.remove(0); + + cElementalDefinitionStack def= getDefinitionStack(list); + cElementalInstanceStack instanceStack=new cElementalInstanceStack(def,1,0,Long.parseLong(energy)); + + sender.addChatMessage(new ChatComponentText(instanceStack.definition.getSymbol()+" - "+instanceStack.definition.getName())); + + cElementalInstanceStackMap instanceMap=new cElementalInstanceStackMap(instanceStack); + + ItemStack itemStack=new ItemStack(DebugElementalInstanceContainer_EM.INSTANCE); + NBTTagCompound contents=new NBTTagCompound(); + contents.setTag("info", instanceMap.getInfoNBT()); + contents.setTag("content", instanceMap.toNBT()); + itemStack.setTagCompound(contents); + + ((EntityPlayerMP) sender).inventory.addItemStackToInventory(itemStack); + } + } + } + + private cElementalDefinitionStack getDefinitionStack(ArrayList<String> args){ + if(args.get(0).equals("<")){ + args.remove(0); + return null; + } + long amount=Long.parseLong(args.remove(0)); + try{ + int id=Integer.parseInt(args.get(0)); + args.remove(0); + iElementalDefinition primitive=cElementalPrimitive.getBindsPrimitive().get(id); + return new cElementalDefinitionStack(primitive,amount); + }catch (NumberFormatException e){ + byte clazz = (byte) args.remove(0).charAt(0); + Method constructor = cElementalDefinition.getBindsComplex().get(clazz); + + cElementalMutableDefinitionStackMap stacks=new cElementalMutableDefinitionStackMap(); + while(args.size()>0){ + cElementalDefinitionStack tempStack=getDefinitionStack(args); + if(tempStack==null) { + break; + }else { + stacks.putUnify(tempStack); + } + } + + try { + return ((iElementalDefinition) constructor.invoke(null, stacks.toNBT())).getStackForm(amount); + } catch (Exception e1) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + return nbtE__.getStackForm(amount); + } + } + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List<String> getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { + if(args.length==2){ + return completionsForClassOrID(); + } + return null; + } + + private List<String> completionsForClassOrID(){ + ArrayList<String> strings=new ArrayList<>(8); + Map<Byte,Method> binds= cElementalDefinition.getBindsComplex(); + for (Map.Entry<Byte,Method> e:binds.entrySet()) { + strings.add(String.valueOf((char)e.getKey().byteValue())); + } + Map<Integer, cElementalPrimitive> bindsBO = cElementalPrimitive.getBindsPrimitive(); + for (Map.Entry<Integer,cElementalPrimitive> e:bindsBO.entrySet()) { + strings.add(String.valueOf(e.getKey().byteValue())); + } + return strings; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "em_give energy count classOrId (count classOrId , ... <) if complex"; + } + + @Override + public int compareTo(Object o) { + if(o instanceof ICommand){ + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/commands/ListEM.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/commands/ListEM.java new file mode 100644 index 0000000000..2d296c1c9c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/commands/ListEM.java @@ -0,0 +1,96 @@ +package com.github.technus.tectech.elementalMatter.core.commands; + +import com.github.technus.tectech.elementalMatter.core.templates.cElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.templates.cElementalPrimitive; +import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; +import net.minecraft.command.ICommand; +import net.minecraft.command.ICommandSender; +import net.minecraft.util.ChatComponentText; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * Created by danie_000 on 30.12.2017. + */ +public class ListEM implements ICommand { + ArrayList<String> aliases=new ArrayList<>(); + + public ListEM(){ + aliases.add("em_list"); + aliases.add("list_em"); + } + + @Override + public void processCommand(ICommandSender sender, String[] args) { + if (!sender.getEntityWorld().isRemote) { + if(args.length == 0) { + sender.addChatMessage(new ChatComponentText(" Available Classes: tag - name")); + Map<Byte,Method> binds= cElementalDefinition.getBindsComplex(); + for (Map.Entry<Byte,Method> e:binds.entrySet()) { + sender.addChatMessage(new ChatComponentText(String.valueOf((char)e.getKey().byteValue())+" - "+e.getValue().getReturnType().getSimpleName())); + } + }else if(args.length==1){ + sender.addChatMessage(new ChatComponentText(" Available Primitives: symbol - name")); + if(args[0].equals(String.valueOf((char)cElementalPrimitive.nbtType))){ + Map<Integer, cElementalPrimitive> bindsBO = cElementalPrimitive.getBindsPrimitive(); + for (Map.Entry<Integer,cElementalPrimitive> e:bindsBO.entrySet()) { + sender.addChatMessage(new ChatComponentText(e.getKey() + " - "+e.getValue().getName())); + } + }else{ + sender.addChatMessage(new ChatComponentText("Complex definition - needs contents")); + } + }else{ + sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); + } + } + } + + @Override + public boolean isUsernameIndex(String[] p_82358_1_, int p_82358_2_) { + return false; + } + + @Override + public List<String> getCommandAliases() { + return aliases; + } + + @Override + public String getCommandName() { + return aliases.get(0); + } + + @Override + public List<String> addTabCompletionOptions(ICommandSender sender, String[] args) { + if(args.length==0){ + Map<Byte,Method> binds= cElementalDefinition.getBindsComplex(); + ArrayList<String> strings=new ArrayList<>(binds.size()); + for (Map.Entry<Byte,Method> e:binds.entrySet()) { + strings.add(String.valueOf((char)e.getKey().byteValue())+' '+e.getValue().getReturnType().getSimpleName()); + } + return strings; + } + return null; + } + + @Override + public String getCommandUsage(ICommandSender p_71518_1_) { + return "em_list (optional class tag)"; + } + + @Override + public int compareTo(Object o) { + if(o instanceof ICommand){ + return getCommandName().compareTo(((ICommand) o).getCommandName()); + } + return 0; + } + + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iElementalInstanceContainer.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/iElementalInstanceContainer.java index 448328cb30..74d371272b 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iElementalInstanceContainer.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/iElementalInstanceContainer.java @@ -1,6 +1,4 @@ -package com.github.technus.tectech.elementalMatter.core.interfaces; - -import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +package com.github.technus.tectech.elementalMatter.core; /** * Created by danie_000 on 25.01.2017. diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/rElementalRecipe.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/rElementalRecipe.java index b6cd7a5ccb..29fea2fa4c 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/rElementalRecipe.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/rElementalRecipe.java @@ -12,7 +12,7 @@ public class rElementalRecipe implements Comparable<rElementalRecipe> { public final cElementalDefinitionStackMap outEM; public final ItemStack[] outItems; public final FluidStack[] outFluids; - public Object[] extension = null; + public Object[] extension; public rElementalRecipe( cElementalDefinitionStackMap inEM,//not null plz @@ -24,7 +24,7 @@ public class rElementalRecipe implements Comparable<rElementalRecipe> { this.outEM = outEM; this.outItems = outItems; this.outFluids = outFluids; - this.ID = id;//allows multiple recipes with the same input EM,so u can actually extend... + ID = id;//allows multiple recipes with the same input EM,so u can actually extend... } public rElementalRecipe extend(Object... data) { @@ -34,14 +34,24 @@ public class rElementalRecipe implements Comparable<rElementalRecipe> { @Override public int compareTo(rElementalRecipe o) { - final int compare = inEM.compareTo(o.inEM); - return compare != 0 ? compare : (int) ID - o.ID; + int compare = inEM.compareTo(o.inEM); + if(compare!=0) { + return compare; + } + if(ID>o.ID) { + return 1; + } + if(ID<o.ID) { + return -1; + } + return 0; } @Override public boolean equals(Object obj) { - if (obj instanceof rElementalRecipe) + if (obj instanceof rElementalRecipe) { return compareTo((rElementalRecipe) obj) == 0; + } return false; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/rElementalRecipeMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/rElementalRecipeMap.java index 41aff17327..9a8ad52252 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/rElementalRecipeMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/rElementalRecipeMap.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.elementalMatter.core; import java.util.HashMap; +import java.util.Map; /** * Created by Tec on 02.03.2017. @@ -24,8 +25,9 @@ public class rElementalRecipeMap {//TODO FIX } public void putAll(rElementalRecipe... contents) { - for (rElementalRecipe recipe : contents) + for (rElementalRecipe recipe : contents) { put(recipe); + } } public rElementalRecipe remove(cElementalStackMap map, short id) { @@ -51,16 +53,20 @@ public class rElementalRecipeMap {//TODO FIX //Return a recipeShortMap when the content of input matches the recipe input - does not ignore amounts but ignores instance data! @Deprecated public HashMap<Short, rElementalRecipe> findMatch(cElementalMutableDefinitionStackMap in, boolean testOnlyTruePreferred) { - for (cElementalDefinitionStackMap requirement : recipes.keySet()) - if (in.removeAllAmounts(testOnlyTruePreferred, requirement)) - return recipes.get(requirement); + for (Map.Entry<cElementalDefinitionStackMap, HashMap<Short, rElementalRecipe>> cElementalDefinitionStackMapHashMapEntry : recipes.entrySet()) { + if (in.removeAllAmounts(testOnlyTruePreferred, cElementalDefinitionStackMapHashMapEntry.getKey())) { + return cElementalDefinitionStackMapHashMapEntry.getValue(); + } + } return null; } public HashMap<Short, rElementalRecipe> findMatch(cElementalInstanceStackMap in, boolean testOnly) { - for (cElementalDefinitionStackMap requirement : recipes.keySet()) - if (in.removeAllAmounts(testOnly, requirement)) - return recipes.get(requirement); + for (Map.Entry<cElementalDefinitionStackMap, HashMap<Short, rElementalRecipe>> cElementalDefinitionStackMapHashMapEntry : recipes.entrySet()) { + if (in.removeAllAmounts(testOnly, cElementalDefinitionStackMapHashMapEntry.getKey())) { + return cElementalDefinitionStackMapHashMapEntry.getValue(); + } + } return null; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalDefinitionStack.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalDefinitionStack.java index 8a119e356c..4e74650786 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalDefinitionStack.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalDefinitionStack.java @@ -1,6 +1,5 @@ package com.github.technus.tectech.elementalMatter.core.stacks; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.templates.cElementalDefinition; import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; import net.minecraft.nbt.NBTTagCompound; @@ -15,12 +14,12 @@ public final class cElementalDefinitionStack implements iHasElementalDefinition public final long amount; public cElementalDefinitionStack(iElementalDefinition def, long amount) { - this.definition = def == null ? null__ : def; + definition = def == null ? null__ : def; this.amount = amount; } @Override - public final cElementalDefinitionStack clone() { + public cElementalDefinitionStack clone() { return this;//IMMUTABLE } @@ -34,10 +33,12 @@ public final class cElementalDefinitionStack implements iHasElementalDefinition return amount; } + @Override public long getCharge() { return definition.getCharge() * amount; } + @Override public float getMass() { return definition.getMass() * amount; } @@ -56,16 +57,21 @@ public final class cElementalDefinitionStack implements iHasElementalDefinition } public cElementalDefinitionStack addAmountIntoNewInstance(long amount) { - if(amount==0) return this; + if(amount==0) { + return this; + } return new cElementalDefinitionStack(definition, amount + this.amount); } public cElementalDefinitionStack addAmountIntoNewInstance(cElementalDefinitionStack... other) { - if (other == null || other.length == 0) return this; - long i = 0; - for (cElementalDefinitionStack stack : other) - i += stack.amount; - return addAmountIntoNewInstance(i); + if (other == null || other.length == 0) { + return this; + } + long l = 0; + for (cElementalDefinitionStack stack : other) { + l += stack.amount; + } + return addAmountIntoNewInstance(l); } @Override @@ -75,10 +81,12 @@ public final class cElementalDefinitionStack implements iHasElementalDefinition @Override public boolean equals(Object obj) { - if (obj instanceof iElementalDefinition) + if (obj instanceof iElementalDefinition) { return definition.compareTo((iElementalDefinition) obj) == 0; - if (obj instanceof iHasElementalDefinition) + } + if (obj instanceof iHasElementalDefinition) { return definition.compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; + } return false; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalInstanceStack.java index e9de353597..4193153d57 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/cElementalInstanceStack.java @@ -5,7 +5,6 @@ import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.cElementalDecay; import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.templates.cElementalDefinition; import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; import net.minecraft.nbt.NBTTagCompound; @@ -42,16 +41,16 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } public cElementalInstanceStack(iElementalDefinition defSafe, long amount, float lifeTimeMult, long age, long energy) { - this.definition = defSafe == null ? null__ : defSafe; - byte color = definition.getColor(); - if (color < 0 || color > 2) {//transforms colorable??? into proper color - this.color = color; + definition = defSafe == null ? null__ : defSafe; + byte bColor = definition.getColor(); + if (bColor < 0 || bColor > 2) {//transforms colorable??? into proper color + this.color = bColor; } else { - this.color = (byte) (TecTech.Rnd.nextInt(3)); + this.color = (byte) TecTech.Rnd.nextInt(3); } this.lifeTimeMult = lifeTimeMult; this.energy = energy; - this.lifeTime = definition.getRawTimeSpan(energy) * this.lifeTimeMult; + lifeTime = definition.getRawTimeSpan(energy) * this.lifeTimeMult; this.age = age; this.amount = amount; } @@ -68,7 +67,7 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } @Override - public final cElementalInstanceStack clone() { + public cElementalInstanceStack clone() { return new cElementalInstanceStack(this); } @@ -77,10 +76,12 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { return amount; } + @Override public long getCharge() { return definition.getCharge() * amount; } + @Override public float getMass() { return definition.getMass() * amount; } @@ -118,13 +119,17 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } public byte setColor(byte color) {//does not allow changing magic element - if (this.color < 0 || this.color > 2 || color < 0 || color >= 3) return this.color; + if (this.color < 0 || this.color > 2 || color < 0 || color >= 3) { + return this.color; + } return this.color = color; } public byte nextColor() {//does not allow changing magic element - if (this.color < 0 || this.color > 2) return this.color; - return this.color = (byte) (TecTech.Rnd.nextInt(3)); + if (color < 0 || color > 2) { + return color; + } + return color = (byte) TecTech.Rnd.nextInt(3); } public float getLifeTime() { @@ -133,11 +138,15 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { public float setLifeTimeMultipleOfBaseValue(float mult) { if(mult<=0) //since infinity*0=nan + { throw new IllegalArgumentException("mult must be >0"); - this.lifeTimeMult = mult; - if (definition.getRawTimeSpan(energy) <= 0) return this.lifeTime; - this.lifeTime = definition.getRawTimeSpan(energy) * this.lifeTimeMult; - return this.lifeTime; + } + lifeTimeMult = mult; + if (definition.getRawTimeSpan(energy) <= 0) { + return lifeTime; + } + lifeTime = definition.getRawTimeSpan(energy) * lifeTimeMult; + return lifeTime; } public float getLifeTimeMult() { @@ -153,21 +162,24 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } public cElementalInstanceStackMap decay(float lifeTimeMult, long apparentAge, long postEnergize) { - long newEnergyLevel=postEnergize+this.energy; - if(newEnergyLevel>0) newEnergyLevel-=1; - else if(newEnergyLevel<0) newEnergyLevel+=1; - if (this.energy > 0 && !definition.usesSpecialEnergeticDecayHandling()) { + long newEnergyLevel=postEnergize+ energy; + if(newEnergyLevel>0) { + newEnergyLevel -= 1; + } else if(newEnergyLevel<0) { + newEnergyLevel += 1; + } + if (energy > 0 && !definition.usesSpecialEnergeticDecayHandling()) { setLifeTimeMultipleOfBaseValue(getLifeTimeMult()); - return decayCompute(definition.getEnergyInducedDecay(this.energy), lifeTimeMult, -1, newEnergyLevel); + return decayCompute(definition.getEnergyInducedDecay(energy), lifeTimeMult, -1, newEnergyLevel); }else if (definition.getRawTimeSpan(energy) < 0) { return null;//return null, decay cannot be achieved } else if(definition.isTimeSpanHalfLife()){ - return exponentialDecayCompute(energy>0?definition.getEnergyInducedDecay(this.energy):definition.getDecayArray(), lifeTimeMult, -1, newEnergyLevel); + return exponentialDecayCompute(energy>0?definition.getEnergyInducedDecay(energy):definition.getDecayArray(), lifeTimeMult, -1, newEnergyLevel); } else{ - if (1F > this.lifeTime) { - return decayCompute(energy>0?definition.getEnergyInducedDecay(this.energy):definition.getNaturalDecayInstant(), lifeTimeMult, 0, newEnergyLevel); - } else if (((float) apparentAge) > this.lifeTime) { - return decayCompute(energy>0?definition.getEnergyInducedDecay(this.energy):definition.getDecayArray(), lifeTimeMult, 0, newEnergyLevel); + if (1F > lifeTime) { + return decayCompute(energy>0?definition.getEnergyInducedDecay(energy):definition.getNaturalDecayInstant(), lifeTimeMult, 0, newEnergyLevel); + } else if ((float) apparentAge > lifeTime) { + return decayCompute(energy>0?definition.getEnergyInducedDecay(energy):definition.getDecayArray(), lifeTimeMult, 0, newEnergyLevel); } } return null;//return null since decay cannot be achieved @@ -177,51 +189,55 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { private cElementalInstanceStackMap exponentialDecayCompute(cElementalDecay[] decays, float lifeTimeMult, long newProductsAge, long energy) { double decayInverseRatio=Math.pow(2d,1d/* 1 second *//(double)lifeTime); double newAmount=(double)amount/decayInverseRatio; - long amountRemaining=((long)Math.floor(newAmount))+(TecTech.Rnd.nextDouble()<=newAmount-Math.floor(newAmount)?1:0); - if(amountRemaining==amount) return null;//nothing decayed - else if(amountRemaining<=0) return decayCompute(decays,lifeTimeMult,newProductsAge,energy); + long amountRemaining= (long)Math.floor(newAmount) +(TecTech.Rnd.nextDouble()<=newAmount-Math.floor(newAmount)?1:0); + if(amountRemaining==amount) { + return null;//nothing decayed + } else if(amountRemaining<=0) { + return decayCompute(decays, lifeTimeMult, newProductsAge, energy); + } //split to non decaying and decaying part long amount=this.amount; this.amount-=amountRemaining; cElementalInstanceStackMap products=decayCompute(decays,lifeTimeMult,newProductsAge,energy); this.amount=amountRemaining; - products.putUnify(this.clone()); + products.putUnify(clone()); this.amount=amount; return products; } //Use to get direct decay output providing correct decay array public cElementalInstanceStackMap decayCompute(cElementalDecay[] decays, float lifeTimeMult, long newProductsAge, long energy) { - if (decays == null) return null;//Can not decay so it wont - else if (decays.length == 0) + if (decays == null) { + return null;//Can not decay so it wont + } else if (decays.length == 0) { return new cElementalInstanceStackMap();//provide non null 0 length array for annihilation - else if (decays.length == 1) {//only one type of decay :D, doesn't need dead end - cElementalInstanceStackMap products=decays[0].getResults(lifeTimeMult, newProductsAge, energy, this.amount); + } else if (decays.length == 1) {//only one type of decay :D, doesn't need dead end + cElementalInstanceStackMap products=decays[0].getResults(lifeTimeMult, newProductsAge, energy, amount); if(newProductsAge<0){ - for(cElementalInstanceStack s:products.values()){ - if(s.definition.equals(definition)){ - s.age=this.age; - s.energy=this.energy; + for(cElementalInstanceStack stack:products.values()){ + if(stack.definition.equals(definition)){ + stack.age= age; + stack.energy=this.energy; } } }else{ - for(cElementalInstanceStack s:products.values()){ - if(s.definition.equals(definition)){ - s.energy=this.energy; + for(cElementalInstanceStack stack:products.values()){ + if(stack.definition.equals(definition)){ + stack.energy=this.energy; } } } return products; } else { cElementalInstanceStackMap output = new cElementalInstanceStackMap(); - final int differentDecays = decays.length; + int differentDecays = decays.length; long[] qttyOfDecay = new long[differentDecays]; long amountRemaining = this.amount, amount = this.amount; float remainingProbability = 1F; for (int i = 0; i < differentDecays; i++) { if (decays[i].probability > 1F) { - long thisDecayAmount = (long) (Math.floor(remainingProbability * (double) amount)); + long thisDecayAmount = (long) Math.floor(remainingProbability * (double) amount); if (thisDecayAmount == 0) { //remainingProbability=something; break; @@ -236,9 +252,9 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { //remainingProbability=0; break; } - long thisDecayAmount = (long) (Math.floor(decays[i].probability * (double) amount)); + long thisDecayAmount = (long) Math.floor(decays[i].probability * (double) amount); if (thisDecayAmount <= amountRemaining && thisDecayAmount > 0) {//some was made - remainingProbability -= (decays[i].probability); + remainingProbability -= decays[i].probability; amountRemaining -= thisDecayAmount; qttyOfDecay[i] += thisDecayAmount; } else if (thisDecayAmount > amountRemaining) {//too much was made @@ -261,21 +277,22 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } for (int i = 0; i < differentDecays; i++) { - if (qttyOfDecay[i] > 0) + if (qttyOfDecay[i] > 0) { output.putUnifyAll(decays[i].getResults(lifeTimeMult, newProductsAge, energy, qttyOfDecay[i])); + } } if(newProductsAge<0){ - for(cElementalInstanceStack s:output.values()){ - if(s.definition.equals(definition)){ - s.age=this.age; - s.energy=this.energy; + for(cElementalInstanceStack stack:output.values()){ + if(stack.definition.equals(definition)){ + stack.age= age; + stack.energy=this.energy; } } }else{ - for(cElementalInstanceStack s:output.values()){ - if(s.definition.equals(definition)){ - s.energy=this.energy; + for(cElementalInstanceStack stack:output.values()){ + if(stack.definition.equals(definition)){ + stack.energy=this.energy; } } } @@ -284,59 +301,70 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { } public cElementalInstanceStack unifyIntoThis(cElementalInstanceStack... instances) { - if (instances == null) return this; + if (instances == null) { + return this; + } //returns with the definition from the first object passed - long energy = this.energy * this.amount; - float lifeTimeMul = this.lifeTimeMult; + long energy = this.energy * amount; + float lifeTimeMul = lifeTimeMult; for (cElementalInstanceStack instance : instances) { - if (instance != null && this.compareTo(instance) == 0) { - this.amount += instance.amount; + if (instance != null && compareTo(instance) == 0) { + amount += instance.amount; energy += instance.energy * instance.amount; lifeTimeMul = Math.min(lifeTimeMul, instance.lifeTimeMult); - this.age = Math.max(this.age, instance.age); + age = Math.max(age, instance.age); } } - if (amount != 0) energy /= Math.abs(amount); + if (amount != 0) { + energy /= Math.abs(amount); + } this.energy = energy; - this.setLifeTimeMultipleOfBaseValue(lifeTimeMul); + setLifeTimeMultipleOfBaseValue(lifeTimeMul); return this; } public void addScanResults(ArrayList<String> lines, int[] detailsOnDepthLevels){ - final int capabilities=detailsOnDepthLevels[0]; - if(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,capabilities)) - lines.add("DEPTH = "+0); + int capabilities=detailsOnDepthLevels[0]; + if(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,capabilities)) { + lines.add("DEPTH = " + 0); + } definition.addScanResults(lines,capabilities,energy); if(Util.areBitsSet(SCAN_GET_TIMESPAN_MULT,capabilities)) { lines.add("TIME SPAN MULTIPLIER = " + lifeTimeMult); - if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO,capabilities)) - lines.add("TIME SPAN MULTIPLIED = "+lifeTime+" s"); + if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO,capabilities)) { + lines.add("TIME SPAN MULTIPLIED = " + lifeTime + " s"); + } + } + if(Util.areBitsSet(SCAN_GET_AGE,capabilities)) { + lines.add("AGE = " + age + " s"); + } + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { + lines.add("COLOR = " + color + " RGB or CMY"); + } + if(Util.areBitsSet(SCAN_GET_ENERGY_LEVEL,capabilities)) { + lines.add("E. LEVEL = " + energy); + } + if(Util.areBitsSet(SCAN_GET_AMOUNT,capabilities)) { + lines.add("AMOUNT = " + amount); } - if(Util.areBitsSet(SCAN_GET_AGE,capabilities)) - lines.add("AGE = " + age+" s"); - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) - lines.add("COLOR = "+color+" RGB or CMY"); - if(Util.areBitsSet(SCAN_GET_ENERGY_LEVEL,capabilities)) - lines.add("ENERGY LEVEL = "+energy); - if(Util.areBitsSet(SCAN_GET_AMOUNT,capabilities)) - lines.add("AMOUNT = "+amount); - lines.add(null);//def separator scanContents(lines,definition.getSubParticles(),1,detailsOnDepthLevels); } private void scanContents(ArrayList<String> lines, cElementalDefinitionStackMap definitions, int depth, int[] detailsOnDepthLevels){ if(definitions!=null && depth<detailsOnDepthLevels.length){ - final int deeper=depth+1; + int deeper=depth+1; for(cElementalDefinitionStack definitionStack:definitions.values()) { - if(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,detailsOnDepthLevels[depth])) + lines.add("");//def separator + if(Util.areBitsSet(SCAN_GET_DEPTH_LEVEL,detailsOnDepthLevels[depth])) { lines.add("DEPTH = " + depth); + } definition.addScanResults(lines,detailsOnDepthLevels[depth],energy); - if(Util.areBitsSet(SCAN_GET_AMOUNT,detailsOnDepthLevels[depth])) - lines.add("AMOUNT = "+definitionStack.amount); - lines.add(null);//def separator + if(Util.areBitsSet(SCAN_GET_AMOUNT,detailsOnDepthLevels[depth])) { + lines.add("AMOUNT = " + definitionStack.amount); + } scanContents(lines,definitionStack.definition.getSubParticles(),deeper,detailsOnDepthLevels); } } @@ -372,10 +400,12 @@ public final class cElementalInstanceStack implements iHasElementalDefinition { @Override public boolean equals(Object obj) { - if (obj instanceof iElementalDefinition) + if (obj instanceof iElementalDefinition) { return definition.compareTo((iElementalDefinition) obj) == 0; - if (obj instanceof iHasElementalDefinition) + } + if (obj instanceof iHasElementalDefinition) { return definition.compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; + } return false; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iHasElementalDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/iHasElementalDefinition.java index 2659898d62..68ca71f33c 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iHasElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/stacks/iHasElementalDefinition.java @@ -1,4 +1,4 @@ -package com.github.technus.tectech.elementalMatter.core.interfaces; +package com.github.technus.tectech.elementalMatter.core.stacks; import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalDefinition.java index 9eb682f4b8..505bb5ab48 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalDefinition.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.elementalMatter.core.templates; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; import net.minecraft.nbt.NBTTagCompound; @@ -24,8 +24,16 @@ public abstract class cElementalDefinition extends iElementalDefinition { private static final HashSet<Byte> classSet = new HashSet<>(); protected static void addCreatorFromNBT(byte shortcutNBT, Method constructorFromNBT,byte classID) { - if(nbtCreationBind.put(shortcutNBT, constructorFromNBT)!=null) throw new Error("Duplicate NBT shortcut! "+shortcutNBT); - if(!classSet.add(classID)) throw new Error("Duplicate Class ID! "+classID); + if(nbtCreationBind.put(shortcutNBT, constructorFromNBT)!=null) { + throw new Error("Duplicate NBT shortcut! " + shortcutNBT + " used for NBT based creation"); + } + if(!classSet.add(classID)) { + throw new Error("Duplicate Class ID! " + classID + " used for class comparison"); + } + } + + public static Map<Byte, Method> getBindsComplex(){ + return nbtCreationBind; } @Override @@ -37,15 +45,19 @@ public abstract class cElementalDefinition extends iElementalDefinition { try { return (iElementalDefinition) nbtCreationBind.get(nbt.getByte("t")).invoke(null, nbt); } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return nbtE__; } } @Override public int compareTo(iElementalDefinition o) { - final int classCompare = compareClassID(o); - if (classCompare != 0) return classCompare; + int classCompare = compareClassID(o); + if (classCompare != 0) { + return classCompare; + } //only of the internal def stacks!!! //that allows neat check if the same thing and @@ -56,44 +68,61 @@ public abstract class cElementalDefinition extends iElementalDefinition { //use only for nested operations! private static int compareInnerContentsWithAmounts(cElementalDefinitionStack[] tc, cElementalDefinitionStack[] sc) { if (tc == null) { - if (sc == null) return 0; - else return -1; + if (sc == null) { + return 0; + } else { + return -1; + } + } + if (sc == null) { + return 1; } - if (sc == null) return 1; - final int lenDiff = tc.length - sc.length; - if (lenDiff != 0) return lenDiff; + int lenDiff = tc.length - sc.length; + if (lenDiff != 0) { + return lenDiff; + } for (int i = 0; i < tc.length; i++) { int cn = tc[i].definition.compareTo(sc[i].definition); - if (cn != 0) return cn; - - if (tc[i].amount > sc[i].amount) return 1; - if (tc[i].amount < sc[i].amount) return -1; + if (cn != 0) { + return cn; + } + + if (tc[i].amount > sc[i].amount) { + return 1; + } + if (tc[i].amount < sc[i].amount) { + return -1; + } } return 0; } @Override - public final cElementalDefinitionStack getStackForm(int i) { + public final cElementalDefinitionStack getStackForm(long i) { return new cElementalDefinitionStack(this,i); } @Override public final boolean equals(Object obj) { - if(this==obj)return true; - if (obj instanceof iElementalDefinition) + if(this==obj) { + return true; + } + if (obj instanceof iElementalDefinition) { return compareTo((iElementalDefinition) obj) == 0; - if (obj instanceof iHasElementalDefinition) + } + if (obj instanceof iHasElementalDefinition) { return compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; + } return false; } @Override public int hashCode() {//Internal amounts should be also hashed int hash = -(getSubParticles().size() << 4); - for (cElementalDefinitionStack s : getSubParticles().values()) { - hash += ((s.amount & 0x1) == 0 ? -s.amount : s.amount) + s.definition.hashCode(); + for (cElementalDefinitionStack stack : getSubParticles().values()) { + hash += ((stack.amount & 0x1) == 0 ? -stack.amount : stack.amount) + stack.definition.hashCode(); } return hash; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java index b44332d5c8..ab571e9d4c 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/cElementalPrimitive.java @@ -25,9 +25,13 @@ import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileE * EXTEND THIS TO ADD NEW PRIMITIVES, WATCH OUT FOR ID'S!!! (-1 to 32 can be assumed as used) */ public abstract class cElementalPrimitive extends cElementalDefinition { - private static final byte nbtType = (byte) 'p'; + public static final byte nbtType = (byte) 'p'; - public static final Map<Integer, iElementalDefinition> bindsBO = new HashMap<>(); + private static final Map<Integer, cElementalPrimitive> bindsBO = new HashMap<>(); + + public static Map<Integer, cElementalPrimitive> getBindsPrimitive() { + return bindsBO; + } public final String name; public final String symbol; @@ -60,17 +64,18 @@ public abstract class cElementalPrimitive extends cElementalDefinition { this.charge = (byte) charge; this.color = (byte) color; this.ID = ID; - if (bindsBO.put(ID, this) != null) + if (bindsBO.put(ID, this) != null) { Minecraft.getMinecraft().crashed(new CrashReport("Primitive definition", new tElementalException("Duplicate ID"))); + } } // protected void init(cElementalPrimitive antiParticle, float rawLifeTime, int naturalInstant, int energeticInstant, cElementalDecay... elementalDecaysArray) { - this.anti = antiParticle; + anti = antiParticle; this.rawLifeTime = rawLifeTime; - this.naturalDecayInstant = (byte) naturalInstant; - this.energeticDecayInstant = (byte) energeticInstant; - this.elementalDecays = elementalDecaysArray; + naturalDecayInstant = (byte) naturalInstant; + energeticDecayInstant = (byte) energeticInstant; + elementalDecays = elementalDecaysArray; } @Override @@ -105,19 +110,23 @@ public abstract class cElementalPrimitive extends cElementalDefinition { @Override public cElementalDecay[] getNaturalDecayInstant() { - if (naturalDecayInstant < 0) return elementalDecays; + if (naturalDecayInstant < 0) { + return elementalDecays; + } return new cElementalDecay[]{elementalDecays[naturalDecayInstant]}; } @Override public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { - if (energeticDecayInstant < 0) return elementalDecays; + if (energeticDecayInstant < 0) { + return elementalDecays; + } return new cElementalDecay[]{elementalDecays[energeticDecayInstant]}; } @Override public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { - return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); } @Override @@ -168,8 +177,8 @@ public abstract class cElementalPrimitive extends cElementalDefinition { return nbt; } - public static iElementalDefinition fromNBT(NBTTagCompound content) { - iElementalDefinition primitive = bindsBO.get(content.getInteger("c")); + public static cElementalPrimitive fromNBT(NBTTagCompound content) { + cElementalPrimitive primitive = bindsBO.get(content.getInteger("c")); return primitive == null ? null__ : primitive; } @@ -180,18 +189,22 @@ public abstract class cElementalPrimitive extends cElementalDefinition { @Override public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) - lines.add("CLASS = "+nbtType+" "+getClassType()); + if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + lines.add("CLASS = " + nbtType + ' ' + getClassType()); + } if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add("NAME = "+getName()); lines.add("SYMBOL = "+getSymbol()); } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) - lines.add("CHARGE = "+getCharge()/3f+" eV"); - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) - lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) - lines.add("MASS = "+getMass()+" eV/c\u00b2"); + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { + lines.add("CHARGE = " + getCharge() / 3f + " e"); + } + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { + lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); + } + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + lines.add("MASS = " + getMass() + " eV/c\u00b2"); + } if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ lines.add((isTimeSpanHalfLife()?"HALF LIFE = ":"LIFE TIME = ")+getRawTimeSpan(energyLevel)+ " s"); lines.add(" "+"At current energy level"); @@ -202,18 +215,25 @@ public abstract class cElementalPrimitive extends cElementalDefinition { try { cElementalDefinition.addCreatorFromNBT(nbtType, cElementalPrimitive.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-128); } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + if(DEBUG_MODE) { + TecTech.Logger.info("Registered Elemental Matter Class: Primitive " + nbtType + ' ' + -128); } - if(DEBUG_MODE) - TecTech.Logger.info("Registered Elemental Matter Class: Primitive "+nbtType+" "+(-128)); } @Override public final int compareTo(iElementalDefinition o) { if (getClassType() == o.getClassType()) { int oID = ((cElementalPrimitive) o).ID; - if (ID > oID) return 1; - if (ID < oID) return -1; + if (ID > oID) { + return 1; + } + if (ID < oID) { + return -1; + } return 0; } return compareClassID(o); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/iElementalDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/iElementalDefinition.java index c34bca652e..23d2df06a8 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/iElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/templates/iElementalDefinition.java @@ -64,11 +64,12 @@ public abstract class iElementalDefinition implements Comparable<iElementalDefin public abstract NBTTagCompound toNBT(); - public abstract cElementalDefinitionStack getStackForm(int i); + public abstract cElementalDefinitionStack getStackForm(long i); + @Override public abstract iElementalDefinition clone(); - final int compareClassID(iElementalDefinition obj) { - return ((int) getClassType()) - obj.getClassType(); + final /*default*/ int compareClassID(iElementalDefinition obj) { + return (int) getClassType() - obj.getClassType(); } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aFluidDequantizationInfo.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aFluidDequantizationInfo.java index 6da5ffe114..6f66830f83 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aFluidDequantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aFluidDequantizationInfo.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.elementalMatter.core.transformations; -import com.github.technus.tectech.elementalMatter.core.interfaces.iExchangeInfo; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aFluidQuantizationInfo.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aFluidQuantizationInfo.java index 0848c7b9f9..714b991c55 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aFluidQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aFluidQuantizationInfo.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.elementalMatter.core.transformations; -import com.github.technus.tectech.elementalMatter.core.interfaces.iExchangeInfo; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aItemDequantizationInfo.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aItemDequantizationInfo.java index c04f180215..d7ab4cc9f7 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aItemDequantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aItemDequantizationInfo.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.elementalMatter.core.transformations; -import com.github.technus.tectech.elementalMatter.core.interfaces.iExchangeInfo; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_OreDictUnificator; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aItemQuantizationInfo.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aItemQuantizationInfo.java index ce652e9d6d..cc240e1246 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aItemQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aItemQuantizationInfo.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.elementalMatter.core.transformations; -import com.github.technus.tectech.elementalMatter.core.interfaces.iExchangeInfo; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -41,23 +40,29 @@ public class aItemQuantizationInfo implements iExchangeInfo { @Override public int hashCode() { - return (GameRegistry.findUniqueIdentifierFor(in.getItem())+":"+in.getUnlocalizedName()+":"+in.getItemDamage()).hashCode(); + return (GameRegistry.findUniqueIdentifierFor(in.getItem())+":"+in.getUnlocalizedName()+ ':' +in.getItemDamage()).hashCode(); } @Override public boolean equals(Object obj) { if(obj instanceof aItemQuantizationInfo){ //alias - ItemStack b=((aItemQuantizationInfo) obj).in; - if(!in.getUnlocalizedName().equals(((aItemQuantizationInfo) obj).in.getUnlocalizedName())) return false; + ItemStack stack=((aItemQuantizationInfo) obj).in; + if(!in.getUnlocalizedName().equals(((aItemQuantizationInfo) obj).in.getUnlocalizedName())) { + return false; + } if(!GameRegistry.findUniqueIdentifierFor(in.getItem()).equals( - GameRegistry.findUniqueIdentifierFor(((aItemQuantizationInfo) obj).in.getItem()))) return false; + GameRegistry.findUniqueIdentifierFor(((aItemQuantizationInfo) obj).in.getItem()))) { + return false; + } - if(in.getItemDamage() != OreDictionary.WILDCARD_VALUE && b.getItemDamage() != OreDictionary.WILDCARD_VALUE) { - if (in.getItemDamage() != b.getItemDamage()) return false; + if(in.getItemDamage() != OreDictionary.WILDCARD_VALUE && stack.getItemDamage() != OreDictionary.WILDCARD_VALUE) { + if (in.getItemDamage() != stack.getItemDamage()) { + return false; + } } - return skipNBT || ItemStack.areItemStackTagsEqual(in, b); + return skipNBT || ItemStack.areItemStackTagsEqual(in, stack); } return false; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aOredictDequantizationInfo.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aOredictDequantizationInfo.java index e19ac74d63..0d0e75e5af 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aOredictDequantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aOredictDequantizationInfo.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.elementalMatter.core.transformations; -import com.github.technus.tectech.elementalMatter.core.interfaces.iExchangeInfo; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import net.minecraftforge.oredict.OreDictionary; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aOredictQuantizationInfo.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aOredictQuantizationInfo.java index 9edaa93d98..3d9a873520 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aOredictQuantizationInfo.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/aOredictQuantizationInfo.java @@ -1,7 +1,6 @@ package com.github.technus.tectech.elementalMatter.core.transformations; -import com.github.technus.tectech.elementalMatter.core.interfaces.iExchangeInfo; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import net.minecraftforge.oredict.OreDictionary; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/bTransformationInfo.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/bTransformationInfo.java index e51142c841..0584a7566c 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/bTransformationInfo.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/bTransformationInfo.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.elementalMatter.core.transformations; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; @@ -15,13 +15,13 @@ import java.util.HashMap; * Created by Tec on 26.05.2017. */ public class bTransformationInfo { - final static public HashMap<Integer,aFluidQuantizationInfo> fluidQuantization=new HashMap<>(32); + public static final HashMap<Integer,aFluidQuantizationInfo> fluidQuantization=new HashMap<>(32); public HashMap<iElementalDefinition,aFluidDequantizationInfo> fluidDequantization; - final static public HashMap<aItemQuantizationInfo,aItemQuantizationInfo> itemQuantization=new HashMap<>(32); + public static final HashMap<aItemQuantizationInfo,aItemQuantizationInfo> itemQuantization=new HashMap<>(32); public HashMap<iElementalDefinition,aItemDequantizationInfo> itemDequantization; - final static public HashMap<Integer,aOredictQuantizationInfo> oredictQuantization=new HashMap<>(32); + public static final HashMap<Integer,aOredictQuantizationInfo> oredictQuantization=new HashMap<>(32); public HashMap<iElementalDefinition,aOredictDequantizationInfo> oredictDequantization; public bTransformationInfo(){ @@ -31,9 +31,15 @@ public class bTransformationInfo { } public bTransformationInfo(int fluidCap,int itemCap, int oreCap){ - if(fluidCap>0)fluidDequantization=new HashMap<>(fluidCap); - if(itemCap>0)itemDequantization=new HashMap<>(itemCap); - if(oreCap>0)oredictDequantization=new HashMap<>(oreCap); + if(fluidCap>0) { + fluidDequantization = new HashMap<>(fluidCap); + } + if(itemCap>0) { + itemDequantization = new HashMap<>(itemCap); + } + if(oreCap>0) { + oredictDequantization = new HashMap<>(oreCap); + } } public void addFluid(iHasElementalDefinition em, FluidStack fluidStack){ diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iExchangeInfo.java b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/iExchangeInfo.java index cfae8a20a1..84c5855dab 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/core/interfaces/iExchangeInfo.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/core/transformations/iExchangeInfo.java @@ -1,11 +1,11 @@ -package com.github.technus.tectech.elementalMatter.core.interfaces; +package com.github.technus.tectech.elementalMatter.core.transformations; /** * Created by Tec on 23.05.2017. */ public interface iExchangeInfo { Object output();//what should be given - ItemStack,FluidStack,AspectStack, (EM definitionStack->)EM instance stack - etc. - //This must return new Object! - if obj is immutable dont care that much (applies to defStacks) + //This must return new Object! - if obj is immutable don't care that much (applies to defStacks) Object input();//same as above but for input } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java index 75aabe9af3..1b17407970 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/dAtomDefinition.java @@ -21,7 +21,6 @@ import com.github.technus.tectech.elementalMatter.definitions.primitive.eLeptonD import com.github.technus.tectech.elementalMatter.definitions.primitive.eNeutrinoDefinition; import cpw.mods.fml.common.Loader; import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; import net.minecraft.nbt.NBTTagCompound; import java.util.*; @@ -52,10 +51,15 @@ public final class dAtomDefinition extends cElementalDefinition { private static final Map<Integer, dAtomDefinition> unstableAtoms = new HashMap<>(); private static cElementalDefinitionStack alpha,deuterium,tritium,helium_3,beryllium_8,carbon_14,neon_24,silicon_34; private static final HashMap<dAtomDefinition,Float> lifetimeOverrides = new HashMap<>(); - public static final ArrayList<Runnable> overrides = new ArrayList<>(); public final iaeaNuclide iaea; + private static dAtomDefinition somethingHeavy; + public static dAtomDefinition getSomethingHeavy() { + return somethingHeavy; + } + + private static final ArrayList<Runnable> overrides = new ArrayList<>(); public static void addOverride(dAtomDefinition atom, float rawLifeTime){ lifetimeOverrides.put(atom,rawLifeTime); } @@ -105,8 +109,10 @@ public final class dAtomDefinition extends cElementalDefinition { } private dAtomDefinition(boolean check, cElementalDefinitionStackMap things) throws tElementalException { - if (check && !canTheyBeTogether(things)) throw new tElementalException("Atom Definition error"); - this.elementalStacks = things; + if (check && !canTheyBeTogether(things)) { + throw new tElementalException("Atom Definition error"); + } + elementalStacks = things; float mass = 0; int cLeptons = 0; @@ -118,22 +124,28 @@ public final class dAtomDefinition extends cElementalDefinition { iElementalDefinition def = stack.definition; int amount = (int)stack.amount; mass += stack.getMass(); - if (def.getType() < 0) containsAnti = true; + if (def.getType() < 0) { + containsAnti = true; + } type = Math.max(type, Math.abs(def.getType())); if (def instanceof eLeptonDefinition) { cLeptons += stack.getCharge(); } else { cNucleus += stack.getCharge(); - if (def.getCharge() == 3) element += amount; - else if (def.getCharge() == -3) element -= amount; - else if (def.getCharge() == 0) neutralCount += amount; + if (def.getCharge() == 3) { + element += amount; + } else if (def.getCharge() == -3) { + element -= amount; + } else if (def.getCharge() == 0) { + neutralCount += amount; + } } } this.type = containsAnti ? (byte) -type : (byte) type; //this.mass = mass; - this.chargeLeptons = cLeptons; - this.charge = cNucleus + cLeptons; + chargeLeptons = cLeptons; + charge = cNucleus + cLeptons; this.neutralCount = neutralCount; this.element = element; @@ -145,46 +157,50 @@ public final class dAtomDefinition extends cElementalDefinition { int izoDiffAbs = Math.abs(izoDiff); xstr.setSeed((element + 1L) * (neutralCount + 100L)); - this.iaea=iaeaNuclide.get(element,neutralCount); + iaea =iaeaNuclide.get(element,neutralCount); if(iaea!=null){ - if(Float.isNaN(iaea.mass)) this.mass=mass; - else this.mass=iaea.mass; + if(Float.isNaN(iaea.mass)) { + this.mass = mass; + } else { + this.mass = iaea.mass; + } if(Float.isNaN(iaea.halfTime)) { - Float overriddenLifeTime=lifetimeOverrides.get(this); + Float overriddenLifeTime= lifetimeOverrides.get(this); float rawLifeTimeTemp; - if(overriddenLifeTime!=null) + if(overriddenLifeTime!=null) { rawLifeTimeTemp = overriddenLifeTime; - else { + } else { rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); } - this.rawLifeTime=rawLifeTimeTemp> STABLE_RAW_LIFE_TIME ? STABLE_RAW_LIFE_TIME :rawLifeTimeTemp; + rawLifeTime =rawLifeTimeTemp> iElementalDefinition.STABLE_RAW_LIFE_TIME ? iElementalDefinition.STABLE_RAW_LIFE_TIME :rawLifeTimeTemp; }else { - this.rawLifeTime = containsAnti ? iaea.halfTime * 1.5514433E-21f * (1f + xstr.nextFloat() * 9f) : iaea.halfTime; + rawLifeTime = containsAnti ? iaea.halfTime * 1.5514433E-21f * (1f + xstr.nextFloat() * 9f) : iaea.halfTime; } - this.iaeaDefinitionExistsAndHasEnergyLevels =iaea.energeticStatesArray.length>1; + iaeaDefinitionExistsAndHasEnergyLevels =iaea.energeticStatesArray.length>1; }else{ this.mass=mass; - Float overriddenLifeTime=lifetimeOverrides.get(this); + Float overriddenLifeTime= lifetimeOverrides.get(this); float rawLifeTimeTemp; - if(overriddenLifeTime!=null) + if(overriddenLifeTime!=null) { rawLifeTimeTemp = overriddenLifeTime; - else { + } else { rawLifeTimeTemp = calculateLifeTime(izoDiff, izoDiffAbs, element, neutralCount, containsAnti); } - this.rawLifeTime=rawLifeTimeTemp> STABLE_RAW_LIFE_TIME ? STABLE_RAW_LIFE_TIME :rawLifeTimeTemp; + rawLifeTime =rawLifeTimeTemp> iElementalDefinition.STABLE_RAW_LIFE_TIME ? iElementalDefinition.STABLE_RAW_LIFE_TIME :rawLifeTimeTemp; - this.iaeaDefinitionExistsAndHasEnergyLevels =false; + iaeaDefinitionExistsAndHasEnergyLevels =false; } if(iaea==null || iaea.energeticStatesArray[0].energy!=0) { - if (izoDiff == 0) - this.decayMode = 0; - else - this.decayMode = izoDiff > 0 ? (byte) Math.min(2, 1 + izoDiffAbs / 4) : (byte) -Math.min(2, 1 + izoDiffAbs / 4); + if (izoDiff == 0) { + decayMode = 0; + } else { + decayMode = izoDiff > 0 ? (byte) Math.min(2, 1 + izoDiffAbs / 4) : (byte) -Math.min(2, 1 + izoDiffAbs / 4); + } }else{ - this.decayMode = izoDiff > 0 ? (byte) (Math.min(2, 1 + izoDiffAbs / 4)+ BYTE_OFFSET) : (byte) (-Math.min(2, 1 + izoDiffAbs / 4) + BYTE_OFFSET); + decayMode = izoDiff > 0 ? (byte) (Math.min(2, 1 + izoDiffAbs / 4)+ BYTE_OFFSET) : (byte) (-Math.min(2, 1 + izoDiffAbs / 4) + BYTE_OFFSET); } //this.stable = this.rawLifeTime >= STABLE_RAW_LIFE_TIME; @@ -201,21 +217,15 @@ public final class dAtomDefinition extends cElementalDefinition { private static float calculateLifeTime(int izoDiff, int izoDiffAbs, int element, int isotope, boolean containsAnti) { float rawLifeTime; - if (element <= 83 && isotope < 127 && (izoDiffAbs == 0 || - (element == 1 && isotope == 0) || - (element == 2 && isotope == 1) || - (izoDiffAbs == 1 && element > 2 && element % 2 == 1) || - (izoDiffAbs == 3 && element > 30 && element % 2 == 0) || - (izoDiffAbs == 5 && element > 30 && element % 2 == 0) || - (izoDiffAbs == 2 && element > 20 && element % 2 == 1))) { + if (element <= 83 && isotope < 127 && (izoDiffAbs == 0 || element == 1 && isotope == 0 || element == 2 && isotope == 1 || izoDiffAbs == 1 && element > 2 && element % 2 == 1 || izoDiffAbs == 3 && element > 30 && element % 2 == 0 || izoDiffAbs == 5 && element > 30 && element % 2 == 0 || izoDiffAbs == 2 && element > 20 && element % 2 == 1)) { rawLifeTime = containsAnti ? 2.381e4f * (1f + xstr.nextFloat() * 9f) : (1f + xstr.nextFloat() * 9f) * 1.5347e25F; } else { //Y = (X-A)/(B-A) * (D-C) + C - float unstabilityEXP = 0; + float unstabilityEXP; if (element == 0) { return 1e-35f; } else if (element == 1) { - unstabilityEXP = 1.743f - (Math.abs(izoDiff - 1) * 9.743f); + unstabilityEXP = 1.743f - Math.abs(izoDiff - 1) * 9.743f; } else if (element == 2) { switch (isotope) { case 4: @@ -231,21 +241,33 @@ public final class dAtomDefinition extends cElementalDefinition { unstabilityEXP = -(izoDiffAbs * 6.165F); break; } - } else if (element <= 83 || (isotope <= 127 && element <= 120)) { + } else if (element <= 83 || isotope <= 127 && element <= 120) { float elementPow4 = (float) Math.pow(element, 4f); - unstabilityEXP = Math.min(element / 2.4f, 6 + ((element + 1) % 2) * 3e6F / elementPow4) + (((float) -izoDiff * elementPow4) / 1e8F) - (Math.abs(izoDiff - 1 + element / 60F) * (3f - (element / 12.5f) + ((element * element) / 1500f))); + unstabilityEXP = Math.min(element / 2.4f, 6 + ((element + 1) % 2) * 3e6F / elementPow4) + (float) -izoDiff * elementPow4 / 1e8F - Math.abs(izoDiff - 1 + element / 60F) * (3f - element / 12.5f + element * element / 1500f); } else if (element < 180) { - unstabilityEXP = Math.min((element - 85) * 2, 16 + ((isotope + 1) % 2) * 2.5F - (element - 85) / 3F) - (Math.abs(izoDiff) * (3f - (element / 13f) + ((element * element) / 1600f))); - } else return -1; - if ((isotope == 127 || isotope == 128) && (element < 120 && element > 83)) unstabilityEXP -= 1.8f; - if (element > 83 && element < 93 && isotope % 2 == 0 && izoDiff == 3) unstabilityEXP += 6; - if (element > 93 && element < 103 && isotope % 2 == 0 && izoDiff == 4) unstabilityEXP += 6; - rawLifeTime = (containsAnti ? 1e-8f : 1f) * (float) (Math.pow(10F, unstabilityEXP)) * (1f + xstr.nextFloat() * 9f); + unstabilityEXP = Math.min((element - 85) * 2, 16 + ((isotope + 1) % 2) * 2.5F - (element - 85) / 3F) - Math.abs(izoDiff) * (3f - element / 13f + element * element / 1600f); + } else { + return -1; + } + if ((isotope == 127 || isotope == 128) && element < 120 && element > 83) { + unstabilityEXP -= 1.8f; + } + if (element > 83 && element < 93 && isotope % 2 == 0 && izoDiff == 3) { + unstabilityEXP += 6; + } + if (element > 93 && element < 103 && isotope % 2 == 0 && izoDiff == 4) { + unstabilityEXP += 6; + } + rawLifeTime = (containsAnti ? 1e-8f : 1f) * (float) Math.pow(10F, unstabilityEXP) * (1f + xstr.nextFloat() * 9f); } - if (rawLifeTime < 8e-15) return 1e-35f; - if (rawLifeTime > 8e28) return 8e30f; + if (rawLifeTime < 8e-15) { + return 1e-35f; + } + if (rawLifeTime > 8e28) { + return 8e30f; + } return rawLifeTime; } @@ -254,9 +276,13 @@ public final class dAtomDefinition extends cElementalDefinition { long qty=0; for (cElementalDefinitionStack stack : stacks.values()) { if (stack.definition instanceof dHadronDefinition) { - if (((dHadronDefinition) stack.definition).amount != 3) return false; + if (((dHadronDefinition) stack.definition).amount != 3) { + return false; + } nuclei = true; - } else if (!(stack.definition instanceof eLeptonDefinition)) return false; + } else if (!(stack.definition instanceof eLeptonDefinition)) { + return false; + } qty+=stack.amount; } return nuclei && qty<ATOM_COMPLEXITY_LIMIT; @@ -276,7 +302,7 @@ public final class dAtomDefinition extends cElementalDefinition { } public int getIonizationElementWise() { - return (element * 3) + chargeLeptons; + return element * 3 + chargeLeptons; } @Override @@ -291,7 +317,9 @@ public final class dAtomDefinition extends cElementalDefinition { @Override public float getRawTimeSpan(long currentEnergy) { - if(currentEnergy<=0) return rawLifeTime; + if(currentEnergy<=0) { + return rawLifeTime; + } if(iaeaDefinitionExistsAndHasEnergyLevels){ if(currentEnergy>=iaea.energeticStatesArray.length){ return iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].Thalf/(currentEnergy-iaea.energeticStatesArray.length+1); @@ -313,31 +341,39 @@ public final class dAtomDefinition extends cElementalDefinition { @Override public String getName() { - final int element = Math.abs(this.element); - final boolean negative = element < 0; + int element = Math.abs(this.element); + boolean negative = element < 0; try { - if (type != 1) return (negative ? "~? " : "? ") + nomenclature.Name[element]; - return negative ? "~" + nomenclature.Name[-element] : nomenclature.Name[element]; + if (type != 1) { + return (negative ? "~? " : "? ") + nomenclature.Name[element]; + } + return negative ? '~' + nomenclature.Name[-element] : nomenclature.Name[element]; } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return (negative ? "Element: ~" : "Element: ") + element; } } @Override public String getSymbol() { - final int element = Math.abs(this.element); - final boolean negative = element < 0; + int element = Math.abs(this.element); + boolean negative = element < 0; try { - return (negative ? "~" : "") + nomenclature.Symbol[element] + " N:" + neutralCount + " I:" + (neutralCount+element) + " C: " + getCharge(); + return (negative ? "~" : "") + nomenclature.Symbol[element] + " N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (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:" + neutralCount + " I:" + (neutralCount+element) + " C: " + getCharge(); + int s100 = element / 100, s1 = element / 10 % 10, s10 = element % 10; + return (negative ? "~" : "") + nomenclature.SymbolIUPAC[10 + s100] + nomenclature.SymbolIUPAC[s10] + nomenclature.SymbolIUPAC[s1] + " N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); } catch (Exception E) { - if (DEBUG_MODE) e.printStackTrace(); - return (negative ? "~" : "") + "? N:" + neutralCount + " I:" + (neutralCount+element) + " C: " + getCharge(); + if (DEBUG_MODE) { + e.printStackTrace(); + } + return (negative ? "~" : "") + "? N:" + neutralCount + " I:" + (neutralCount+element) + " C:" + getCharge(); } } } @@ -354,57 +390,69 @@ public final class dAtomDefinition extends cElementalDefinition { } private cElementalDecay[] getDecayArray(ArrayList<cElementalDecay> decaysList,int decayMode,boolean tryAnti) { - if (this.type == 1) { + if (type == 1) { switch (decayMode) { case -2: - if(TecTech.Rnd.nextBoolean() && ElectronCapture(decaysList)) + if(TecTech.Rnd.nextBoolean() && ElectronCapture(decaysList)) { return decaysList.toArray(new cElementalDecay[decaysList.size()]); - else if(PbetaDecay(decaysList)) + } else if(PbetaDecay(decaysList)) { return decaysList.toArray(new cElementalDecay[decaysList.size()]); + } break; case -1: - if(Emmision(decaysList, dHadronDefinition.hadron_p1)) + if(Emmision(decaysList, dHadronDefinition.hadron_p1)) { return decaysList.toArray(new cElementalDecay[decaysList.size()]); + } break; case 0: - if(alphaDecay(decaysList)) + if(alphaDecay(decaysList)) { return decaysList.toArray(new cElementalDecay[decaysList.size()]); + } break; case 1: - if(Emmision(decaysList, dHadronDefinition.hadron_n1)) + if(Emmision(decaysList, dHadronDefinition.hadron_n1)) { return decaysList.toArray(new cElementalDecay[decaysList.size()]); + } break; case 2: - if(MbetaDecay(decaysList)) + if(MbetaDecay(decaysList)) { return decaysList.toArray(new cElementalDecay[decaysList.size()]); + } break; default: if(decayMode>8){ - if(iaeaDecay(decaysList,0)) + if(iaeaDecay(decaysList,0)) { return decaysList.toArray(new cElementalDecay[decaysList.size()]); - return getDecayArray(decaysList,decayMode-BYTE_OFFSET,false); + } + return getDecayArray(decaysList,decayMode- BYTE_OFFSET,false); } } return cElementalDecay.noDecay; - }else if(this.type==-1){ + }else if(type ==-1){ dAtomDefinition anti=getAnti(); - if(anti!=null) return anti.getDecayArray(decaysList,decayMode,false); + if(anti!=null) { + return anti.getDecayArray(decaysList, decayMode, false); + } } return getNaturalDecayInstant(); } private boolean iaeaDecay(ArrayList<cElementalDecay> decaysList,long energy){ iaeaNuclide.energeticState state; - if(energy>iaea.energeticStatesArray.length) state = iaea.energeticStatesArray[iaea.energeticStatesArray.length-1]; - else if(energy<=0) state = iaea.energeticStatesArray[0]; - else state=iaea.energeticStatesArray[(int)energy]; + if(energy>iaea.energeticStatesArray.length) { + state = iaea.energeticStatesArray[iaea.energeticStatesArray.length - 1]; + } else if(energy<=0) { + state = iaea.energeticStatesArray[0]; + } else { + state = iaea.energeticStatesArray[(int) energy]; + } for (int i=0;i<state.decaymodes.length;i++){ if(!getDecayFromIaea(decaysList,state.decaymodes[i],energy)) { decaysList.clear(); return false; } } - return decaysList.size()>0; + return !decaysList.isEmpty(); } private boolean getDecayFromIaea(ArrayList<cElementalDecay> decaysList, iaeaNuclide.iaeaDecay decay, long energy){ @@ -446,7 +494,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -458,7 +508,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -470,7 +522,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -482,7 +536,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -496,7 +552,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -510,7 +568,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -524,7 +584,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -538,7 +600,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -551,7 +615,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -564,7 +630,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -578,7 +646,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -592,7 +662,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -607,7 +679,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -622,7 +696,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -636,7 +712,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -651,7 +729,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -666,7 +746,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -680,7 +762,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -693,7 +777,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -707,7 +793,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -721,7 +809,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -735,7 +825,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -747,7 +839,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -759,7 +853,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -771,7 +867,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -783,21 +881,30 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; - case "SF": - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) return true; + case "SF": { + if (Fission(decaysList, withThis, newStuff, decay.chance, false)) { + return true; + } + } break; case "B-F": { if (withThis.removeAllAmounts(false, dHadronDefinition.hadron_n1)){ withThis.putUnify(dHadronDefinition.hadron_p1); newStuff.putReplace(eLeptonDefinition.lepton_e1); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) return true; + if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { + return true; + } }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -806,9 +913,13 @@ public final class dAtomDefinition extends cElementalDefinition { withThis.putUnify(dHadronDefinition.hadron_n1); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) return true; + if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { + return true; + } }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -818,9 +929,13 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eLeptonDefinition.lepton_e_1); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve2); try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) return true; + if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { + return true; + } }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; @@ -830,18 +945,24 @@ public final class dAtomDefinition extends cElementalDefinition { newStuff.putReplace(eNeutrinoDefinition.lepton_Ve1); newStuff.putReplace(eNeutrinoDefinition.lepton_Ve_1); try{ - if(Fission(decaysList,withThis,newStuff,decay.chance,false)) return true; + if(Fission(decaysList,withThis,newStuff,decay.chance,false)) { + return true; + } }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; case "IT": case "IT?": case "G": { if(energy>0){ - decaysList.add(new cElementalDecay(decay.chance, this, eBosonDefinition.boson_Y__)); + decaysList.add(new cElementalDecay(decay.chance, this, boson_Y__)); return true; }else{ - if(DEBUG_MODE) TecTech.Logger.info("Tried to emit Gamma from ground state"); + if(DEBUG_MODE) { + TecTech.Logger.info("Tried to emit Gamma from ground state"); + } decaysList.add(new cElementalDecay(decay.chance, this)); return true; } @@ -857,95 +978,110 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(decay.chance,newStuff.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; }catch (Exception e){ - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } } } break; case "DEAD_END": decaysList.add(deadEnd); return true; - default: throw new Error("Unsupported decay mode: " + decay.decayName + " "+ neutralCount+" "+element); + default: throw new Error("Unsupported decay mode: " + decay.decayName + ' ' + neutralCount+ ' ' +element); + } + if(DEBUG_MODE) { + TecTech.Logger.info("Failed to decay " + element + ' ' + neutralCount + ' ' + decay.decayName); } - if(DEBUG_MODE) TecTech.Logger.info("Failed to decay "+element+" "+neutralCount+" "+decay.decayName); return false; } private boolean Emmision(ArrayList<cElementalDecay> decaysList, cElementalDefinitionStack emit) { - final cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); if (tree.removeAmount(false, emit)) { try { decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), emit)); return true; } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } return false; } private boolean alphaDecay(ArrayList<cElementalDecay> decaysList) { - final cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); if (tree.removeAllAmounts(false, alpha.definition.getSubParticles())) { try { decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), alpha)); return true; } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } return false; } private boolean MbetaDecay(ArrayList<cElementalDecay> decaysList) { - final cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); if (tree.removeAmount(false, dHadronDefinition.hadron_n1)) { try { tree.putUnify(dHadronDefinition.hadron_p1); decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), eLeptonDefinition.lepton_e1, eNeutrinoDefinition.lepton_Ve_1)); return true; } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } return false; } private boolean PbetaDecay(ArrayList<cElementalDecay> decaysList) { - final cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); if (tree.removeAmount(false, dHadronDefinition.hadron_p1)) { try { tree.putUnify(dHadronDefinition.hadron_n1); decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), eLeptonDefinition.lepton_e_1, eNeutrinoDefinition.lepton_Ve1)); return true; } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } return false; } private boolean ElectronCapture(ArrayList<cElementalDecay> decaysList) { - final cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); + cElementalMutableDefinitionStackMap tree = elementalStacks.toMutable(); if (tree.removeAllAmounts(false, dHadronDefinition.hadron_p1,eLeptonDefinition.lepton_e1)) { try { tree.putUnify(dHadronDefinition.hadron_n1); decaysList.add(new cElementalDecay((float) 1, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable_unsafeMightLeaveExposedElementalTree()), 1), eNeutrinoDefinition.lepton_Ve1)); return true; } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } return false; } private boolean Fission(ArrayList<cElementalDecay> decaysList, cElementalMutableDefinitionStackMap fissile, cElementalMutableDefinitionStackMap particles,float probability,boolean spontaneousCheck) { - final cElementalMutableDefinitionStackMap heavy = new cElementalMutableDefinitionStackMap(); - final double[] liquidDrop=liquidDropFunction(Math.abs(element)<=97); + cElementalMutableDefinitionStackMap heavy = new cElementalMutableDefinitionStackMap(); + double[] liquidDrop= liquidDropFunction(Math.abs(element)<=97); for(cElementalDefinitionStack stack: fissile.values()){ if(spontaneousCheck && stack.definition instanceof dHadronDefinition && - (stack.amount<=80 || (stack.amount<90 && XSTR_INSTANCE.nextInt(10)<stack.amount-80))) + (stack.amount<=80 || stack.amount<90 && XSTR_INSTANCE.nextInt(10)<stack.amount-80)) { return false; + } if(stack.definition.getCharge()==0){ //if(stack.definition instanceof dHadronDefinition){ double neutrals=stack.amount*liquidDrop[2]; @@ -954,8 +1090,9 @@ public final class dAtomDefinition extends cElementalDefinition { particles.putUnify(new cElementalDefinitionStack(stack.definition, neutrals_cnt)); int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[1]); - while(heavy_cnt+neutrals_cnt>stack.amount) + while(heavy_cnt+neutrals_cnt>stack.amount) { heavy_cnt--; + } fissile.removeAmount(false,new cElementalDefinitionStack(stack.definition,heavy_cnt+neutrals_cnt)); heavy.putReplace(new cElementalDefinitionStack(stack.definition, heavy_cnt)); //}else{ @@ -964,8 +1101,9 @@ public final class dAtomDefinition extends cElementalDefinition { //} }else{ int heavy_cnt=(int)Math.ceil(stack.amount*liquidDrop[0]); - if(heavy_cnt%2==1 && XSTR_INSTANCE.nextFloat()>0.05f) + if(heavy_cnt%2==1 && XSTR_INSTANCE.nextFloat()>0.05f) { heavy_cnt--; + } cElementalDefinitionStack new_stack=new cElementalDefinitionStack(stack.definition, heavy_cnt); fissile.removeAmount(false,new_stack); heavy.putReplace(new_stack); @@ -978,7 +1116,9 @@ public final class dAtomDefinition extends cElementalDefinition { decaysList.add(new cElementalDecay(probability, particles.toImmutable_unsafeMightLeaveExposedElementalTree())); return true; } catch (Exception e) { - if(DEBUG_MODE) e.printStackTrace(); + if(DEBUG_MODE) { + e.printStackTrace(); + } } return false; } @@ -988,28 +1128,34 @@ public final class dAtomDefinition extends cElementalDefinition { out[0] = XSTR_INSTANCE.nextGaussian(); - if (out[0] < 1 && out[0] >= -1) - if (XSTR_INSTANCE.nextBoolean()) + if (out[0] < 1 && out[0] >= -1) { + if (XSTR_INSTANCE.nextBoolean()) { out[0] = XSTR_INSTANCE.nextDouble() * 2d - 1d; + } + } - if (asymmetric && out[0] > XSTR_INSTANCE.nextDouble() && XSTR_INSTANCE.nextInt(4) == 0) + if (asymmetric && out[0] > XSTR_INSTANCE.nextDouble() && XSTR_INSTANCE.nextInt(4) == 0) { out[0] = -out[0]; + } //scale to splitting ratio out[0] = out[0] * 0.05d + .6d; - if (out[0] < 0 || out[0] > 1) + if (out[0] < 0 || out[0] > 1) { return liquidDropFunction(asymmetric); - if (out[0] < .5d) + } + if (out[0] < .5d) { out[0] = 1d - out[0]; + } //extra neutrals out[2] = 0.012d + XSTR_INSTANCE.nextDouble() * 0.01d; - if (asymmetric) + if (asymmetric) { out[1] = out[0]; - else + } else { out[1] = out[0] - out[2] * .5d; + } return out; } @@ -1023,7 +1169,7 @@ public final class dAtomDefinition extends cElementalDefinition { } } if(energyLevel< Math.abs(charge)/3+neutralCount) { - return new cElementalDecay[]{new cElementalDecay(1, this, eBosonDefinition.boson_Y__)}; + return new cElementalDecay[]{new cElementalDecay(1, this, boson_Y__)}; } return getNaturalDecayInstant(); } @@ -1040,18 +1186,28 @@ public final class dAtomDefinition extends cElementalDefinition { } if(currentEnergyLevel<=0){ - if(newEnergyLevel<=0) return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); - else result+=DEFAULT_ENERGY_REQUIREMENT*(-currentEnergyLevel); - }else result-=iaea.energeticStatesArray[(int)Math.min(iaea.energeticStatesArray.length-1,currentEnergyLevel)].energy; + if(newEnergyLevel<=0) { + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); + } else { + result += iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * -currentEnergyLevel; + } + }else { + result -= iaea.energeticStatesArray[(int) Math.min(iaea.energeticStatesArray.length - 1, currentEnergyLevel)].energy; + } if(newEnergyLevel>=iaea.energeticStatesArray.length){ - if(currentEnergyLevel>=iaea.energeticStatesArray.length) return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); - else result+=DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-iaea.energeticStatesArray.length+1); + if(currentEnergyLevel>=iaea.energeticStatesArray.length) { + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - currentEnergyLevel); + } else { + result += iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT * (newEnergyLevel - iaea.energeticStatesArray.length + 1); + } result+=iaea.energeticStatesArray[iaea.energeticStatesArray.length-1].energy; - }else result+=iaea.energeticStatesArray[(int)Math.max(0,newEnergyLevel)].energy; + }else { + result += iaea.energeticStatesArray[(int) Math.max(0, newEnergyLevel)].energy; + } return backwards?-result:result; } - return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); } @Override @@ -1072,7 +1228,7 @@ public final class dAtomDefinition extends cElementalDefinition { decaysInto.add(new cElementalDefinitionStack(boson_Y__, 2)); } } - return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[decaysInto.size()])), eBosonDefinition.deadEnd}; + return new cElementalDecay[]{new cElementalDecay(0.75F, decaysInto.toArray(new cElementalDefinitionStack[decaysInto.size()])), deadEnd}; } //@Override @@ -1093,12 +1249,15 @@ public final class dAtomDefinition extends cElementalDefinition { @Override public dAtomDefinition getAnti() { cElementalMutableDefinitionStackMap anti = new cElementalMutableDefinitionStackMap(); - for (cElementalDefinitionStack stack : elementalStacks.values()) + for (cElementalDefinitionStack stack : elementalStacks.values()) { anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); + } try { return new dAtomDefinition(anti.toImmutable_unsafeMightLeaveExposedElementalTree()); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return null; } } @@ -1118,11 +1277,10 @@ public final class dAtomDefinition extends cElementalDefinition { return transformation.oredictDequantization.get(this); } - private final static class nomenclature { - private nomenclature(){} - static final private String[] Symbol = new String[]{"Nt", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; - static final private String[] Name = new String[]{"Neutronium", "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; - static final private String[] SymbolIUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; + private static final class nomenclature { + private static final String[] Symbol = new String[]{"Nt", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu", "Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y", "Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In", "Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr", "Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm", "Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au", "Hg", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu", "Am", "Cm", "Bk", "Cf", "Es", "Fm", "Md", "No", "Lr", "Rf", "Db", "Sg", "Bh", "Hs", "Mt", "Ds", "Rg", "Cn", "Nh", "Fl", "Mc", "Lv", "Ts", "Og"}; + private static final String[] Name = new String[]{"Neutronium", "Hydrogen", "Helium", "Lithium", "Beryllium", "Boron", "Carbon", "Nitrogen", "Oxygen", "Fluorine", "Neon", "Sodium", "Magnesium", "Aluminium", "Silicon", "Phosphorus", "Sulfur", "Chlorine", "Argon", "Potassium", "Calcium", "Scandium", "Titanium", "Vanadium", "Chromium", "Manganese", "Iron", "Cobalt", "Nickel", "Copper", "Zinc", "Gallium", "Germanium", "Arsenic", "Selenium", "Bromine", "Krypton", "Rubidium", "Strontium", "Yttrium", "Zirconium", "Niobium", "Molybdenum", "Technetium", "Ruthenium", "Rhodium", "Palladium", "Silver", "Cadmium", "Indium", "Tin", "Antimony", "Tellurium", "Iodine", "Xenon", "Caesium", "Barium", "Lanthanum", "Cerium", "Praseodymium", "Neodymium", "Promethium", "Samarium", "Europium", "Gadolinium", "Terbium", "Dysprosium", "Holmium", "Erbium", "Thulium", "Ytterbium", "Lutetium", "Hafnium", "Tantalum", "Tungsten", "Rhenium", "Osmium", "Iridium", "Platinum", "Gold", "Mercury", "Thallium", "Lead", "Bismuth", "Polonium", "Astatine", "Radon", "Francium", "Radium", "Actinium", "Thorium", "Protactinium", "Uranium", "Neptunium", "Plutonium", "Americium", "Curium", "Berkelium", "Californium", "Einsteinium", "Fermium", "Mendelevium", "Nobelium", "Lawrencium", "Rutherfordium", "Dubnium", "Seaborgium", "Bohrium", "Hassium", "Meitnerium", "Darmstadtium", "Roentgenium", "Copernicium", "Nihonium", "Flerovium", "Moscovium", "Livermorium", "Tennessine", "Oganesson"}; + private static final String[] SymbolIUPAC = new String[]{"n", "u", "b", "t", "q", "p", "h", "s", "o", "e", "N", "U", "B", "T", "Q", "P", "H", "S", "O", "E"}; } @Override @@ -1131,25 +1289,31 @@ public final class dAtomDefinition extends cElementalDefinition { nbt.setByte("t", nbtType); cElementalDefinitionStack[] elementalStacksValues = elementalStacks.values(); nbt.setInteger("i", elementalStacksValues.length); - for (int i = 0; i < elementalStacksValues.length; i++) + for (int i = 0; i < elementalStacksValues.length; i++) { nbt.setTag(Integer.toString(i), elementalStacksValues[i].toNBT()); + } return nbt; } - public static iElementalDefinition fromNBT(NBTTagCompound nbt) { + public static dAtomDefinition fromNBT(NBTTagCompound nbt) { cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) + for (int i = 0; i < stacks.length; i++) { stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); + } try { return new dAtomDefinition(stacks); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return null; } } public static void run() { - for (Runnable r : overrides) r.run(); + for (Runnable r : overrides) { + r.run(); + } for(Map.Entry<dAtomDefinition,Float> entry:lifetimeOverrides.entrySet()){ try { @@ -1161,51 +1325,60 @@ public final class dAtomDefinition extends cElementalDefinition { //populate stable isotopes for (int element = 1; element < 83; element++)//Up to Bismuth exclusive + { for (int isotope = 0; isotope < 130; isotope++) { xstr.setSeed((long) (element + 1) * (isotope + 100)); //stability curve - final int StableIsotope = stableIzoCurve(element); - final int izoDiff = isotope - StableIsotope; - final int izoDiffAbs = Math.abs(izoDiff); - final float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); - iaeaNuclide nuclide=iaeaNuclide.get(element,isotope); - if (rawLifeTime>= STABLE_RAW_LIFE_TIME || (nuclide!=null && nuclide.halfTime >=STABLE_RAW_LIFE_TIME)) { + int StableIsotope = stableIzoCurve(element); + int izoDiff = isotope - StableIsotope; + int izoDiffAbs = Math.abs(izoDiff); + float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); + iaeaNuclide nuclide = iaeaNuclide.get(element, isotope); + if (rawLifeTime >= STABLE_RAW_LIFE_TIME || nuclide != null && nuclide.halfTime >= STABLE_RAW_LIFE_TIME) { 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); } } + } //populate unstable isotopes - for (int element = 83; element < 150; element++) + for (int element = 83; element < 150; element++) { for (int isotope = 100; 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); + int Isotope = stableIzoCurve(element); + int izoDiff = isotope - Isotope; + int izoDiffAbs = Math.abs(izoDiff); + float rawLifeTime = calculateLifeTime(izoDiff, izoDiffAbs, element, isotope, false); TreeMap<Float, Integer> isotopes = mostStableUnstableIsotopes.get(element); - if (isotopes == null) mostStableUnstableIsotopes.put(element, isotopes = new TreeMap<>()); + 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 (DEBUG_MODE) - TecTech.Logger.info("Added Stable Atom:" + key + " " + stableIsotopes.get(key).first() + " " + stableAtoms.get(key).getMass()); + for (Map.Entry<Integer, TreeSet<Integer>> integerTreeSetEntry : stableIsotopes.entrySet()) { + stableAtoms.put(integerTreeSetEntry.getKey(), new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p, integerTreeSetEntry.getKey()), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, integerTreeSetEntry.getValue().first()), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, integerTreeSetEntry.getKey()))); + if (DEBUG_MODE) { + TecTech.Logger.info("Added Stable Atom:" + integerTreeSetEntry.getKey() + ' ' + integerTreeSetEntry.getValue().first() + ' ' + stableAtoms.get(integerTreeSetEntry.getKey()).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 (DEBUG_MODE) - TecTech.Logger.info("Added Unstable Atom:" + key + " " + mostStableUnstableIsotopes.get(key).lastEntry().getValue() + " " + unstableAtoms.get(key).getMass()); + for (Map.Entry<Integer, TreeMap<Float, Integer>> integerTreeMapEntry : mostStableUnstableIsotopes.entrySet()) { + unstableAtoms.put(integerTreeMapEntry.getKey(), new dAtomDefinition( + new cElementalDefinitionStack(dHadronDefinition.hadron_p, integerTreeMapEntry.getKey()), + new cElementalDefinitionStack(dHadronDefinition.hadron_n, integerTreeMapEntry.getValue().lastEntry().getValue()), + new cElementalDefinitionStack(eLeptonDefinition.lepton_e, integerTreeMapEntry.getKey()))); + if (DEBUG_MODE) { + TecTech.Logger.info("Added Unstable Atom:" + integerTreeMapEntry.getKey() + ' ' + integerTreeMapEntry.getValue().lastEntry().getValue() + ' ' + unstableAtoms.get(integerTreeMapEntry.getKey()).getMass()); + } } deuterium=new dAtomDefinition( dHadronDefinition.hadron_p1, @@ -1239,16 +1412,21 @@ public final class dAtomDefinition extends cElementalDefinition { new cElementalDefinitionStack(dHadronDefinition.hadron_n, 20), new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 14)).getStackForm(1); } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } try { cElementalDefinition.addCreatorFromNBT(nbtType, dAtomDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)64); } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + if(DEBUG_MODE) { + TecTech.Logger.info("Registered Elemental Matter Class: Atom " + nbtType + ' ' + 64); } - if(DEBUG_MODE) - TecTech.Logger.info("Registered Elemental Matter Class: Atom "+nbtType+" "+64); } public static void setTransformation(){ @@ -1269,7 +1447,7 @@ public final class dAtomDefinition extends cElementalDefinition { transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(12), 144), dust, Materials.Magnesium,1); transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(13), 144), dust, Materials.Aluminium,1); transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(14), 144), dust, Materials.Silicon,1); - transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(15), 144), dust, Materials.Phosphorus,1); + transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(15), 144), dust, Materials.Phosphor,1); transformation.addOredict(new cElementalDefinitionStack(getFirstStableIsotope(16), 144), dust, Materials.Sulfur,1); transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(17), 144),Materials.Chlorine.mGas.getID(), 144); transformation.addFluid(new cElementalDefinitionStack(getFirstStableIsotope(18), 144),Materials.Argon.mGas.getID(), 144); @@ -1368,33 +1546,46 @@ public final class dAtomDefinition extends cElementalDefinition { new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), new cElementalDefinitionStack(dHadronDefinition.hadron_n, 146) ); - transformation.addOredict(new cElementalDefinitionStack(temp, 144),OrePrefixes.dust, Materials.Uranium/*238*/,1); + transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium/*238*/,1); + + float tempMass=temp.getMass(); temp=new dAtomDefinition( new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 92), new cElementalDefinitionStack(dHadronDefinition.hadron_p, 92), new cElementalDefinitionStack(dHadronDefinition.hadron_n, 143) ); - transformation.addOredict(new cElementalDefinitionStack(temp, 144),OrePrefixes.dust, Materials.Uranium235,1); + transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Uranium235,1); + + TecTech.Logger.info("Diff Mass U : "+(tempMass-temp.getMass())); temp=new dAtomDefinition( new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), new cElementalDefinitionStack(dHadronDefinition.hadron_n, 145) ); - transformation.addOredict(new cElementalDefinitionStack(temp, 144),OrePrefixes.dust, Materials.Plutonium/*239*/,1); + transformation.addOredict(new cElementalDefinitionStack(temp, 144), dust, Materials.Plutonium/*239*/,1); - temp=new dAtomDefinition( + somethingHeavy=new dAtomDefinition( new cElementalDefinitionStack(eLeptonDefinition.lepton_e, 94), new cElementalDefinitionStack(dHadronDefinition.hadron_p, 94), new cElementalDefinitionStack(dHadronDefinition.hadron_n, 147) ); - transformation.addOredict(new cElementalDefinitionStack(temp, 144),OrePrefixes.dust, Materials.Plutonium241,1); + transformation.addOredict(new cElementalDefinitionStack(somethingHeavy, 144), dust, Materials.Plutonium241,1); + + TecTech.Logger.info("Diff Mass Pu: "+(somethingHeavy.getMass()-temp.getMass())); + + TecTech.Logger.info("Neutron Mass: "+dHadronDefinition.hadron_n.getMass()); + } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } - if(Loader.isModLoaded("miscutils")) new GtppAtomLoader().run(); + if(Loader.isModLoaded("miscutils")) { + new GtppAtomLoader().run(); + } } public static dAtomDefinition getFirstStableIsotope(int element) { @@ -1415,23 +1606,25 @@ public final class dAtomDefinition extends cElementalDefinition { return hash; } - - @Override public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) - lines.add("CLASS = "+nbtType+" "+getClassType()); + if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + lines.add("CLASS = " + nbtType + ' ' + getClassType()); + } if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add("NAME = "+getName()); lines.add("SYMBOL = "+getSymbol()); } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) - lines.add("CHARGE = "+getCharge()/3f+" eV"); - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) - lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) - lines.add("MASS = "+getMass()+" eV/c\u00b2"); - if(iaeaDefinitionExistsAndHasEnergyLevels){ + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { + lines.add("CHARGE = " + getCharge() / 3f + " e"); + } + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { + lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); + } + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + lines.add("MASS = " + getMass() + " eV/c\u00b2"); + } + if(iaeaDefinitionExistsAndHasEnergyLevels && Util.areBitsSet(SCAN_GET_ENERGY_STATES,capabilities)){ for(int i=1;i<iaea.energeticStatesArray.length;i++){ lines.add("ENERGY LEVEL "+i+" = "+iaea.energeticStatesArray[i].energy+" eV"); } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/iaeaNuclide.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/iaeaNuclide.java index 5c4c10f86d..49cb89b53c 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/iaeaNuclide.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/atom/iaeaNuclide.java @@ -29,15 +29,17 @@ public final class iaeaNuclide { ArrayList<String[]> blockOfData=new ArrayList<>(4); while((line=reader.readLine())!=null) { String[] split= Util.splitButDifferent(line,","); - if(split.length!=19) throw new Error("Invalid count ("+split.length+") of separators in IAEA nuclides database " + line); - if(split[1].length()>0 && blockOfData.size()>0) { - new iaeaNuclide(blockOfData.toArray(new String[0][])); + if(split.length!=19) { + throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuclides database " + line); + } + if(!split[1].isEmpty() && !blockOfData.isEmpty()) { + new iaeaNuclide(blockOfData.toArray(new String[blockOfData.size()][])); blockOfData.clear(); } blockOfData.add(split); } - if(blockOfData.size()>0) { - new iaeaNuclide(blockOfData.toArray(new String[0][])); + if(!blockOfData.isEmpty()) { + new iaeaNuclide(blockOfData.toArray(new String[blockOfData.size()][])); blockOfData.clear(); } reader.close(); @@ -50,7 +52,9 @@ public final class iaeaNuclide { BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("nuclidesTable.csv"))); while((line=reader.readLine())!=null) { String[] split= Util.splitButDifferent(line,","); - if(split.length!=47) throw new Error("Invalid count ("+split.length+") of separators in IAEA nuvlidesTable database " + line); + if(split.length!=47) { + throw new Error("Invalid count (" + split.length + ") of separators in IAEA nuvlidesTable database " + line); + } get(Integer.parseInt(split[0]),Integer.parseInt(split[1])).getMoreData(split); } reader.close(); @@ -63,7 +67,9 @@ public final class iaeaNuclide { BufferedReader reader = new BufferedReader(new InputStreamReader(iaeaNuclide.class.getResourceAsStream("energyLevels.csv"))); while((line=reader.readLine())!=null) { String[] split= Util.splitButDifferent(line,","); - if(split.length!=27) throw new Error("Invalid count ("+split.length+") of separators in IAEA energyLevels database " + line); + if(split.length!=27) { + throw new Error("Invalid count (" + split.length + ") of separators in IAEA energyLevels database " + line); + } new energeticState(split); } reader.close(); @@ -72,8 +78,9 @@ public final class iaeaNuclide { e.printStackTrace(); } - for(iaeaNuclide nuclide:NUCLIDES.values()) + for(iaeaNuclide nuclide:NUCLIDES.values()) { nuclide.makeArrayOfEnergyStates(); + } } public static iaeaNuclide get(int protons, int neutrons){ @@ -91,12 +98,17 @@ public final class iaeaNuclide { private iaeaNuclide(String[][] rows){ N=Short.parseShort(rows[1][2]); Z=Short.parseShort(rows[1][0]); - NUCLIDES.put((((int)Z)<<16)+N,this); + NUCLIDES.put(((int)Z <<16)+N,this); String[] parts = Util.splitButDifferent(rows[0][16], "|"); double Mass=doubleOrNaN(parts[0],"mass"); - if(Mass!=Double.NaN) mass = (float)(Mass*MICRO_AMU_TO_EV_DIV_C_C); - else mass=Float.NaN; + if(!Double.isNaN(Mass)) { + //System.out.println("Mass =\t" + Mass+"\t"+(N+Z)+"\t"+N+"\t"+Z+"\t"+(Mass/(N+Z))); + mass = (float)(Mass* MICRO_AMU_TO_EV_DIV_C_C); + } + else { + mass = Float.NaN; + } discovery=(short)doubleOrNaN(rows[0][18],"discovery"); @@ -114,30 +126,36 @@ public final class iaeaNuclide { // if (add(cells[17])) System.out.println(N + " " + Z); // if (add(cells[20])) System.out.println(N + " " + Z); //} - new energeticState(this, halfTime,getDecaysFixed(cells[14],doubleOrNaN(cells[15],"chance1"),cells[17],doubleOrNaN(cells[18],"chance1"),cells[20],doubleOrNaN(cells[21],"chance1"))); + new energeticState(this, halfTime, getDecaysFixed(cells[14],doubleOrNaN(cells[15],"chance1"),cells[17],doubleOrNaN(cells[18],"chance1"),cells[20],doubleOrNaN(cells[21],"chance1"))); } private static final energeticState[] empty=new energeticState[0]; private void makeArrayOfEnergyStates(){ - if(energeticStates==null || energeticStates.size()==0)energeticStatesArray=empty; - else energeticStatesArray=energeticStates.values().toArray(new energeticState[energeticStates.size()]); + if(energeticStates==null || energeticStates.isEmpty()) { + energeticStatesArray = empty; + } else { + energeticStatesArray = energeticStates.values().toArray(new energeticState[energeticStates.size()]); + } } private double doubleOrNaN(String s, String name){ s=s.replaceAll("#",""); - if(s.length()>0) { + if(!s.isEmpty()) { try { double value=Double.parseDouble(s); - return value != 0 ?value:Float.NaN; + if(Double.isNaN(value)) { + return Double.NaN; + } + return value != 0 ?value:Double.NaN; } catch (Exception e) { - System.out.println("Invalid Value " + name + " " + N + " " + Z + " " + s); + System.out.println("Invalid Value " + name + ' ' + N + ' ' + Z + ' ' + s); e.printStackTrace(); } } return Double.NaN; } - public static class energeticState{ + public static final class energeticState{ public final float energy; public final float Thalf; public final iaeaDecay[] decaymodes; @@ -146,20 +164,24 @@ public final class iaeaNuclide { energy=0; this.Thalf=Thalf; this.decaymodes=decaymodes; - if(nuclide.energeticStates==null) - nuclide.energeticStates=new TreeMap<>(); + if(nuclide.energeticStates==null) { + nuclide.energeticStates = new TreeMap<>(); + } nuclide.energeticStates.put(energy,this); } private energeticState(String[] cells){ - iaeaNuclide nuclide=get((int)doubleOrNaN(cells[0],"protons"),(int)doubleOrNaN(cells[1],"neutrons")); - if(nuclide==null) - throw new Error("Missing nuclide "+(int)doubleOrNaN(cells[0],"protons")+" "+(int)doubleOrNaN(cells[1],"neutrons")); - this.energy=(float) (doubleOrNaN(cells[3],"energy level",nuclide)*1000f);//to eV - if(energy<0) throw new Error("Invalid energy "+ nuclide.N +" "+nuclide.Z+ " "+cells[3]); - this.Thalf=(float) doubleOrNaN(cells[10],"half life",nuclide); + iaeaNuclide nuclide= get((int)doubleOrNaN(cells[0],"protons"),(int)doubleOrNaN(cells[1],"neutrons")); + if(nuclide==null) { + throw new Error("Missing nuclide " + (int) doubleOrNaN(cells[0], "protons") + ' ' + (int) doubleOrNaN(cells[1], "neutrons")); + } + energy =(float) (doubleOrNaN(cells[3],"energy level",nuclide)*1000f);//to eV + if(energy<0) { + throw new Error("Invalid energy " + nuclide.N + ' ' + nuclide.Z + ' ' + cells[3]); + } + Thalf =(float) doubleOrNaN(cells[10],"half life",nuclide); if(nuclide.energeticStates==null) { - new Exception("Should be initialized before doing this... "+ nuclide.N +" "+nuclide.Z).printStackTrace(); + new Exception("Should be initialized before doing this... "+ nuclide.N + ' ' +nuclide.Z).printStackTrace(); nuclide.energeticStates = new TreeMap<>(); } nuclide.energeticStates.put(energy,this); @@ -168,7 +190,7 @@ public final class iaeaNuclide { // if (add(cells[15])) System.out.println(nuclide.N + " " + nuclide.Z); // if (add(cells[18])) System.out.println(nuclide.N + " " + nuclide.Z); //} - this.decaymodes=getDecaysFixed(cells[12],doubleOrNaN(cells[13],"chance 1",nuclide),cells[15],doubleOrNaN(cells[16],"chance 2",nuclide),cells[18],doubleOrNaN(cells[19],"chance 3",nuclide)); + decaymodes = getDecaysFixed(cells[12],doubleOrNaN(cells[13],"chance 1",nuclide),cells[15],doubleOrNaN(cells[16],"chance 2",nuclide),cells[18],doubleOrNaN(cells[19],"chance 3",nuclide)); } private double doubleOrNaN(String s, String name){ @@ -177,14 +199,14 @@ public final class iaeaNuclide { private double doubleOrNaN(String s, String name, iaeaNuclide nuclide){ s = s.replaceAll("#", ""); - if (s.length() > 0) { + if (!s.isEmpty()) { try { return Double.parseDouble(s); } catch (Exception e) { if(nuclide==null){ - System.out.println("Invalid Value " + name + " " + s); + System.out.println("Invalid Value " + name + ' ' + s); }else { - System.out.println("Invalid Value " + name + " " + nuclide.N + " " + nuclide.Z + " " + s); + System.out.println("Invalid Value " + name + ' ' + nuclide.N + ' ' + nuclide.Z + ' ' + s); } e.printStackTrace(); } @@ -204,46 +226,49 @@ public final class iaeaNuclide { private static iaeaDecay[] getDecaysFixed(String decay1, double chance1,String decay2, double chance2,String decay3, double chance3){ boolean do1,do2,do3; - do1=(decay1.length()>0 && !Double.isNaN(chance1)); - do2=(decay2.length()>0 && !Double.isNaN(chance2)); - do3=(decay3.length()>0 && !Double.isNaN(chance3)); + do1= !decay1.isEmpty() && !Double.isNaN(chance1); + do2= !decay2.isEmpty() && !Double.isNaN(chance2); + do3= !decay3.isEmpty() && !Double.isNaN(chance3); TreeMap<Double,iaeaDecay> decays=new TreeMap<>(); if(do1 && do2 && chance1==100 && chance2==100 && chance3!=100){ decays.put(1D, new iaeaDecay(1f, decay1)); if(do3) { chance3/=100d; - decays.put(chance3, new iaeaDecay((float) (chance3), decay2)); + decays.put(chance3, new iaeaDecay((float) chance3, decay2)); chance2=1d-chance3; } chance2/=2d; - decays.put(chance2, new iaeaDecay((float) (chance2), decay2)); + decays.put(chance2, new iaeaDecay((float) chance2, decay2)); }else if(do1 && chance1==100){ decays.put(1D, new iaeaDecay(1f, decay1)); if(do2) { chance2/=100d; - decays.put(chance2, new iaeaDecay((float) (chance2), decay2)); + decays.put(chance2, new iaeaDecay((float) chance2, decay2)); } if(do3) { chance3 /= 100d; - if(do2) chance3 *= chance2; - decays.put(chance3, new iaeaDecay((float) (chance3), decay3)); + if(do2) { + chance3 *= chance2; + } + decays.put(chance3, new iaeaDecay((float) chance3, decay3)); } }else{ - double normalization=((do1?chance1:0)+(do2?chance2:0)+(do3?chance3:0)); + double normalization= (do1?chance1:0) + (do2?chance2:0) + (do3?chance3:0); if(do1) { chance1/=normalization; - decays.put(chance1, new iaeaDecay((float) (chance1), decay1)); + decays.put(chance1, new iaeaDecay((float) chance1, decay1)); } if(do2) { chance2/=normalization; - decays.put(chance2, new iaeaDecay((float) (chance2), decay2)); + decays.put(chance2, new iaeaDecay((float) chance2, decay2)); } if(do3) { chance3/=normalization; - decays.put(chance3, new iaeaDecay((float) (chance3), decay3)); + decays.put(chance3, new iaeaDecay((float) chance3, decay3)); + } + if(do1||do2||do3) { + decays.put(1D, iaeaDecay.DEAD_END); } - if(do1||do2||do3) - decays.put(1D,iaeaDecay.DEAD_END); } //if(DEBUG_MODE){ // System.out.println("INVALID SUM?\t"+normalization+"\t"+decay1+"\t"+chance1+"\t"+decay2+"\t"+chance2+"\t"+decay3+"\t"+chance3); @@ -251,7 +276,7 @@ public final class iaeaNuclide { return decays.values().toArray(new iaeaDecay[decays.size()]); } - public static class iaeaDecay{ + public static final class iaeaDecay{ public final float chance; public final String decayName; public static final iaeaDecay DEAD_END=new iaeaDecay(1f,"DEAD_END"); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/hadron/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/hadron/dHadronDefinition.java index 902f79b3f4..c08588090d 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/hadron/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/complex/hadron/dHadronDefinition.java @@ -2,7 +2,6 @@ package com.github.technus.tectech.elementalMatter.definitions.complex.hadron; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.Util; -import com.github.technus.tectech.auxiliary.TecTechConfig; import com.github.technus.tectech.elementalMatter.core.cElementalDecay; import com.github.technus.tectech.elementalMatter.core.cElementalDefinitionStackMap; import com.github.technus.tectech.elementalMatter.core.cElementalMutableDefinitionStackMap; @@ -38,6 +37,8 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi public static cElementalDefinitionStack hadron_p1, hadron_n1, hadron_p2, hadron_n2, hadron_p3, hadron_n3, hadron_p5; private static float protonMass = 0F; private static float neutronMass = 0F; + private static final float actualProtonMass=938272081.3f; + private static final float actualNeutronMass=939565413.3f; //float-mass in eV/c^2 public final float mass; @@ -75,8 +76,10 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi } private dHadronDefinition(boolean check, cElementalDefinitionStackMap quarks) throws tElementalException { - if (check && !canTheyBeTogether(quarks)) throw new tElementalException("Hadron Definition error"); - this.quarkStacks = quarks; + if (check && !canTheyBeTogether(quarks)) { + throw new tElementalException("Hadron Definition error"); + } + quarkStacks = quarks; byte amount = 0; int charge = 0; @@ -88,26 +91,32 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi mass += quarkStack.getMass(); charge += quarkStack.getCharge(); type = Math.max(Math.abs(quarkStack.definition.getType()), type); - if (quarkStack.definition.getType() < 0) containsAnti = true; + if (quarkStack.definition.getType() < 0) { + containsAnti = true; + } } this.amount = amount; this.charge = charge; - this.type = containsAnti ? (byte) (-type) : (byte) type; + this.type = containsAnti ? (byte) -type : (byte) type; int mult = this.amount * this.amount * (this.amount - 1); - this.mass = mass * 5.543F * (float) mult;//yes it becomes heavier - - if (this.mass == protonMass && this.amount == 3) this.rawLifeTime = STABLE_RAW_LIFE_TIME; - else if (this.mass == neutronMass && this.amount == 3) this.rawLifeTime = 882F; - else { + mass = mass * 5.543F * (float) mult;//yes it becomes heavier + + if (mass == protonMass && this.amount == 3) { + rawLifeTime = iElementalDefinition.STABLE_RAW_LIFE_TIME; + mass=actualProtonMass; + } else if (mass == neutronMass && this.amount == 3) { + rawLifeTime = 882F; + mass=actualNeutronMass; + } else { if (this.amount == 3) { - this.rawLifeTime = (1.34F / this.mass) * (float) Math.pow(9.81, charge); + rawLifeTime = 1.34F / mass * (float) Math.pow(9.81, charge); } else if (this.amount == 2) { - this.rawLifeTime = (1.21F / this.mass) / (float) Math.pow(19.80, charge); + rawLifeTime = 1.21F / mass / (float) Math.pow(19.80, charge); } else { - this.rawLifeTime = (1.21F / this.mass) / (float) Math.pow(9.80, charge); + rawLifeTime = 1.21F / mass / (float) Math.pow(9.80, charge); } } - + this.mass=mass; hash=super.hashCode(); } @@ -115,7 +124,9 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { long amount = 0; for (cElementalDefinitionStack quarks : stacks.values()) { - if (!(quarks.definition instanceof eQuarkDefinition)) return false; + if (!(quarks.definition instanceof eQuarkDefinition)) { + return false; + } amount += quarks.amount; } return amount >= 2 && amount <= 12; @@ -150,11 +161,13 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @Override public String getSymbol() { - String symbol = ""; - for (cElementalDefinitionStack quark : quarkStacks.values()) - for (int i = 0; i < quark.amount; i++) - symbol += quark.definition.getSymbol(); - return symbol; + StringBuilder symbol = new StringBuilder(8); + for (cElementalDefinitionStack quark : quarkStacks.values()) { + for (int i = 0; i < quark.amount; i++) { + symbol.append(quark.definition.getSymbol()); + } + } + return symbol.toString(); } @Override @@ -170,8 +183,9 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @Override public cElementalDecay[] getNaturalDecayInstant() { cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) + if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { return cElementalDecay.noProduct; + } ArrayList<cElementalDefinitionStack> decaysInto = new ArrayList<>(); for (cElementalDefinitionStack quarks : quarkStacks) { if (quarks.definition.getType() == 1 || quarks.definition.getType() == -1) { @@ -191,14 +205,15 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @Override public cElementalDecay[] getEnergyInducedDecay(long energyLevel) { cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) + if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { return cElementalDecay.noProduct; + } return new cElementalDecay[]{new cElementalDecay(0.75F, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks } @Override public float getEnergyDiffBetweenStates(long currentEnergyLevel, long newEnergyLevel) { - return DEFAULT_ENERGY_REQUIREMENT*(newEnergyLevel-currentEnergyLevel); + return iElementalDefinition.DEFAULT_ENERGY_REQUIREMENT *(newEnergyLevel-currentEnergyLevel); } @Override @@ -209,16 +224,17 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @Override public cElementalDecay[] getDecayArray() { cElementalDefinitionStack[] quarkStacks = this.quarkStacks.values(); - if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) + if (amount == 2 && quarkStacks.length == 2 && quarkStacks[0].definition.getMass() == quarkStacks[1].definition.getMass() && quarkStacks[0].definition.getType() == -quarkStacks[1].definition.getType()) { return cElementalDecay.noProduct; - else if (amount != 3) + } else if (amount != 3) { return new cElementalDecay[]{new cElementalDecay(0.95F, quarkStacks), eBosonDefinition.deadEnd}; //decay into quarks - else { - ArrayList<eQuarkDefinition> newBaryon = new ArrayList<eQuarkDefinition>(); + } else { + ArrayList<eQuarkDefinition> newBaryon = new ArrayList<>(); iElementalDefinition[] Particles = new iElementalDefinition[2]; for (cElementalDefinitionStack quarks : quarkStacks) { - for (int i = 0; i < quarks.amount; i++) + for (int i = 0; i < quarks.amount; i++) { newBaryon.add((eQuarkDefinition) quarks.definition); + } } //remove last eQuarkDefinition lastQuark = newBaryon.remove(2); @@ -243,7 +259,9 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi new cElementalDecay(0.001F, new dHadronDefinition(false, contentOfBaryon), Particles[0], Particles[1], boson_Y__), eBosonDefinition.deadEnd}; } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return new cElementalDecay[]{eBosonDefinition.deadEnd}; } } @@ -292,12 +310,15 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @Override public iElementalDefinition getAnti() { cElementalMutableDefinitionStackMap anti = new cElementalMutableDefinitionStackMap(); - for (cElementalDefinitionStack stack : quarkStacks.values()) + for (cElementalDefinitionStack stack : quarkStacks.values()) { anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); + } try { return new dHadronDefinition(anti.toImmutable_unsafeMightLeaveExposedElementalTree()); } catch (tElementalException e) { - if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return null; } } @@ -323,19 +344,23 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi nbt.setByte("t", nbtType); cElementalDefinitionStack[] quarkStacksValues = quarkStacks.values(); nbt.setInteger("i", quarkStacksValues.length); - for (int i = 0; i < quarkStacksValues.length; i++) + for (int i = 0; i < quarkStacksValues.length; i++) { nbt.setTag(Integer.toString(i), quarkStacksValues[i].toNBT()); + } return nbt; } - public static iElementalDefinition fromNBT(NBTTagCompound nbt) { + public static dHadronDefinition fromNBT(NBTTagCompound nbt) { cElementalDefinitionStack[] stacks = new cElementalDefinitionStack[nbt.getInteger("i")]; - for (int i = 0; i < stacks.length; i++) + for (int i = 0; i < stacks.length; i++) { stacks[i] = cElementalDefinitionStack.fromNBT(nbt.getCompoundTag(Integer.toString(i))); + } try { return new dHadronDefinition(stacks); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return null; } } @@ -346,14 +371,16 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi protonMass = hadron_p.mass; //redefine the proton with proper lifetime (the lifetime is based on mass comparison) hadron_p = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(2), eQuarkDefinition.quark_d.getStackForm(1))); - hadron_p_ = (dHadronDefinition) (hadron_p.getAnti()); + hadron_p_ = (dHadronDefinition) hadron_p.getAnti(); hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2))); neutronMass = hadron_n.mass; //redefine the neutron with proper lifetime (the lifetime is based on mass comparison) hadron_n = new dHadronDefinition(new cElementalDefinitionStackMap(eQuarkDefinition.quark_u.getStackForm(1), eQuarkDefinition.quark_d.getStackForm(2))); - hadron_n_ = (dHadronDefinition) (hadron_n.getAnti()); + hadron_n_ = (dHadronDefinition) hadron_n.getAnti(); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } protonMass = -1; neutronMass = -1; } @@ -368,15 +395,18 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi try { cElementalDefinition.addCreatorFromNBT(nbtType, dHadronDefinition.class.getMethod("fromNBT", NBTTagCompound.class),(byte)-64); } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } + } + if(DEBUG_MODE) { + TecTech.Logger.info("Registered Elemental Matter Class: Hadron " + nbtType + ' ' + -64); } - if(DEBUG_MODE) - TecTech.Logger.info("Registered Elemental Matter Class: Hadron "+nbtType+" "+(-64)); } public static void setTransformations(){ //Added to atom map, but should be in its own - cElementalDefinitionStack neutrons=new cElementalDefinitionStack(dHadronDefinition.hadron_n, 100000); + cElementalDefinitionStack neutrons=new cElementalDefinitionStack(hadron_n, 100000); transformation.oredictDequantization.put(neutrons.definition,new aOredictDequantizationInfo(neutrons, dust, Materials.Neutronium,1)); bTransformationInfo.oredictQuantization.put( OreDictionary.getOreID(OrePrefixes.ingotHot.name()+Materials.Neutronium.mName), @@ -396,18 +426,22 @@ public final class dHadronDefinition extends cElementalDefinition {//TODO Optimi @Override public void addScanResults(ArrayList<String> lines, int capabilities, long energyLevel) { - if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) - lines.add("CLASS = "+nbtType+" "+getClassType()); + if(Util.areBitsSet(SCAN_GET_CLASS_TYPE, capabilities)) { + lines.add("CLASS = " + nbtType + ' ' + getClassType()); + } if(Util.areBitsSet(SCAN_GET_NOMENCLATURE|SCAN_GET_CHARGE|SCAN_GET_MASS|SCAN_GET_TIMESPAN_INFO, capabilities)) { lines.add("NAME = "+getSimpleName()); //lines.add("SYMBOL = "+getSymbol()); } - if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) - lines.add("CHARGE = "+getCharge()/3f+" eV"); - if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) - lines.add(getColor()<0?"NOT COLORED":"CARRIES COLOR"); - if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) - lines.add("MASS = "+getMass()+" eV/c\u00b2"); + if(Util.areBitsSet(SCAN_GET_CHARGE,capabilities)) { + lines.add("CHARGE = " + getCharge() / 3f + " e"); + } + if(Util.areBitsSet(SCAN_GET_COLOR,capabilities)) { + lines.add(getColor() < 0 ? "COLORLESS" : "CARRIES COLOR"); + } + if(Util.areBitsSet(SCAN_GET_MASS,capabilities)) { + lines.add("MASS = " + getMass() + " eV/c\u00b2"); + } if(Util.areBitsSet(SCAN_GET_TIMESPAN_INFO, capabilities)){ lines.add("HALF LIFE = "+getRawTimeSpan(energyLevel)+ " s"); lines.add(" "+"At current energy level"); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/cPrimitiveDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/cPrimitiveDefinition.java index 1a4582386b..24904e6a31 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/cPrimitiveDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/primitive/cPrimitiveDefinition.java @@ -15,7 +15,7 @@ public final class cPrimitiveDefinition extends cElementalPrimitive { magic = new cPrimitiveDefinition("Magic", "Ma", 4, 1e5F, 0, 0, 1), magic_ = new cPrimitiveDefinition("Antimagic", "~Ma", -4, 1e5F, 0, 0, 2); - protected cPrimitiveDefinition(String name, String symbol, int type, float mass, int charge, int color, int ID) { + private cPrimitiveDefinition(String name, String symbol, int type, float mass, int charge, int color, int ID) { super(name, symbol, type, mass, charge, color, ID); } diff --git a/src/main/java/com/github/technus/tectech/entity/fx/BlockHint.java b/src/main/java/com/github/technus/tectech/entity/fx/BlockHint.java index 8983857119..29533c5a0a 100644 --- a/src/main/java/com/github/technus/tectech/entity/fx/BlockHint.java +++ b/src/main/java/com/github/technus/tectech/entity/fx/BlockHint.java @@ -21,16 +21,18 @@ public class BlockHint extends EntityFX { prevPosY = posY; prevPosZ = posZ; noClip = true; - particleMaxAge = 200 + TecTech.Rnd.nextInt(200); - for (int i = 0; i < 6; i++) icons[i] = block.getIcon(i, meta); + particleMaxAge = 2000 + TecTech.Rnd.nextInt(200); + for (int i = 0; i < 6; i++) { + icons[i] = block.getIcon(i, meta); + } } @Override public void renderParticle(Tessellator tes, float subTickTime, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) { float size = .5f; - float X = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) subTickTime - interpPosX); - float Y = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) subTickTime - interpPosY) - size / 2; - float Z = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) subTickTime - interpPosZ); + float X = (float) (prevPosX + (posX - prevPosX) * (double) subTickTime - EntityFX.interpPosX); + float Y = (float) (prevPosY + (posY - prevPosY) * (double) subTickTime - EntityFX.interpPosY) - size / 2; + float Z = (float) (prevPosZ + (posZ - prevPosZ) * (double) subTickTime - EntityFX.interpPosZ); GL11.glDisable(GL11.GL_CULL_FACE); GL11.glDepthMask(false); tes.setColorRGBA_F(.9F, .95F, 1F, .75f); @@ -38,7 +40,9 @@ public class BlockHint extends EntityFX { //var8, var9 - X U //var 10, var 11 - Y V for(int i=0;i<6;i++){ - if(icons[i]==null) continue; + if(icons[i]==null) { + continue; + } double u=icons[i].getMinU(); double U=icons[i].getMaxU(); double v=icons[i].getMinV(); diff --git a/src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java index 783f508454..e24b9cbf42 100644 --- a/src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/BloodyRecipeLoader.java @@ -4,6 +4,9 @@ import com.github.technus.tectech.recipe.TT_recipeAdder; import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.item.ConstructableTriggerItem; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_Centrifuge; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.Behaviour_ElectromagneticSeparator; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine; import gregtech.api.enums.*; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; @@ -18,11 +21,11 @@ import net.minecraftforge.fluids.FluidStack; public class BloodyRecipeLoader implements Runnable { @Override public void run() { - Object[] o = new Object[0]; + //todo fix recipes (of assembler) //Quantum Glass GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Containment.get(1, o), + CustomItemList.eM_Containment.get(1), GT_ModHandler.getIC2Item("reinforcedGlass", 1L) }, Materials.Osmium.getMolten(576), new ItemStack(QuantumGlassBlock.INSTANCE, 1), 200, 500000); @@ -35,9 +38,9 @@ public class BloodyRecipeLoader implements Runnable { //Data GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - ItemList.Circuit_Parts_GlassFiber.get(8, o), + ItemList.Circuit_Parts_GlassFiber.get(8), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Silver, 8) - }, Materials.Polytetrafluoroethylene.getMolten(144), CustomItemList.DATApipe.get(1, o), 200, 30720, true); + }, Materials.Polytetrafluoroethylene.getMolten(144), CustomItemList.DATApipe.get(1), 200, 30720); //endregion @@ -52,108 +55,120 @@ public class BloodyRecipeLoader implements Runnable { GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 16), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Copper, 16), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NiobiumTitanium, 2) - }, Materials.TungstenSteel.getMolten(576), CustomItemList.eM_Power.get(1, o), 100, 30720); + }, Materials.TungstenSteel.getMolten(576), CustomItemList.eM_Power.get(1), 100, 30720); //Computer Casing GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Power.get(1, o), + CustomItemList.eM_Power.get(1), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 8), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.NiobiumTitanium, 2) - }, Materials.Aluminium.getMolten(1296), CustomItemList.eM_Computer_Casing.get(1, o), 200, 122880); + }, Materials.Aluminium.getMolten(1296), CustomItemList.eM_Computer_Casing.get(1), 200, 122880); //Computer Vent Casing GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ GT_OreDictUnificator.get(OrePrefixes.frameGt, Materials.StainlessSteel, 1), - ItemList.Electric_Motor_IV.get(2, o), + ItemList.Electric_Motor_IV.get(2), GT_OreDictUnificator.get(OrePrefixes.rotor, Materials.StainlessSteel, 2), GT_OreDictUnificator.get(OrePrefixes.pipeTiny, Materials.StainlessSteel, 16), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Copper, 16), GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 1) - }, Materials.SolderingAlloy.getMolten(1296), CustomItemList.eM_Computer_Vent.get(1, o), 100, 1920); + }, Materials.SolderingAlloy.getMolten(1296), CustomItemList.eM_Computer_Vent.get(1), 100, 1920); //Advanced Computer Casing GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), + CustomItemList.eM_Computer_Casing.get(1), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Ultimate, 1), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 64), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Electrum, 64), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Superconductor, 4) - }, Materials.Iridium.getMolten(1296), CustomItemList.eM_Computer_Bus.get(1, o), 200, 122880, true); + }, Materials.Iridium.getMolten(1296), CustomItemList.eM_Computer_Bus.get(1), 200, 122880); //Molecular Casing GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Power.get(1, o), + CustomItemList.eM_Power.get(1), GT_OreDictUnificator.get(OrePrefixes.plateDense, Materials.Osmiridium, 6), GT_OreDictUnificator.get(OrePrefixes.foil, Materials.Osmium, 12), GT_OreDictUnificator.get(OrePrefixes.screw, Materials.TungstenSteel, 24), GT_OreDictUnificator.get(OrePrefixes.ring, Materials.TungstenSteel, 24), - ItemList.Field_Generator_IV.get(1, o) - }, Materials.Osmium.getMolten(1296), CustomItemList.eM_Containment.get(1, o), 800, 500000); + ItemList.Field_Generator_IV.get(1) + }, Materials.Osmium.getMolten(1296), CustomItemList.eM_Containment.get(1), 800, 500000); //endregion //region hatches - //Dynamo Hatches UV-UIV - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2)}, Materials.Silver.getMolten(1000), CustomItemList.eM_dynamomulti4_UV.get(1, o), 100, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4)}, Materials.Electrum.getMolten(1000), CustomItemList.eM_dynamomulti16_UV.get(1, o), 200, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6)}, Materials.Tungsten.getMolten(1000), CustomItemList.eM_dynamomulti64_UV.get(1, o), 400, 122880); + //Dynamo Hatches IV-UIV + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Tungsten, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 2)}, Materials.Silver.getMolten(144), CustomItemList.eM_dynamomulti4_IV.get(1), 100, 1920); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Tungsten, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 4)}, Materials.Electrum.getMolten(144), CustomItemList.eM_dynamomulti16_IV.get(1), 200, 1920); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_IV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Tungsten, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.TungstenSteel, 6)}, Materials.Tungsten.getMolten(144), CustomItemList.eM_dynamomulti64_IV.get(1), 400, 1920); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_MAX.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2)}, Materials.Silver.getMolten(2000), CustomItemList.eM_dynamomulti4_UHV.get(1, o), 100, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_UHV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4)}, Materials.Electrum.getMolten(2000), CustomItemList.eM_dynamomulti16_UHV.get(1, o), 200, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_UHV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6)}, Materials.Tungsten.getMolten(2000), CustomItemList.eM_dynamomulti64_UHV.get(1, o), 400, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.VanadiumGallium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Chrome, 2)}, Materials.Silver.getMolten(288), CustomItemList.eM_dynamomulti4_LuV.get(1), 100, 7860); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.VanadiumGallium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Chrome, 4)}, Materials.Electrum.getMolten(288), CustomItemList.eM_dynamomulti16_LuV.get(1), 200, 7860); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_LuV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.VanadiumGallium, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Chrome, 6)}, Materials.Tungsten.getMolten(288), CustomItemList.eM_dynamomulti64_LuV.get(1), 400, 7860); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_MAX.get(4, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 8)}, Materials.Silver.getMolten(4000), CustomItemList.eM_dynamomulti4_UEV.get(1, o), 100, 2000000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 16)}, Materials.Electrum.getMolten(4000), CustomItemList.eM_dynamomulti16_UEV.get(1, o), 200, 2000000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 24)}, Materials.Tungsten.getMolten(4000), CustomItemList.eM_dynamomulti64_UEV.get(1, o), 400, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Naquadah, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 2)}, Materials.Silver.getMolten(576), CustomItemList.eM_dynamomulti4_ZPM.get(1), 100, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Naquadah, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 4)}, Materials.Electrum.getMolten(576), CustomItemList.eM_dynamomulti16_ZPM.get(1), 200, 30720); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_ZPM.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Naquadah, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Iridium, 6)}, Materials.Tungsten.getMolten(576), CustomItemList.eM_dynamomulti64_ZPM.get(1), 400, 30720); + + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2)}, Materials.Silver.getMolten(1152), CustomItemList.eM_dynamomulti4_UV.get(1), 100, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4)}, Materials.Electrum.getMolten(1152), CustomItemList.eM_dynamomulti16_UV.get(1), 200, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6)}, Materials.Tungsten.getMolten(1152), CustomItemList.eM_dynamomulti64_UV.get(1), 400, 122880); + + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2)}, Materials.Silver.getMolten(2304), CustomItemList.eM_dynamomulti4_UHV.get(1), 100, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4)}, Materials.Electrum.getMolten(2304), CustomItemList.eM_dynamomulti16_UHV.get(1), 200, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6)}, Materials.Tungsten.getMolten(2304), CustomItemList.eM_dynamomulti64_UHV.get(1), 400, 500000); + + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Dynamo_MAX.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 8)}, Materials.Silver.getMolten(4608), CustomItemList.eM_dynamomulti4_UEV.get(1), 100, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti4_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 16)}, Materials.Electrum.getMolten(4608), CustomItemList.eM_dynamomulti16_UEV.get(1), 200, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_dynamomulti16_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 24)}, Materials.Tungsten.getMolten(4608), CustomItemList.eM_dynamomulti64_UEV.get(1), 400, 2000000); //Energy Hatches UV-UIV - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2)}, Materials.Silver.getMolten(1000), CustomItemList.eM_energymulti4_UV.get(1, o), 100, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti4_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4)}, Materials.Electrum.getMolten(1000), CustomItemList.eM_energymulti16_UV.get(1, o), 200, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti16_UV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6)}, Materials.Tungsten.getMolten(1000), CustomItemList.eM_energymulti64_UV.get(1, o), 400, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 2)}, Materials.Silver.getMolten(1152), CustomItemList.eM_energymulti4_UV.get(1), 100, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti4_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 4)}, Materials.Electrum.getMolten(1152), CustomItemList.eM_energymulti16_UV.get(1), 200, 122880); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti16_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.NaquadahAlloy, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Osmium, 6)}, Materials.Tungsten.getMolten(1152), CustomItemList.eM_energymulti64_UV.get(1), 400, 122880); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_MAX.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2)}, Materials.Silver.getMolten(2000), CustomItemList.eM_energymulti4_UHV.get(1, o), 100, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti4_UHV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4)}, Materials.Electrum.getMolten(2000), CustomItemList.eM_energymulti16_UHV.get(1, o), 200, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti16_UHV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6)}, Materials.Tungsten.getMolten(2000), CustomItemList.eM_energymulti64_UHV.get(1, o), 400, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_MAX.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 2)}, Materials.Silver.getMolten(2304), CustomItemList.eM_energymulti4_UHV.get(1), 100, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti4_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 4)}, Materials.Electrum.getMolten(2304), CustomItemList.eM_energymulti16_UHV.get(1), 200, 500000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti16_UHV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 2), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 6)}, Materials.Tungsten.getMolten(2304), CustomItemList.eM_energymulti64_UHV.get(1), 400, 500000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_MAX.get(4, o), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 8)}, Materials.Silver.getMolten(4000), CustomItemList.eM_energymulti4_UEV.get(1, o), 100, 2000000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti4_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 16)}, Materials.Electrum.getMolten(4000), CustomItemList.eM_energymulti16_UEV.get(1, o), 200, 2000000); - GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti16_UEV.get(1, o), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 24)}, Materials.Tungsten.getMolten(4000), CustomItemList.eM_energymulti64_UEV.get(1, o), 400, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ItemList.Hatch_Energy_MAX.get(4), GT_OreDictUnificator.get(OrePrefixes.wireGt04, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 8)}, Materials.Silver.getMolten(4608), CustomItemList.eM_energymulti4_UEV.get(1), 100, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti4_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt08, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 16)}, Materials.Electrum.getMolten(4608), CustomItemList.eM_energymulti16_UEV.get(1), 200, 2000000); + GT_Values.RA.addAssemblerRecipe(new ItemStack[]{CustomItemList.eM_energymulti16_UEV.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt12, Materials.Superconductor, 8), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.Neutronium, 24)}, Materials.Tungsten.getMolten(4608), CustomItemList.eM_energymulti64_UEV.get(1), 400, 2000000); //Data Input GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), - ItemList.Hatch_Input_Bus_LuV.get(1, o), - ItemList.Circuit_Crystalcomputer.get(1, o), - CustomItemList.DATApipe.get(2, o) - }, Materials.Iridium.getMolten(1296), CustomItemList.dataIn_Hatch.get(1, o), 200, 122880, true); + CustomItemList.eM_Computer_Casing.get(1), + ItemList.Hatch_Input_Bus_LuV.get(1), + ItemList.Circuit_Crystalcomputer.get(1), + CustomItemList.DATApipe.get(2) + }, Materials.Iridium.getMolten(1296), CustomItemList.dataIn_Hatch.get(1), 200, 122880); //Data Output GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), - ItemList.Hatch_Output_Bus_LuV.get(1, o), - ItemList.Circuit_Crystalcomputer.get(1, o), - CustomItemList.DATApipe.get(2, o) - }, Materials.Iridium.getMolten(1296), CustomItemList.dataOut_Hatch.get(1, o), 200, 122880, true); + CustomItemList.eM_Computer_Casing.get(1), + ItemList.Hatch_Output_Bus_LuV.get(1), + ItemList.Circuit_Crystalcomputer.get(1), + CustomItemList.DATApipe.get(2) + }, Materials.Iridium.getMolten(1296), CustomItemList.dataOut_Hatch.get(1), 200, 122880); //Rack GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Bus.get(1, o), - ItemList.Hatch_Input_Bus_ZPM.get(1, o), - ItemList.Circuit_Crystalcomputer.get(2, o), - CustomItemList.DATApipe.get(4, o) - }, Materials.Iridium.getMolten(1296), CustomItemList.rack_Hatch.get(1, o), 800, 122880, true); + CustomItemList.eM_Computer_Bus.get(1), + ItemList.Hatch_Input_Bus_ZPM.get(1), + ItemList.Circuit_Crystalcomputer.get(2), + CustomItemList.DATApipe.get(4) + }, Materials.Iridium.getMolten(1296), CustomItemList.rack_Hatch.get(1), 800, 122880); //Object Holder GT_Values.RA.addAssemblylineRecipe(ItemList.Hatch_Input_Bus_ZPM.get(1), 10000, new ItemStack[]{ ItemList.Hatch_Input_Bus_ZPM.get(1), - CustomItemList.eM_Computer_Bus.get(1, o), + CustomItemList.eM_Computer_Bus.get(1), ItemList.Emitter_ZPM.get(8), ItemList.Robot_Arm_ZPM.get(1), ItemList.Electric_Motor_ZPM.get(2), ItemList.Circuit_Crystalmainframe.get(1), GT_OreDictUnificator.get(OrePrefixes.cableGt02, Materials.Naquadah, 2), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Naquadah, 16), - CustomItemList.DATApipe.get(2, o), + CustomItemList.DATApipe.get(2), }, new FluidStack[]{ Materials.UUMatter.getFluid(500), Materials.Iridium.getMolten(1000), @@ -162,42 +177,42 @@ public class BloodyRecipeLoader implements Runnable { //Parameterizer GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), - ItemList.Circuit_Masterquantumcomputer.get(1, o), - CustomItemList.DATApipe.get(4, o), - ItemList.Cover_Screen.get(1, o ), + CustomItemList.eM_Computer_Casing.get(1), + ItemList.Circuit_Masterquantumcomputer.get(1), + CustomItemList.DATApipe.get(4), + ItemList.Cover_Screen.get(1 ), new ItemStack(Blocks.stone_button, 16), - }, Materials.Iridium.getMolten(2592), CustomItemList.Parametrizer_Hatch.get(1, o), 800, 122880); + }, Materials.Iridium.getMolten(2592), CustomItemList.Parametrizer_Hatch.get(1), 800, 122880); //Uncertainty GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Computer_Casing.get(1, o), - ItemList.Circuit_Ultimatecrystalcomputer.get(1, o), - CustomItemList.DATApipe.get(16, o), - ItemList.Cover_Screen.get(1, o ), + CustomItemList.eM_Computer_Casing.get(1), + ItemList.Circuit_Ultimatecrystalcomputer.get(1), + CustomItemList.DATApipe.get(16), + ItemList.Cover_Screen.get(1 ), new ItemStack(Blocks.stone_button, 16), - }, Materials.Iridium.getMolten(2592), CustomItemList.Uncertainty_Hatch.get(1, o), 1200, 122880, true); + }, Materials.Iridium.getMolten(2592), CustomItemList.Uncertainty_Hatch.get(1), 1200, 122880); //Elemental Input GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Containment.get(1, o), - ItemList.Hatch_Input_UV.get(1, o), + CustomItemList.eM_Containment.get(1), + ItemList.Hatch_Input_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Naquadah, 2), - ItemList.Sensor_UV.get(1, o) - }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_in_UV.get(1, o), 800, 500000, true); + ItemList.Sensor_UV.get(1) + }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_in_UV.get(1), 800, 500000); //Elemental Output GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Containment.get(1, o), - ItemList.Hatch_Output_UV.get(1, o), + CustomItemList.eM_Containment.get(1), + ItemList.Hatch_Output_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.pipeMedium, Materials.Naquadah, 2), - ItemList.Emitter_UV.get(1, o) - }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_out_UV.get(1, o), 800, 500000, true); + ItemList.Emitter_UV.get(1) + }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_out_UV.get(1), 800, 500000); //Overflow GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.eM_Containment.get(1, o), - ItemList.Hatch_Muffler_UV.get(1, o), + CustomItemList.eM_Containment.get(1), + ItemList.Hatch_Muffler_UV.get(1), GT_OreDictUnificator.get(OrePrefixes.pipeLarge, Materials.Naquadah, 1), - ItemList.Field_Generator_UV.get(1, o) - }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_muffler_UV.get(1, o), 800, 500000, true); + ItemList.Field_Generator_UV.get(1) + }, Materials.Osmiridium.getMolten(1296), CustomItemList.eM_muffler_UV.get(1), 800, 500000); //endregion @@ -206,38 +221,38 @@ public class BloodyRecipeLoader implements Runnable { //Microwave Grinder GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - ItemList.Machine_HV_Microwave.get(1,o), + ItemList.Machine_HV_Microwave.get(1), GT_OreDictUnificator.get(OrePrefixes.plate, Materials.StainlessSteel, 4), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Advanced, 4), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.AnnealedCopper, 16), - ItemList.Upgrade_Overclocker.get(4, o), - }, Materials.Copper.getMolten(576), CustomItemList.Machine_Multi_Microwave.get(1, o), 800, 480); + ItemList.Upgrade_Overclocker.get(4), + }, Materials.Copper.getMolten(576), CustomItemList.Machine_Multi_Microwave.get(1), 800, 480); //Active Transformer GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - ItemList.Transformer_ZPM_LuV.get(16, o), - ItemList.Circuit_Board_Elite.get(1, o),//? + ItemList.Transformer_ZPM_LuV.get(16), + ItemList.Circuit_Board_Elite.get(1),//? GT_OreDictUnificator.get(OrePrefixes.wireGt01, Materials.Superconductor, 16), - ItemList.Circuit_Chip_UHPIC.get(2, o), - }, Materials.TungstenSteel.getMolten(576), CustomItemList.Machine_Multi_Transformer.get(1, o), 400, 30720); + ItemList.Circuit_Chip_HPIC.get(2), + }, Materials.TungstenSteel.getMolten(576), CustomItemList.Machine_Multi_Transformer.get(1), 400, 30720); //Network Switch GT_Values.RA.addAssemblerRecipe(new ItemStack[]{ - CustomItemList.Machine_Multi_Transformer.get(1, o), - ItemList.Circuit_Ultimatecrystalcomputer.get(1, o), + CustomItemList.Machine_Multi_Transformer.get(1), + ItemList.Circuit_Ultimatecrystalcomputer.get(1), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Cobalt, 64), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Copper, 64), - CustomItemList.DATApipe.get(4, o), - }, Materials.Iridium.getMolten(1296), CustomItemList.Machine_Multi_Switch.get(1, o), 800, 122880); + CustomItemList.DATApipe.get(4), + }, Materials.Iridium.getMolten(1296), CustomItemList.Machine_Multi_Switch.get(1), 800, 122880); //Quantum Computer GT_Values.RA.addAssemblylineRecipe(ItemList.Tool_DataOrb.get(1), 20000, new ItemStack[]{ CustomItemList.Machine_Multi_Switch.get(1), GT_OreDictUnificator.get(OrePrefixes.circuit, Materials.Superconductor, 2), ItemList.Tool_DataOrb.get(1), - ItemList.Cover_Screen.get(1, o), + ItemList.Cover_Screen.get(1), GT_OreDictUnificator.get(OrePrefixes.wireGt02, Materials.Superconductor, 8), - CustomItemList.DATApipe.get(8, o), + CustomItemList.DATApipe.get(8), }, new FluidStack[]{ Materials.UUMatter.getFluid(1000), Materials.Iridium.getMolten(1296), @@ -254,7 +269,7 @@ public class BloodyRecipeLoader implements Runnable { ItemList.Electric_Motor_ZPM.get(2), GT_OreDictUnificator.get(OrePrefixes.cableGt02, Materials.Naquadah, 4), GT_OreDictUnificator.get(OrePrefixes.wireFine, Materials.Naquadah, 32), - CustomItemList.DATApipe.get(16, o), + CustomItemList.DATApipe.get(16), }, new FluidStack[]{ Materials.UUMatter.getFluid(1000), Materials.Iridium.getMolten(1296), @@ -355,5 +370,43 @@ public class BloodyRecipeLoader implements Runnable { Materials.Osmiridium.getMolten(1296), }, CustomItemList.Machine_Multi_Scanner.get(1), 24000, 500000); //endregion + + register_machine_EM_behaviours(); + } + + private void register_machine_EM_behaviours(){ + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(6),ItemList.Machine_IV_Centrifuge.get(1)); + try { + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),ItemList.valueOf("Machine_LuV_Centrifuge").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),ItemList.valueOf("Machine_ZPM_Centrifuge").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),ItemList.valueOf("Machine_UV_Centrifuge").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),ItemList.valueOf("Machine_UV_Centrifuge").get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),ItemList.valueOf("Machine_UV_Centrifuge").get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),ItemList.valueOf("Machine_UV_Centrifuge").get(64)); + }catch (IllegalArgumentException|NullPointerException e){ + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(7),ItemList.Machine_IV_Centrifuge.get(2)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(8),ItemList.Machine_IV_Centrifuge.get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(9),ItemList.Machine_IV_Centrifuge.get(8)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(10),ItemList.Machine_IV_Centrifuge.get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(11),ItemList.Machine_IV_Centrifuge.get(32)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_Centrifuge(12),ItemList.Machine_IV_Centrifuge.get(64)); + } + + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(6),ItemList.Machine_IV_ElectromagneticSeparator.get(1)); + try { + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),ItemList.valueOf("Machine_LuV_ElectromagneticSeparator").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),ItemList.valueOf("Machine_ZPM_ElectromagneticSeparator").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(1)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),ItemList.valueOf("Machine_UV_ElectromagneticSeparator").get(64)); + }catch (IllegalArgumentException|NullPointerException e){ + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(7),ItemList.Machine_IV_ElectromagneticSeparator.get(2)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(8),ItemList.Machine_IV_ElectromagneticSeparator.get(4)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(9),ItemList.Machine_IV_ElectromagneticSeparator.get(8)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(10),ItemList.Machine_IV_ElectromagneticSeparator.get(16)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(11),ItemList.Machine_IV_ElectromagneticSeparator.get(32)); + GT_MetaTileEntity_EM_machine.registerBehaviour(new Behaviour_ElectromagneticSeparator(12),ItemList.Machine_IV_ElectromagneticSeparator.get(64)); + } } } diff --git a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java index 51f49d0bf9..ec321fd3b8 100644 --- a/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ElementalLoader.java @@ -4,14 +4,15 @@ import com.github.technus.tectech.compatibility.thaumcraft.definitions.dComplexA import com.github.technus.tectech.compatibility.thaumcraft.definitions.ePrimalAspectDefinition; import com.github.technus.tectech.elementalMatter.core.templates.cElementalPrimitive; import com.github.technus.tectech.elementalMatter.definitions.complex.atom.dAtomDefinition; -import com.github.technus.tectech.elementalMatter.definitions.complex.hadron.dHadronDefinition; import com.github.technus.tectech.elementalMatter.definitions.complex.atom.iaeaNuclide; +import com.github.technus.tectech.elementalMatter.definitions.complex.hadron.dHadronDefinition; import com.github.technus.tectech.elementalMatter.definitions.primitive.*; /** * Created by danie_000 on 16.11.2016. */ public class ElementalLoader implements Runnable { + @Override public void run() { // =================================================================================================== // Definition init diff --git a/src/main/java/com/github/technus/tectech/loader/EntityLoader.java b/src/main/java/com/github/technus/tectech/loader/EntityLoader.java index 389238e6c6..5769a5d5d2 100644 --- a/src/main/java/com/github/technus/tectech/loader/EntityLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/EntityLoader.java @@ -11,7 +11,8 @@ import openmodularturrets.entity.projectiles.projectileEM; public class EntityLoader implements Runnable { @Override public void run() { - if(Loader.isModLoaded("openmodularturrets")) + if(Loader.isModLoaded("openmodularturrets")) { EntityRegistry.registerModEntity(projectileEM.class, "projectileEM", 0, TecTech.instance, 16, 5, true); + } } } diff --git a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java index 761af0b60d..ac3d404816 100644 --- a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java @@ -5,6 +5,7 @@ import com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity. import com.github.technus.tectech.thing.metaTileEntity.hatch.*; import com.github.technus.tectech.thing.metaTileEntity.multi.*; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_Data; import com.github.technus.tectech.thing.metaTileEntity.pipe.GT_MetaTileEntity_Pipe_EM; import com.github.technus.tectech.thing.metaTileEntity.single.GT_MetaTileEntity_DebugPowerGenerator; @@ -16,6 +17,7 @@ import static com.github.technus.tectech.thing.CustomItemList.*; * Created by danie_000 on 16.11.2016. */ public class MachineLoader implements Runnable { + @Override public void run() { // =================================================================================================== // eM IN @@ -65,22 +67,22 @@ public class MachineLoader implements Runnable { // eM Waste OUT // =================================================================================================== - eM_muffler_UV.set(new GT_MetaTileEntity_Hatch_MufflerElemental( + eM_muffler_UV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( 15020, "hatch.emmuffler.tier.08", "UV Overflow Output Hatch", 8, 1e10f).getStackForm(1L)); - eM_muffler_UHV.set(new GT_MetaTileEntity_Hatch_MufflerElemental( + eM_muffler_UHV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( 15021, "hatch.emmuffler.tier.09", "UHV Overflow Output Hatch", 9, 5e10f).getStackForm(1L)); - eM_muffler_UEV.set(new GT_MetaTileEntity_Hatch_MufflerElemental( + eM_muffler_UEV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( 15022, "hatch.emmuffler.tier.10", "UEV Overflow Output Hatch", 10, 25e10f).getStackForm(1L)); - eM_muffler_UIV.set(new GT_MetaTileEntity_Hatch_MufflerElemental( + eM_muffler_UIV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( 15023, "hatch.emmuffler.tier.11", "UIV Overflow Output Hatch", 11, 125e10f).getStackForm(1L)); - eM_muffler_UMV.set(new GT_MetaTileEntity_Hatch_MufflerElemental( + eM_muffler_UMV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( 15024, "hatch.emmuffler.tier.12", "UMV Overflow Output Hatch", 12, 125e11f).getStackForm(1L)); - eM_muffler_UXV.set(new GT_MetaTileEntity_Hatch_MufflerElemental( + eM_muffler_UXV.set(new GT_MetaTileEntity_Hatch_OverflowElemental( 15025, "hatch.emmuffler.tier.13", "UXV Overflow Output Hatch", 13, 125e12f).getStackForm(1L)); // =================================================================================================== diff --git a/src/main/java/com/github/technus/tectech/loader/MainLoader.java b/src/main/java/com/github/technus/tectech/loader/MainLoader.java index 1fc1ddda22..2e715d7b9c 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -62,8 +62,8 @@ public final class MainLoader { TecTech.Logger.info("Entities registered"); progressBarLoad.step("Add damage types"); - microwaving=new DamageSource("microwaving").setDamageBypassesArmor(); - elementalPollution=new DamageSource("elementalPollution").setDamageBypassesArmor(); + microwaving =new DamageSource("microwaving").setDamageBypassesArmor(); + elementalPollution =new DamageSource("elementalPollution").setDamageBypassesArmor(); TecTech.Logger.info("Damage types addition Done"); ProgressManager.pop(progressBarLoad); @@ -86,23 +86,7 @@ public final class MainLoader { TecTech.Logger.info("Recipe Init Done"); progressBarPostLoad.step("Creative Tab part1"); - mainTab = new CreativeTabs("TecTech") { - @SideOnly(Side.CLIENT) - @Override - public Item getTabIconItem() { - return DebugElementalInstanceContainer_EM.INSTANCE; - } - - @Override - public void displayAllReleventItems(List stuffToShow) { - for(CustomItemList item: CustomItemList.values()){ - if (item.hasBeenSet() && item.getBlock() == GregTech_API.sBlockMachines) { - stuffToShow.add(item.get(1)); - } - } - super.displayAllReleventItems(stuffToShow); - } - }; + mainTab = new MyCreativeTab(); progressBarPostLoad.step("Creative Tab part2"); registerThingsInTabs(); TecTech.Logger.info("CreativeTab initiation complete"); @@ -195,4 +179,24 @@ public final class MainLoader { //todo add GC GS stuff } + + private static final class MyCreativeTab extends CreativeTabs { + private MyCreativeTab() {super("TecTech");} + + @SideOnly(Side.CLIENT) + @Override + public Item getTabIconItem() { + return DebugElementalInstanceContainer_EM.INSTANCE; + } + + @Override + public void displayAllReleventItems(List stuffToShow) { + for(CustomItemList item: CustomItemList.values()){ + if (item.hasBeenSet() && item.getBlock() == GregTech_API.sBlockMachines) { + stuffToShow.add(item.get(1)); + } + } + super.displayAllReleventItems(stuffToShow); + } + } } diff --git a/src/main/java/com/github/technus/tectech/loader/ModGuiHandler.java b/src/main/java/com/github/technus/tectech/loader/ModGuiHandler.java new file mode 100644 index 0000000000..5a3ca7a877 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/loader/ModGuiHandler.java @@ -0,0 +1,27 @@ +package com.github.technus.tectech.loader; + +import com.github.technus.tectech.thing.item.gui.ScanDisplayScreen; +import cpw.mods.fml.common.network.IGuiHandler; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; + +/** + * Created by danie_000 on 17.12.2017. + */ +public class ModGuiHandler implements IGuiHandler { + public static final int SCAN_DISPLAY_SCREEN_ID =0; + + @Override + public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + @Override + public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + switch (ID){ + case SCAN_DISPLAY_SCREEN_ID: + return new ScanDisplayScreen(player); + default: return null; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java b/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java index 1723506d6f..db323ee038 100644 --- a/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java @@ -17,6 +17,7 @@ import static gregtech.api.enums.GT_Values.RA; * Created by danie_000 on 16.11.2016. */ public class RecipeLoader implements Runnable { + @Override public void run() { dAtomDefinition.setTransformation(); dHadronDefinition.setTransformations(); @@ -25,14 +26,16 @@ public class RecipeLoader implements Runnable { // Recipes init - common goes here rest goes into methods below // =================================================================================================== - for(int i=0;i<=15;i++) - RA.addAssemblerRecipe(new ItemStack[]{ - GT_Utility.getIntegratedCircuit(i), - GT_OreDictUnificator.get(OrePrefixes.dust,Materials.Cobalt,1)}, - Materials.Aluminium.getMolten(864), - new ItemStack(TT_Container_Casings.sHintCasingsTT, 1,i),32,120); + for(int i=0;i<=15;i++) { + RA.addAssemblerRecipe(new ItemStack[]{GT_Utility.getIntegratedCircuit(i), GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Cobalt, 1)}, Materials.Aluminium.getMolten(864), new ItemStack(TT_Container_Casings.sHintCasingsTT, 1, i), 32, 120); + } + + if (Loader.isModLoaded("dreamcraft")) { + new DreamCraftRecipeLoader().run();//init recipes for GTNH version + } else { + new BloodyRecipeLoader().run();//init recipes for NON-GTNH version + } + - if (Loader.isModLoaded("dreamcraft")) new DreamCraftRecipeLoader().run();//init recipes for GTNH version - else new BloodyRecipeLoader().run();//init recipes for NON-GTNH version } } diff --git a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java index e42e8e8edc..5906f3d3de 100644 --- a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java @@ -9,14 +9,23 @@ import com.github.technus.tectech.thing.casing.GT_Block_HintTT; import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.thing.item.*; import cpw.mods.fml.common.Loader; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; import openmodularturrets.blocks.turretbases.TurretBaseEM; import openmodularturrets.blocks.turretheads.TurretHeadEM; +import static com.github.technus.tectech.TecTech.tectechTexturePage1; + /** * Created by danie_000 on 16.11.2016. */ public class ThingsLoader implements Runnable { + @Override public void run() { + if(Textures.BlockIcons.casingTexturePages[tectechTexturePage1]==null) { + Textures.BlockIcons.casingTexturePages[tectechTexturePage1] = new ITexture[128]; + } + TecTech.Logger.info("Added texture page if was null"); TT_Container_Casings.sBlockCasingsTT = new GT_Block_CasingsTT(); TecTech.Logger.info("Elemental Casing registered"); TT_Container_Casings.sHintCasingsTT = new GT_Block_HintTT(); diff --git a/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java b/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java index 05f5018fdc..3e1949014d 100644 --- a/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java +++ b/src/main/java/com/github/technus/tectech/nei/NEI_TT_Config.java @@ -9,6 +9,7 @@ public class NEI_TT_Config implements IConfigureNEI {//must be NEI*Config public static TT_NEI_ResearchHandler TT_RH; public static TT_NEI_ScannerHandler TT_SH; + @Override public void loadConfig() { sIsAdded = false; if(FMLCommonHandler.instance().getEffectiveSide().isClient()) { @@ -18,10 +19,12 @@ public class NEI_TT_Config implements IConfigureNEI {//must be NEI*Config sIsAdded = true; } + @Override public String getName() { return "TecTech NEI Plugin"; } + @Override public String getVersion() { return "(1.0)"; } diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java index 38a127900b..e64a68304f 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ResearchHandler.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.nei; import codechicken.lib.gui.GuiDraw; +import codechicken.nei.ItemList; import codechicken.nei.PositionedStack; import codechicken.nei.guihook.GuiContainerManager; import codechicken.nei.guihook.IContainerInputHandler; @@ -8,6 +9,7 @@ import codechicken.nei.guihook.IContainerTooltipHandler; import codechicken.nei.recipe.GuiCraftingRecipe; import codechicken.nei.recipe.GuiRecipe; import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.RecipeInfo; import codechicken.nei.recipe.TemplateRecipeHandler; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.auxiliary.Reference; @@ -35,6 +37,8 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import static gregtech.api.enums.ItemList.Display_Fluid; + public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { public static final int sOffsetX = 5; public static final int sOffsetY = 11; @@ -47,17 +51,17 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { protected final TT_recipe.GT_Recipe_MapTT mRecipeMap; public TT_NEI_ResearchHandler(TT_recipe.GT_Recipe_MapTT aRecipeMap) { - this.mRecipeMap = aRecipeMap; - this.transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); + mRecipeMap = aRecipeMap; + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); if (!NEI_TT_Config.sIsAdded) { - FMLInterModComms.sendRuntimeMessage(TecTech.instance, "NEIPlugins", "register-crafting-handler", Reference.MODID+"@" + getRecipeName() + "@" + getOverlayIdentifier()); + FMLInterModComms.sendRuntimeMessage(TecTech.instance, "NEIPlugins", "register-crafting-handler", Reference.MODID+ '@' + getRecipeName() + '@' + getOverlayIdentifier()); GuiCraftingRecipe.craftinghandlers.add(this); GuiUsageRecipe.usagehandlers.add(this); } } public List<GT_Recipe> getSortedRecipes() { - List<GT_Recipe> result = new ArrayList<>(this.mRecipeMap.mRecipeList); + List<GT_Recipe> result = new ArrayList<>(mRecipeMap.mRecipeList); Collections.sort(result); return result; } @@ -66,16 +70,18 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); } + @Override public TemplateRecipeHandler newInstance() { NEI_TT_Config.TT_RH=new TT_NEI_ResearchHandler(mRecipeMap); return NEI_TT_Config.TT_RH; } + @Override public void loadCraftingRecipes(String outputId, Object... results) { if (outputId.equals(getOverlayIdentifier())) { for (GT_Recipe tRecipe : getSortedRecipes()) { if (!tRecipe.mHidden) { - this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + arecipes.add(new CachedDefaultRecipe(tRecipe)); } } } else { @@ -83,13 +89,14 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { } } + @Override public void loadCraftingRecipes(ItemStack aResult) { ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); ArrayList<ItemStack> tResults = new ArrayList<>(); tResults.add(aResult); tResults.add(GT_OreDictUnificator.get(true, aResult)); - if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + if (tPrefixMaterial != null && !tPrefixMaterial.mBlackListed && !tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty()) { for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); } @@ -108,7 +115,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); for (ItemStack tStack : tResults) { if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { - this.arecipes.add(tNEIRecipe); + arecipes.add(tNEIRecipe); break; } } @@ -117,13 +124,14 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { CachedDefaultRecipe tNEIRecipe; } + @Override public void loadUsageRecipes(ItemStack aInput) { ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); ArrayList<ItemStack> tInputs = new ArrayList<>(); tInputs.add(aInput); tInputs.add(GT_OreDictUnificator.get(false, aInput)); - if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + if (tPrefixMaterial != null && !tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty()) { for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); } @@ -142,7 +150,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); for (ItemStack tStack : tInputs) { if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { - this.arecipes.add(tNEIRecipe); + arecipes.add(tNEIRecipe); break; } } @@ -151,46 +159,51 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { CachedDefaultRecipe tNEIRecipe; } + @Override public String getOverlayIdentifier() { - return this.mRecipeMap.mNEIName; + return mRecipeMap.mNEIName; } + @Override public void drawBackground(int recipe) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GuiDraw.changeTexture(getGuiTexture()); GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); } + @Override public int recipiesPerPage() { return 1; } + @Override public String getRecipeName() { - return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + return GT_LanguageManager.getTranslation(mRecipeMap.mUnlocalizedName); } + @Override public String getGuiTexture() { // return "gregtech:textures/gui/" + this.mRecipeMap.mUnlocalizedName + ".png"; - return this.mRecipeMap.mNEIGUIPath; + return mRecipeMap.mNEIGUIPath; } + @Override public List<String> handleItemTooltip(GuiRecipe gui, ItemStack aStack, List<String> currenttip, int aRecipeIndex) { - TemplateRecipeHandler.CachedRecipe tObject = this.arecipes.get(aRecipeIndex); - if ((tObject instanceof CachedDefaultRecipe)) { + TemplateRecipeHandler.CachedRecipe tObject = arecipes.get(aRecipeIndex); + if (tObject instanceof CachedDefaultRecipe) { CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; for (PositionedStack tStack : tRecipe.mOutputs) { if (aStack == tStack.item) { - if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + if (!(tStack instanceof FixedPositionedStack) || ((FixedPositionedStack) tStack).mChance <= 0 || ((FixedPositionedStack) tStack).mChance == 10000) { break; } - currenttip.add(trans("150","Chance: ") + ((FixedPositionedStack) tStack).mChance / 100 + "." + (((FixedPositionedStack) tStack).mChance % 100 < 10 ? "0" + ((FixedPositionedStack) tStack).mChance % 100 : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + currenttip.add(trans("150","Chance: ") + ((FixedPositionedStack) tStack).mChance / 100 + '.' + (((FixedPositionedStack) tStack).mChance % 100 < 10 ? "0" + ((FixedPositionedStack) tStack).mChance % 100 : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + '%'); break; } } for (PositionedStack tStack : tRecipe.mInputs) { if (aStack == tStack.item) { - if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || - (tStack.item.stackSize != 0)) { + if (Display_Fluid.isStackEqual(tStack.item, true, true) || tStack.item.stackSize != 0) { break; } currenttip.add(trans("151","Does not get consumed in the process")); @@ -201,22 +214,23 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { return currenttip; } - public void drawExtras(int aRecipeIndex) { - int tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; - int computation = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; - String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); + @Override + public void drawExtras(int aRecipeIndex) { + int tEUt = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mEUt; + int computation = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mDuration; + String[] recipeDesc = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); if (recipeDesc == null) { - int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + int tSpecial = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; short ampere=(short) (tSpecial & 0xFFFF),minComputationPerSec=(short)(tSpecial>>>16); if (tEUt != 0) { - drawText(10, 73, trans("152","Max Total: ") + ((1+((computation-minComputationPerSec)/minComputationPerSec)) * (long)tEUt * ampere * 20) + " EU", -16777216); - drawText(10, 83, trans("153","Usage: ") + ((long)tEUt*ampere) + " EU/t", -16777216); - if (this.mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10, 93, trans("154","Voltage: ") + tEUt + " EU", -16777216); - drawText(10, 103, trans("155","Amperage: ") + ampere, -16777216); + drawText(10, 73, trans("152","Max Total: ") + (1+ (computation-minComputationPerSec) /minComputationPerSec) * (long)tEUt * ampere * 20 + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + (long)tEUt*ampere + " EU/t", -16777216); + if (mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, trans("154","Voltage: ") + tEUt + " EU", -16777216); + drawText(10, 103, trans("155","Amperage: ") + ampere, -16777216); } else { - drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); - drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); + drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); + drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); } } drawText(10, 113, "Computation: "+computation, -16777216); @@ -224,7 +238,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { } else { int i = 0; for (String descLine : recipeDesc) { - drawText(10, 73 + 10 * i, descLine, -16777216); + drawText(10, 73 + 10 * i, descLine, -16777216); i++; } } @@ -232,6 +246,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { public static class GT_RectHandler implements IContainerInputHandler, IContainerTooltipHandler { + @Override public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { if (canHandle(gui)) { if (button == 0) { @@ -244,19 +259,21 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { return false; } + @Override public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) { return false; } public boolean canHandle(GuiContainer gui) { - return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) || ((gui instanceof GT_GUIContainer_FusionReactor)) && (GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI))); + return gui instanceof GT_GUIContainer_BasicMachine && GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI) || gui instanceof GT_GUIContainer_FusionReactor && GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI); } + @Override public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) { - if ((canHandle(gui)) && (currenttip.isEmpty())) { - if (gui instanceof GT_GUIContainer_BasicMachine && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + if (canHandle(gui) && currenttip.isEmpty()) { + if (gui instanceof GT_GUIContainer_BasicMachine && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - RecipeInfo.getGuiOffset(gui)[1]))) { currenttip.add("Recipes"); - } else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + } else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - RecipeInfo.getGuiOffset(gui)[1]))) { currenttip.add("Recipes"); } @@ -266,41 +283,50 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { private boolean transferRect(GuiContainer gui, boolean usage) { if (gui instanceof GT_GUIContainer_BasicMachine) { - return (canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI)); + return canHandle(gui) && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - RecipeInfo.getGuiOffset(gui)[1])) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI)); } else if (gui instanceof GT_GUIContainer_FusionReactor) { - return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI)); + return canHandle(gui) && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - RecipeInfo.getGuiOffset(gui)[1])) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI)); } return false; } + @Override public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) { return currenttip; } + @Override public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List<String> currenttip) { return currenttip; } + @Override public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) { return false; } + @Override public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { } + @Override public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { } + @Override public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { } + @Override public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { return false; } + @Override public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { } + @Override public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { } } @@ -315,22 +341,23 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { public FixedPositionedStack(Object object, int x, int y, int aChance) { super(object, x, y, true); - this.mChance = aChance; + mChance = aChance; } + @Override public void generatePermutations() { - if (this.permutated) { + if (permutated) { return; } ArrayList<ItemStack> tDisplayStacks = new ArrayList<>(); - for (ItemStack tStack : this.items) { + for (ItemStack tStack : items) { if (GT_Utility.isStackValid(tStack)) { if (tStack.getItemDamage() == 32767) { - List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + List<ItemStack> permutations = ItemList.itemMap.get(tStack.getItem()); if (!permutations.isEmpty()) { ItemStack stack; - for (Iterator i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, stack))) { - stack = (ItemStack) i$.next(); + for (Iterator<ItemStack> iterator = permutations.iterator(); iterator.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, stack))) { + stack = iterator.next(); } } else { ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); @@ -342,11 +369,11 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { } } } - this.items = tDisplayStacks.toArray(new ItemStack[0]); - if (this.items.length == 0) { - this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + items = tDisplayStacks.toArray(new ItemStack[tDisplayStacks.size()]); + if (items.length == 0) { + items = new ItemStack[]{new ItemStack(Blocks.fire)}; } - this.permutated = true; + permutated = true; setPermutationToRender(0); } } @@ -358,8 +385,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { public final List<PositionedStack> mInputs; public CachedDefaultRecipe(GT_Recipe aRecipe) { - super(); - this.mRecipe = aRecipe; + mRecipe = aRecipe; mOutputs = new ArrayList<>(); mInputs = new ArrayList<>(); @@ -370,7 +396,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { // break; //case 1: if (aRecipe.getRepresentativeInput(tStartIndex) != null) { - this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14+9)); + mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14+9)); } //tStartIndex++; //break; @@ -567,7 +593,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { // tStartIndex++; //} if (aRecipe.mSpecialItems != null) { - this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); } //tStartIndex = 0; //switch (mRecipeMap.mUsualOutputCount) { @@ -575,7 +601,7 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { // break; //case 1: if (aRecipe.getOutput(tStartIndex) != null) { - this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14+9, aRecipe.getOutputChance(tStartIndex))); + mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14+9, aRecipe.getOutputChance(tStartIndex))); } //tStartIndex++; //break; @@ -798,16 +824,19 @@ public class TT_NEI_ResearchHandler extends TemplateRecipeHandler { //} } + @Override public List<PositionedStack> getIngredients() { - return getCycledIngredients(cycleticks / 10, this.mInputs); + return getCycledIngredients(cycleticks / 10, mInputs); } + @Override public PositionedStack getResult() { return null; } + @Override public List<PositionedStack> getOtherStacks() { - return this.mOutputs; + return mOutputs; } } diff --git a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java index 5ec6e18874..5a46f13f12 100644 --- a/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java +++ b/src/main/java/com/github/technus/tectech/nei/TT_NEI_ScannerHandler.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.nei; import codechicken.lib.gui.GuiDraw; +import codechicken.nei.ItemList; import codechicken.nei.PositionedStack; import codechicken.nei.guihook.GuiContainerManager; import codechicken.nei.guihook.IContainerInputHandler; @@ -8,6 +9,7 @@ import codechicken.nei.guihook.IContainerTooltipHandler; import codechicken.nei.recipe.GuiCraftingRecipe; import codechicken.nei.recipe.GuiRecipe; import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.RecipeInfo; import codechicken.nei.recipe.TemplateRecipeHandler; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.auxiliary.Reference; @@ -35,6 +37,8 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; +import static gregtech.api.enums.ItemList.Display_Fluid; + public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { public static final int sOffsetX = 5; public static final int sOffsetY = 11; @@ -47,17 +51,17 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { protected final TT_recipe.GT_Recipe_MapTT mRecipeMap; public TT_NEI_ScannerHandler(TT_recipe.GT_Recipe_MapTT aRecipeMap) { - this.mRecipeMap = aRecipeMap; - this.transferRects.add(new RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); + mRecipeMap = aRecipeMap; + transferRects.add(new RecipeTransferRect(new Rectangle(65, 13, 36, 18), getOverlayIdentifier())); if (!NEI_TT_Config.sIsAdded) { - FMLInterModComms.sendRuntimeMessage(TecTech.instance, "NEIPlugins", "register-crafting-handler", Reference.MODID+"@" + getRecipeName() + "@" + getOverlayIdentifier()); + FMLInterModComms.sendRuntimeMessage(TecTech.instance, "NEIPlugins", "register-crafting-handler", Reference.MODID+ '@' + getRecipeName() + '@' + getOverlayIdentifier()); GuiCraftingRecipe.craftinghandlers.add(this); GuiUsageRecipe.usagehandlers.add(this); } } public List<GT_Recipe> getSortedRecipes() { - List<GT_Recipe> result = new ArrayList<>(this.mRecipeMap.mRecipeList); + List<GT_Recipe> result = new ArrayList<>(mRecipeMap.mRecipeList); Collections.sort(result); return result; } @@ -66,16 +70,18 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { Minecraft.getMinecraft().fontRenderer.drawString(aString, aX, aY, aColor); } + @Override public TemplateRecipeHandler newInstance() { NEI_TT_Config.TT_SH=new TT_NEI_ScannerHandler(mRecipeMap); return NEI_TT_Config.TT_SH; } + @Override public void loadCraftingRecipes(String outputId, Object... results) { if (outputId.equals(getOverlayIdentifier())) { for (GT_Recipe tRecipe : getSortedRecipes()) { if (!tRecipe.mHidden) { - this.arecipes.add(new CachedDefaultRecipe(tRecipe)); + arecipes.add(new CachedDefaultRecipe(tRecipe)); } } } else { @@ -83,13 +89,14 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { } } + @Override public void loadCraftingRecipes(ItemStack aResult) { ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aResult); ArrayList<ItemStack> tResults = new ArrayList<>(); tResults.add(aResult); tResults.add(GT_OreDictUnificator.get(true, aResult)); - if ((tPrefixMaterial != null) && (!tPrefixMaterial.mBlackListed) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + if (tPrefixMaterial != null && !tPrefixMaterial.mBlackListed && !tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty()) { for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { tResults.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); } @@ -108,7 +115,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); for (ItemStack tStack : tResults) { if (tNEIRecipe.contains(tNEIRecipe.mOutputs, tStack)) { - this.arecipes.add(tNEIRecipe); + arecipes.add(tNEIRecipe); break; } } @@ -117,13 +124,14 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { CachedDefaultRecipe tNEIRecipe; } + @Override public void loadUsageRecipes(ItemStack aInput) { ItemData tPrefixMaterial = GT_OreDictUnificator.getAssociation(aInput); ArrayList<ItemStack> tInputs = new ArrayList<>(); tInputs.add(aInput); tInputs.add(GT_OreDictUnificator.get(false, aInput)); - if ((tPrefixMaterial != null) && (!tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty())) { + if (tPrefixMaterial != null && !tPrefixMaterial.mPrefix.mFamiliarPrefixes.isEmpty()) { for (OrePrefixes tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) { tInputs.add(GT_OreDictUnificator.get(tPrefix, tPrefixMaterial.mMaterial.mMaterial, 1L)); } @@ -142,7 +150,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { CachedDefaultRecipe tNEIRecipe = new CachedDefaultRecipe(tRecipe); for (ItemStack tStack : tInputs) { if (tNEIRecipe.contains(tNEIRecipe.mInputs, tStack)) { - this.arecipes.add(tNEIRecipe); + arecipes.add(tNEIRecipe); break; } } @@ -151,46 +159,51 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { CachedDefaultRecipe tNEIRecipe; } + @Override public String getOverlayIdentifier() { - return this.mRecipeMap.mNEIName; + return mRecipeMap.mNEIName; } + @Override public void drawBackground(int recipe) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GuiDraw.changeTexture(getGuiTexture()); GuiDraw.drawTexturedModalRect(-4, -8, 1, 3, 174, 78); } + @Override public int recipiesPerPage() { return 1; } + @Override public String getRecipeName() { - return GT_LanguageManager.getTranslation(this.mRecipeMap.mUnlocalizedName); + return GT_LanguageManager.getTranslation(mRecipeMap.mUnlocalizedName); } + @Override public String getGuiTexture() { // return "gregtech:textures/gui/" + this.mRecipeMap.mUnlocalizedName + ".png"; - return this.mRecipeMap.mNEIGUIPath; + return mRecipeMap.mNEIGUIPath; } + @Override public List<String> handleItemTooltip(GuiRecipe gui, ItemStack aStack, List<String> currenttip, int aRecipeIndex) { - CachedRecipe tObject = this.arecipes.get(aRecipeIndex); - if ((tObject instanceof CachedDefaultRecipe)) { + TemplateRecipeHandler.CachedRecipe tObject = arecipes.get(aRecipeIndex); + if (tObject instanceof CachedDefaultRecipe) { CachedDefaultRecipe tRecipe = (CachedDefaultRecipe) tObject; for (PositionedStack tStack : tRecipe.mOutputs) { if (aStack == tStack.item) { - if ((!(tStack instanceof FixedPositionedStack)) || (((FixedPositionedStack) tStack).mChance <= 0) || (((FixedPositionedStack) tStack).mChance == 10000)) { + if (!(tStack instanceof FixedPositionedStack) || ((FixedPositionedStack) tStack).mChance <= 0 || ((FixedPositionedStack) tStack).mChance == 10000) { break; } - currenttip.add(trans("150","Chance: ") + ((FixedPositionedStack) tStack).mChance / 100 + "." + (((FixedPositionedStack) tStack).mChance % 100 < 10 ? "0" + ((FixedPositionedStack) tStack).mChance % 100 : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + "%"); + currenttip.add(trans("150","Chance: ") + ((FixedPositionedStack) tStack).mChance / 100 + '.' + (((FixedPositionedStack) tStack).mChance % 100 < 10 ? "0" + ((FixedPositionedStack) tStack).mChance % 100 : Integer.valueOf(((FixedPositionedStack) tStack).mChance % 100)) + '%'); break; } } for (PositionedStack tStack : tRecipe.mInputs) { if (aStack == tStack.item) { - if ((gregtech.api.enums.ItemList.Display_Fluid.isStackEqual(tStack.item, true, true)) || - (tStack.item.stackSize != 0)) { + if (Display_Fluid.isStackEqual(tStack.item, true, true) || tStack.item.stackSize != 0) { break; } currenttip.add(trans("151","Does not get consumed in the process")); @@ -201,22 +214,23 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { return currenttip; } - public void drawExtras(int aRecipeIndex) { - int tEUt = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mEUt; - int computation = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mDuration; - String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); + @Override + public void drawExtras(int aRecipeIndex) { + int tEUt = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mEUt; + int computation = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mDuration; + String[] recipeDesc = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); if (recipeDesc == null) { - int tSpecial = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; + int tSpecial = ((CachedDefaultRecipe) arecipes.get(aRecipeIndex)).mRecipe.mSpecialValue; short ampere=(short) (tSpecial & 0xFFFF),minComputationPerSec=(short)(tSpecial>>>16); if (tEUt != 0) { - drawText(10, 73, trans("152","Max Total: ") + ((1+((computation-minComputationPerSec)/minComputationPerSec)) * (long)tEUt * ampere * 20) + " EU", -16777216); - drawText(10, 83, trans("153","Usage: ") + ((long)tEUt*ampere) + " EU/t", -16777216); - if (this.mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10, 93, trans("154","Voltage: ") + tEUt + " EU", -16777216); - drawText(10, 103, trans("155","Amperage: ") + ampere, -16777216); + drawText(10, 73, trans("152","Max Total: ") + (1+ (computation-minComputationPerSec) /minComputationPerSec) * (long)tEUt * ampere * 20 + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + (long)tEUt*ampere + " EU/t", -16777216); + if (mRecipeMap.mShowVoltageAmperageInNEI) { + drawText(10, 93, trans("154","Voltage: ") + tEUt + " EU", -16777216); + drawText(10, 103, trans("155","Amperage: ") + ampere, -16777216); } else { - drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); - drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); + drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); + drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); } } drawText(10, 113, "Computation: "+computation, -16777216); @@ -224,7 +238,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { } else { int i = 0; for (String descLine : recipeDesc) { - drawText(10, 73 + 10 * i, descLine, -16777216); + drawText(10, 73 + 10 * i, descLine, -16777216); i++; } } @@ -232,6 +246,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { public static class GT_RectHandler implements IContainerInputHandler, IContainerTooltipHandler { + @Override public boolean mouseClicked(GuiContainer gui, int mousex, int mousey, int button) { if (canHandle(gui)) { if (button == 0) { @@ -244,19 +259,21 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { return false; } + @Override public boolean lastKeyTyped(GuiContainer gui, char keyChar, int keyCode) { return false; } public boolean canHandle(GuiContainer gui) { - return (((gui instanceof GT_GUIContainer_BasicMachine)) && (GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI)) || ((gui instanceof GT_GUIContainer_FusionReactor)) && (GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI))); + return gui instanceof GT_GUIContainer_BasicMachine && GT_Utility.isStringValid(((GT_GUIContainer_BasicMachine) gui).mNEI) || gui instanceof GT_GUIContainer_FusionReactor && GT_Utility.isStringValid(((GT_GUIContainer_FusionReactor) gui).mNEI); } + @Override public List<String> handleTooltip(GuiContainer gui, int mousex, int mousey, List<String> currenttip) { - if ((canHandle(gui)) && (currenttip.isEmpty())) { - if (gui instanceof GT_GUIContainer_BasicMachine && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + if (canHandle(gui) && currenttip.isEmpty()) { + if (gui instanceof GT_GUIContainer_BasicMachine && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - RecipeInfo.getGuiOffset(gui)[1]))) { currenttip.add("Recipes"); - } else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) { + } else if (gui instanceof GT_GUIContainer_FusionReactor && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - RecipeInfo.getGuiOffset(gui)[1]))) { currenttip.add("Recipes"); } @@ -266,41 +283,50 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { private boolean transferRect(GuiContainer gui, boolean usage) { if (gui instanceof GT_GUIContainer_BasicMachine) { - return (canHandle(gui)) && (new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI)); + return canHandle(gui) && new Rectangle(65, 13, 36, 18).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_BasicMachine) gui).getLeft() - RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_BasicMachine) gui).getTop() - RecipeInfo.getGuiOffset(gui)[1])) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_BasicMachine) gui).mNEI)); } else if (gui instanceof GT_GUIContainer_FusionReactor) { - return (canHandle(gui)) && (new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - codechicken.nei.recipe.RecipeInfo.getGuiOffset(gui)[1]))) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI)); + return canHandle(gui) && new Rectangle(145, 0, 24, 24).contains(new Point(GuiDraw.getMousePosition().x - ((GT_GUIContainer_FusionReactor) gui).getLeft() - RecipeInfo.getGuiOffset(gui)[0], GuiDraw.getMousePosition().y - ((GT_GUIContainer_FusionReactor) gui).getTop() - RecipeInfo.getGuiOffset(gui)[1])) && (usage ? GuiUsageRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI) : GuiCraftingRecipe.openRecipeGui(((GT_GUIContainer_FusionReactor) gui).mNEI)); } return false; } + @Override public List<String> handleItemDisplayName(GuiContainer gui, ItemStack itemstack, List<String> currenttip) { return currenttip; } + @Override public List<String> handleItemTooltip(GuiContainer gui, ItemStack itemstack, int mousex, int mousey, List<String> currenttip) { return currenttip; } + @Override public boolean keyTyped(GuiContainer gui, char keyChar, int keyCode) { return false; } + @Override public void onKeyTyped(GuiContainer gui, char keyChar, int keyID) { } + @Override public void onMouseClicked(GuiContainer gui, int mousex, int mousey, int button) { } + @Override public void onMouseUp(GuiContainer gui, int mousex, int mousey, int button) { } + @Override public boolean mouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { return false; } + @Override public void onMouseScrolled(GuiContainer gui, int mousex, int mousey, int scrolled) { } + @Override public void onMouseDragged(GuiContainer gui, int mousex, int mousey, int button, long heldTime) { } } @@ -315,22 +341,23 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { public FixedPositionedStack(Object object, int x, int y, int aChance) { super(object, x, y, true); - this.mChance = aChance; + mChance = aChance; } + @Override public void generatePermutations() { - if (this.permutated) { + if (permutated) { return; } ArrayList<ItemStack> tDisplayStacks = new ArrayList<>(); - for (ItemStack tStack : this.items) { + for (ItemStack tStack : items) { if (GT_Utility.isStackValid(tStack)) { if (tStack.getItemDamage() == 32767) { - List<ItemStack> permutations = codechicken.nei.ItemList.itemMap.get(tStack.getItem()); + List<ItemStack> permutations = ItemList.itemMap.get(tStack.getItem()); if (!permutations.isEmpty()) { ItemStack stack; - for (Iterator i$ = permutations.iterator(); i$.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, stack))) { - stack = (ItemStack) i$.next(); + for (Iterator<ItemStack> iterator = permutations.iterator(); iterator.hasNext(); tDisplayStacks.add(GT_Utility.copyAmount(tStack.stackSize, stack))) { + stack = iterator.next(); } } else { ItemStack base = new ItemStack(tStack.getItem(), tStack.stackSize); @@ -342,24 +369,23 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { } } } - this.items = tDisplayStacks.toArray(new ItemStack[0]); - if (this.items.length == 0) { - this.items = new ItemStack[]{new ItemStack(Blocks.fire)}; + items = tDisplayStacks.toArray(new ItemStack[tDisplayStacks.size()]); + if (items.length == 0) { + items = new ItemStack[]{new ItemStack(Blocks.fire)}; } - this.permutated = true; + permutated = true; setPermutationToRender(0); } } public class CachedDefaultRecipe - extends CachedRecipe { + extends TemplateRecipeHandler.CachedRecipe { public final GT_Recipe mRecipe; public final List<PositionedStack> mOutputs; public final List<PositionedStack> mInputs; public CachedDefaultRecipe(GT_Recipe aRecipe) { - super(); - this.mRecipe = aRecipe; + mRecipe = aRecipe; mOutputs = new ArrayList<>(); mInputs = new ArrayList<>(); @@ -370,7 +396,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { // break; //case 1: if (aRecipe.getRepresentativeInput(tStartIndex) != null) { - this.mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14+9)); + mInputs.add(new FixedPositionedStack(aRecipe.getRepresentativeInput(tStartIndex), 48, 14+9)); } //tStartIndex++; //break; @@ -567,7 +593,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { // tStartIndex++; //} if (aRecipe.mSpecialItems != null) { - this.mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); + mInputs.add(new FixedPositionedStack(aRecipe.mSpecialItems, 120, 52)); } //tStartIndex = 0; //switch (mRecipeMap.mUsualOutputCount) { @@ -575,7 +601,7 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { // break; //case 1: if (aRecipe.getOutput(tStartIndex) != null) { - this.mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14+9, aRecipe.getOutputChance(tStartIndex))); + mOutputs.add(new FixedPositionedStack(aRecipe.getOutput(tStartIndex), 102, 14+9, aRecipe.getOutputChance(tStartIndex))); } //tStartIndex++; //break; @@ -798,16 +824,19 @@ public class TT_NEI_ScannerHandler extends TemplateRecipeHandler { //} } + @Override public List<PositionedStack> getIngredients() { - return getCycledIngredients(cycleticks / 10, this.mInputs); + return getCycledIngredients(cycleticks / 10, mInputs); } + @Override public PositionedStack getResult() { return null; } + @Override public List<PositionedStack> getOtherStacks() { - return this.mOutputs; + return mOutputs; } } diff --git a/src/main/java/com/github/technus/tectech/network/Dispatcher.java b/src/main/java/com/github/technus/tectech/network/Dispatcher.java index b9b4d02fe5..cae93a7ce8 100644 --- a/src/main/java/com/github/technus/tectech/network/Dispatcher.java +++ b/src/main/java/com/github/technus/tectech/network/Dispatcher.java @@ -11,6 +11,7 @@ public class Dispatcher extends PacketDispatcher { super(Reference.MODID); } + @Override public void registerPackets() { //this.registerMessage(SpawnParticleFXMessage.SpawnParticleFXMessageHandler.class, SpawnParticleFXMessage.class); } diff --git a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java index 9321a1b2bc..92e0fa6822 100644 --- a/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/ClientProxy.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.proxy; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.entity.fx.BlockHint; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumGlassRender; @@ -9,8 +10,6 @@ import com.github.technus.tectech.thing.block.QuantumStuffRender; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Loader; -import gregtech.api.enums.Textures; -import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; @@ -27,12 +26,6 @@ import org.lwjgl.opengl.GL11; public class ClientProxy extends CommonProxy { @Override - public void addTexturePage(byte page){ - if(Textures.BlockIcons.casingTexturePages[page]==null) - Textures.BlockIcons.casingTexturePages[page]=new ITexture[128]; - } - - @Override public void registerRenderInfo() { QuantumGlassBlock.renderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(QuantumGlassBlock.renderID, new QuantumGlassRender()); @@ -40,7 +33,9 @@ public class ClientProxy extends CommonProxy { QuantumStuffBlock.renderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(QuantumStuffBlock.renderID, new QuantumStuffRender()); - if(Loader.isModLoaded("openmodularturrets")) new TT_turret_loader().run(); + if(Loader.isModLoaded("openmodularturrets")) { + new TT_turret_loader().run(); + } } @Override @@ -85,7 +80,7 @@ public class ClientProxy extends CommonProxy { boolean origFont = fontRenderer.getUnicodeFlag(); - if ((mc.gameSettings.guiScale) == 3) { + if (mc.gameSettings.guiScale == 3) { fontRenderer.setUnicodeFlag(true); float dist = 0.08F; y--; @@ -101,8 +96,9 @@ public class ClientProxy extends CommonProxy { dist = -dist; } fontRenderer.setUnicodeFlag(origFont); - } else + } else { fontRenderer.drawSplitString(str, x, y, maxWidth, color); + } } @Override @@ -112,4 +108,9 @@ public class ClientProxy extends CommonProxy { chat.printChatMessage(new ChatComponentText(s)); } } + + @Override + public void playSound(IGregTechTileEntity base,String name) { + base.getWorld().playSoundEffect(base.getXCoord(),base.getYCoord(),base.getZCoord(), Reference.MODID+':'+name, 1, 1); + } } diff --git a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java index 6bc3fb026e..271887d579 100644 --- a/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java +++ b/src/main/java/com/github/technus/tectech/proxy/CommonProxy.java @@ -9,8 +9,6 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; public class CommonProxy implements IGuiHandler { - public void addTexturePage(byte page){} - public void registerRenderInfo() {} public void hint_particle(World world, int x, int y, int z, Block block, int meta){} @@ -42,4 +40,6 @@ public class CommonProxy implements IGuiHandler { } public void printInchat(String... strings){} + + public void playSound(IGregTechTileEntity base,String name){} } diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java index 439a28e384..ff26894729 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipe.java @@ -17,7 +17,9 @@ import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; public class TT_recipe extends GT_Recipe { public static final String E_RECIPE_ID = "eRecipeID"; - public final cElementalDefinitionStackMap input[],output[], eCatalyst[]; + public final cElementalDefinitionStackMap[] input; + public final cElementalDefinitionStackMap[] output; + public final cElementalDefinitionStackMap[] eCatalyst; public final AdditionalCheck additionalCheck; public TT_recipe(boolean aOptimize, @@ -40,13 +42,17 @@ public class TT_recipe extends GT_Recipe { } public boolean EMisRecipeInputEqual(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap[] in, cElementalInstanceStackMap[] catalyst) { - if(additionalCheck !=null && !additionalCheck.check(this,consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,catalyst)) return false; - if (this.eCatalyst != null) { - if (catalyst != null && catalyst.length >= this.eCatalyst.length) { - for (int i = 0; i < this.eCatalyst.length; i++) { - if (this.eCatalyst[i] != null && this.eCatalyst[i].hasStacks()) { + if(additionalCheck !=null && !additionalCheck.check(this,consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,catalyst)) { + return false; + } + if (eCatalyst != null) { + if (catalyst != null && catalyst.length >= eCatalyst.length) { + for (int i = 0; i < eCatalyst.length; i++) { + if (eCatalyst[i] != null && eCatalyst[i].hasStacks()) { if (catalyst[i] != null && catalyst[i].hasStacks()) { - if (!catalyst[i].removeAllAmounts(true, this.eCatalyst[i])) return false; + if (!catalyst[i].removeAllAmounts(true, eCatalyst[i])) { + return false; + } } else { return false; } @@ -61,7 +67,9 @@ public class TT_recipe extends GT_Recipe { for (int i = 0; i < input.length; i++) { if (input[i] != null && input[i].hasStacks()) { if (in[i] != null && in[i].hasStacks()) { - if (!in[i].removeAllAmounts(consume, input[i])) return false; + if (!in[i].removeAllAmounts(consume, input[i])) { + return false; + } } else { return false; } @@ -79,13 +87,17 @@ public class TT_recipe extends GT_Recipe { } public boolean EMisRecipeInputEqualConsumeFromOne(boolean consume, boolean doNotCheckStackSizes, ItemStack[] itemStacks, FluidStack[] fluidStacks, cElementalInstanceStackMap in, cElementalInstanceStackMap[] catalyst) { - if(additionalCheck !=null && !additionalCheck.check(this,consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,catalyst)) return false; - if (this.eCatalyst != null) { - if (catalyst != null && catalyst.length >= this.eCatalyst.length) { - for (int i = 0; i < this.eCatalyst.length; i++) { - if (this.eCatalyst[i] != null && this.eCatalyst[i].hasStacks()) { + if(additionalCheck !=null && !additionalCheck.check(this,consume,doNotCheckStackSizes,itemStacks,fluidStacks,in,catalyst)) { + return false; + } + if (eCatalyst != null) { + if (catalyst != null && catalyst.length >= eCatalyst.length) { + for (int i = 0; i < eCatalyst.length; i++) { + if (eCatalyst[i] != null && eCatalyst[i].hasStacks()) { if (catalyst[i] != null && catalyst[i].hasStacks()) { - if (!catalyst[i].removeAllAmounts(true, this.eCatalyst[i])) return false; + if (!catalyst[i].removeAllAmounts(true, eCatalyst[i])) { + return false; + } } else { return false; } @@ -97,10 +109,12 @@ public class TT_recipe extends GT_Recipe { } if (input != null) { if (in != null) { - for (int i = 0; i < input.length; i++) { - if (input[i] != null && input[i].hasStacks()) { + for (cElementalDefinitionStackMap anInput : input) { + if (anInput != null && anInput.hasStacks()) { if (in.hasStacks()) { - if (!in.removeAllAmounts(consume, input[i])) return false; + if (!in.removeAllAmounts(consume, anInput)) { + return false; + } } else { return false; } @@ -134,7 +148,9 @@ public class TT_recipe extends GT_Recipe { } public T findRecipe(ItemStack dataHandler){ - if(dataHandler==null || dataHandler.stackTagCompound==null) return null; + if(dataHandler==null || dataHandler.stackTagCompound==null) { + return null; + } return mRecipeMap.get(dataHandler.stackTagCompound.getString(E_RECIPE_ID)); } @@ -216,11 +232,15 @@ public class TT_recipe extends GT_Recipe { } public T findRecipe(ItemStack dataHandler){ - if(dataHandler==null || dataHandler.stackTagCompound==null) return null; + if(dataHandler==null || dataHandler.stackTagCompound==null) { + return null; + } try { return mRecipeMap.get(cElementalDefinition.fromNBT(dataHandler.stackTagCompound.getCompoundTag(E_RECIPE_ID))); }catch (Exception e){ - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return null; } } diff --git a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java index 6324854082..5f69cbbc6d 100644 --- a/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java +++ b/src/main/java/com/github/technus/tectech/recipe/TT_recipeAdder.java @@ -6,7 +6,7 @@ import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefiniti import com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition; import com.github.technus.tectech.thing.item.ElementalDefinitionContainer_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafting; -import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_machine; +import com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine; import gregtech.api.enums.ItemList; import gregtech.api.util.GT_Recipe; import gregtech.common.GT_RecipeAdder; @@ -18,9 +18,13 @@ public class TT_recipeAdder extends GT_RecipeAdder { public static final FluidStack[] nullFluid=new FluidStack[0]; public static boolean addResearchableAssemblylineRecipe(ItemStack aResearchItem, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, ItemStack[] aInputs, FluidStack[] aFluidInputs, ItemStack aOutput, int assDuration, int assEUt) { - if(aInputs==null)aInputs=nullItem; - if(aFluidInputs==null)aFluidInputs=nullFluid; - if ((aResearchItem==null)||(totalComputationRequired<=0)||(aOutput == null) || aInputs.length>15) { + if(aInputs==null) { + aInputs = nullItem; + } + if(aFluidInputs==null) { + aFluidInputs = nullFluid; + } + if (aResearchItem==null || totalComputationRequired<=0 || aOutput == null || aInputs.length>15) { return false; } for(ItemStack tItem : aInputs){ @@ -28,11 +32,17 @@ public class TT_recipeAdder extends GT_RecipeAdder { TecTech.Logger.error("addResearchableAssemblingLineRecipe "+aResearchItem.getDisplayName()+" --> "+aOutput.getUnlocalizedName()+" there is some null item in that recipe"); } } - if(researchAmperage<=0) researchAmperage=1; - else if(researchAmperage > Short.MAX_VALUE) researchAmperage=Short.MAX_VALUE; - if(computationRequiredPerSec<=0) computationRequiredPerSec=1; - else if(computationRequiredPerSec > Short.MAX_VALUE) computationRequiredPerSec=Short.MAX_VALUE; - TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result")}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); + if(researchAmperage<=0) { + researchAmperage = 1; + } else if(researchAmperage > Short.MAX_VALUE) { + researchAmperage = Short.MAX_VALUE; + } + if(computationRequiredPerSec<=0) { + computationRequiredPerSec = 1; + } else if(computationRequiredPerSec > Short.MAX_VALUE) { + computationRequiredPerSec = Short.MAX_VALUE; + } + TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Writes Research result")}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); GT_Recipe.GT_Recipe_Map.sAssemblylineVisualRecipes.addFakeRecipe(false, aInputs, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataStick.getWithName(1L, "Reads Research result")}, aFluidInputs, null, assDuration, assEUt, 0,true); GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes.add(new GT_Recipe.GT_Recipe_AssemblyLine( aResearchItem, 0/*ignored*/, aInputs, aFluidInputs, aOutput, assDuration, assEUt)); return true; @@ -49,9 +59,13 @@ public class TT_recipeAdder extends GT_RecipeAdder { ItemStack aResearchItem, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, ItemStack[] aInputs, FluidStack[] aFluidInputs, cElementalDefinitionStackMap[] eInputs, ItemStack aOutput, int machineDuration, int machineEUt, int machineAmperage) { - if(aInputs==null)aInputs=nullItem; - if(aFluidInputs==null)aFluidInputs=nullFluid; - if ((aResearchItem==null)||(totalComputationRequired<=0)||(aOutput == null)) { + if(aInputs==null) { + aInputs = nullItem; + } + if(aFluidInputs==null) { + aFluidInputs = nullFluid; + } + if (aResearchItem==null || totalComputationRequired<=0 || aOutput == null) { return false; } for(ItemStack tItem : aInputs){ @@ -59,11 +73,17 @@ public class TT_recipeAdder extends GT_RecipeAdder { TecTech.Logger.error("addResearchableEMmachineRecipe "+aResearchItem.getDisplayName()+" --> "+aOutput.getUnlocalizedName()+" there is some null item in that recipe"); } } - if(researchAmperage<=0) researchAmperage=1; - else if(researchAmperage > Short.MAX_VALUE) researchAmperage=Short.MAX_VALUE; - if(computationRequiredPerSec<=0) computationRequiredPerSec=1; - else if(computationRequiredPerSec > Short.MAX_VALUE) computationRequiredPerSec=Short.MAX_VALUE; - TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_machine.machine)}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); + if(researchAmperage<=0) { + researchAmperage = 1; + } else if(researchAmperage > Short.MAX_VALUE) { + researchAmperage = Short.MAX_VALUE; + } + if(computationRequiredPerSec<=0) { + computationRequiredPerSec = 1; + } else if(computationRequiredPerSec > Short.MAX_VALUE) { + computationRequiredPerSec = Short.MAX_VALUE; + } + TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_machine.machine)}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); TT_recipe.TT_Recipe_Map.sMachineRecipes.add(new TT_recipe.TT_assLineRecipe(false,aResearchItem,aInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Reads Research result")}, aFluidInputs,machineDuration,machineEUt,machineAmperage,eInputs)); return true; @@ -73,14 +93,20 @@ public class TT_recipeAdder extends GT_RecipeAdder { ItemStack aResearchItem, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, cElementalDefinitionStackMap[] eInputs, cElementalDefinitionStackMap[] catalyst, TT_recipe.AdditionalCheck check, ItemStack aOutput, int crafterDuration, int crafterEUt, int crafterAmperage) { - if ((aResearchItem==null)||(totalComputationRequired<=0)||(aOutput == null)) { + if (aResearchItem==null || totalComputationRequired<=0 || aOutput == null) { return false; } - if(researchAmperage<=0) researchAmperage=1; - else if(researchAmperage > Short.MAX_VALUE) researchAmperage=Short.MAX_VALUE; - if(computationRequiredPerSec<=0) computationRequiredPerSec=1; - else if(computationRequiredPerSec > Short.MAX_VALUE) computationRequiredPerSec=Short.MAX_VALUE; - TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_crafting.crafter)}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); + if(researchAmperage<=0) { + researchAmperage = 1; + } else if(researchAmperage > Short.MAX_VALUE) { + researchAmperage = Short.MAX_VALUE; + } + if(computationRequiredPerSec<=0) { + computationRequiredPerSec = 1; + } else if(computationRequiredPerSec > Short.MAX_VALUE) { + computationRequiredPerSec = Short.MAX_VALUE; + } + TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.addFakeRecipe(false, new ItemStack[]{aResearchItem}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_crafting.crafter)}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); TT_recipe.TT_Recipe_Map.sCrafterRecipes.add(new TT_recipe.TT_assLineRecipe(false,aResearchItem,null,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Reads Research result")}, null,crafterDuration,crafterEUt,crafterAmperage,eInputs,null,catalyst,check)); return true; @@ -90,9 +116,13 @@ public class TT_recipeAdder extends GT_RecipeAdder { iElementalDefinition aResearchEM, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, ItemStack[] aInputs, FluidStack[] aFluidInputs, cElementalDefinitionStackMap[] eInputs, ItemStack aOutput, int machineDuration, int machineEUt, int machineAmperage) { - if(aInputs==null)aInputs=nullItem; - if(aFluidInputs==null)aFluidInputs=nullFluid; - if ((aResearchEM==null)||(totalComputationRequired<=0)||(aOutput == null)) { + if(aInputs==null) { + aInputs = nullItem; + } + if(aFluidInputs==null) { + aFluidInputs = nullFluid; + } + if (aResearchEM==null || totalComputationRequired<=0 || aOutput == null) { return false; } for(ItemStack tItem : aInputs){ @@ -100,13 +130,19 @@ public class TT_recipeAdder extends GT_RecipeAdder { TecTech.Logger.error("addScannableEMmachineRecipe "+aResearchEM+" --> "+aOutput.getUnlocalizedName()+" there is some null item in that recipe"); } } - if(researchAmperage<=0) researchAmperage=1; - else if(researchAmperage > Short.MAX_VALUE) researchAmperage=Short.MAX_VALUE; - if(computationRequiredPerSec<=0) computationRequiredPerSec=1; - else if(computationRequiredPerSec > Short.MAX_VALUE) computationRequiredPerSec=Short.MAX_VALUE; + if(researchAmperage<=0) { + researchAmperage = 1; + } else if(researchAmperage > Short.MAX_VALUE) { + researchAmperage = Short.MAX_VALUE; + } + if(computationRequiredPerSec<=0) { + computationRequiredPerSec = 1; + } else if(computationRequiredPerSec > Short.MAX_VALUE) { + computationRequiredPerSec = Short.MAX_VALUE; + } ItemStack placeholder=new ItemStack(ElementalDefinitionContainer_EM.INSTANCE); ElementalDefinitionContainer_EM.setContent(placeholder,new cElementalDefinitionStackMap(new cElementalDefinitionStack(aResearchEM,1))); - GT_Recipe thisRecipe=TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes.addFakeRecipe(false, new ItemStack[]{placeholder}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_machine.machine)}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); + GT_Recipe thisRecipe=TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes.addFakeRecipe(false, new ItemStack[]{placeholder}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_machine.machine)}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.add(new TT_recipe.TT_EMRecipe(false,thisRecipe,aResearchEM,aInputs,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Reads Research result")}, aFluidInputs,machineDuration,machineEUt,machineAmperage,eInputs)); return true; @@ -116,16 +152,22 @@ public class TT_recipeAdder extends GT_RecipeAdder { iElementalDefinition aResearchEM, int totalComputationRequired, int computationRequiredPerSec, int researchEUt, int researchAmperage, cElementalDefinitionStackMap[] eInputs, cElementalDefinitionStackMap[] catalyst, TT_recipe.AdditionalCheck check, ItemStack aOutput, int crafterDuration, int crafterEUt, int crafterAmperage) { - if ((aResearchEM==null)||(totalComputationRequired<=0)||(aOutput == null)) { + if (aResearchEM==null || totalComputationRequired<=0 || aOutput == null) { return false; } - if(researchAmperage<=0) researchAmperage=1; - else if(researchAmperage > Short.MAX_VALUE) researchAmperage=Short.MAX_VALUE; - if(computationRequiredPerSec<=0) computationRequiredPerSec=1; - else if(computationRequiredPerSec > Short.MAX_VALUE) computationRequiredPerSec=Short.MAX_VALUE; + if(researchAmperage<=0) { + researchAmperage = 1; + } else if(researchAmperage > Short.MAX_VALUE) { + researchAmperage = Short.MAX_VALUE; + } + if(computationRequiredPerSec<=0) { + computationRequiredPerSec = 1; + } else if(computationRequiredPerSec > Short.MAX_VALUE) { + computationRequiredPerSec = Short.MAX_VALUE; + } ItemStack placeholder=new ItemStack(ElementalDefinitionContainer_EM.INSTANCE); ElementalDefinitionContainer_EM.setContent(placeholder,new cElementalDefinitionStackMap(new cElementalDefinitionStack(aResearchEM,1))); - GT_Recipe thisRecipe=TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes.addFakeRecipe(false, new ItemStack[]{placeholder}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_crafting.crafter)}, null, null, totalComputationRequired, researchEUt, researchAmperage|(computationRequiredPerSec<<16)); + GT_Recipe thisRecipe=TT_recipe.GT_Recipe_MapTT.sScannableFakeRecipes.addFakeRecipe(false, new ItemStack[]{placeholder}, new ItemStack[]{aOutput}, new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Writes Research result for "+ GT_MetaTileEntity_EM_crafting.crafter)}, null, null, totalComputationRequired, researchEUt, researchAmperage| computationRequiredPerSec<<16); TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.add(new TT_recipe.TT_EMRecipe(false,thisRecipe,aResearchEM,null,new ItemStack[]{aOutput},new ItemStack[]{ItemList.Tool_DataOrb.getWithName(1L, "Reads Research result")}, null,crafterDuration,crafterEUt,crafterAmperage,eInputs,null,catalyst,check)); return true; diff --git a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java index 543f6124a6..49e186dfb5 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -50,10 +50,12 @@ public enum CustomItemList implements IItemContainer { Machine_Multi_Stabilizer, Machine_Multi_EMCrafter, Machine_Multi_Wormhole, Machine_Multi_Annihilation, Machine_Multi_BHG, - hint_0,hint_1,hint_2,hint_3,hint_4,hint_5,hint_6,hint_7,hint_8,hint_9,hint_10,hint_11, hint_general,hint_air,hint_noAir,hint_error; + hint_0,hint_1,hint_2,hint_3,hint_4,hint_5,hint_6,hint_7,hint_8,hint_9,hint_10,hint_11, hint_general,hint_air,hint_noAir,hint_error, + scanContainer,parametrizerMemory; - private ItemStack mStack = null; + + private ItemStack mStack; private boolean mHasNotBeenSet = true; //public static Fluid sOilExtraHeavy, sOilHeavy, sOilMedium, sOilLight, sNaturalGas; @@ -61,7 +63,9 @@ public enum CustomItemList implements IItemContainer { @Override public IItemContainer set(Item aItem) { mHasNotBeenSet = false; - if (aItem == null) return this; + if (aItem == null) { + return this; + } ItemStack aStack = new ItemStack(aItem, 1, 0); mStack = GT_Utility.copyAmount(1, aStack); return this; @@ -76,16 +80,20 @@ public enum CustomItemList implements IItemContainer { @Override public Item getItem() { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return null; + } + if (GT_Utility.isStackInvalid(mStack)) { + return null; + } return mStack.getItem(); } @Override public Block getBlock() { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } return GT_Utility.getBlockFromStack(new ItemStack(getItem())); } @@ -101,46 +109,62 @@ public enum CustomItemList implements IItemContainer { @Override public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { - if (GT_Utility.isStackInvalid(aStack)) return false; + if (GT_Utility.isStackInvalid(aStack)) { + return false; + } return GT_Utility.areUnificationsEqual((ItemStack) aStack, aWildcard ? getWildcard(1) : get(1), aIgnoreNBT); } @Override public ItemStack get(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } return GT_Utility.copyAmount(aAmount, GT_OreDictUnificator.get(mStack)); } @Override public ItemStack getWildcard(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } return GT_Utility.copyAmountAndMetaData(aAmount, W, GT_OreDictUnificator.get(mStack)); } @Override public ItemStack getUndamaged(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } return GT_Utility.copyAmountAndMetaData(aAmount, 0, GT_OreDictUnificator.get(mStack)); } @Override public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } return GT_Utility.copyAmountAndMetaData(aAmount, mStack.getMaxDamage() - 1, GT_OreDictUnificator.get(mStack)); } @Override public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) { ItemStack rStack = get(1, aReplacements); - if (GT_Utility.isStackInvalid(rStack)) return null; + if (GT_Utility.isStackInvalid(rStack)) { + return null; + } rStack.setStackDisplayName(aDisplayName); return GT_Utility.copyAmount(aAmount, rStack); } @@ -148,32 +172,43 @@ public enum CustomItemList implements IItemContainer { @Override public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements) { ItemStack rStack = get(1, aReplacements); - if (GT_Utility.isStackInvalid(rStack)) return null; + if (GT_Utility.isStackInvalid(rStack)) { + return null; + } GT_ModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); return GT_Utility.copyAmount(aAmount, rStack); } @Override public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - if (GT_Utility.isStackInvalid(mStack)) return GT_Utility.copyAmount(aAmount, aReplacements); + } + if (GT_Utility.isStackInvalid(mStack)) { + return GT_Utility.copyAmount(aAmount, aReplacements); + } return GT_Utility.copyAmountAndMetaData(aAmount, aMetaValue, GT_OreDictUnificator.get(mStack)); } @Override public IItemContainer registerOre(Object... aOreNames) { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, get(1)); + } + for (Object tOreName : aOreNames) { + GT_OreDictUnificator.registerOre(tOreName, get(1)); + } return this; } @Override public IItemContainer registerWildcardAsOre(Object... aOreNames) { - if (mHasNotBeenSet) + if (mHasNotBeenSet) { throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); - for (Object tOreName : aOreNames) GT_OreDictUnificator.registerOre(tOreName, getWildcard(1)); + } + 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/thing/block/QuantumGlassBlock.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java index 88ad7cfbcb..44018a7392 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassBlock.java @@ -24,7 +24,7 @@ public final class QuantumGlassBlock extends BlockBase { public QuantumGlassBlock() { super(Material.iron); - this.setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockBounds(0, 0, 0, 1, 1, 1); setBlockName("quantumGlass"); setHarvestLevel("wrench", 3); setHardness(50); @@ -59,11 +59,13 @@ public final class QuantumGlassBlock extends BlockBase { return false; } + @Override @SideOnly(Side.CLIENT) public int getRenderBlockPass() { return 1; } + @Override public boolean renderAsNormalBlock() { return false; } @@ -77,14 +79,14 @@ public final class QuantumGlassBlock extends BlockBase { @Override public int getRenderType() { - return QuantumGlassBlock.renderID; + return renderID; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { super.registerBlockIcons(p_149651_1_); - stuff = this.blockIcon; + stuff = blockIcon; } public static void run() { diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassItem.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassItem.java index 171e8db6e9..aff5f8bbb7 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassItem.java +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassItem.java @@ -16,8 +16,8 @@ import static com.github.technus.tectech.CommonValues.TEC_MARK_EM; public class QuantumGlassItem extends ItemBlock { public static QuantumGlassItem INSTANCE; - public QuantumGlassItem(Block b) { - super(b); + public QuantumGlassItem(Block block) { + super(block); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassRender.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassRender.java index 0cbac64692..cec06002fa 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassRender.java +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumGlassRender.java @@ -13,9 +13,6 @@ import org.lwjgl.opengl.GL11; */ public final class QuantumGlassRender implements ISimpleBlockRenderingHandler { - public QuantumGlassRender() { - } - @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffBlock.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffBlock.java index 9480d28c75..bd26c838ba 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffBlock.java +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffBlock.java @@ -27,7 +27,7 @@ public final class QuantumStuffBlock extends BlockBase { public QuantumStuffBlock() { super(Material.iron); - this.setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockBounds(0, 0, 0, 1, 1, 1); setBlockName("quantumStuff"); setHarvestLevel("wrench", 0); setHardness(500); @@ -45,7 +45,7 @@ public final class QuantumStuffBlock extends BlockBase { @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { super.registerBlockIcons(p_149651_1_); - stuff = this.blockIcon; + stuff = blockIcon; } @Override @@ -68,15 +68,18 @@ public final class QuantumStuffBlock extends BlockBase { return false; } + @Override @SideOnly(Side.CLIENT) public int getRenderBlockPass() { return 1; } + @Override public boolean renderAsNormalBlock() { return false; } + @Override @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { return false; @@ -84,7 +87,7 @@ public final class QuantumStuffBlock extends BlockBase { @Override public int getRenderType() { - return QuantumStuffBlock.renderID; + return renderID; } public static void run() { diff --git a/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffRender.java b/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffRender.java index 7bcc52af43..add97c46a1 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffRender.java +++ b/src/main/java/com/github/technus/tectech/thing/block/QuantumStuffRender.java @@ -16,8 +16,6 @@ import org.lwjgl.opengl.GL11; public final class QuantumStuffRender implements ISimpleBlockRenderingHandler { private static Tessellator tes=Tessellator.instance; - public QuantumStuffRender() {} - @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { GL11.glTranslatef(-0.5F, -0.5F, -0.5F); @@ -52,6 +50,7 @@ public final class QuantumStuffRender implements ISimpleBlockRenderingHandler { GL11.glPopMatrix(); } + @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { //renderer.renderStandardBlock(block, x, y, z); GL11.glPushMatrix(); @@ -59,8 +58,8 @@ public final class QuantumStuffRender implements ISimpleBlockRenderingHandler { tes.setBrightness(15728880); IIcon side = QuantumStuffBlock.stuff; for(int i=0;i<6;i++){ - float b = 1 - (TecTech.Rnd.nextFloat() / 4f), g = b - (TecTech.Rnd.nextFloat() / 4f), r = g - (TecTech.Rnd.nextFloat() / 4f) - 0.25f; - tes.setColorOpaque_F(r, g, b); + float f = 1 - TecTech.Rnd.nextFloat() / 4f, g = f - TecTech.Rnd.nextFloat() / 4f, r = g - TecTech.Rnd.nextFloat() / 4f - 0.25f; + tes.setColorOpaque_F(r, g, f); float rotX=TecTech.Rnd.nextFloat()*2*(float) Math.PI,rotY=TecTech.Rnd.nextFloat()*2*(float) Math.PI,rotZ=TecTech.Rnd.nextFloat()*2*(float) Math.PI; tesAbuse(x,y,z,-1.425f,-1.425f,.1f,rotX,rotY,rotZ,side.getMinU(), side.getMaxV()); tesAbuse(x,y,z,-1.425f,1.425f,.1f,rotX,rotY,rotZ,side.getMinU(), side.getMinV()); diff --git a/src/main/java/com/github/technus/tectech/thing/block/ReactorSimBlock.java b/src/main/java/com/github/technus/tectech/thing/block/ReactorSimBlock.java index 2b3d78cd49..ebe5808a4a 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/ReactorSimBlock.java +++ b/src/main/java/com/github/technus/tectech/thing/block/ReactorSimBlock.java @@ -28,7 +28,7 @@ public class ReactorSimBlock extends Block implements ITileEntityProvider { public ReactorSimBlock() { super(Material.iron); - this.setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockBounds(0, 0, 0, 1, 1, 1); setBlockName("reactorSim"); setHarvestLevel("wrench", 3); setHardness(50); @@ -57,7 +57,7 @@ public class ReactorSimBlock extends Block implements ITileEntityProvider { @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { super.registerBlockIcons(p_149651_1_); - stuff = this.blockIcon; + stuff = blockIcon; } public static void run() { @@ -71,6 +71,7 @@ public class ReactorSimBlock extends Block implements ITileEntityProvider { return new ReactorSimTileEntity(); } + @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float a, float b, float c) { if(entityPlayer.isSneaking()) { return false; @@ -80,6 +81,7 @@ public class ReactorSimBlock extends Block implements ITileEntityProvider { } } + @Override public void onNeighborBlockChange(World world, int x, int y, int z, Block srcBlock) { TileEntity te = world.getTileEntity(x,y,z); if(te instanceof TileEntityBlock) { diff --git a/src/main/java/com/github/technus/tectech/thing/block/ReactorSimItem.java b/src/main/java/com/github/technus/tectech/thing/block/ReactorSimItem.java index c21820eea5..4625dca434 100644 --- a/src/main/java/com/github/technus/tectech/thing/block/ReactorSimItem.java +++ b/src/main/java/com/github/technus/tectech/thing/block/ReactorSimItem.java @@ -16,8 +16,8 @@ import static com.github.technus.tectech.CommonValues.TEC_MARK_GENERAL; public class ReactorSimItem extends ItemBlock { public static QuantumGlassItem INSTANCE; - public ReactorSimItem(Block b) { - super(b); + public ReactorSimItem(Block block) { + super(block); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java index 15f9adb188..2ea22b625d 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_CasingsTT.java @@ -24,14 +24,14 @@ import static com.github.technus.tectech.TecTech.tectechTexturePage1; */ public class GT_Block_CasingsTT extends GT_Block_Casings_Abstract { public static final byte texturePage=tectechTexturePage1; - public final static short textureOffset = texturePage << 7;//Start of PAGE 8 (which is the 9th page) (8*128) + public static final short textureOffset = texturePage << 7;//Start of PAGE 8 (which is the 9th page) (8*128) private static IIcon eM0, eM1, eM1s, eM2, eM2s, eM3, eM3s, eM4, eM5, eM6, eM7, eM7s, eM8, eM9, eM10, eM11, eM12, eM13, eM14; - private static IIcon debug[] = new IIcon[6]; + private static IIcon[] debug = new IIcon[6]; public GT_Block_CasingsTT() { super(GT_Item_CasingsTT.class, "gt.blockcasingsTT", GT_Material_Casings.INSTANCE); - for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.casingTexturePages[texturePage][i] = new GT_CopiedBlockTexture(this, 6, i); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[texturePage][b] = new GT_CopiedBlockTexture(this, 6, b); /*IMPORTANT for block recoloring**/ } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "High Power Casing"); @@ -118,18 +118,25 @@ public class GT_Block_CasingsTT extends GT_Block_Casings_Abstract { debug[5] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_5"); } + @Override public IIcon getIcon(int aSide, int aMeta) { switch (aMeta) { case 0: return eM0; case 1: - if (aSide < 2) return eM1; + if (aSide < 2) { + return eM1; + } return eM1s; case 2: - if (aSide < 2) return eM2; + if (aSide < 2) { + return eM2; + } return eM2s; case 3: - if (aSide < 2) return eM3; + if (aSide < 2) { + return eM3; + } return eM3s; case 4: return eM4; @@ -138,7 +145,9 @@ public class GT_Block_CasingsTT extends GT_Block_Casings_Abstract { case 6: return eM6; case 7: - if (aSide < 2) return eM7; + if (aSide < 2) { + return eM7; + } return eM7s; case 8: return eM8; @@ -161,6 +170,7 @@ public class GT_Block_CasingsTT extends GT_Block_Casings_Abstract { } } + @Override @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java index 4e4d6ba3b3..5112f156c7 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Block_HintTT.java @@ -20,7 +20,7 @@ import java.util.List; * Created by danie_000 on 03.10.2016. */ public class GT_Block_HintTT extends GT_Block_Casings_Abstract { - private static IIcon hint[] = new IIcon[16]; + private static IIcon[] hint = new IIcon[16]; public GT_Block_HintTT() { super(GT_Item_HintTT.class, "gt.blockhintTT", GT_Material_Casings.INSTANCE); @@ -82,10 +82,12 @@ public class GT_Block_HintTT extends GT_Block_Casings_Abstract { hint[15] = aIconRegister.registerIcon(Reference.MODID+":iconsets/HINT_ERROR"); } + @Override public IIcon getIcon(int aSide, int aMeta) { return hint[aMeta]; } + @Override @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); diff --git a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsTT.java b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsTT.java index 88bbbca39d..6751e4b24b 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsTT.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/GT_Item_CasingsTT.java @@ -21,8 +21,11 @@ public class GT_Item_CasingsTT extends GT_Item_Casings_Abstract { @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { - if(aStack.getItemDamage()>0 && aStack.getItemDamage()<15) aList.add(TEC_MARK_EM); - else aList.add(TEC_MARK_GENERAL); + if(aStack.getItemDamage()>0 && aStack.getItemDamage()<15) { + aList.add(TEC_MARK_EM); + } else { + aList.add(TEC_MARK_GENERAL); + } switch (aStack.getItemDamage()) { case 0://"High Power Casing" aList.add("Well suited for high power applications."); diff --git a/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java b/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java index 98f53cfe30..4526a98f2e 100644 --- a/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java +++ b/src/main/java/com/github/technus/tectech/thing/casing/TT_Container_Casings.java @@ -5,7 +5,9 @@ import net.minecraft.block.Block; /** * Created by danie_000 on 03.10.2016. */ -public class TT_Container_Casings { +public final class TT_Container_Casings { public static Block sBlockCasingsTT; public static Block sHintCasingsTT; + + private TT_Container_Casings() {} } diff --git a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java index 0b2101d145..ab83518607 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java @@ -31,13 +31,12 @@ import static gregtech.api.GregTech_API.sBlockCasings1; /** * Created by Tec on 15.03.2017. */ -public class ConstructableTriggerItem extends Item { +public final class ConstructableTriggerItem extends Item { public static ConstructableTriggerItem INSTANCE; public static HashMap<String,MultiblockInfoContainer> multiblockMap= new HashMap<>(); private ConstructableTriggerItem() { - super(); setUnlocalizedName("em.debugBuilder"); setTextureName(MODID + ":itemDebugBuilder"); } @@ -45,7 +44,9 @@ public class ConstructableTriggerItem extends Item { @Override public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int aSide, float hitX, float hitY, float hitZ) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if(tTileEntity==null || aPlayer instanceof FakePlayer) return aPlayer instanceof EntityPlayerMP; + if(tTileEntity==null || aPlayer instanceof FakePlayer) { + return aPlayer instanceof EntityPlayerMP; + } if (aPlayer instanceof EntityPlayerMP) { //struct gen if (aPlayer.isSneaking() && aPlayer.capabilities.isCreativeMode) { @@ -150,9 +151,9 @@ public class ConstructableTriggerItem extends Item { }); } - public abstract static class MultiblockInfoContainer { - public abstract void construct(int stackSize, boolean hintsOnly, TileEntity tileEntity, int aSide); + public interface MultiblockInfoContainer { + void construct(int stackSize, boolean hintsOnly, TileEntity tileEntity, int aSide); @SideOnly(Side.CLIENT) - public abstract String[] getDescription(int stackSize); + String[] getDescription(int stackSize); } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java index 89362c9469..52ebed6a21 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugElementalInstanceContainer_EM.java @@ -3,7 +3,7 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.elementalMatter.core.interfaces.iElementalInstanceContainer; +import com.github.technus.tectech.elementalMatter.core.iElementalInstanceContainer; import com.github.technus.tectech.elementalMatter.core.tElementalException; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -27,11 +27,10 @@ import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; /** * Created by Tec on 15.03.2017. */ -public class DebugElementalInstanceContainer_EM extends Item { +public final class DebugElementalInstanceContainer_EM extends Item { public static DebugElementalInstanceContainer_EM INSTANCE; private DebugElementalInstanceContainer_EM() { - super(); setMaxStackSize(1); setUnlocalizedName("em.debugContainer"); setTextureName(MODID + ":itemDebugContainer"); @@ -43,15 +42,17 @@ public class DebugElementalInstanceContainer_EM extends Item { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (aPlayer instanceof EntityPlayerMP) { aStack.stackSize = 1; - if (tTileEntity != null && tTileEntity instanceof IGregTechTileEntity) { + if (tTileEntity instanceof IGregTechTileEntity) { IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); - if (metaTE != null && metaTE instanceof iElementalInstanceContainer) { + if (metaTE instanceof iElementalInstanceContainer) { cElementalInstanceStackMap content = ((iElementalInstanceContainer) metaTE).getContainerHandler(); if (tNBT.hasKey("content")) { try { content.putUnifyAll(cElementalInstanceStackMap.fromNBT(tNBT.getCompoundTag("content"))); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } return true; } ((iElementalInstanceContainer) metaTE).purgeOverflow(); diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java index 931a0a94cc..c2137df464 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionContainer_EM.java @@ -20,11 +20,10 @@ import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; /** * Created by Tec on 15.03.2017. */ -public class ElementalDefinitionContainer_EM extends Item { +public final class ElementalDefinitionContainer_EM extends Item { public static ElementalDefinitionContainer_EM INSTANCE; private ElementalDefinitionContainer_EM() { - super(); setMaxStackSize(1); setUnlocalizedName("em.definitionContainer"); setTextureName(MODID + ":itemDefinitionContainer"); @@ -34,14 +33,18 @@ public class ElementalDefinitionContainer_EM extends Item { public static cElementalDefinitionStackMap setContent(ItemStack containerItem, cElementalDefinitionStackMap definitions){ if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM) { NBTTagCompound tNBT = containerItem.stackTagCompound; - if (tNBT == null) tNBT=containerItem.stackTagCompound=new NBTTagCompound(); + if (tNBT == null) { + tNBT = containerItem.stackTagCompound = new NBTTagCompound(); + } cElementalDefinitionStackMap oldMap=null; if (tNBT.hasKey("content")) { try { oldMap=cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } tNBT.setTag("info", definitions.getInfoNBT()); @@ -55,11 +58,15 @@ public class ElementalDefinitionContainer_EM extends Item { if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM){ NBTTagCompound tNBT = containerItem.stackTagCompound; - if (tNBT == null || !tNBT.hasKey("content")) return null; + if (tNBT == null || !tNBT.hasKey("content")) { + return null; + } try { return cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } return null; @@ -68,14 +75,18 @@ public class ElementalDefinitionContainer_EM extends Item { public static cElementalDefinitionStackMap clearContent(ItemStack containerItem){ if(containerItem.getItem() instanceof ElementalDefinitionContainer_EM){ NBTTagCompound tNBT = containerItem.stackTagCompound; - if (tNBT == null) return null; + if (tNBT == null) { + return null; + } cElementalDefinitionStackMap oldMap=null; if (tNBT.hasKey("content")) { try { oldMap=cElementalDefinitionStackMap.fromNBT(tNBT.getCompoundTag("content")); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } tNBT.removeTag("info"); diff --git a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java index b650e4a564..4ba1323d15 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ElementalDefinitionScanStorage_EM.java @@ -1,8 +1,11 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.Util; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.loader.ModGuiHandler; +import com.github.technus.tectech.thing.CustomItemList; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -12,23 +15,22 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; +import net.minecraft.world.World; -import java.util.Collections; import java.util.List; import static com.github.technus.tectech.auxiliary.Reference.MODID; -import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; /** * Created by Tec on 15.03.2017. */ -public class ElementalDefinitionScanStorage_EM extends Item { +public final class ElementalDefinitionScanStorage_EM extends Item { public static ElementalDefinitionScanStorage_EM INSTANCE; public static IIcon offline, online; private ElementalDefinitionScanStorage_EM() { - super(); setMaxStackSize(1); setUnlocalizedName("em.definitionScanStorage"); setTextureName(MODID + ":itemDefinitionScanStorage"); @@ -37,18 +39,27 @@ public class ElementalDefinitionScanStorage_EM extends Item { //return previous thing public static void setContent(ItemStack containerItem, cElementalInstanceStackMap definitions, int[] detailsOnDepthLevels){ if(containerItem.getItem() instanceof ElementalDefinitionScanStorage_EM) { - if (containerItem.stackTagCompound == null) containerItem.stackTagCompound=new NBTTagCompound(); + if (containerItem.stackTagCompound == null) { + containerItem.stackTagCompound = new NBTTagCompound(); + } containerItem.stackTagCompound.setTag("elementalInfo", definitions.getScanInfoNBT(detailsOnDepthLevels)); } } public static void clearContent(ItemStack containerItem){ if(containerItem.getItem() instanceof ElementalDefinitionScanStorage_EM){ - if (containerItem.stackTagCompound == null) return; + if (containerItem.stackTagCompound == null) { + return; + } containerItem.stackTagCompound=null; - return; } - return; + } + + public static String[] getLines(ItemStack containerItem){ + if(containerItem.stackTagCompound!=null && containerItem.stackTagCompound.hasKey("elementalInfo")) { + return Util.infoFromNBT(containerItem.stackTagCompound.getCompoundTag("elementalInfo")); + } + return null; } @Override @@ -56,9 +67,12 @@ public class ElementalDefinitionScanStorage_EM extends Item { aList.add(CommonValues.TEC_MARK_EM); try { if (aStack.stackTagCompound != null && aStack.stackTagCompound.hasKey("elementalInfo")) { - aList.add("Contains scan result"); - if(DEBUG_MODE) - Collections.addAll(aList, Util.infoFromNBT(aStack.stackTagCompound.getCompoundTag("elementalInfo"))); + aList.add(EnumChatFormatting.BLUE+"Contains scan result"); + aList.add("Use to read"); + //if(DEBUG_MODE) { + // aList.add("DEBUG MODE INFO - U CHEATER"); + // Collections.addAll(aList, Util.infoFromNBT(aStack.stackTagCompound.getCompoundTag("elementalInfo"))); + //} } else { aList.add("Storage for matter scan data"); } @@ -70,20 +84,31 @@ public class ElementalDefinitionScanStorage_EM extends Item { public static void run() { INSTANCE = new ElementalDefinitionScanStorage_EM(); GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.scanContainer.set(INSTANCE); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { offline =iconRegister.registerIcon(MODID + ":itemDefinitionScanStorageOff"); - online =this.itemIcon = iconRegister.registerIcon(this.getIconString()); + online = itemIcon = iconRegister.registerIcon(getIconString()); } @Override public IIcon getIconIndex(ItemStack itemStack) { NBTTagCompound tagCompound=itemStack.stackTagCompound; - if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) + if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { + return online; + } + return offline; + } + + @Override + public IIcon getIcon(ItemStack itemStack, int pass) { + NBTTagCompound tagCompound=itemStack.stackTagCompound; + if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { return online; + } return offline; } @@ -92,4 +117,15 @@ public class ElementalDefinitionScanStorage_EM extends Item { ItemStack that = new ItemStack(this, 1); list.add(that); } + + @Override + public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + if(world.isRemote){ + NBTTagCompound tagCompound=itemStack.stackTagCompound; + if(tagCompound!=null && tagCompound.hasKey("elementalInfo")) { + player.openGui(TecTech.instance, ModGuiHandler.SCAN_DISPLAY_SCREEN_ID, world, 0, 0, 0); + } + } + return itemStack; + } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java index ce6d23ddbd..883a1923a1 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ParametrizerMemoryCard.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.thing.item; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.Util; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -23,16 +24,16 @@ import net.minecraft.world.World; import java.util.List; import static com.github.technus.tectech.auxiliary.Reference.MODID; +import static com.github.technus.tectech.thing.CustomItemList.parametrizerMemory; /** * Created by Tec on 15.03.2017. */ -public class ParametrizerMemoryCard extends Item { +public final class ParametrizerMemoryCard extends Item { public static ParametrizerMemoryCard INSTANCE; public static IIcon locked,unlocked; private ParametrizerMemoryCard() { - super(); setMaxStackSize(1); setHasSubtypes(true); setUnlocalizedName("em.parametrizerMemoryCard"); @@ -44,30 +45,53 @@ public class ParametrizerMemoryCard extends Item { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (aPlayer instanceof EntityPlayerMP) { aStack.stackSize = 1; - if (tTileEntity != null && tTileEntity instanceof IGregTechTileEntity) { + if (tTileEntity instanceof IGregTechTileEntity) { IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); - if (metaTE != null && metaTE instanceof GT_MetaTileEntity_Hatch_Param) { - GT_MetaTileEntity_Hatch_Param parametrizer = ((GT_MetaTileEntity_Hatch_Param) metaTE); - if(aStack.getTagCompound()==null) aStack.setTagCompound(new NBTTagCompound()); - NBTTagCompound tNBT=aStack.getTagCompound(); - if (aStack.getItemDamage()==1) { - //write to parametrizer - parametrizer.param = tNBT.getInteger("param"); - if(parametrizer.setUsingFloats(tNBT.getBoolean("usesFloats"))) { - parametrizer.value0i = (int)Float.intBitsToFloat(tNBT.getInteger("value0i")); - parametrizer.value1i = (int)Float.intBitsToFloat(tNBT.getInteger("value1i")); - }else{ - parametrizer.value0i = tNBT.getInteger("value0i"); - parametrizer.value1i = tNBT.getInteger("value1i"); + if (metaTE != null) { + if (metaTE instanceof GT_MetaTileEntity_Hatch_Param) { + GT_MetaTileEntity_Hatch_Param parametrizer = (GT_MetaTileEntity_Hatch_Param) metaTE; + if (aStack.getTagCompound() == null) { + aStack.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (aStack.getItemDamage() == 1) { + //write to parametrizer + parametrizer.param = tNBT.getInteger("param"); + if (parametrizer.setUsingFloats(tNBT.getBoolean("usesFloats"))) { + parametrizer.value0i = (int) Float.intBitsToFloat(tNBT.getInteger("value0i")); + parametrizer.value1i = (int) Float.intBitsToFloat(tNBT.getInteger("value1i")); + } else { + parametrizer.value0i = tNBT.getInteger("value0i"); + parametrizer.value1i = tNBT.getInteger("value1i"); + } + } else { + //read from parametrizer + tNBT.setInteger("param", parametrizer.param); + tNBT.setBoolean("usesFloats", parametrizer.isUsingFloats()); + tNBT.setInteger("value0i", parametrizer.value0i); + tNBT.setInteger("value1i", parametrizer.value1i); + } + return true; + }else if(metaTE instanceof GT_MetaTileEntity_MultiblockBase_EM){ + GT_MetaTileEntity_MultiblockBase_EM base = (GT_MetaTileEntity_MultiblockBase_EM) metaTE; + if (aStack.getTagCompound() == null) { + aStack.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if(aStack.getItemDamage()== 1){ + //write to base + if(tNBT.getBoolean("usesFloats")){ + base.setParameterPairIn_ClearOut(tNBT.getInteger("param"),true + ,Float.intBitsToFloat(tNBT.getInteger("value0i")) + ,Float.intBitsToFloat(tNBT.getInteger("value1i"))); + }else{ + base.setParameterPairIn_ClearOut(tNBT.getInteger("param"),false + ,tNBT.getInteger("value0i") + ,tNBT.getInteger("value1i")); + } + return true; } - } else { - //read from parametrizer - tNBT.setInteger("param", parametrizer.param); - tNBT.setBoolean("usesFloats", parametrizer.isUsingFloats()); - tNBT.setInteger("value0i", parametrizer.value0i); - tNBT.setInteger("value1i", parametrizer.value1i); } - return true; } } } @@ -95,9 +119,9 @@ public class ParametrizerMemoryCard extends Item { aList.add("Stores Parameters"); if(aStack.getItemDamage()==1) { - aList.add(EnumChatFormatting.BLUE + "Use on Parametrizer to configure it"); + aList.add(EnumChatFormatting.BLUE + "Use on Parametrizer/Controller to configure it"); }else{ - aList.add(EnumChatFormatting.BLUE + "Use on Parametrizer to save parameters"); + aList.add(EnumChatFormatting.BLUE + "Use on Parametrizer to store parameters"); } aList.add(EnumChatFormatting.BLUE + "Sneak right click to lock/unlock"); @@ -120,13 +144,14 @@ public class ParametrizerMemoryCard extends Item { public static void run() { INSTANCE = new ParametrizerMemoryCard(); GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + parametrizerMemory.set(INSTANCE); } @Override @SideOnly(Side.CLIENT) public void registerIcons(IIconRegister iconRegister) { - locked=iconRegister.registerIcon(MODID + ":itemParametrizerMemoryCardLocked"); - unlocked=this.itemIcon = iconRegister.registerIcon(this.getIconString()); + locked =iconRegister.registerIcon(MODID + ":itemParametrizerMemoryCardLocked"); + unlocked = itemIcon = iconRegister.registerIcon(getIconString()); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java new file mode 100644 index 0000000000..3c8411639a --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/item/gui/ScanDisplayScreen.java @@ -0,0 +1,155 @@ +package com.github.technus.tectech.thing.item.gui; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.auxiliary.Reference; +import com.github.technus.tectech.thing.item.ElementalDefinitionScanStorage_EM; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; +import net.minecraft.client.audio.SoundHandler; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; + +import static org.lwjgl.opengl.GL11.*; + +/** + * Created by danie_000 on 17.12.2017. + */ +public class ScanDisplayScreen extends GuiScreen { + private static final int sizeX=240,sizeY=220, renderedLines =10; + private int baseX,baseY; + private Button up,down,pgUp,pgDown; + private final String[] lines; + private int firstLine =0; + + private static final ResourceLocation[] BACKGROUNDS =new ResourceLocation[]{new ResourceLocation("tectech:textures/gui/scanDisplayScreen1.png"), + new ResourceLocation("tectech:textures/gui/scanDisplayScreen2.png"), + new ResourceLocation("tectech:textures/gui/scanDisplayScreen3.png"), + new ResourceLocation("tectech:textures/gui/scanDisplayScreen4.png"), + new ResourceLocation("tectech:textures/gui/scanDisplayScreen5.png"), + new ResourceLocation("tectech:textures/gui/scanDisplayScreen6.png"), + new ResourceLocation("tectech:textures/gui/scanDisplayScreen7.png"), + new ResourceLocation("tectech:textures/gui/scanDisplayScreen8.png")}; + private static final ResourceLocation ITEM =new ResourceLocation("tectech:textures/gui/scanDisplayItem.png"); + + public ScanDisplayScreen(EntityPlayer player){ + lines=ElementalDefinitionScanStorage_EM.getLines(player.getHeldItem()); + } + + @Override + public void drawScreen(int x, int y, float partialTicks) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + mc.getTextureManager().bindTexture(ITEM); + long tick=System.currentTimeMillis()/150; + int itick=(int)(tick%12); + drawTexturedModalRect(baseX+99,baseY+189,32*(itick/6),32*(itick%6), 32, 32); + mc.getTextureManager().bindTexture(BACKGROUNDS[(int)(tick%8)]); + drawTexturedModalRect(baseX,baseY,0,0, sizeX, sizeY); + glDisable(GL_BLEND); + super.drawScreen(x,y,partialTicks); + + itick=(TecTech.Rnd.nextInt(0x66)<<16)+0x77EEFF; + int textBaseX=baseX+20; + int textBaseXX=baseX+95; + int textBaseY=baseY+28; + for(int i=firstLine-1, j=8;i>=0 && j!=0;i--,j/=2){ + int equalPos=lines[i].indexOf('='); + if(equalPos>=0){ + TecTech.proxy.renderUnicodeString(lines[i].substring(0,equalPos), textBaseX, textBaseY - 8 + j, 200, itick); + TecTech.proxy.renderUnicodeString(lines[i].substring(equalPos), textBaseXX, textBaseY - 8 + j, 200, itick); + }else { + TecTech.proxy.renderUnicodeString(lines[i], textBaseX, textBaseY - 8 + j, 200, itick); + } + } + for(int i = firstLine, j = 0; i<lines.length && j< renderedLines; i++,j++){ + textBaseY += 9; + int equalPos=lines[i].indexOf('='); + if(equalPos>=0){ + TecTech.proxy.renderUnicodeString(lines[i].substring(0,equalPos), textBaseX, textBaseY, 200, itick); + TecTech.proxy.renderUnicodeString(lines[i].substring(equalPos), textBaseXX, textBaseY, 200, itick); + }else { + TecTech.proxy.renderUnicodeString(lines[i], textBaseX, textBaseY, 200, itick); + } + } + for(int i = firstLine+ renderedLines, j = 8; i<lines.length && j!=0; i++,j/=2){ + int equalPos=lines[i].indexOf('='); + if(equalPos>=0){ + TecTech.proxy.renderUnicodeString(lines[i].substring(0,equalPos), textBaseX, textBaseY + 17 - j, 200, itick); + TecTech.proxy.renderUnicodeString(lines[i].substring(equalPos), textBaseXX, textBaseY + 17 - j, 200, itick); + }else { + TecTech.proxy.renderUnicodeString(lines[i], textBaseX, textBaseY + 17 - j, 200, itick); + } + } + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } + + @Override + public void initGui() { + baseX=(width- sizeX)/2; + baseY=(height- sizeY)/2-12; + int buttonBaseY=baseY+145; + buttonList.add(pgUp= new Button(0, baseX + 77, buttonBaseY, 0, 220)); + buttonList.add(up= new Button(1, baseX + 99, buttonBaseY, 20, 220)); + buttonList.add(down= new Button(2, baseX + 121, buttonBaseY, 40, 220)); + buttonList.add(pgDown= new Button(3, baseX + 143, buttonBaseY, 60, 220)); + } + + @Override + protected void actionPerformed(GuiButton button) { + if (lines.length <= renderedLines) { + return; + } + if (button == pgUp) { + firstLine -= renderedLines; + } else if (button == up) { + firstLine--; + } else if (button == down) { + firstLine++; + } else if (button == pgDown) { + firstLine += renderedLines; + } + if (firstLine > lines.length - renderedLines) { + firstLine = lines.length - renderedLines; + } + if (firstLine < 0) { + firstLine = 0; + } + } + + private static class Button extends GuiButton{ + int u,v; + Button(int id,int x,int y,int u,int v){ + super(id,x,y,20,20,""); + this.u=u; + this.v=v; + } + + @Override + public void drawButton(Minecraft mc, int xPos, int yPos) + { + if (visible) + { + field_146123_n = xPos >= xPosition && yPos >= yPosition && xPos < xPosition + width && yPos < yPosition + height; + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + mc.getTextureManager().bindTexture(BACKGROUNDS[0]); + drawTexturedModalRect(xPosition, yPosition, u + getHoverState(field_146123_n) * 80, v, width, height); + glDisable(GL_BLEND); + glEnable(GL_BLEND); + } + } + + //play cool sound fx + @Override + public void func_146113_a(SoundHandler soundHandler) + { + soundHandler.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(Reference.MODID+":fx_click"), 1.0F)); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java index 8cfc075b31..16eb50b4e4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DataConnector.java @@ -33,11 +33,11 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE public short id = -1; - public GT_MetaTileEntity_Hatch_DataConnector(int aID, String aName, String aNameRegional, int aTier, String descr) { + protected GT_MetaTileEntity_Hatch_DataConnector(int aID, String aName, String aNameRegional, int aTier, String descr) { super(aID, aName, aNameRegional, aTier, 0, descr); } - public GT_MetaTileEntity_Hatch_DataConnector(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + protected GT_MetaTileEntity_Hatch_DataConnector(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); } @@ -64,16 +64,18 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setShort("eID", id); - if (q != null) + if (q != null) { aNBT.setTag("eDATA", q.toNbt()); + } } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); id = aNBT.getShort("eID"); - if (aNBT.hasKey("eDATA")) + if (aNBT.hasKey("eDATA")) { q = new QuantumDataPacket(aNBT.getCompoundTag("eDATA")); + } } @Override @@ -139,11 +141,9 @@ public abstract class GT_MetaTileEntity_Hatch_DataConnector extends GT_MetaTileE @Override public String[] getInfoData() { - if (id > 0) return new String[]{ - "ID: " + EnumChatFormatting.AQUA + id, - "Computation: " + EnumChatFormatting.AQUA + (q != null ? q.computation : 0), - "PacketHistory: " + EnumChatFormatting.RED + (q != null ? q.trace.size() : 0), - }; + if (id > 0) { + return new String[]{"ID: " + EnumChatFormatting.AQUA + id, "Computation: " + EnumChatFormatting.AQUA + (q != null ? q.computation : 0), "PacketHistory: " + EnumChatFormatting.RED + (q != null ? q.trace.size() : 0),}; + } return new String[]{ "Computation: " + EnumChatFormatting.AQUA + (q != null ? q.computation : 0), "PacketHistory: " + EnumChatFormatting.RED + (q != null ? q.trace.size() : 0), diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java index 78d278e463..d83c0ba7e1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_DynamoMulti.java @@ -87,7 +87,7 @@ public class GT_MetaTileEntity_Hatch_DynamoMulti extends GT_MetaTileEntity_Hatch @Override public long getMinimumStoredEU() { - return 128 * Amperes; + return 128L * Amperes; } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java index a469872047..4ff8a5db75 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java @@ -1,9 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch; -import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.elementalMatter.core.interfaces.iElementalInstanceContainer; +import com.github.technus.tectech.elementalMatter.core.iElementalInstanceContainer; import com.github.technus.tectech.elementalMatter.core.tElementalException; import com.github.technus.tectech.thing.metaTileEntity.pipe.iConnectsToEMpipe; import cpw.mods.fml.relauncher.Side; @@ -43,7 +42,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta private byte deathDelay = 2; public final int eTier; - public GT_MetaTileEntity_Hatch_ElementalContainer(int aID, String aName, String aNameRegional, int aTier, String descr) { + protected GT_MetaTileEntity_Hatch_ElementalContainer(int aID, String aName, String aNameRegional, int aTier, String descr) { super(aID, aName, aNameRegional, aTier, 0, descr); eTier=aTier; } @@ -53,7 +52,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta // eTier=aTier; //} - public GT_MetaTileEntity_Hatch_ElementalContainer(String aName, int aTier, int eTier, String aDescription, ITexture[][][] aTextures) { + protected GT_MetaTileEntity_Hatch_ElementalContainer(String aName, int aTier, int eTier, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); this.eTier=eTier; } @@ -97,8 +96,12 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta try { content = cElementalInstanceStackMap.fromNBT(aNBT.getCompoundTag("eM_Stacks")); } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); - if (content == null) content = new cElementalInstanceStackMap(); + if (DEBUG_MODE) { + e.printStackTrace(); + } + if (content == null) { + content = new cElementalInstanceStackMap(); + } } } @@ -116,29 +119,37 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta } else { if (deathDelay == 1) { IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide(aBaseMetaTileEntity.getBackFacing()); - if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) + if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_OverflowElemental)) { tGTTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityAtSide((byte) 0); - if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_MufflerElemental)) + } + if (tGTTileEntity == null || !(tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_OverflowElemental)) { 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(); + } + if (tGTTileEntity != null && tGTTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_OverflowElemental) { + GT_MetaTileEntity_Hatch_OverflowElemental aMetaTileEntity = (GT_MetaTileEntity_Hatch_OverflowElemental) tGTTileEntity.getMetaTileEntity(); if (aMetaTileEntity.addOverflowMatter(overflowMatter)) { - if (TecTech.ModConfig.BOOM_ENABLE) tGTTileEntity.doExplosion(V[14]); - else - TecTech.proxy.broadcast("Container1 BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + if (TecTech.ModConfig.BOOM_ENABLE) { + tGTTileEntity.doExplosion(V[14]); + } else { + TecTech.proxy.broadcast("Container1 BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); + } } deathDelay = 3;//needed in some cases like repetitive failures. Should be 4 since there is -- at end but meh... overflowMatter = 0F; } } else if (deathDelay < 1) { - if (TecTech.ModConfig.BOOM_ENABLE) getBaseMetaTileEntity().doExplosion(V[14]); - else - TecTech.proxy.broadcast("Container0 BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + if (TecTech.ModConfig.BOOM_ENABLE) { + getBaseMetaTileEntity().doExplosion(V[14]); + } else { + TecTech.proxy.broadcast("Container0 BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); + } } deathDelay--; } } else if (MOVE_AT == Tick) { - if (content.hasStacks()) moveAround(aBaseMetaTileEntity); + if (content.hasStacks()) { + moveAround(aBaseMetaTileEntity); + } getBaseMetaTileEntity().setActive(content.hasStacks()); } } @@ -214,26 +225,30 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta public String[] getInfoData() { if(TecTech.ModConfig.EASY_SCAN) { if (id > 0) { - if (content == null || content.size() == 0) + if (content == null || content.size() == 0) { return new String[]{"ID: " + EnumChatFormatting.AQUA + id, "No Stacks"}; - else { - final String[] lines = content.getElementalInfo(); - final String[] output = new String[lines.length + 1]; + } else { + String[] lines = content.getElementalInfo(); + String[] output = new String[lines.length + 1]; output[0] = "ID: " + EnumChatFormatting.AQUA + id; System.arraycopy(lines, 0, output, 1, lines.length); return output; } } - if (content == null || content.size() == 0) return new String[]{"No Stacks"}; + if (content == null || content.size() == 0) { + return new String[]{"No Stacks"}; + } return content.getElementalInfo(); } else { if(id>0){ - if (content == null || content.size() == 0) + if (content == null || content.size() == 0) { return new String[]{"ID: " + EnumChatFormatting.AQUA + id, "No Stacks"}; + } return new String[]{"ID: " + EnumChatFormatting.AQUA + id, "Contains EM"}; } - if (content == null || content.size() == 0) + if (content == null || content.size() == 0) { return new String[]{"No Stacks"}; + } return new String[]{"Contains EM"}; } } @@ -245,7 +260,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta @Override public String[] getDescription() { return new String[]{ - CommonValues.TEC_MARK_EM, + TEC_MARK_EM, mDescription, "Max stacks amount: " + EnumChatFormatting.AQUA + getMaxStacksCount(), "Stack capacity: " + EnumChatFormatting.AQUA + getMaxStackSize(), @@ -260,9 +275,12 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta @Override public void onRemoval() { - if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) - if (TecTech.ModConfig.BOOM_ENABLE) getBaseMetaTileEntity().doExplosion(V[15]); - else - TecTech.proxy.broadcast("BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) { + if (TecTech.ModConfig.BOOM_ENABLE) { + getBaseMetaTileEntity().doExplosion(V[15]); + } else { + TecTech.proxy.broadcast("BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); + } + } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java index 45bd08fbca..ea40ec8fc3 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Holder.java @@ -97,7 +97,9 @@ public class GT_MetaTileEntity_Hatch_Holder extends GT_MetaTileEntity_Hatch { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } //if(aBaseMetaTileEntity.isActive()) // aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); //else if(heat>0) diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java index 2d5a0a3b6b..8a3ae77b7f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_InputData.java @@ -51,7 +51,10 @@ public class GT_MetaTileEntity_Hatch_InputData extends GT_MetaTileEntity_Hatch_D @Override public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { - if (delDelay) delDelay = false; - else q = null; + if (delDelay) { + delDelay = false; + } else { + q = null; + } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java index afaadef072..ef5bc961bb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputData.java @@ -65,17 +65,24 @@ public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_ public iConnectsToDataPipe getNext(iConnectsToDataPipe source/*==this*/) { IGregTechTileEntity base = getBaseMetaTileEntity(); byte color = base.getColorization(); - if (color < 0) return null; + if (color < 0) { + return null; + } IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); - if (next == null || color != base.getColorization()) return null; + if (next == null || color != base.getColorization()) { + return null; + } IMetaTileEntity meta = next.getMetaTileEntity(); if (meta instanceof iConnectsToDataPipe) { if (meta instanceof GT_MetaTileEntity_Hatch_InputData - && GT_Utility.getOppositeSide(next.getFrontFacing()) == base.getFrontFacing()) + && GT_Utility.getOppositeSide(next.getFrontFacing()) == base.getFrontFacing()) { return (iConnectsToDataPipe) meta; + } if (meta instanceof GT_MetaTileEntity_Pipe_Data /*&& ((GT_MetaTileEntity_Pipe_Data) meta).connectionCount==2*/)//Checked later + { return (iConnectsToDataPipe) meta; + } } return null; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java index b334befcce..22ae90a3c0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OutputElemental.java @@ -46,7 +46,9 @@ public class GT_MetaTileEntity_Hatch_OutputElemental extends GT_MetaTileEntity_H @Override public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { byte color = getBaseMetaTileEntity().getColorization(); - if (color < 0) return; + if (color < 0) { + return; + } byte front = aBaseMetaTileEntity.getFrontFacing(); byte opposite = GT_Utility.getOppositeSide(front); for (byte dist = 1; dist < 16; dist++) { @@ -61,10 +63,18 @@ public class GT_MetaTileEntity_Hatch_OutputElemental extends GT_MetaTileEntity_H content.clear(); return; } else if (aMetaTileEntity instanceof GT_MetaTileEntity_Pipe_EM) { - if (((GT_MetaTileEntity_Pipe_EM) aMetaTileEntity).connectionCount > 2) return; - } else return; - } else return; - } else return; + if (((GT_MetaTileEntity_Pipe_EM) aMetaTileEntity).connectionCount > 2) { + return; + } + } else { + return; + } + } else { + return; + } + } else { + return; + } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java index 1a9a811538..4fa2682a27 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_MufflerElemental.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_OverflowElemental.java @@ -23,6 +23,8 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.EnumSkyBlock; import net.minecraftforge.common.util.ForgeDirection; +import java.util.Locale; + import static com.github.technus.tectech.CommonValues.DISPERSE_AT; import static com.github.technus.tectech.Util.V; import static com.github.technus.tectech.loader.MainLoader.elementalPollution; @@ -32,7 +34,7 @@ import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Mult /** * Created by danie_000 on 12.12.2016. */ -public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_Hatch { +public class GT_MetaTileEntity_Hatch_OverflowElemental extends GT_MetaTileEntity_Hatch { private static Textures.BlockIcons.CustomIcon EM_T_SIDES; private static Textures.BlockIcons.CustomIcon EM_T_ACTIVE; private static Textures.BlockIcons.CustomIcon MufflerEM; @@ -42,7 +44,7 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ private final float overflowDisperse; private final int eTier; - public GT_MetaTileEntity_Hatch_MufflerElemental(int aID, String aName, String aNameRegional, int aTier, float max) { + public GT_MetaTileEntity_Hatch_OverflowElemental(int aID, String aName, String aNameRegional, int aTier, float max) { super(aID, aName, aNameRegional, aTier, 0, "Disposes excess elemental Matter"); overflowMatter = max / 2; overflowMax = max; @@ -58,7 +60,7 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ // eTier=aTier; //} - public GT_MetaTileEntity_Hatch_MufflerElemental(String aName, int aTier, int eTier, float max, String aDescription, ITexture[][][] aTextures) { + public GT_MetaTileEntity_Hatch_OverflowElemental(String aName, int aTier, int eTier, float max, String aDescription, ITexture[][][] aTextures) { super(aName, aTier, 0, aDescription, aTextures); overflowMatter = max / 2; overflowMax = max; @@ -91,8 +93,8 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ return new String[]{ CommonValues.TEC_MARK_EM, mDescription, - "Mass capacity: " + EnumChatFormatting.AQUA + String.format(java.util.Locale.ENGLISH, "%+.2E", overflowMax) + " eV/c^2", - "Disposal Speed: " + EnumChatFormatting.AQUA + String.format(java.util.Locale.ENGLISH, "%+.2E", overflowDisperse) + " (eV/c^2)/s", + "Mass capacity: " + EnumChatFormatting.AQUA + String.format(Locale.ENGLISH, "%+.2E", overflowMax) + " eV/c\u00b2", + "Disposal Speed: " + EnumChatFormatting.AQUA + String.format(Locale.ENGLISH, "%+.2E", overflowDisperse) + " (eV/c\u00b2)/s", "DO NOT OBSTRUCT THE OUTPUT!" }; } @@ -119,7 +121,7 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_MufflerElemental(mName, mTier, eTier, overflowMax, mDescription, mTextures); + return new GT_MetaTileEntity_Hatch_OverflowElemental(mName, mTier, eTier, overflowMax, mDescription, mTextures); } @Override @@ -146,10 +148,13 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isServerSide() && (aTick % 20) == DISPERSE_AT) { + if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == DISPERSE_AT) { if (aBaseMetaTileEntity.isActive()) { - overflowMatter -= overflowDisperse; - if (overflowMatter < 0) { + if (overflowMatter > overflowDisperse) { + //todo add full dose of dispersed pollution (reduced by tier, or make recycler machine only capable of reduction?) + overflowMatter -= overflowDisperse; + } else { + //todo add partial dose of dispersed pollution (reduced by tier, or make recycler machine only capable of reduction?) overflowMatter = 0; aBaseMetaTileEntity.setActive(false); aBaseMetaTileEntity.setLightValue((byte) 0); @@ -197,18 +202,21 @@ public class GT_MetaTileEntity_Hatch_MufflerElemental extends GT_MetaTileEntity_ public String[] getInfoData() { return new String[]{ "Contained mass:", - EnumChatFormatting.RED + Double.toString(overflowMatter) + EnumChatFormatting.RESET + " eV/c^2 /", - EnumChatFormatting.GREEN + Double.toString(overflowMax) + EnumChatFormatting.RESET + " eV/c^2", - "Mass Disposal speed: " + EnumChatFormatting.BLUE + Double.toString(overflowDisperse) + EnumChatFormatting.RESET + " (eV/c^2)/s" + EnumChatFormatting.RED + Double.toString(overflowMatter) + EnumChatFormatting.RESET + " eV/c\u00b2 /", + EnumChatFormatting.GREEN + Double.toString(overflowMax) + EnumChatFormatting.RESET + " eV/c\u00b2", + "Mass Disposal speed: " + EnumChatFormatting.BLUE + Double.toString(overflowDisperse) + EnumChatFormatting.RESET + " (eV/c\u00b2)/s" }; } @Override public void onRemoval() { - if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) - if (TecTech.ModConfig.BOOM_ENABLE) getBaseMetaTileEntity().doExplosion(V[15]); - else - TecTech.proxy.broadcast("Muffler BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + if (isValidMetaTileEntity(this) && getBaseMetaTileEntity().isActive()) { + if (TecTech.ModConfig.BOOM_ENABLE) { + getBaseMetaTileEntity().doExplosion(V[15]); + } else { + TecTech.proxy.broadcast("Muffler BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); + } + } } //Return - Should Explode diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java index 6f79722ea6..ba65fe90a8 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Param.java @@ -54,13 +54,17 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { @Override public Object getServerGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if (mTier >= 10) return new GT_Container_ParamAdv(aPlayerInventory, aBaseMetaTileEntity); + if (mTier >= 10) { + return new GT_Container_ParamAdv(aPlayerInventory, aBaseMetaTileEntity); + } return new GT_Container_Param(aPlayerInventory, aBaseMetaTileEntity); } @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if (mTier >= 10) return new GT_GUIContainer_ParamAdv(aPlayerInventory, aBaseMetaTileEntity); + if (mTier >= 10) { + return new GT_GUIContainer_ParamAdv(aPlayerInventory, aBaseMetaTileEntity); + } return new GT_GUIContainer_Param(aPlayerInventory, aBaseMetaTileEntity); } @@ -100,18 +104,9 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { @Override public String[] getInfoData() { - if(mTier>=10) - return new String[]{ - "Parametrizer ID: " + EnumChatFormatting.GREEN + param, - "Value 0I: " + EnumChatFormatting.AQUA + value0i, - "Value 0FB: " + EnumChatFormatting.AQUA + Float.intBitsToFloat(value0i)+" "+ Util.intBitsToShortString(value0i), - "Value 1I: " + EnumChatFormatting.BLUE + value1i, - "Value 1FB: " + EnumChatFormatting.BLUE + Float.intBitsToFloat(value1i)+" "+ Util.intBitsToShortString(value1i), - "Input 0I: " + EnumChatFormatting.GOLD + input0i, - "Input 0FB: " + EnumChatFormatting.GOLD + Float.intBitsToFloat(input0i)+" "+ Util.intBitsToShortString(input0i), - "Input 1I: " + EnumChatFormatting.YELLOW + input1i, - "Input 1FB: " + EnumChatFormatting.YELLOW + Float.intBitsToFloat(input1i)+" "+ Util.intBitsToShortString(input1i), - }; + if(mTier>=10) { + return new String[]{"Parametrizer ID: " + EnumChatFormatting.GREEN + param, "Value 0I: " + EnumChatFormatting.AQUA + value0i, "Value 0FB: " + EnumChatFormatting.AQUA + Float.intBitsToFloat(value0i) + ' ' + Util.intBitsToShortString(value0i), "Value 1I: " + EnumChatFormatting.BLUE + value1i, "Value 1FB: " + EnumChatFormatting.BLUE + Float.intBitsToFloat(value1i) + ' ' + Util.intBitsToShortString(value1i), "Input 0I: " + EnumChatFormatting.GOLD + input0i, "Input 0FB: " + EnumChatFormatting.GOLD + Float.intBitsToFloat(input0i) + ' ' + Util.intBitsToShortString(input0i), "Input 1I: " + EnumChatFormatting.YELLOW + input1i, "Input 1FB: " + EnumChatFormatting.YELLOW + Float.intBitsToFloat(input1i) + ' ' + Util.intBitsToShortString(input1i),}; + } return new String[]{ "Parametrizer ID: " + EnumChatFormatting.GREEN + param, "Value 0I: " + EnumChatFormatting.AQUA + value0i, @@ -136,6 +131,7 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { return false; } + @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setBoolean("eFloats", usesFloat); @@ -147,6 +143,7 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { aNBT.setInteger("eParam", param); } + @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); usesFloat = aNBT.getBoolean("eFloats"); @@ -185,7 +182,9 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } aBaseMetaTileEntity.openGUI(aPlayer); return true; } @@ -195,7 +194,7 @@ public class GT_MetaTileEntity_Hatch_Param extends GT_MetaTileEntity_Hatch { return new String[]{ CommonValues.TEC_MARK_GENERAL, mDescription, - EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "E=mine*craft^2" + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "E=mine*craft\u00b2" }; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java index 6b4c6cb3ec..b06bef34ee 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Rack.java @@ -36,7 +36,7 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { private static Textures.BlockIcons.CustomIcon EM_R_ACTIVE; public int heat = 0; private float overClock = 1, overVolt = 1; - private static Map<String, component> componentBinds = new HashMap<>(); + private static Map<String, RackComponent> componentBinds = new HashMap<>(); public GT_MetaTileEntity_Hatch_Rack(int aID, String aName, String aNameRegional, int aTier, String descr) { super(aID, aName, aNameRegional, aTier, 4, descr); @@ -107,13 +107,17 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { @Override public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aBaseMetaTileEntity.isActive() || heat > 500) return false; + if (aBaseMetaTileEntity.isActive() || heat > 500) { + return false; + } return aSide == aBaseMetaTileEntity.getFrontFacing(); } @Override public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, byte aSide, ItemStack aStack) { - if (aBaseMetaTileEntity.isActive() || heat > 500) return false; + if (aBaseMetaTileEntity.isActive() || heat > 500) { + return false; + } return aSide == aBaseMetaTileEntity.getFrontFacing(); } @@ -129,7 +133,9 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } //if(aBaseMetaTileEntity.isActive()) // aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); //else if(heat>0) @@ -142,18 +148,23 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { private int getComputationPower(float overclock, float overvolt, boolean tickingComponents) { float computation = 0, heat = 0; for (int i = 0; i < mInventory.length; i++) { - if (mInventory[i] == null || mInventory[i].stackSize != 1) continue; - component comp = componentBinds.get(getUniqueIdentifier(mInventory[i])); - if (comp == null) continue; + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + RackComponent comp = componentBinds.get(getUniqueIdentifier(mInventory[i])); + if (comp == null) { + continue; + } if (tickingComponents) { if (this.heat > comp.maxHeat) { mInventory[i] = null; continue; } else if (comp.subZero || this.heat >= 0) { - heat += (1f + (comp.coEff * this.heat / 10000f)) * (comp.heat > 0 ? comp.heat * overclock * overclock * overvolt : comp.heat); + heat += (1f + comp.coEff * this.heat / 10000f) * (comp.heat > 0 ? comp.heat * overclock * overclock * overvolt : comp.heat); //=MAX(0;MIN(MIN($B4;1*C$3+C$3-0,25);1+RAND()+(C$3-1)-($B4-1)/2)) - if (overvolt * 10f > 7f + TecTech.Rnd.nextFloat()) + if (overvolt * 10f > 7f + TecTech.Rnd.nextFloat()) { computation += comp.computation * Math.max(0, Math.min(Math.min(overclock, overvolt + overvolt - 0.25), 1 + TecTech.Rnd.nextFloat() + (overvolt - 1) - (overclock - 1) / 2)); + } } } else { computation += comp.computation * overclock; @@ -171,7 +182,9 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { } public int tickComponents(float oc, float ov) { - if (oc > 3 + TecTech.Rnd.nextFloat() || ov > 2 + TecTech.Rnd.nextFloat()) getBaseMetaTileEntity().setToFire(); + if (oc > 3 + TecTech.Rnd.nextFloat() || ov > 2 + TecTech.Rnd.nextFloat()) { + getBaseMetaTileEntity().setToFire(); + } overClock = oc; overVolt = ov; return getComputationPower(overClock, overVolt, true); @@ -181,27 +194,38 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { if (aTick % 20 == MULTI_CHECK_AT) { - if (this.heat > 0) { + if (heat > 0) { float heatC = 0; for (int i = 0; i < mInventory.length; i++) { - if (mInventory[i] == null || mInventory[i].stackSize != 1) continue; - component comp = componentBinds.get(getUniqueIdentifier(mInventory[i])); - if (comp == null) continue; - if (this.heat > comp.maxHeat) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + RackComponent comp = componentBinds.get(getUniqueIdentifier(mInventory[i])); + if (comp == null) { + continue; + } + if (heat > comp.maxHeat) { mInventory[i] = null; } else if (comp.heat < 0) { - heatC += comp.heat * (this.heat / 10000); + heatC += comp.heat * (heat / 10000f); } } - this.heat += Math.max(-this.heat, Math.ceil(heatC)); + heat += Math.max(-heat, Math.ceil(heatC)); } - if (heat > 0) heat -= Math.max(heat / 1000, 1); - else if (heat < 0) heat -= Math.min(heat / 1000, -1); + if (heat > 0) { + heat -= Math.max(heat / 1000, 1); + } else if (heat < 0) { + heat -= Math.min(heat / 1000, -1); + } - if (heat > 9000) aBaseMetaTileEntity.setOnFire(); - else if (heat > 10000) aBaseMetaTileEntity.setToFire(); - else if (heat < -10000) this.heat = -10000; + if (heat > 9000) { + aBaseMetaTileEntity.setOnFire(); + } else if (heat > 10000) { + aBaseMetaTileEntity.setToFire(); + } else if (heat < -10000) { + heat = -10000; + } } } } @@ -237,69 +261,69 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { return new String[]{ "Base computation: " + EnumChatFormatting.AQUA + getComputationPower(1, 0, false), "After overclocking: " + EnumChatFormatting.AQUA + getComputationPower(overClock, 0, false), - "Heat Accumulated: " + EnumChatFormatting.RED + ((heat + 99) / 100) + EnumChatFormatting.RESET + " %"}; + "Heat Accumulated: " + EnumChatFormatting.RED + (heat + 99) / 100 + EnumChatFormatting.RESET + " %"}; //heat==0? --> ((heat+9)/10) = 0 //Heat==1-10? --> 1 } public static void run() {//20k heat cap max! - new component(ItemList.Circuit_Primitive.get(1), 1, 4, 0, 500, true); - new component(ItemList.Circuit_Basic.get(1), 4, 8, 0, 1000, true); - new component(ItemList.Circuit_Good.get(1), 6, 9, -.05f, 1500, true); - new component(ItemList.Circuit_Parts_Advanced.get(1), 1, 2, -.05f, 2000, true); - new component(ItemList.Circuit_Advanced.get(1), 8, 10, -.1f, 2500, true); - new component(ItemList.Circuit_Data.get(1), 1, 1, -.1f, 3000, true); - new component(ItemList.Circuit_Master.get(1), 12, 10, -.2F, 5000, true); - new component(ItemList.Circuit_Elite.get(1), 16, 12, -.15F, 3500, true); - - new component("IC2:ic2.reactorVent", 0, -1, 10f, 1000, false); - new component("IC2:ic2.reactorVentCore", 0, -1, 20f, 2500, false); - new component("IC2:ic2.reactorVentGold", 0, -1, 40f, 5000, false); - new component("IC2:ic2.reactorVentDiamond", 0, -1, 80f, 10000, false);//2x oc + new RackComponent(ItemList.Circuit_Primitive.get(1), 1, 4, 0, 500, true); + new RackComponent(ItemList.Circuit_Basic.get(1), 4, 8, 0, 1000, true); + new RackComponent(ItemList.Circuit_Good.get(1), 6, 9, -.05f, 1500, true); + new RackComponent(ItemList.Circuit_Parts_Advanced.get(1), 1, 2, -.05f, 2000, true); + new RackComponent(ItemList.Circuit_Advanced.get(1), 8, 10, -.1f, 2500, true); + new RackComponent(ItemList.Circuit_Data.get(1), 1, 1, -.1f, 3000, true); + new RackComponent(ItemList.Circuit_Master.get(1), 12, 10, -.2F, 5000, true); + new RackComponent(ItemList.Circuit_Elite.get(1), 16, 12, -.15F, 3500, true); + + new RackComponent("IC2:ic2.reactorVent", 0, -1, 10f, 1000, false); + new RackComponent("IC2:ic2.reactorVentCore", 0, -1, 20f, 2500, false); + new RackComponent("IC2:ic2.reactorVentGold", 0, -1, 40f, 5000, false); + new RackComponent("IC2:ic2.reactorVentDiamond", 0, -1, 80f, 10000, false);//2x oc if (Loader.isModLoaded("dreamcraft")) { - new component("dreamcraft:item.HighEnergyCircuitParts", 3, 2, -.1f, 9001, true); - new component("dreamcraft:item.HighEnergyFlowCircuit", 24, 16, -.25f, 10000, true); - new component("dreamcraft:item.NanoCircuit", 32, 20, -.15f, 8000, true); - new component("dreamcraft:item.PikoCircuit", 64, 32, -.2f, 8500, true); - new component("dreamcraft:item.QuantumCircuit", 128, 48, -.3f, 9000, true); + new RackComponent("dreamcraft:item.HighEnergyCircuitParts", 3, 2, -.1f, 9001, true); + new RackComponent("dreamcraft:item.HighEnergyFlowCircuit", 24, 16, -.25f, 10000, true); + new RackComponent("dreamcraft:item.NanoCircuit", 32, 20, -.15f, 8000, true); + new RackComponent("dreamcraft:item.PikoCircuit", 64, 32, -.2f, 8500, true); + new RackComponent("dreamcraft:item.QuantumCircuit", 128, 48, -.3f, 9000, true); } if (Loader.isModLoaded("OpenComputers")) { - new component("OpenComputers:item.23", 0, 1, 0f, 100, true);//Transistor - new component("OpenComputers:item.24", 7, 12, -.05f, 1500, true);//chip t1 - new component("OpenComputers:item.25", 18, 20, -.1f, 3000, true);//chip t2 - new component("OpenComputers:item.26", 25, 22, -.15f, 4500, true);//chip t3 - new component("OpenComputers:item.27", 10, 15, -.05f, 3000, true);//alu - new component("OpenComputers:item.28", 25, 18, -.05f, 1500, true);//cu - - new component("OpenComputers:item.70", 42, 30, -.05f, 1500, true);//bus t1 - new component("OpenComputers:item.71", 70, 50, -.1f, 3000, true);//bus t2 - new component("OpenComputers:item.72", 105, 72, -.15f, 4500, true);//bus t3 - - new component("OpenComputers:item.29", 106, 73, -.1f, 1500, true);//cpu t1 - new component("OpenComputers:item.42", 226, 153, -.15f, 3000, true);//cpu t2 - new component("OpenComputers:item.43", 374, 241, -.2f, 4500, true);//cpu t3 - - new component("OpenComputers:item.8", 20, 27, -.1f, 1500, true);//gpu t1 - new component("OpenComputers:item.9", 62, 67, -.2f, 3000, true);//gpu t2 - new component("OpenComputers:item.10", 130, 111, -.3f, 4500, true);//gpu t3 - - new component("OpenComputers:item.101", 350, 234, -.1f, 1500, true);//apu t1 - new component("OpenComputers:item.102", 606, 398, -.2f, 4500, true);//apu t2 - new component("OpenComputers:item.103", 1590, 1006, -.3f, 9000, true);//apu tC + new RackComponent("OpenComputers:item.23", 0, 1, 0f, 100, true);//Transistor + new RackComponent("OpenComputers:item.24", 7, 12, -.05f, 1500, true);//chip t1 + new RackComponent("OpenComputers:item.25", 18, 20, -.1f, 3000, true);//chip t2 + new RackComponent("OpenComputers:item.26", 25, 22, -.15f, 4500, true);//chip t3 + new RackComponent("OpenComputers:item.27", 10, 15, -.05f, 3000, true);//alu + new RackComponent("OpenComputers:item.28", 25, 18, -.05f, 1500, true);//cu + + new RackComponent("OpenComputers:item.70", 42, 30, -.05f, 1500, true);//bus t1 + new RackComponent("OpenComputers:item.71", 70, 50, -.1f, 3000, true);//bus t2 + new RackComponent("OpenComputers:item.72", 105, 72, -.15f, 4500, true);//bus t3 + + new RackComponent("OpenComputers:item.29", 106, 73, -.1f, 1500, true);//cpu t1 + new RackComponent("OpenComputers:item.42", 226, 153, -.15f, 3000, true);//cpu t2 + new RackComponent("OpenComputers:item.43", 374, 241, -.2f, 4500, true);//cpu t3 + + new RackComponent("OpenComputers:item.8", 20, 27, -.1f, 1500, true);//gpu t1 + new RackComponent("OpenComputers:item.9", 62, 67, -.2f, 3000, true);//gpu t2 + new RackComponent("OpenComputers:item.10", 130, 111, -.3f, 4500, true);//gpu t3 + + new RackComponent("OpenComputers:item.101", 350, 234, -.1f, 1500, true);//apu t1 + new RackComponent("OpenComputers:item.102", 606, 398, -.2f, 4500, true);//apu t2 + new RackComponent("OpenComputers:item.103", 1590, 1006, -.3f, 9000, true);//apu tC } } - public static class component implements Comparable<component> { + public static class RackComponent implements Comparable<RackComponent> { private final String unlocalizedName; private final float heat, coEff, computation, maxHeat; private final boolean subZero; - component(ItemStack is, float computation, float heat, float coEff, float maxHeat, boolean subZero) { + RackComponent(ItemStack is, float computation, float heat, float coEff, float maxHeat, boolean subZero) { this(getUniqueIdentifier(is), computation, heat, coEff, maxHeat, subZero); } - component(String is, float computation, float heat, float coEff, float maxHeat, boolean subZero) { + RackComponent(String is, float computation, float heat, float coEff, float maxHeat, boolean subZero) { unlocalizedName = is; this.heat = heat; this.coEff = coEff; @@ -307,14 +331,23 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch { this.maxHeat = maxHeat; this.subZero = subZero; componentBinds.put(unlocalizedName, this); - if (DEBUG_MODE) + if (DEBUG_MODE) { TecTech.Logger.info("Component registered: " + unlocalizedName); + } } @Override - public int compareTo(component o) { + public int compareTo(RackComponent o) { return unlocalizedName.compareTo(o.unlocalizedName); } + + @Override + public boolean equals(Object obj) { + if(obj instanceof RackComponent) { + return compareTo((RackComponent) obj) == 0; + } + return false; + } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java index 81f05fad7c..7736ee2bcc 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_Uncertainty.java @@ -55,7 +55,9 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - if (mTier >= 10) return new GT_GUIContainer_UncertaintyAdv(aPlayerInventory, aBaseMetaTileEntity); + if (mTier >= 10) { + return new GT_GUIContainer_UncertaintyAdv(aPlayerInventory, aBaseMetaTileEntity); + } return new GT_GUIContainer_Uncertainty(aPlayerInventory, aBaseMetaTileEntity); } @@ -115,25 +117,29 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch return false; } + @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); aNBT.setByte("mSel", selection); aNBT.setByte("mMode", mode); aNBT.setByte("mStatus", status); NBTTagCompound mat = new NBTTagCompound(); - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { mat.setShort(Integer.toString(i), matrix[i]); + } aNBT.setTag("mMat", mat); } + @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); selection = aNBT.getByte("mSel"); mode = aNBT.getByte("mMode"); status = aNBT.getByte("mStatus"); NBTTagCompound mat = aNBT.getCompoundTag("mMat"); - for (int i = 0; i < 16; i++) + for (int i = 0; i < 16; i++) { matrix[i] = mat.getShort(Integer.toString(i)); + } } @Override @@ -163,7 +169,9 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } aBaseMetaTileEntity.openGUI(aPlayer); return true; } @@ -182,12 +190,13 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch for (int i = 0; i < masses.length >> 1; i++) { inequality += Math.abs(masses[i] - masses[masses.length - i - 1]); } - return inequality < (masses.length << 7); + return inequality < masses.length << 7; } public void regenerate() { - for (int i = 0; i < matrix.length; i++) + for (int i = 0; i < matrix.length; i++) { matrix[i] = (short) TecTech.Rnd.nextInt(1000); + } } public byte compute() { @@ -260,16 +269,23 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch } private void shift() { - final int i = TecTech.Rnd.nextInt(16), j = TecTech.Rnd.nextInt(128); - matrix[i] += (((matrix[i] & 1) == 0) ? 2 : -2) * j >> 5; + int i = TecTech.Rnd.nextInt(16), j = TecTech.Rnd.nextInt(128); + matrix[i] += ((matrix[i] & 1) == 0 ? 2 : -2) * j >> 5; matrix[i] += j == 0 ? 1 : 0; - if (matrix[i] < 0) matrix[i] = 0; - else if (matrix[i] > 1000) matrix[i] = 999; + if (matrix[i] < 0) { + matrix[i] = 0; + } else if (matrix[i] > 1000) { + matrix[i] = 999; + } } public byte update(int newMode) { - if (newMode == mode) return status; - if (newMode < 0 || newMode > 5) newMode = 0; + if (newMode == mode) { + return status; + } + if (newMode < 0 || newMode > 5) { + newMode = 0; + } mode = (byte) newMode; regenerate(); compute(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Holder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Holder.java index ca1ef49fe2..e8377ba7bb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Holder.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Holder.java @@ -15,51 +15,66 @@ public class GT_Container_Holder extends GT_ContainerMetaTile_Machine { super(aInventoryPlayer, aTileEntity); } + @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot(this.mTileEntity, 0, 80, 39)); + addSlotToContainer(new Slot(mTileEntity, 0, 80, 39)); } + @Override public int getSlotCount() { return 1; } + @Override public int getShiftClickSlotCount() { return 1; } @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (mActive != 0) return null; + if (mActive != 0) { + return null; + } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } @Override public ItemStack transferStackInSlot(EntityPlayer aPlayer, int aSlotIndex) { - if (mActive != 0) return null; + if (mActive != 0) { + return null; + } return super.transferStackInSlot(aPlayer, aSlotIndex); } @Override public boolean canDragIntoSlot(Slot par1Slot) { - if (mActive != 0) return false; + if (mActive != 0) { + return false; + } return super.canDragIntoSlot(par1Slot); } @Override public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack) { - if (mActive != 0) return; + if (mActive != 0) { + return; + } super.putStacksInSlots(par1ArrayOfItemStack); } @Override protected boolean mergeItemStack(ItemStack aStack, int aStartIndex, int aSlotCount, boolean par4) { - if (mActive != 0) return false; + if (mActive != 0) { + return false; + } return super.mergeItemStack(aStack, aStartIndex, aSlotCount, par4); } @Override public void putStackInSlot(int par1, ItemStack par2ItemStack) { - if (mActive != 0) return; + if (mActive != 0) { + return; + } super.putStackInSlot(par1, par2ItemStack); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java index 3a6d4b74fa..fec3be6e20 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Param.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -12,8 +13,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.Iterator; - public class GT_Container_Param extends GT_ContainerMetaTile_Machine { public int param = 0; public int value0f = 0; @@ -27,25 +26,25 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 59, false, false, 1)); } @Override @@ -53,58 +52,58 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { if (aSlotIndex < 0) { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); boolean doStuff = true; - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { - GT_MetaTileEntity_Hatch_Param paramH = (GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity(); + if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { + GT_MetaTileEntity_Hatch_Param paramH = (GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity(); switch (aSlotIndex) { case 0: - paramH.param -= (aShifthold == 1 ? 16 : 4); + paramH.param -= aShifthold == 1 ? 16 : 4; break; case 1: - paramH.value0i -= (aShifthold == 1 ? 4096 : 256); + paramH.value0i -= aShifthold == 1 ? 4096 : 256; break; case 2: - paramH.value1i -= (aShifthold == 1 ? 4096 : 256); + paramH.value1i -= aShifthold == 1 ? 4096 : 256; break; case 3: paramH.value0i >>= aShifthold == 1 ? 16 : 4; paramH.value1i >>= aShifthold == 1 ? 16 : 4; break; case 4: - paramH.param -= (aShifthold == 1 ? 2 : 1); + paramH.param -= aShifthold == 1 ? 2 : 1; break; case 5: - paramH.value0i -= (aShifthold == 1 ? 16 : 1); + paramH.value0i -= aShifthold == 1 ? 16 : 1; break; case 6: - paramH.value1i -= (aShifthold == 1 ? 16 : 1); + paramH.value1i -= aShifthold == 1 ? 16 : 1; break; case 7: paramH.value0i >>= aShifthold == 1 ? 2 : 1; paramH.value1i >>= aShifthold == 1 ? 2 : 1; break; case 8: - paramH.param += (aShifthold == 1 ? 16 : 4); + paramH.param += aShifthold == 1 ? 16 : 4; break; case 9: - paramH.value0i += (aShifthold == 1 ? 4096 : 256); + paramH.value0i += aShifthold == 1 ? 4096 : 256; break; case 10: - paramH.value1i += (aShifthold == 1 ? 4096 : 256); + paramH.value1i += aShifthold == 1 ? 4096 : 256; break; case 11: paramH.value0i <<= aShifthold == 1 ? 16 : 4; paramH.value1i <<= aShifthold == 1 ? 16 : 4; break; case 12: - paramH.param += (aShifthold == 1 ? 2 : 1); + paramH.param += aShifthold == 1 ? 2 : 1; break; case 13: - paramH.value0i += (aShifthold == 1 ? 16 : 1); + paramH.value0i += aShifthold == 1 ? 16 : 1; break; case 14: - paramH.value1i += (aShifthold == 1 ? 16 : 1); + paramH.value1i += aShifthold == 1 ? 16 : 1; break; case 15: paramH.value0i <<= aShifthold == 1 ? 2 : 1; @@ -114,8 +113,13 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { doStuff = false; } if (doStuff) { - if (paramH.param > 9) paramH.param = 9; - else if (paramH.param < -1) paramH.param = -1; + IGregTechTileEntity base=paramH.getBaseMetaTileEntity(); + TecTech.proxy.playSound(base,"fx_click"); + if (paramH.param > 9) { + paramH.param = 9; + } else if (paramH.param < -1) { + paramH.param = -1; + } } } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); @@ -124,64 +128,64 @@ public class GT_Container_Param extends GT_ContainerMetaTile_Machine { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { return; } - this.param = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).param; - this.value0f = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).value0i; - this.value1f = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).value1i; - this.input0f = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).input0i; - this.input1f = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).input1i; + param = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).param; + value0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value0i; + value1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value1i; + input0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input0i; + input1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input1i; - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, this.param & 0xFFFF); - var1.sendProgressBarUpdate(this, 101, this.param >>> 16); - var1.sendProgressBarUpdate(this, 102, this.value0f & 0xFFFF); - var1.sendProgressBarUpdate(this, 103, this.value0f >>> 16); - var1.sendProgressBarUpdate(this, 104, this.value1f & 0xFFFF); - var1.sendProgressBarUpdate(this, 105, this.value1f >>> 16); - var1.sendProgressBarUpdate(this, 106, this.input0f & 0xFFFF); - var1.sendProgressBarUpdate(this, 107, this.input0f >>> 16); - var1.sendProgressBarUpdate(this, 108, this.input1f & 0xFFFF); - var1.sendProgressBarUpdate(this, 109, this.input1f >>> 16); + for (Object crafter : crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 100, param & 0xFFFF); + var1.sendProgressBarUpdate(this, 101, param >>> 16); + var1.sendProgressBarUpdate(this, 102, value0f & 0xFFFF); + var1.sendProgressBarUpdate(this, 103, value0f >>> 16); + var1.sendProgressBarUpdate(this, 104, value1f & 0xFFFF); + var1.sendProgressBarUpdate(this, 105, value1f >>> 16); + var1.sendProgressBarUpdate(this, 106, input0f & 0xFFFF); + var1.sendProgressBarUpdate(this, 107, input0f >>> 16); + var1.sendProgressBarUpdate(this, 108, input1f & 0xFFFF); + var1.sendProgressBarUpdate(this, 109, input1f >>> 16); } } + @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { super.updateProgressBar(par1, par2); switch (par1) { case 100: - this.param = (this.param & 0xFFFF0000 | par2); + param = param & 0xFFFF0000 | par2; return; case 101: - this.param = (this.param & 0xFFFF | (par2 << 16)); + param = param & 0xFFFF | par2 << 16; return; case 102: - this.value0f = (this.value0f & 0xFFFF0000 | par2); + value0f = value0f & 0xFFFF0000 | par2; break; case 103: - this.value0f = (this.value0f & 0xFFFF | (par2 << 16)); + value0f = value0f & 0xFFFF | par2 << 16; break; case 104: - this.value1f = (this.value1f & 0xFFFF0000 | par2); + value1f = value1f & 0xFFFF0000 | par2; break; case 105: - this.value1f = (this.value1f & 0xFFFF | (par2 << 16)); + value1f = value1f & 0xFFFF | par2 << 16; break; case 106: - this.input0f = (this.input0f & 0xFFFF0000 | par2); + input0f = input0f & 0xFFFF0000 | par2; break; case 107: - this.input0f = (this.input0f & 0xFFFF | (par2 << 16)); + input0f = input0f & 0xFFFF | par2 << 16; break; case 108: - this.input1f = (this.input1f & 0xFFFF0000 | par2); + input1f = input1f & 0xFFFF0000 | par2; return; case 109: - this.input1f = (this.input1f & 0xFFFF | (par2 << 16)); + input1f = input1f & 0xFFFF | par2 << 16; return; default: } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java index 2c4670e52f..289588a40a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_ParamAdv.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Param; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -12,8 +13,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.Iterator; - public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { public boolean usesFloats = false; public int pointer=0; @@ -29,25 +28,25 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 59, false, false, 1)); } @Override @@ -55,98 +54,148 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { if (aSlotIndex < 0) { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); boolean doStuff = true; - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { - GT_MetaTileEntity_Hatch_Param paramH = (GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity(); + if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { + GT_MetaTileEntity_Hatch_Param paramH = (GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity(); int columnPointer=paramH.pointer &0xff; boolean secondRow=(paramH.pointer &0x0100)!=0; boolean showInts=!paramH.isUsingFloats(); switch (aSlotIndex) { case 0: - paramH.param -= (aShifthold == 1 ? 16 : 4); + paramH.param -= aShifthold == 1 ? 16 : 4; break; case 1: - if (secondRow) secondRow = false; - else columnPointer -= (aShifthold == 1 ? 16 : 4); + if (secondRow) { + secondRow = false; + } else { + columnPointer -= aShifthold == 1 ? 16 : 4; + } break; case 2: - if (secondRow) columnPointer -= (aShifthold == 1 ? 16 : 4); - else secondRow = true; + if (secondRow) { + columnPointer -= aShifthold == 1 ? 16 : 4; + } else { + secondRow = true; + } break; case 3: if (aShifthold == 1) { - if (secondRow) paramH.value1i = 0xFFFFFFFF; - else paramH.value0i = 0xFFFFFFFF; + if (secondRow) { + paramH.value1i = 0xFFFFFFFF; + } else { + paramH.value0i = 0xFFFFFFFF; + } } else { - if (secondRow) paramH.value1i |= 1 << columnPointer; - else paramH.value0i |= 1 << columnPointer; + if (secondRow) { + paramH.value1i |= 1 << columnPointer; + } else { + paramH.value0i |= 1 << columnPointer; + } } break; case 4: - paramH.param -= (aShifthold == 1 ? 2 : 1); + paramH.param -= aShifthold == 1 ? 2 : 1; break; case 5: - if (secondRow) secondRow = false; - else columnPointer -= (aShifthold == 1 ? 2 : 1); + if (secondRow) { + secondRow = false; + } else { + columnPointer -= aShifthold == 1 ? 2 : 1; + } break; case 6: - if (secondRow) columnPointer -= (aShifthold == 1 ? 2 : 1); - else secondRow = true; + if (secondRow) { + columnPointer -= aShifthold == 1 ? 2 : 1; + } else { + secondRow = true; + } break; case 7: if (aShifthold == 1) { - if (secondRow) paramH.value1i = 0; - else paramH.value0i = 0; + if (secondRow) { + paramH.value1i = 0; + } else { + paramH.value0i = 0; + } } else { - if (secondRow) paramH.value1i &= ~(1 << columnPointer); - else paramH.value0i &= ~(1 << columnPointer); + if (secondRow) { + paramH.value1i &= ~(1 << columnPointer); + } else { + paramH.value0i &= ~(1 << columnPointer); + } } break; case 8: - paramH.param += (aShifthold == 1 ? 16 : 4); + paramH.param += aShifthold == 1 ? 16 : 4; break; case 9: - if (secondRow) secondRow = false; - else columnPointer += (aShifthold == 1 ? 16 : 4); + if (secondRow) { + secondRow = false; + } else { + columnPointer += aShifthold == 1 ? 16 : 4; + } break; case 10: - if (secondRow) columnPointer += (aShifthold == 1 ? 16 : 4); - else secondRow = true; + if (secondRow) { + columnPointer += aShifthold == 1 ? 16 : 4; + } else { + secondRow = true; + } break; case 11: showInts ^= true; break; case 12: - paramH.param += (aShifthold == 1 ? 2 : 1); + paramH.param += aShifthold == 1 ? 2 : 1; break; case 13: - if (secondRow) secondRow = false; - else columnPointer += (aShifthold == 1 ? 2 : 1); + if (secondRow) { + secondRow = false; + } else { + columnPointer += aShifthold == 1 ? 2 : 1; + } break; case 14: - if (secondRow) columnPointer += (aShifthold == 1 ? 2 : 1); - else secondRow = true; + if (secondRow) { + columnPointer += aShifthold == 1 ? 2 : 1; + } else { + secondRow = true; + } break; case 15: if (aShifthold == 1) { - if (secondRow) paramH.value1i ^= 0xFFFFFFFF; - else paramH.value0i ^= 0xFFFFFFFF; + if (secondRow) { + paramH.value1i ^= 0xFFFFFFFF; + } else { + paramH.value0i ^= 0xFFFFFFFF; + } } else { - if (secondRow) paramH.value1i ^= 1 << columnPointer; - else paramH.value0i ^= 1 << columnPointer; + if (secondRow) { + paramH.value1i ^= 1 << columnPointer; + } else { + paramH.value0i ^= 1 << columnPointer; + } } break; default: doStuff = false; } if (doStuff) { - if(columnPointer>=32) columnPointer=31; - else if(columnPointer<0) columnPointer=0; + IGregTechTileEntity base=paramH.getBaseMetaTileEntity(); + TecTech.proxy.playSound(base,"fx_click"); + if(columnPointer>=32) { + columnPointer = 31; + } else if(columnPointer<0) { + columnPointer = 0; + } paramH.pointer=secondRow?columnPointer+0x100:columnPointer; paramH.setUsingFloats(!showInts); - if (paramH.param > 9) paramH.param = 9; - else if (paramH.param < -1) paramH.param = -1; + if (paramH.param > 9) { + paramH.param = 9; + } else if (paramH.param < -1) { + paramH.param = -1; + } } } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); @@ -155,71 +204,71 @@ public class GT_Container_ParamAdv extends GT_ContainerMetaTile_Machine { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { return; } - this.param = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).param; - this.value0f = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).value0i; - this.value1f = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).value1i; - this.input0f = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).input0i; - this.input1f = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).input1i; - this.pointer = ((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).pointer; - this.usesFloats =((GT_MetaTileEntity_Hatch_Param) this.mTileEntity.getMetaTileEntity()).isUsingFloats(); + param = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).param; + value0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value0i; + value1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).value1i; + input0f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input0i; + input1f = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).input1i; + pointer = ((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).pointer; + usesFloats =((GT_MetaTileEntity_Hatch_Param) mTileEntity.getMetaTileEntity()).isUsingFloats(); - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, this.param & 0xFFFF); - var1.sendProgressBarUpdate(this, 101, this.param >>> 16); - var1.sendProgressBarUpdate(this, 102, this.value0f & 0xFFFF); - var1.sendProgressBarUpdate(this, 103, this.value0f >>> 16); - var1.sendProgressBarUpdate(this, 104, this.value1f & 0xFFFF); - var1.sendProgressBarUpdate(this, 105, this.value1f >>> 16); - var1.sendProgressBarUpdate(this, 106, this.input0f & 0xFFFF); - var1.sendProgressBarUpdate(this, 107, this.input0f >>> 16); - var1.sendProgressBarUpdate(this, 108, this.input1f & 0xFFFF); - var1.sendProgressBarUpdate(this, 109, this.input1f >>> 16); - var1.sendProgressBarUpdate(this, 110, this.usesFloats?this.pointer+0x10000:this.pointer); + for (Object crafter : crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 100, param & 0xFFFF); + var1.sendProgressBarUpdate(this, 101, param >>> 16); + var1.sendProgressBarUpdate(this, 102, value0f & 0xFFFF); + var1.sendProgressBarUpdate(this, 103, value0f >>> 16); + var1.sendProgressBarUpdate(this, 104, value1f & 0xFFFF); + var1.sendProgressBarUpdate(this, 105, value1f >>> 16); + var1.sendProgressBarUpdate(this, 106, input0f & 0xFFFF); + var1.sendProgressBarUpdate(this, 107, input0f >>> 16); + var1.sendProgressBarUpdate(this, 108, input1f & 0xFFFF); + var1.sendProgressBarUpdate(this, 109, input1f >>> 16); + var1.sendProgressBarUpdate(this, 110, usesFloats ? pointer + 0x10000 : pointer); } } + @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { super.updateProgressBar(par1, par2); switch (par1) { case 100: - this.param = (this.param & 0xFFFF0000 | par2); + param = param & 0xFFFF0000 | par2; return; case 101: - this.param = (this.param & 0xFFFF | (par2 << 16)); + param = param & 0xFFFF | par2 << 16; return; case 102: - this.value0f = (this.value0f & 0xFFFF0000 | par2); + value0f = value0f & 0xFFFF0000 | par2; break; case 103: - this.value0f = (this.value0f & 0xFFFF | (par2 << 16)); + value0f = value0f & 0xFFFF | par2 << 16; break; case 104: - this.value1f = (this.value1f & 0xFFFF0000 | par2); + value1f = value1f & 0xFFFF0000 | par2; break; case 105: - this.value1f = (this.value1f & 0xFFFF | (par2 << 16)); + value1f = value1f & 0xFFFF | par2 << 16; break; case 106: - this.input0f = (this.input0f & 0xFFFF0000 | par2); + input0f = input0f & 0xFFFF0000 | par2; break; case 107: - this.input0f = (this.input0f & 0xFFFF | (par2 << 16)); + input0f = input0f & 0xFFFF | par2 << 16; break; case 108: - this.input1f = (this.input1f & 0xFFFF0000 | par2); + input1f = input1f & 0xFFFF0000 | par2; return; case 109: - this.input1f = (this.input1f & 0xFFFF | (par2 << 16)); + input1f = input1f & 0xFFFF | par2 << 16; return; case 110: - this.pointer = par2 & 0xFFFF; - this.usesFloats=par2>=0x10000; + pointer = par2 & 0xFFFF; + usesFloats =par2>=0x10000; default: } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Rack.java index 87bedcb3dd..1ce14585bc 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Rack.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Rack.java @@ -11,8 +11,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.Iterator; - /** * Created by Tec on 09.04.2017. */ @@ -23,17 +21,20 @@ public class GT_Container_Rack extends GT_ContainerMetaTile_Machine { super(aInventoryPlayer, aTileEntity); } + @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - this.addSlotToContainer(new Slot(this.mTileEntity, 0, 69, 28)); - this.addSlotToContainer(new Slot(this.mTileEntity, 1, 91, 28)); - this.addSlotToContainer(new Slot(this.mTileEntity, 2, 69, 50)); - this.addSlotToContainer(new Slot(this.mTileEntity, 3, 91, 50)); + addSlotToContainer(new Slot(mTileEntity, 0, 69, 28)); + addSlotToContainer(new Slot(mTileEntity, 1, 91, 28)); + addSlotToContainer(new Slot(mTileEntity, 2, 69, 50)); + addSlotToContainer(new Slot(mTileEntity, 3, 91, 50)); } + @Override public int getSlotCount() { return 4; } + @Override public int getShiftClickSlotCount() { return 4; } @@ -41,61 +42,72 @@ public class GT_Container_Rack extends GT_ContainerMetaTile_Machine { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { return; } - this.heat = ((GT_MetaTileEntity_Hatch_Rack) this.mTileEntity.getMetaTileEntity()).heat > 0; + heat = ((GT_MetaTileEntity_Hatch_Rack) mTileEntity.getMetaTileEntity()).heat > 0; - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, this.heat ? 1 : 0); + for (Object crafter : crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 100, heat ? 1 : 0); } } + @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { super.updateProgressBar(par1, par2); switch (par1) { case 100: - this.heat = par2 != 0; - return; + heat = par2 != 0; } } @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (heat || mActive != 0) return null; + if (heat || mActive != 0) { + return null; + } return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } @Override public ItemStack transferStackInSlot(EntityPlayer aPlayer, int aSlotIndex) { - if (heat || mActive != 0) return null; + if (heat || mActive != 0) { + return null; + } return super.transferStackInSlot(aPlayer, aSlotIndex); } @Override public boolean canDragIntoSlot(Slot par1Slot) { - if (heat || mActive != 0) return false; + if (heat || mActive != 0) { + return false; + } return super.canDragIntoSlot(par1Slot); } @Override public void putStacksInSlots(ItemStack[] par1ArrayOfItemStack) { - if (heat || mActive != 0) return; + if (heat || mActive != 0) { + return; + } super.putStacksInSlots(par1ArrayOfItemStack); } @Override protected boolean mergeItemStack(ItemStack aStack, int aStartIndex, int aSlotCount, boolean par4) { - if (heat || mActive != 0) return false; + if (heat || mActive != 0) { + return false; + } return super.mergeItemStack(aStack, aStartIndex, aSlotCount, par4); } @Override public void putStackInSlot(int par1, ItemStack par2ItemStack) { - if (heat || mActive != 0) return; + if (heat || mActive != 0) { + return; + } super.putStackInSlot(par1, par2ItemStack); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Uncertainty.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Uncertainty.java index 8db5fc1aa4..45bc8dede0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Uncertainty.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Uncertainty.java @@ -1,5 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Uncertainty; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -12,8 +13,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.Iterator; - public class GT_Container_Uncertainty extends GT_ContainerMetaTile_Machine { 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; @@ -24,25 +23,25 @@ public class GT_Container_Uncertainty extends GT_ContainerMetaTile_Machine { @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 59, false, false, 1)); - - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 59, false, false, 1)); + + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 59, false, false, 1)); } @Override @@ -50,12 +49,14 @@ public class GT_Container_Uncertainty extends GT_ContainerMetaTile_Machine { if (aSlotIndex < 0) { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { - GT_MetaTileEntity_Hatch_Uncertainty catH = (GT_MetaTileEntity_Hatch_Uncertainty) this.mTileEntity.getMetaTileEntity(); + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { + GT_MetaTileEntity_Hatch_Uncertainty catH = (GT_MetaTileEntity_Hatch_Uncertainty) mTileEntity.getMetaTileEntity(); if (aSlotIndex < 16 && catH.matrix != null) { + IGregTechTileEntity base=catH.getBaseMetaTileEntity(); + TecTech.proxy.playSound(base,"fx_click"); if (catH.selection == -1) { - catH.selection = (byte) (aSlotIndex); + catH.selection = (byte) aSlotIndex; } else { short temp = catH.matrix[catH.selection]; catH.matrix[catH.selection] = catH.matrix[aSlotIndex]; @@ -71,49 +72,53 @@ public class GT_Container_Uncertainty extends GT_ContainerMetaTile_Machine { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { return; } - ((GT_MetaTileEntity_Hatch_Uncertainty) this.mTileEntity.getMetaTileEntity()).compute(); + ((GT_MetaTileEntity_Hatch_Uncertainty) mTileEntity.getMetaTileEntity()).compute(); - if (this.matrix != null) - for (int i = 0; i < 16; i++) - this.matrix[i] = ((GT_MetaTileEntity_Hatch_Uncertainty) this.mTileEntity.getMetaTileEntity()).matrix[i]; + if (matrix != null) { + for (int i = 0; i < 16; i++) { + matrix[i] = ((GT_MetaTileEntity_Hatch_Uncertainty) mTileEntity.getMetaTileEntity()).matrix[i]; + } + } - this.selection = ((GT_MetaTileEntity_Hatch_Uncertainty) this.mTileEntity.getMetaTileEntity()).selection; - this.mode = ((GT_MetaTileEntity_Hatch_Uncertainty) this.mTileEntity.getMetaTileEntity()).mode; - this.status = ((GT_MetaTileEntity_Hatch_Uncertainty) this.mTileEntity.getMetaTileEntity()).status; + selection = ((GT_MetaTileEntity_Hatch_Uncertainty) mTileEntity.getMetaTileEntity()).selection; + mode = ((GT_MetaTileEntity_Hatch_Uncertainty) mTileEntity.getMetaTileEntity()).mode; + status = ((GT_MetaTileEntity_Hatch_Uncertainty) mTileEntity.getMetaTileEntity()).status; - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); - var1.sendProgressBarUpdate(this, 100, this.selection); - var1.sendProgressBarUpdate(this, 101, this.mode); - var1.sendProgressBarUpdate(this, 102, this.status); + for (Object crafter : crafters) { + ICrafting var1 = (ICrafting) crafter; + var1.sendProgressBarUpdate(this, 100, selection); + var1.sendProgressBarUpdate(this, 101, mode); + var1.sendProgressBarUpdate(this, 102, status); - if (this.matrix != null) - for (int i = 0; i < 16; i++) - var1.sendProgressBarUpdate(this, 103 + i, this.matrix[i]); + if (matrix != null) { + for (int i = 0; i < 16; i++) { + var1.sendProgressBarUpdate(this, 103 + i, matrix[i]); + } + } } } + @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { super.updateProgressBar(par1, par2); switch (par1) { case 100: - this.selection = (byte) par2; + selection = (byte) par2; break; case 101: - this.mode = (byte) par2; + mode = (byte) par2; break; case 102: - this.status = (byte) par2; + status = (byte) par2; break; default: if (matrix != null && par1 >= 103 && par1 < 119) { - this.matrix[par1 - 103] = (short) par2; + matrix[par1 - 103] = (short) par2; break; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Holder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Holder.java index 596d8f5420..7019a6128e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Holder.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Holder.java @@ -12,21 +12,24 @@ public class GT_GUIContainer_Holder extends GT_GUIContainerMetaTile_Machine { public GT_GUIContainer_Holder(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_Holder(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/holder.png"); - this.mName = aName; + mName = aName; } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); + fontRendererObj.drawString(mName, 8, 4, 4210752); } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null) { - if (((GT_Container_Holder) mContainer).mActive == 1) + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if (mContainer != null) { + if (((GT_Container_Holder) mContainer).mActive == 1) { drawTexturedModalRect(x + 151, y + 23, 183, 23, 18, 18); + } } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java index 4a7d25c95a..d9502333d8 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Param.java @@ -15,25 +15,27 @@ public class GT_GUIContainer_Param extends GT_GUIContainerMetaTile_Machine { super(new GT_Container_Param(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Parametrizer.png"); } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - if (this.mContainer != null) { - proxy.renderUnicodeString("Parameters: " + ((GT_Container_Param) this.mContainer).param, 46, 7, 167, 0xffffff); - Locale locale=java.util.Locale.getDefault(); - proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+d", ((GT_Container_Param) this.mContainer).input0f), 46, 16, 167, 0x22ddff); - proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+d", ((GT_Container_Param) this.mContainer).input1f), 46, 24, 167, 0x00ffff); - proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+d", ((GT_Container_Param) this.mContainer).value0f), 46, 33, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+d", ((GT_Container_Param) this.mContainer).value1f), 46, 41, 167, 0x0077ff); - proxy.renderUnicodeString("\u24EA\u2b06" + Util.intBitsToShortString(((GT_Container_Param) this.mContainer).value0f), 46, 50, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + Util.intBitsToShortString(((GT_Container_Param) this.mContainer).value1f), 46, 58, 167, 0x0077ff); + if (mContainer != null) { + proxy.renderUnicodeString("Parameters: " + ((GT_Container_Param) mContainer).param, 46, 7, 167, 0xffffff); + Locale locale= Locale.getDefault(); + proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+d", ((GT_Container_Param) mContainer).input0f), 46, 16, 167, 0x22ddff); + proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+d", ((GT_Container_Param) mContainer).input1f), 46, 24, 167, 0x00ffff); + proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+d", ((GT_Container_Param) mContainer).value0f), 46, 33, 167, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+d", ((GT_Container_Param) mContainer).value1f), 46, 41, 167, 0x0077ff); + proxy.renderUnicodeString("\u24EA\u2b06" + Util.intBitsToShortString(((GT_Container_Param) mContainer).value0f), 46, 50, 167, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + Util.intBitsToShortString(((GT_Container_Param) mContainer).value1f), 46, 58, 167, 0x0077ff); } else { proxy.renderUnicodeString("Parameters", 46, 7, 167, 0xffffff); } } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java index 8e34664919..245ec91b20 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_ParamAdv.java @@ -15,33 +15,35 @@ public class GT_GUIContainer_ParamAdv extends GT_GUIContainerMetaTile_Machine { super(new GT_Container_ParamAdv(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "ParametrizerAdv.png"); } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - if (this.mContainer != null) { - proxy.renderUnicodeString("Parameters X: " + ((GT_Container_ParamAdv) this.mContainer).param, 46, 7, 167, 0xffffff); - Locale locale=java.util.Locale.getDefault(); - if (((GT_Container_ParamAdv) this.mContainer).usesFloats) { - proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) this.mContainer).input0f)), 46, 16, 167, 0x22ddff); - proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) this.mContainer).input1f)), 46, 24, 167, 0x00ffff); - proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) this.mContainer).value0f)), 46, 33, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) this.mContainer).value1f)), 46, 41, 167, 0x0077ff); + if (mContainer != null) { + proxy.renderUnicodeString("Parameters X: " + ((GT_Container_ParamAdv) mContainer).param, 46, 7, 167, 0xffffff); + Locale locale= Locale.getDefault(); + if (((GT_Container_ParamAdv) mContainer).usesFloats) { + proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) mContainer).input0f)), 46, 16, 167, 0x22ddff); + proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) mContainer).input1f)), 46, 24, 167, 0x00ffff); + proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) mContainer).value0f)), 46, 33, 167, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+.5E", Float.intBitsToFloat(((GT_Container_ParamAdv) mContainer).value1f)), 46, 41, 167, 0x0077ff); } else { - proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+d", ((GT_Container_ParamAdv) this.mContainer).input0f), 46, 16, 167, 0x22ddff); - proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+d", ((GT_Container_ParamAdv) this.mContainer).input1f), 46, 24, 167, 0x00ffff); - proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+d", ((GT_Container_ParamAdv) this.mContainer).value0f), 46, 33, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+d", ((GT_Container_ParamAdv) this.mContainer).value1f), 46, 41, 167, 0x0077ff); + proxy.renderUnicodeString("\u24EA\u2b07" + String.format(locale, "%+d", ((GT_Container_ParamAdv) mContainer).input0f), 46, 16, 167, 0x22ddff); + proxy.renderUnicodeString("\u2460\u2b07" + String.format(locale, "%+d", ((GT_Container_ParamAdv) mContainer).input1f), 46, 24, 167, 0x00ffff); + proxy.renderUnicodeString("\u24EA\u2b06" + String.format(locale, "%+d", ((GT_Container_ParamAdv) mContainer).value0f), 46, 33, 167, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + String.format(locale, "%+d", ((GT_Container_ParamAdv) mContainer).value1f), 46, 41, 167, 0x0077ff); } - proxy.renderUnicodeString("\u24EA\u2b06" + Util.intBitsToShortString(((GT_Container_ParamAdv) this.mContainer).value0f), 46, 50, 167, 0x00bbff); - proxy.renderUnicodeString("\u2460\u2b06" + Util.intBitsToShortString(((GT_Container_ParamAdv) this.mContainer).value1f), 46, 58, 167, 0x0077ff); - proxy.renderUnicodeString("Pointer " + Integer.toHexString(((GT_Container_ParamAdv) this.mContainer).pointer | 0x10000).substring(1), 46, 66, 167, 0x0033ff); + proxy.renderUnicodeString("\u24EA\u2b06" + Util.intBitsToShortString(((GT_Container_ParamAdv) mContainer).value0f), 46, 50, 167, 0x00bbff); + proxy.renderUnicodeString("\u2460\u2b06" + Util.intBitsToShortString(((GT_Container_ParamAdv) mContainer).value1f), 46, 58, 167, 0x0077ff); + proxy.renderUnicodeString("Pointer " + Integer.toHexString(((GT_Container_ParamAdv) mContainer).pointer | 0x10000).substring(1), 46, 66, 167, 0x0033ff); } else { proxy.renderUnicodeString("Parameters X", 46, 7, 167, 0xffffff); } } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Rack.java index e4dc042772..396a690a8f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Rack.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Rack.java @@ -12,23 +12,27 @@ public class GT_GUIContainer_Rack extends GT_GUIContainerMetaTile_Machine { public GT_GUIContainer_Rack(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName) { super(new GT_Container_Rack(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/rack.png"); - this.mName = aName; + mName = aName; } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString(this.mName, 8, 4, 4210752); + fontRendererObj.drawString(mName, 8, 4, 4210752); } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null) { - if (((GT_Container_Rack) mContainer).mActive == 1) + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if (mContainer != null) { + if (((GT_Container_Rack) mContainer).mActive == 1) { drawTexturedModalRect(x + 151, y + 23, 183, 23, 18, 18); - if (((GT_Container_Rack) mContainer).heat) + } + if (((GT_Container_Rack) mContainer).heat) { drawTexturedModalRect(x + 151, y + 41, 183, 41, 18, 18); + } } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Uncertainty.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Uncertainty.java index 19826984c3..f5fe2bd002 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Uncertainty.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Uncertainty.java @@ -14,26 +14,29 @@ public class GT_GUIContainer_Uncertainty extends GT_GUIContainerMetaTile_Machine super(new GT_Container_Uncertainty(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Uncertainty.png"); } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { proxy.renderUnicodeString("Schr\u00F6dinger", 46, 7, 167, 0xffffff); - if (this.mContainer != null && ((GT_Container_Uncertainty) this.mContainer).status == 0) + if (mContainer != null && ((GT_Container_Uncertainty) mContainer).status == 0) { proxy.renderUnicodeString("Status: OK", 46, 16, 167, 0xffffff); - else + } else { proxy.renderUnicodeString("Status: NG", 46, 16, 167, 0xffffff); + } } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null && ((GT_Container_Uncertainty) this.mContainer).matrix != null) { + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if (mContainer != null && ((GT_Container_Uncertainty) mContainer).matrix != null) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - final short bU = 0, rU = 70, fU = 192, V = 210, Vs = 216; + short bU = 0, rU = 70, fU = 192, V = 210, Vs = 216; x += 52; y += 33; - final int state = ((GT_Container_Uncertainty) this.mContainer).status; - switch (((GT_Container_Uncertainty) this.mContainer).mode) { + int state = ((GT_Container_Uncertainty) mContainer).status; + switch (((GT_Container_Uncertainty) mContainer).mode) { case 1://ooo oxo ooo drawTexturedModalRect(x + 12, y + 12, rU + (state == 0 ? 76 : 12), @@ -95,12 +98,13 @@ public class GT_GUIContainer_Uncertainty extends GT_GUIContainerMetaTile_Machine } x -= 6; y -= 6; - for (int i = 0; i < 16; 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) { - int sel = ((GT_Container_Uncertainty) this.mContainer).selection; + for (int i = 0; i < 16; i++) { + if (TecTech.Rnd.nextInt(1000) < ((GT_Container_Uncertainty) 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) mContainer).selection > -1) { + int sel = ((GT_Container_Uncertainty) mContainer).selection; drawTexturedModalRect(x + 12 * (sel / 4), y + 12 * (sel % 4), bU + 12 * (sel / 4), V + 12 * (sel % 4), 10, 10); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_UncertaintyAdv.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_UncertaintyAdv.java index d6a0b14f34..b327424937 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_UncertaintyAdv.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_UncertaintyAdv.java @@ -3,7 +3,6 @@ package com.github.technus.tectech.thing.metaTileEntity.hatch.gui; import gregtech.api.gui.GT_GUIContainerMetaTile_Machine; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.entity.player.InventoryPlayer; -import org.lwjgl.opengl.GL11; import static com.github.technus.tectech.TecTech.proxy; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; @@ -16,82 +15,53 @@ public class GT_GUIContainer_UncertaintyAdv extends GT_GUIContainerMetaTile_Mach super(new GT_Container_Uncertainty(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Uncertainty.png"); } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { proxy.renderUnicodeString("Schr\u00F6dinger X", 46, 7, 167, 0xffffff); - if (this.mContainer != null && ((GT_Container_Uncertainty) this.mContainer).status == 0) + if (mContainer != null && ((GT_Container_Uncertainty) mContainer).status == 0) { proxy.renderUnicodeString("Status: OK", 46, 16, 167, 0xffffff); - else + } else { proxy.renderUnicodeString("Status: NG", 46, 16, 167, 0xffffff); + } } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); - if (this.mContainer != null && ((GT_Container_Uncertainty) this.mContainer).matrix != null) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if (mContainer != null && ((GT_Container_Uncertainty) mContainer).matrix != null) { + glColor4f(1.0F, 1.0F, 1.0F, 1.0F); x += sX; y += sY; - final int state = ((GT_Container_Uncertainty) this.mContainer).status; - switch (((GT_Container_Uncertainty) this.mContainer).mode) { + int state = ((GT_Container_Uncertainty) mContainer).status; + switch (((GT_Container_Uncertainty) mContainer).mode) { case 1://ooo oxo ooo - drawTexturedModalRect(x + 12, y + 12, - rU + (state == 0 ? 76 : 12), - Vs + 12, 10, 10); + drawTexturedModalRect(x + 12, y + 12, rU + (state == 0 ? 76 : 12), Vs + 12, 10, 10); break; case 2://ooo xox ooo - drawTexturedModalRect(x, y + 12, - rU + ((state & 1) == 0 ? 64 : 0), - Vs + 12, 10, 10); - drawTexturedModalRect(x + 24, y + 12, - rU + ((state & 2) == 0 ? 88 : 24), - Vs + 12, 10, 10); + drawTexturedModalRect(x, y + 12, rU + ((state & 1) == 0 ? 64 : 0), Vs + 12, 10, 10); + drawTexturedModalRect(x + 24, y + 12, rU + ((state & 2) == 0 ? 88 : 24), Vs + 12, 10, 10); break; case 3://oxo xox oxo - drawTexturedModalRect(x + 12, y, - rU + ((state & 1) == 0 ? 76 : 12), - Vs, 10, 10); - drawTexturedModalRect(x, y + 12, - rU + ((state & 2) == 0 ? 64 : 0), - Vs + 12, 10, 10); - drawTexturedModalRect(x + 24, y + 12, - rU + ((state & 4) == 0 ? 88 : 24), - Vs + 12, 10, 10); - drawTexturedModalRect(x + 12, y + 24, - rU + ((state & 8) == 0 ? 76 : 12), - Vs + 24, 10, 10); + drawTexturedModalRect(x + 12, y, rU + ((state & 1) == 0 ? 76 : 12), Vs, 10, 10); + drawTexturedModalRect(x, y + 12, rU + ((state & 2) == 0 ? 64 : 0), Vs + 12, 10, 10); + drawTexturedModalRect(x + 24, y + 12, rU + ((state & 4) == 0 ? 88 : 24), Vs + 12, 10, 10); + drawTexturedModalRect(x + 12, y + 24, rU + ((state & 8) == 0 ? 76 : 12), Vs + 24, 10, 10); break; case 4://xox ooo xox - drawTexturedModalRect(x, y, - rU + ((state & 1) == 0 ? 64 : 0), - Vs, 10, 10); - drawTexturedModalRect(x + 24, y, - rU + ((state & 2) == 0 ? 88 : 24), - Vs, 10, 10); - drawTexturedModalRect(x, y + 24, - rU + ((state & 4) == 0 ? 64 : 0), - Vs + 24, 10, 10); - drawTexturedModalRect(x + 24, y + 24, - rU + ((state & 8) == 0 ? 88 : 24), - Vs + 24, 10, 10); + drawTexturedModalRect(x, y, rU + ((state & 1) == 0 ? 64 : 0), Vs, 10, 10); + drawTexturedModalRect(x + 24, y, rU + ((state & 2) == 0 ? 88 : 24), Vs, 10, 10); + drawTexturedModalRect(x, y + 24, rU + ((state & 4) == 0 ? 64 : 0), Vs + 24, 10, 10); + drawTexturedModalRect(x + 24, y + 24, rU + ((state & 8) == 0 ? 88 : 24), Vs + 24, 10, 10); break; case 5://xox ooo xox - drawTexturedModalRect(x, y, - rU + ((state & 1) == 0 ? 64 : 0), - Vs, 10, 10); - drawTexturedModalRect(x + 24, y, - rU + ((state & 2) == 0 ? 88 : 24), - Vs, 10, 10); - drawTexturedModalRect(x + 12, y + 12, - rU + ((state & 4) == 0 ? 76 : 12), - Vs + 12, 10, 10); - drawTexturedModalRect(x, y + 24, - rU + ((state & 8) == 0 ? 64 : 0), - Vs + 24, 10, 10); - drawTexturedModalRect(x + 24, y + 24, - rU + ((state & 16) == 0 ? 88 : 24), - Vs + 24, 10, 10); + drawTexturedModalRect(x, y, rU + ((state & 1) == 0 ? 64 : 0), Vs, 10, 10); + drawTexturedModalRect(x + 24, y, rU + ((state & 2) == 0 ? 88 : 24), Vs, 10, 10); + drawTexturedModalRect(x + 12, y + 12, rU + ((state & 4) == 0 ? 76 : 12), Vs + 12, 10, 10); + drawTexturedModalRect(x, y + 24, rU + ((state & 8) == 0 ? 64 : 0), Vs + 24, 10, 10); + drawTexturedModalRect(x + 24, y + 24, rU + ((state & 16) == 0 ? 88 : 24), Vs + 24, 10, 10); break; } x -= 6; @@ -100,17 +70,15 @@ public class GT_GUIContainer_UncertaintyAdv extends GT_GUIContainerMetaTile_Mach glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); for (int i = 0; i < 16; i++) { - GL11.glColor4f(1f, 1f, 1f, (float) ((GT_Container_Uncertainty) this.mContainer).matrix[i] / 1000f); - drawTexturedModalRect(x + 12 * (i / 4), y + 12 * (i % 4), - fU + 12 * (i / 4), V + 12 * (i % 4), 10, 10); + glColor4f(1f, 1f, 1f, (float) ((GT_Container_Uncertainty) mContainer).matrix[i] / 1000f); + drawTexturedModalRect(x + 12 * (i / 4), y + 12 * (i % 4), fU + 12 * (i / 4), V + 12 * (i % 4), 10, 10); } glDisable(GL_BLEND); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - if (((GT_Container_Uncertainty) this.mContainer).selection > -1) { - int sel = ((GT_Container_Uncertainty) this.mContainer).selection; - drawTexturedModalRect(x + 12 * (sel / 4), y + 12 * (sel % 4), - bU + 12 * (sel / 4), V + 12 * (sel % 4), 10, 10); + glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + if (((GT_Container_Uncertainty) mContainer).selection > -1) { + int sel = ((GT_Container_Uncertainty) mContainer).selection; + drawTexturedModalRect(x + 12 * (sel / 4), y + 12 * (sel % 4), bU + 12 * (sel / 4), V + 12 * (sel % 4), 10, 10); } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java index f64e6c84d5..cfcbf1ac90 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java @@ -63,8 +63,9 @@ public class GT_MetaTileEntity_EM_annihilation extends GT_MetaTileEntity_Multibl super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_annihilation(this.mName); + return new GT_MetaTileEntity_EM_annihilation(mName); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java index a4eb61ae65..748fa18f5a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java @@ -132,8 +132,9 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_bhg(this.mName); + return new GT_MetaTileEntity_EM_bhg(mName); } @Override @@ -152,8 +153,11 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E @Override public void construct(int stackSize, boolean hintsOnly) { - if((stackSize &1)==1) StructureBuilder(shape, blockType, blockMeta,16, 16, 0, getBaseMetaTileEntity(),hintsOnly); - else StructureBuilder(shape2, blockType2, blockMeta2,16, 16, 0, getBaseMetaTileEntity(),hintsOnly); + if((stackSize &1)==1) { + StructureBuilder(shape, blockType, blockMeta, 16, 16, 0, getBaseMetaTileEntity(), hintsOnly); + } else { + StructureBuilder(shape2, blockType2, blockMeta2, 16, 16, 0, getBaseMetaTileEntity(), hintsOnly); + } } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java index 2903b99759..bc814e30d2 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_collider.java @@ -60,12 +60,12 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB {"F2222#\"#2222","F41155555114","F2222#\"#2222",}, }; private static final Block[] blockType = new Block[]{ - TT_Container_Casings.sBlockCasingsTT, - TT_Container_Casings.sBlockCasingsTT, - TT_Container_Casings.sBlockCasingsTT, + sBlockCasingsTT, + sBlockCasingsTT, + sBlockCasingsTT, QuantumGlassBlock.INSTANCE, - TT_Container_Casings.sBlockCasingsTT, - TT_Container_Casings.sBlockCasingsTT + sBlockCasingsTT, + sBlockCasingsTT }; private static final byte[] blockMeta1 = new byte[]{4, 7, 4, 0, 4, 8}; private static final byte[] blockMeta2 = new byte[]{4, 7, 5, 0, 6, 9}; @@ -91,8 +91,9 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_collider(this.mName); + return new GT_MetaTileEntity_EM_collider(mName); } @Override @@ -132,7 +133,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { int xDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetX*2; int zDir = ForgeDirection.getOrientation(iGregTechTileEntity.getBackFacing()).offsetZ*2; - if (iGregTechTileEntity.getBlockOffset(xDir, 0, zDir) != TT_Container_Casings.sBlockCasingsTT) { + if (iGregTechTileEntity.getBlockOffset(xDir, 0, zDir) != sBlockCasingsTT) { eTier = 0; return false; } @@ -149,16 +150,18 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB boolean test; switch (eTier) { case 1: - test = structureCheck_EM(shape, blockType, blockMeta1,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback, 11, 1, 18); + test = structureCheck_EM(shape, blockType, blockMeta1, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 11, 1, 18); break; case 2: - test = structureCheck_EM(shape, blockType, blockMeta2,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback, 11, 1, 18); + test = structureCheck_EM(shape, blockType, blockMeta2, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 11, 1, 18); break; default: eTier = 0; return false; } - if (test) return true; + if (test) { + return true; + } eTier = 0; return false; } @@ -175,17 +178,15 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB iGregTechTileEntity.getZCoord()+zDir, TT_Container_Casings.sHintCasingsTT,12); } else{ - if(iGregTechTileEntity.getBlockOffset(xDir,0,zDir).getMaterial() == Material.air) - iGregTechTileEntity.getWorld().setBlock( - iGregTechTileEntity.getXCoord()+xDir, - iGregTechTileEntity.getYCoord(), - iGregTechTileEntity.getZCoord()+zDir, - TT_Container_Casings.sHintCasingsTT,12,2); + if(iGregTechTileEntity.getBlockOffset(xDir,0,zDir).getMaterial() == Material.air) { + iGregTechTileEntity.getWorld().setBlock(iGregTechTileEntity.getXCoord() + xDir, iGregTechTileEntity.getYCoord(), iGregTechTileEntity.getZCoord() + zDir, TT_Container_Casings.sHintCasingsTT, 12, 2); + } + } + if ((stackSize & 1) == 1) { + StructureBuilder(shape, blockType, blockMeta1, 11, 1, 18, iGregTechTileEntity, hintsOnly); + } else { + StructureBuilder(shape, blockType, blockMeta2, 11, 1, 18, iGregTechTileEntity, hintsOnly); } - if ((stackSize & 1) == 1) - StructureBuilder(shape, blockType, blockMeta1, 11, 1, 18, iGregTechTileEntity,hintsOnly); - else - StructureBuilder(shape, blockType, blockMeta2, 11, 1, 18, iGregTechTileEntity,hintsOnly); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java index e8edf9f307..66c32ac761 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_computer.java @@ -18,11 +18,13 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import java.util.ArrayList; @@ -64,17 +66,24 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB public GT_MetaTileEntity_EM_computer(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); eCertainMode = 5; - eCertainStatus = -128;//no-brainer value + eCertainStatus = -128;//no-brain value } public GT_MetaTileEntity_EM_computer(String aName) { super(aName); eCertainMode = 5; - eCertainStatus = -128;//no-brainer value + eCertainStatus = -128;//no-brain value } + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return GT_MetaTileEntity_EM_switch.activitySound; + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_computer(this.mName); + return new GT_MetaTileEntity_EM_computer(mName); } @Override @@ -94,41 +103,32 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { eAvailableData = 0; maxCurrentTemp = 0; - double overClockRatio,overVoltageRatio; - if (noParametrizers) { - overVoltageRatio=overClockRatio=1; - } else { - overClockRatio= getParameterIn(0,0); - overVoltageRatio= getParameterIn(0,1); - if(Double.isNaN(overClockRatio) || Double.isNaN(overVoltageRatio)) { - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - for (GT_MetaTileEntity_Hatch_Rack r : eRacks) - r.getBaseMetaTileEntity().setActive(false);//todo might be not needed - return false; - } + double overClockRatio= getParameterIn(0,0); + double overVoltageRatio= getParameterIn(0,1); + if(Double.isNaN(overClockRatio) || Double.isNaN(overVoltageRatio)) { + return false; } if(overClockRatio>0 && overVoltageRatio>=0.7f && overClockRatio<=3 && overVoltageRatio<=2){ float eut=V[8] * (float)overVoltageRatio * (float)overClockRatio; - if(eut<Integer.MAX_VALUE-7) - mEUt = -(int)eut; - else{ + if(eut<Integer.MAX_VALUE-7) { + mEUt = -(int) eut; + } else{ mEUt = -(int)V[8]; - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - for (GT_MetaTileEntity_Hatch_Rack r : eRacks) - r.getBaseMetaTileEntity().setActive(false);//todo might be not needed return false; } short thingsActive = 0; int rackComputation; for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) { - if (!isValidMetaTileEntity(rack)) continue; - if (rack.heat > maxCurrentTemp) maxCurrentTemp = rack.heat; + if (!GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { + continue; + } + if (rack.heat > maxCurrentTemp) { + maxCurrentTemp = rack.heat; + } rackComputation = rack.tickComponents((float) overClockRatio, (float) overVoltageRatio); if (rackComputation > 0) { eAvailableData += rackComputation; @@ -137,9 +137,12 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB rack.getBaseMetaTileEntity().setActive(true); } - for (GT_MetaTileEntity_Hatch_InputData di : eInputData) + for (GT_MetaTileEntity_Hatch_InputData di : eInputData) { if (di.q != null)//ok for power losses + { thingsActive++; + } + } if (thingsActive > 0 && eCertainStatus == 0) { thingsActive += eOutputData.size(); @@ -156,109 +159,161 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB return true; } } - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - for (GT_MetaTileEntity_Hatch_Rack r : eRacks) - r.getBaseMetaTileEntity().setActive(false); return false; } @Override + public void outputAfterRecipe_EM() { + if (!eOutputData.isEmpty()) { + Vec3pos pos = new Vec3pos(getBaseMetaTileEntity()); + QuantumDataPacket pack = new QuantumDataPacket(pos, eAvailableData); + for (GT_MetaTileEntity_Hatch_InputData hatch : eInputData) { + if (hatch.q == null || hatch.q.contains(pos)) { + continue; + } + pack = pack.unifyPacketWith(hatch.q); + if (pack == null) { + return; + } + } + + pack.computation /= eOutputData.size(); + + for (GT_MetaTileEntity_Hatch_OutputData o : eOutputData) { + o.q = pack; + } + } + } + + @Override protected long getAvailableData_EM() { return eAvailableData; } @Override - public void updateParameters_EM(boolean busy) { + protected void afterRecipeCheckFailed() { + super.afterRecipeCheckFailed(); + for (GT_MetaTileEntity_Hatch_Rack r : eRacks) { + r.getBaseMetaTileEntity().setActive(false); + } + } + + @Override + protected void parametersLoadDefault_EM() { + setParameterPairIn_ClearOut(0, false, 1, 1); + } + + @Override + public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { double ocRatio = getParameterIn(0, 0); - if (ocRatio < 0) setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); - else if (ocRatio < 1) setStatusOfParameterIn(0, 0, STATUS_LOW); - else if (ocRatio == 1) setStatusOfParameterIn(0, 0, STATUS_OK); - else if (ocRatio <= 3) setStatusOfParameterIn(0, 0, STATUS_HIGH); - else if (Double.isNaN(ocRatio)) setStatusOfParameterIn(0, 0, STATUS_WRONG); - else setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); + if (ocRatio < 0) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (ocRatio < 1) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (ocRatio == 1) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else if (ocRatio <= 3) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + } else if (Double.isNaN(ocRatio)) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } double ovRatio = getParameterIn(0, 1); - if (ovRatio < 0.7f) setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); - else if (ovRatio < 0.8f) setStatusOfParameterIn(0, 1, STATUS_LOW); - else if (ovRatio <= 1.2f) setStatusOfParameterIn(0, 1, STATUS_OK); - else if (ovRatio <= 2) setStatusOfParameterIn(0, 1, STATUS_HIGH); - else if (Double.isNaN(ovRatio)) setStatusOfParameterIn(0, 1, STATUS_WRONG); - else setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); + if (ovRatio < 0.7f) { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (ovRatio < 0.8f) { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (ovRatio <= 1.2f) { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else if (ovRatio <= 2) { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + } else if (Double.isNaN(ovRatio)) { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } setParameterOut(0, 0, maxCurrentTemp); setParameterOut(0, 1, eAvailableData); - if (maxCurrentTemp < -10000) setStatusOfParameterOut(0, 0, STATUS_TOO_LOW); - else if (maxCurrentTemp < 0) setStatusOfParameterOut(0, 0, STATUS_LOW); - else if (maxCurrentTemp == 0) setStatusOfParameterOut(0, 0, STATUS_OK); - else if (maxCurrentTemp <= 5000) setStatusOfParameterOut(0, 0, STATUS_HIGH); - else setStatusOfParameterOut(0, 0, STATUS_TOO_HIGH); - - if (!busy) setStatusOfParameterOut(0, 1, STATUS_WRONG); - else if (eAvailableData <= 0) setStatusOfParameterOut(0, 1, STATUS_TOO_LOW); - else setStatusOfParameterOut(0, 1, STATUS_OK); - } - - @Override - public void outputAfterRecipe_EM() { - if (eOutputData.size() > 0) { - final Vec3pos pos = new Vec3pos(getBaseMetaTileEntity()); - QuantumDataPacket pack = new QuantumDataPacket(pos, eAvailableData); - for (GT_MetaTileEntity_Hatch_InputData i : eInputData) { - if (i.q == null || i.q.contains(pos)) continue; - pack = pack.unifyPacketWith(i.q); - if (pack == null) return; - } - - pack.computation /= eOutputData.size(); + if (maxCurrentTemp < -10000) { + setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (maxCurrentTemp < 0) { + setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (maxCurrentTemp == 0) { + setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else if (maxCurrentTemp <= 5000) { + setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + } else { + setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } - for (GT_MetaTileEntity_Hatch_OutputData o : eOutputData) - o.q = pack; + if (!machineBusy) { + setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + } else if (eAvailableData <= 0) { + setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else { + setStatusOfParameterOut(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); } } + @Override public void onRemoval() { super.onRemoval(); - for (GT_MetaTileEntity_Hatch_Rack r : eRacks) + for (GT_MetaTileEntity_Hatch_Rack r : eRacks) { r.getBaseMetaTileEntity().setActive(false); + } } @Override public void stopMachine() { super.stopMachine(); eAvailableData=0; - for (GT_MetaTileEntity_Hatch_Rack r : eRacks) + for (GT_MetaTileEntity_Hatch_Rack r : eRacks) { r.getBaseMetaTileEntity().setActive(false); + } } @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) - if (isValidMetaTileEntity(rack)) + for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { rack.getBaseMetaTileEntity().setActive(false); + } + } eRacks.clear(); - if (!structureCheck_EM(front, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, 0)) + if (!structureCheck_EM(front, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, 0)) { return false; - if (!structureCheck_EM(cap, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, -1)) + } + if (!structureCheck_EM(cap, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, -1)) { return false; + } byte offset = -2, totalLen = 4; - for (; offset > -16; ) { - if (!structureCheck_EM(slice, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, offset)) + while (offset > -16) { + if (!structureCheck_EM(slice, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, offset)) { break; + } totalLen++; offset--; } - if (totalLen > 16) return false; - if (!structureCheck_EM(cap, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, ++offset)) + if (totalLen > 16) { + return false; + } + if (!structureCheck_EM(cap, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, ++offset)) { return false; - if (!structureCheck_EM(terminator, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, --offset)) + } + if (!structureCheck_EM(terminator, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, --offset)) { return false; + } eCertainMode = (byte) Math.min(totalLen / 3, 5); - for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) - if (isValidMetaTileEntity(rack)) + for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { rack.getBaseMetaTileEntity().setActive(iGregTechTileEntity.isActive()); + } + } return eUncertainHatches.size() == 1; } @@ -284,7 +339,9 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB @Override protected void extraExplosions_EM() { - for (MetaTileEntity tTileEntity : eRacks) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : eRacks) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } } @Override @@ -303,9 +360,13 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB //NEW METHOD public final boolean addRackToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Rack) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return eRacks.add((GT_MetaTileEntity_Hatch_Rack) aMetaTileEntity); @@ -317,7 +378,9 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB try { adderMethodMap.put("addRackToMachineList", GT_MetaTileEntity_EM_computer.class.getMethod("addRackToMachineList", IGregTechTileEntity.class, int.class)); } catch (NoSuchMethodException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java index b2942f8c1c..4c382c178a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java @@ -28,7 +28,7 @@ public class GT_MetaTileEntity_EM_crafting extends GT_MetaTileEntity_MultiblockB private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - public final static String crafter="EM Crafting"; + public static final String crafter="EM Crafting"; //region structure private static final String[][] shape = new String[][]{ {"A000","0 0","0 . 0","0 0","A000",}, @@ -64,8 +64,9 @@ public class GT_MetaTileEntity_EM_crafting extends GT_MetaTileEntity_MultiblockB super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_crafting(this.mName); + return new GT_MetaTileEntity_EM_crafting(mName); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java index a8473b7525..7edd9caa5f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_decay.java @@ -13,6 +13,7 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; @@ -66,8 +67,9 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_decay(this.mName); + return new GT_MetaTileEntity_EM_decay(mName); } @Override @@ -111,21 +113,23 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { cElementalInstanceStackMap map= getInputsClone_EM(); if(map!=null && map.hasStacks() && map.getFirst().getLifeTime()< STABLE_RAW_LIFE_TIME){ return startRecipe(map.getFirst()); } - mEfficiencyIncrease = 0; - mMaxProgresstime = 0; return false; } private float m1,m2,m3; private boolean startRecipe(cElementalInstanceStack input) { m3=(float)Math.ceil(input.getLifeTime() / Math.pow(input.amount,3)); - if(m3<1) explodeMultiblock(); - if(m3>=Integer.MAX_VALUE) return false; + if(m3<1) { + explodeMultiblock(); + } + if(m3>=Integer.MAX_VALUE) { + return false; + } mMaxProgresstime = 1;//(int)m3; mEfficiencyIncrease = 10000; m1 = input.getMass()/input.amount; @@ -141,13 +145,13 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase long storedEnergy = 0; long maxEnergy = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } } for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } @@ -170,7 +174,7 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, "Computation: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET, - m1+" "+m2+" "+m3 + m1+" "+m2+ ' ' +m3 }; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java index 80e5d4aab2..26793ba894 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dequantizer.java @@ -2,19 +2,22 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.elementalMatter.core.interfaces.iExchangeInfo; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.transformations.iExchangeInfo; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.core.transformations.aOredictDequantizationInfo; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; 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; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; @@ -63,8 +66,15 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo super(aName); } + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return GT_MetaTileEntity_EM_quantizer.activitySound; + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_dequantizer(this.mName); + return new GT_MetaTileEntity_EM_dequantizer(mName); } @Override @@ -83,7 +93,7 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { cElementalInstanceStackMap map = in.getContainerHandler(); for (cElementalInstanceStack stack : map.values()) { @@ -109,7 +119,7 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo if (info != null) { if (map.removeAllAmounts(false, (iHasElementalDefinition) info.input())) { ArrayList<ItemStack> items = OreDictionary.getOres(((aOredictDequantizationInfo) info).out); - if (items != null && items.size() > 0) { + if (items != null && !items.isEmpty()) { mOutputItems = new ItemStack[]{items.get(0)}; startRecipe((iHasElementalDefinition) info.input(),stack.getEnergy()); return true; @@ -118,8 +128,6 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo } } } - mEfficiencyIncrease = 0; - mMaxProgresstime = 0; return false; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java index 4115a93910..e8238af2cb 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_infuser.java @@ -3,10 +3,13 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import cofh.api.energy.IEnergyContainerItem; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import ic2.api.item.ElectricItem; @@ -16,6 +19,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import static com.github.technus.tectech.Util.StructureBuilder; import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; @@ -57,13 +61,23 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa eDismantleBoom=true; } + + public final static ResourceLocation activitySound=new ResourceLocation(Reference.MODID+":fx_whooum"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return activitySound; + } + @Override public boolean isFacingValid(byte aFacing) { return aFacing >= 2; } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_infuser(this.mName); + return new GT_MetaTileEntity_EM_infuser(mName); } @Override @@ -73,7 +87,7 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "EMDisplay.png",true,false,true); + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png",true,false,true); } @Override @@ -92,7 +106,7 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { if (itemStack != null && itemStack.stackSize == 1) { Item ofThis = itemStack.getItem(); if (ofThis instanceof IElectricItem) { @@ -105,10 +119,6 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa return true; } } - mEfficiencyIncrease = 0; - mMaxProgresstime = 0; - eAmpereFlow = 0; - mEUt = 0; return false; } @@ -118,16 +128,18 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa if (itemStack != null && itemStack.stackSize == 1) { Item ofThis = itemStack.getItem(); if (ofThis instanceof IElectricItem) { - if (doChargeItemStack((IElectricItem) ofThis, itemStack) == 0) - this.getBaseMetaTileEntity().disableWorking(); + if (doChargeItemStack((IElectricItem) ofThis, itemStack) == 0) { + getBaseMetaTileEntity().disableWorking(); + } return; } else if (TecTech.hasCOFH && ofThis instanceof IEnergyContainerItem) { - if (doChargeItemStackRF((IEnergyContainerItem) ofThis, itemStack) == 0) - this.getBaseMetaTileEntity().disableWorking(); + if (doChargeItemStackRF((IEnergyContainerItem) ofThis, itemStack) == 0) { + getBaseMetaTileEntity().disableWorking(); + } return; } } - this.getBaseMetaTileEntity().disableWorking(); + getBaseMetaTileEntity().disableWorking(); } @Override @@ -144,31 +156,41 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa private long doChargeItemStack(IElectricItem item, ItemStack stack) { try { double euDiff = item.getMaxCharge(stack) - ElectricItem.manager.getCharge(stack); - if (euDiff > 0) this.setEUVar(this.getEUVar() - (this.getEUVar() >> 5)); + if (euDiff > 0) { + setEUVar(getEUVar() - (getEUVar() >> 5)); + } long remove = (long) Math.ceil( ElectricItem.manager.charge(stack, - Math.min(euDiff, this.getEUVar()) + Math.min(euDiff, getEUVar()) , item.getTier(stack), true, false)); - this.setEUVar(this.getEUVar() - remove); - if (this.getEUVar() < 0) this.setEUVar(0); + setEUVar(getEUVar() - remove); + if (getEUVar() < 0) { + setEUVar(0); + } return remove; } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } return 0; } private long doChargeItemStackRF(IEnergyContainerItem item, ItemStack stack) { try { - long RF = Math.min(item.getMaxEnergyStored(stack) - item.getEnergyStored(stack), this.getEUVar() * mEUtoRF / 100L); + long RF = Math.min(item.getMaxEnergyStored(stack) - item.getEnergyStored(stack), getEUVar() * mEUtoRF / 100L); //if(RF>0)this.setEUVar(this.getEUVar()-this.getEUVar()>>10); RF = item.receiveEnergy(stack, RF > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) RF, false); RF = RF * 100L / mEUtoRF; - this.setEUVar(this.getEUVar() - RF); - if (this.getEUVar() < 0) this.setEUVar(0); + setEUVar(getEUVar() - RF); + if (getEUVar() < 0) { + setEUVar(0); + } return RF; } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } return 0; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java index 044b7177e3..c50caf132f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_junction.java @@ -49,8 +49,9 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_junction(this.mName); + return new GT_MetaTileEntity_EM_junction(mName); } @Override @@ -78,43 +79,48 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB } @Override - public void updateParameters_EM(boolean busy) { + public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { double src, dest; for (int i = 0; i < 10; i++) { src = getParameterIn(i, 0); if (src <= 0) { - setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); - setStatusOfParameterIn(i, 1, STATUS_UNUSED); + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); } else if (src > eInputHatches.size()) { - setStatusOfParameterIn(i, 0, STATUS_TOO_HIGH); - setStatusOfParameterIn(i, 1, STATUS_UNUSED); + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); } else if (Double.isNaN(src)) { - setStatusOfParameterIn(i, 0, STATUS_WRONG); - setStatusOfParameterIn(i, 1, STATUS_UNUSED); + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); } else { - setStatusOfParameterIn(i, 0, STATUS_OK); + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); dest = getParameterIn(i, 1); - if (dest < 0) setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); - else if (dest == 0) setStatusOfParameterIn(i, 1, STATUS_LOW); - else if (dest > eOutputHatches.size()) setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); - else if (Double.isNaN(dest)) setStatusOfParameterIn(i, 1, STATUS_WRONG); - else setStatusOfParameterIn(i, 1, STATUS_OK); + if (dest < 0) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (dest == 0) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (dest > eOutputHatches.size()) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } else if (Double.isNaN(dest)) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } } } } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { - for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) + public boolean checkRecipe_EM(ItemStack itemStack) { + for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { if (in.getContainerHandler().hasStacks()) { mEUt = -(int) V[8]; - eAmpereFlow = 1 + ((eInputHatches.size() + eOutputHatches.size()) >> 1); + eAmpereFlow = 1 + (eInputHatches.size() + eOutputHatches.size() >> 1); mMaxProgresstime = 20; mEfficiencyIncrease = 10000; return true; } - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; + } return false; } @@ -124,15 +130,21 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB for (int i = 0; i < 10; i++) { src= getParameterIn(i,0); dest= getParameterIn(i,1); - if(Double.isNaN(src) || Double.isNaN(dest)) continue; - final int inIndex = (int)src - 1; - if (inIndex < 0 || inIndex >= eInputHatches.size()) continue; - final int outIndex = (int)dest - 1; + if(Double.isNaN(src) || Double.isNaN(dest)) { + continue; + } + int inIndex = (int)src - 1; + if (inIndex < 0 || inIndex >= eInputHatches.size()) { + continue; + } + int outIndex = (int)dest - 1; GT_MetaTileEntity_Hatch_InputElemental in = eInputHatches.get(inIndex); if (outIndex == -1) {//param==0 -> null the content cleanHatchContentEM_EM(in); } else { - if (outIndex < 0 || outIndex >= eOutputHatches.size()) continue; + if (outIndex < 0 || outIndex >= eOutputHatches.size()) { + continue; + } GT_MetaTileEntity_Hatch_OutputElemental out = eOutputHatches.get(outIndex); out.getContainerHandler().putUnifyAll(in.getContainerHandler()); in.getContainerHandler().clear(); diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java deleted file mode 100644 index 3c1986d635..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_machine.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi; - -import com.github.technus.tectech.CommonValues; -import com.github.technus.tectech.thing.block.QuantumGlassBlock; -import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.common.blocks.GT_Block_Machines; -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - -import static com.github.technus.tectech.Util.StructureBuilder; -import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; -import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; - -/** - * Created by danie_000 on 17.12.2016. - */ -public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - public final static String machine="EM Machinery"; - - //region structure - private static final String[][] shape = new String[][]{ - {"B0","A ","0 - 0","A ","B0",}, - {"A000","00000","00.00","00000","A000",}, - {"A121","1C1","2C2","1C1","A121",}, - {"A131","1C1","3C3","1C1","A131",}, - {"A121","1C1","2C2","1C1","A121",}, - {"A000","00000","00A00","00000","A000",}, - {"B0","A!!!","0!\"!0","A!!!","B0",}, - }; - private static final Block[] blockType = new Block[]{sBlockCasingsTT, QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{4, 0, 5, 6}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList", "addElementalInputToMachineList"}; - private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4, textureOffset + 4}; - private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; - private static final byte[] blockMetaFallback = new byte[]{0, 4, 4}; - private static final String[] description = new String[]{ - EnumChatFormatting.AQUA+"Hint Details:", - "1 - Classic Hatches or High Power Casing", - "2 - Elemental Hatches or Molecular Casing", - "2 - Elemental Input Hatch", - }; - //endregion - - public GT_MetaTileEntity_EM_machine(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - } - - public GT_MetaTileEntity_EM_machine(String aName) { - super(aName); - } - - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_machine(this.mName); - } - - @Override - public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 2, 1) - && eInputHatches.size()==1 && iGregTechTileEntity.getBlockAtSideAndDistance(iGregTechTileEntity.getBackFacing(),5) instanceof GT_Block_Machines; - } - - @Override - public void construct(int stackSize, boolean hintsOnly) { - StructureBuilder(shape, blockType, blockMeta,2, 2, 1, getBaseMetaTileEntity(),hintsOnly); - } - - @Override - public String[] getStructureDescription(int stackSize) { - return description; - } - - @Override - public String[] getDescription() { - return new String[]{ - CommonValues.TEC_MARK_EM, - "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/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java index 4f90191c07..7b90703749 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_quantizer.java @@ -2,8 +2,9 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; -import com.github.technus.tectech.elementalMatter.core.interfaces.iHasElementalDefinition; +import com.github.technus.tectech.elementalMatter.core.stacks.iHasElementalDefinition; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; import com.github.technus.tectech.elementalMatter.core.transformations.aFluidQuantizationInfo; import com.github.technus.tectech.elementalMatter.core.transformations.aItemQuantizationInfo; @@ -12,15 +13,20 @@ import com.github.technus.tectech.elementalMatter.core.transformations.bTransfor import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; 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; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import java.util.ArrayList; + import static com.github.technus.tectech.Util.*; import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.elementalMatter.core.templates.iElementalDefinition.DEFAULT_ENERGY_LEVEL; @@ -63,8 +69,17 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock super(aName); } + public final static ResourceLocation activitySound=new ResourceLocation(Reference.MODID+":fx_mid_freq"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return activitySound; + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_quantizer(this.mName); + return new GT_MetaTileEntity_EM_quantizer(mName); } @Override @@ -92,60 +107,64 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) {//TODO implement by item quantization, implement instance quantization + public boolean checkRecipe_EM(ItemStack itemStack) {//TODO implement instance quantization if (GregTech_API.sPostloadFinished) { - ItemStack[] inI = getStoredInputs().toArray(new ItemStack[0]); + ArrayList<ItemStack> storedInputs = getStoredInputs(); + ItemStack[] inI = storedInputs.toArray(new ItemStack[storedInputs.size()]); if (inI.length > 0) { for (ItemStack is : inI) { //ITEM STACK quantization aItemQuantizationInfo aIQI = bTransformationInfo.itemQuantization.get(new aItemQuantizationInfo(is, false, null)); if (aIQI == null) { - aIQI = bTransformationInfo.itemQuantization.get(new aItemQuantizationInfo(is, true, null)); + aIQI = bTransformationInfo.itemQuantization.get(new aItemQuantizationInfo(is, true, null));//todo check if works? } if (aIQI == null) { - //ORE DICT quantization + //ORE DICT quantization //todo fix for uranium? int[] oreIDs = OreDictionary.getOreIDs(is); for (int ID : oreIDs) { - if (DEBUG_MODE) - TecTech.Logger.info("Quantifier-Ore-recipe " + is.getItem().getUnlocalizedName() + "." + is.getItemDamage() + " " + OreDictionary.getOreName(ID)); + if (DEBUG_MODE) { + TecTech.Logger.info("Quantifier-Ore-recipe " + is.getItem().getUnlocalizedName() + '.' + is.getItemDamage() + ' ' + OreDictionary.getOreName(ID)); + } aOredictQuantizationInfo aOQI = bTransformationInfo.oredictQuantization.get(ID); - if (aOQI == null) continue; + if (aOQI == null) { + continue; + } iHasElementalDefinition into = aOQI.output(); - if (into != null && isInputEqual(true, false, - nothingF, new ItemStack[]{new ItemStack(is.getItem(), aOQI.amount, is.getItemDamage())}, null, inI)) { + if (into != null && isInputEqual(true, false, GT_MetaTileEntity_MultiblockBase_EM.nothingF, new ItemStack[]{new ItemStack(is.getItem(), aOQI.amount, is.getItemDamage())}, null, inI)) { startRecipe(into); return true; } } } else { //Do ITEM STACK quantization - if (DEBUG_MODE) - TecTech.Logger.info("Quantifier-Item-recipe " + is.getItem().getUnlocalizedName() + "." + is.getItemDamage()); + if (DEBUG_MODE) { + TecTech.Logger.info("Quantifier-Item-recipe " + is.getItem().getUnlocalizedName() + '.' + is.getItemDamage()); + } iHasElementalDefinition into = aIQI.output(); - if (into != null && isInputEqual(true, false, - nothingF, new ItemStack[]{new ItemStack(is.getItem(), aIQI.input().stackSize, is.getItemDamage())}, null, inI)) { + if (into != null && isInputEqual(true, false, GT_MetaTileEntity_MultiblockBase_EM.nothingF, new ItemStack[]{new ItemStack(is.getItem(), aIQI.input().stackSize, is.getItemDamage())}, null, inI)) { startRecipe(into); return true; } } } } - FluidStack[] inF = getStoredFluids().toArray(new FluidStack[0]); + ArrayList<FluidStack> storedFluids = getStoredFluids(); + FluidStack[] inF = storedFluids.toArray(new FluidStack[storedFluids.size()]); if (inF.length > 0) { for (FluidStack fs : inF) { aFluidQuantizationInfo aFQI = bTransformationInfo.fluidQuantization.get(fs.getFluid().getID()); - if (aFQI == null) continue; + if (aFQI == null) { + continue; + } iHasElementalDefinition into = aFQI.output(); if (into != null && fs.amount >= aFQI.input().amount && isInputEqual(true, false, - new FluidStack[]{aFQI.input()}, nothingI, inF, (ItemStack[]) null)) { + new FluidStack[]{aFQI.input()}, GT_MetaTileEntity_MultiblockBase_EM.nothingI, inF, (ItemStack[]) null)) { startRecipe(into); return true; } } } } - mEfficiencyIncrease = 0; - mMaxProgresstime = 0; return false; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java index 382ab68609..dc7c99df7b 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_research.java @@ -16,6 +16,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.MetaTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Recipe; @@ -36,7 +37,7 @@ import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texture import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafting.crafter; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_machine.machine; +import static com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine.machine; import static gregtech.api.enums.GT_Values.E; /** @@ -81,23 +82,29 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_research(this.mName); + return new GT_MetaTileEntity_EM_research(mName); } @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - for (GT_MetaTileEntity_Hatch_Holder rack : eHolders) - if (isValidMetaTileEntity(rack)) + for (GT_MetaTileEntity_Hatch_Holder rack : eHolders) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { rack.getBaseMetaTileEntity().setActive(false); + } + } eHolders.clear(); - if (!structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 3, 4)) + if (!structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 3, 4)) { return false; + } - for (GT_MetaTileEntity_Hatch_Holder rack : eHolders) - if (isValidMetaTileEntity(rack)) + for (GT_MetaTileEntity_Hatch_Holder rack : eHolders) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(rack)) { rack.getBaseMetaTileEntity().setActive(iGregTechTileEntity.isActive()); + } + } return eHolders.size() == 1; } @@ -116,9 +123,11 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB super.saveNBTData(aNBT); aNBT.setLong("eComputationRemaining",computationRemaining); aNBT.setLong("eComputationRequired",computationRequired); - if(holdItem!=null) + if(holdItem!=null) { aNBT.setTag("eHold", holdItem.writeToNBT(new NBTTagCompound())); - else aNBT.removeTag("eHold"); + } else { + aNBT.removeTag("eHold"); + } } @Override @@ -126,9 +135,11 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB super.loadNBTData(aNBT); computationRemaining=aNBT.getLong("eComputationRemaining"); computationRequired=aNBT.getLong("eComputationRequired"); - if(aNBT.hasKey("eHold")) - holdItem =ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("eHold")); - else holdItem=null; + if(aNBT.hasKey("eHold")) { + holdItem = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("eHold")); + } else { + holdItem = null; + } } @Override @@ -148,7 +159,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB } else if (ItemList.Tool_DataOrb.isStackEqual(mInventory[1], false, true)) { for (TT_recipe.TT_assLineRecipe assRecipeTT : TT_recipe.TT_Recipe_Map.sMachineRecipes.recipeList()) { if (GT_Utility.areStacksEqual(assRecipeTT.mResearchItem, holdItem, true)) { - this.aRecipe = assRecipeTT; + aRecipe = assRecipeTT; machineType = machine; break; } @@ -156,7 +167,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB if (aRecipe == null) { for (TT_recipe.TT_assLineRecipe assRecipeTT : TT_recipe.TT_Recipe_Map.sCrafterRecipes.recipeList()) { if (GT_Utility.areStacksEqual(assRecipeTT.mResearchItem, holdItem, true)) { - this.aRecipe = assRecipeTT; + aRecipe = assRecipeTT; machineType = crafter; break; } @@ -169,23 +180,24 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB computationRequired = computationRemaining = 0; mMaxProgresstime = 0; mEfficiencyIncrease = 0; - for (GT_MetaTileEntity_Hatch_Holder r : eHolders) + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { r.getBaseMetaTileEntity().setActive(false); + } } } } } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { tRecipe=null; aRecipe=null; - if(eHolders.size()>0 && eHolders.get(0).mInventory[0]!=null) { + if(!eHolders.isEmpty() && eHolders.get(0).mInventory[0]!=null) { holdItem = eHolders.get(0).mInventory[0].copy(); if(ItemList.Tool_DataStick.isStackEqual(itemStack, false, true)) { for (GT_Recipe.GT_Recipe_AssemblyLine assRecipe : GT_Recipe.GT_Recipe_AssemblyLine.sAssemblylineRecipes) { if (GT_Utility.areStacksEqual(assRecipe.mResearchItem, holdItem, true)) { - this.tRecipe = assRecipe; + tRecipe = assRecipe; //if found for (GT_Recipe ttRecipe : TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.mRecipeList) { if (GT_Utility.areStacksEqual(ttRecipe.mInputs[0], holdItem, true)) { @@ -204,7 +216,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB }else if(ItemList.Tool_DataOrb.isStackEqual(itemStack, false, true)){ for (TT_recipe.TT_assLineRecipe assRecipeTT:TT_recipe.TT_Recipe_Map.sMachineRecipes.recipeList()){ if (GT_Utility.areStacksEqual(assRecipeTT.mResearchItem, holdItem, true)) { - this.aRecipe = assRecipeTT; + aRecipe = assRecipeTT; machineType=machine; //if found for (GT_Recipe ttRecipe : TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.mRecipeList) { @@ -223,7 +235,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB } for (TT_recipe.TT_assLineRecipe assRecipeTT:TT_recipe.TT_Recipe_Map.sCrafterRecipes.recipeList()){ if (GT_Utility.areStacksEqual(assRecipeTT.mResearchItem, holdItem, true)) { - this.aRecipe = assRecipeTT; + aRecipe = assRecipeTT; machineType=crafter; //if found for (GT_Recipe ttRecipe : TT_recipe.GT_Recipe_MapTT.sResearchableFakeRecipes.mRecipeList) { @@ -244,10 +256,9 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB } holdItem=null; computationRequired=computationRemaining=0; - mMaxProgresstime=0; - mEfficiencyIncrease = 0; - for (GT_MetaTileEntity_Hatch_Holder r : eHolders) + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { r.getBaseMetaTileEntity().setActive(false); + } return false; } @@ -266,7 +277,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB @Override public void outputAfterRecipe_EM() { - if(eHolders.size()>0) { + if(!eHolders.isEmpty()) { if (tRecipe != null && ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)){ eHolders.get(0).getBaseMetaTileEntity().setActive(false); eHolders.get(0).mInventory[0] = null; @@ -278,17 +289,17 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB tNBT.setInteger("time", tRecipe.mDuration); tNBT.setInteger("eu", tRecipe.mEUt); for (int i = 0; i < tRecipe.mInputs.length; i++) { - tNBT.setTag("" + i, tRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); + tNBT.setTag(String.valueOf(i), tRecipe.mInputs[i].writeToNBT(new NBTTagCompound())); } for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { tNBT.setTag("f" + i, tRecipe.mFluidInputs[i].writeToNBT(new NBTTagCompound())); } tNBT.setString("author", EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.WHITE + " Assembling Line Recipe Generator"); NBTTagList tNBTList = new NBTTagList(); - tNBTList.appendTag(new NBTTagString("Construction plan for " + tRecipe.mOutput.stackSize + " " + GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName()) + ". Needed EU/t: " + tRecipe.mEUt + " Production time: " + (tRecipe.mDuration / 20))); + tNBTList.appendTag(new NBTTagString("Construction plan for " + tRecipe.mOutput.stackSize + ' ' + GT_LanguageManager.getTranslation(tRecipe.mOutput.getDisplayName()) + ". Needed EU/t: " + tRecipe.mEUt + " Production time: " + tRecipe.mDuration / 20)); for (int i = 0; i < tRecipe.mInputs.length; i++) { if (tRecipe.mInputs[i] != null) { - tNBTList.appendTag(new NBTTagString("Input Bus " + (i + 1) + ": " + tRecipe.mInputs[i].stackSize + " " + GT_LanguageManager.getTranslation(tRecipe.mInputs[i].getDisplayName()))); + tNBTList.appendTag(new NBTTagString("Input Bus " + (i + 1) + ": " + tRecipe.mInputs[i].stackSize + ' ' + GT_LanguageManager.getTranslation(tRecipe.mInputs[i].getDisplayName()))); } } for (int i = 0; i < tRecipe.mFluidInputs.length; i++) { @@ -318,7 +329,9 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB @Override protected void extraExplosions_EM() { - for (MetaTileEntity tTileEntity : eHolders) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : eHolders) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } } @Override @@ -329,7 +342,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][3], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][3], new GT_RenderedTexture(aActive ? GT_MetaTileEntity_MultiblockBase_EM.ScreenON : GT_MetaTileEntity_MultiblockBase_EM.ScreenOFF)}; } return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][3]}; } @@ -347,15 +360,17 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB @Override public void onRemoval() { super.onRemoval(); - for (GT_MetaTileEntity_Hatch_Holder r : eHolders) + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { r.getBaseMetaTileEntity().setActive(false); + } } @Override public void stopMachine() { super.stopMachine(); - for (GT_MetaTileEntity_Hatch_Holder r : eHolders) + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) { r.getBaseMetaTileEntity().setActive(false); + } computationRequired=computationRemaining=0; tRecipe=null; aRecipe=null; @@ -364,9 +379,13 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB //NEW METHOD public final boolean addHolderToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Holder) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return eHolders.add((GT_MetaTileEntity_Hatch_Holder) aMetaTileEntity); @@ -378,7 +397,9 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB try { adderMethodMap.put("addHolderToMachineList", GT_MetaTileEntity_EM_research.class.getMethod("addHolderToMachineList", IGregTechTileEntity.class, int.class)); } catch (NoSuchMethodException e) { - if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); + if (TecTechConfig.DEBUG_MODE) { + e.printStackTrace(); + } } } @@ -392,13 +413,13 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB long storedEnergy = 0; long maxEnergy = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } } for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java index e92753a897..eab87fe71a 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java @@ -1,12 +1,16 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.elementalMatter.core.tElementalException; import com.github.technus.tectech.recipe.TT_recipe; +import com.github.technus.tectech.thing.CustomItemList; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.thing.block.QuantumStuffBlock; +import com.github.technus.tectech.thing.item.ElementalDefinitionScanStorage_EM; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; @@ -14,6 +18,7 @@ import gregtech.api.enums.ItemList; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Recipe; import net.minecraft.block.Block; @@ -24,28 +29,30 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; -import static com.github.technus.tectech.Util.StructureBuilder; -import static com.github.technus.tectech.Util.VN; +import static com.github.technus.tectech.Util.*; +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; import static com.github.technus.tectech.elementalMatter.definitions.primitive.cPrimitiveDefinition.nbtE__; import static com.github.technus.tectech.recipe.TT_recipe.E_RECIPE_ID; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_crafting.crafter; -import static com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_machine.machine; +import static com.github.technus.tectech.thing.metaTileEntity.multi.em_machine.GT_MetaTileEntity_EM_machine.machine; /** * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { public static final int SCAN_DO_NOTHING=0, - SCAN_GET_MASS=1, SCAN_GET_CHARGE=2, SCAN_GET_CLASS_TYPE=4, SCAN_GET_NOMENCLATURE=8, SCAN_GET_TIMESPAN_INFO=16, - SCAN_GET_AMOUNT=256, SCAN_GET_COLOR=512, SCAN_GET_ENERGY_LEVEL=1024, SCAN_GET_AGE=2048, SCAN_GET_TIMESPAN_MULT =4096, - SCAN_GET_DEPTH_LEVEL= 8192, SCAN_GET_ENERGY_STATES=16384; + SCAN_GET_NOMENCLATURE=1,SCAN_GET_DEPTH_LEVEL=2,SCAN_GET_AMOUNT=4,SCAN_GET_CHARGE=8, + SCAN_GET_MASS=16,SCAN_GET_ENERGY_LEVEL=32,SCAN_GET_TIMESPAN_INFO=64,SCAN_GET_ENERGY_STATES=128, + SCAN_GET_COLOR=256,SCAN_GET_AGE=512,SCAN_GET_TIMESPAN_MULT=1024,SCAN_GET_CLASS_TYPE=2048; private TT_recipe.TT_EMRecipe.TT_EMRecipe eRecipe; private cElementalDefinitionStack objectResearched; + private cElementalInstanceStackMap objectsScanned; private String machineType; - private long computationRemaining,computationRequired; + private long totalComputationRemaining, totalComputationRequired; + private int[] scanComplexity; //region structure private static final String[][] shape = new String[][]{ @@ -87,14 +94,16 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa eDismantleBoom=true; } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_scanner(this.mName); + return new GT_MetaTileEntity_EM_scanner(mName); } @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - if (!structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 2, 0)) + if (!structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 2, 0)) { return false; + } return eInputHatches.size() == 1 && eOutputHatches.size() == 1 && eOutputHatches.get(0).getBaseMetaTileEntity().getFrontFacing() == iGregTechTileEntity.getFrontFacing(); } @@ -120,22 +129,50 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setLong("eComputationRemaining",computationRemaining); - aNBT.setLong("eComputationRequired",computationRequired); - if(objectResearched!=null) - aNBT.setTag("eObject",objectResearched.toNBT()); - else aNBT.removeTag("eObject"); + aNBT.setLong("eComputationRemaining", totalComputationRemaining); + aNBT.setLong("eComputationRequired", totalComputationRequired); + if(objectResearched!=null) { + aNBT.setTag("eObject", objectResearched.toNBT()); + } else { + aNBT.removeTag("eObject"); + } + if(scanComplexity!=null) { + aNBT.setIntArray("eScanComplexity", scanComplexity); + } else { + aNBT.removeTag("eScanComplexity"); + } + if(objectsScanned!=null) { + aNBT.setTag("eScanObjects", objectsScanned.toNBT()); + } else { + aNBT.removeTag("eScanObjects"); + } } @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - computationRemaining=aNBT.getLong("eComputationRemaining"); - computationRequired=aNBT.getLong("eComputationRequired"); + totalComputationRemaining =aNBT.getLong("eComputationRemaining"); + totalComputationRequired =aNBT.getLong("eComputationRequired"); if(aNBT.hasKey("eObject")) { objectResearched = cElementalDefinitionStack.fromNBT(aNBT.getCompoundTag("eObject")); - if(objectResearched.definition==nbtE__) objectResearched=null; - }else objectResearched=null; + if(objectResearched.definition==nbtE__) { + objectResearched = null; + } + }else { + objectResearched = null; + } + if(aNBT.hasKey("eScanComplexity")) { + scanComplexity = aNBT.getIntArray("eScanComplexity"); + } else { + scanComplexity = null; + } + try { + if (aNBT.hasKey("eScanObjects")) { + objectsScanned = cElementalInstanceStackMap.fromNBT(aNBT.getCompoundTag("eScanObjects")); + } + }catch (tElementalException e){ + objectsScanned=new cElementalInstanceStackMap(); + } } @Override @@ -151,40 +188,42 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { if(aBaseMetaTileEntity.isServerSide()) { - if (computationRemaining > 0) { + if (totalComputationRemaining > 0 && objectResearched!=null) { eRecipe = null; - if (objectResearched != null) { - if (ItemList.Tool_DataOrb.isStackEqual(mInventory[1], false, true)) { - eRecipe = TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.findRecipe(objectResearched.definition); + if (ItemList.Tool_DataOrb.isStackEqual(mInventory[1], false, true)) { + eRecipe = TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.findRecipe(objectResearched.definition); + if (eRecipe != null) { + machineType = machine; + } else { + eRecipe = TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.findRecipe(objectResearched.definition); if (eRecipe != null) { - machineType = machine; - } else { - eRecipe = TT_recipe.TT_Recipe_Map_EM.sCrafterRecipesEM.findRecipe(objectResearched.definition); - if (eRecipe != null) { - machineType = crafter; - } + machineType = crafter; } } } if (eRecipe == null) { quantumStuff(false); objectResearched = null; - computationRequired = computationRemaining = 0; + eRequiredData=0; + totalComputationRequired = totalComputationRemaining = 0; mMaxProgresstime = 0; mEfficiencyIncrease = 0; - } else quantumStuff(true); + } else { + quantumStuff(true); + } } } } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { eRecipe=null; - if(eInputHatches.size()>0 && eInputHatches.get(0).getContainerHandler().hasStacks() && !eOutputHatches.isEmpty()) { + if(!eInputHatches.isEmpty() && eInputHatches.get(0).getContainerHandler().hasStacks() && !eOutputHatches.isEmpty()) { cElementalInstanceStackMap researchEM = eInputHatches.get(0).getContainerHandler(); if(ItemList.Tool_DataOrb.isStackEqual(itemStack, false, true)) { GT_Recipe scannerRecipe=null; for(cElementalInstanceStack stackEM:researchEM.values()){ + objectsScanned=null; eRecipe = TT_recipe.TT_Recipe_Map_EM.sMachineRecipesEM.findRecipe(stackEM.definition); if(eRecipe!=null) { scannerRecipe=eRecipe.scannerRecipe; @@ -207,8 +246,8 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa researchEM.remove(stackEM.definition); } if(eRecipe!=null && scannerRecipe!=null){//make sure it werks - computationRequired = computationRemaining = scannerRecipe.mDuration * 20L; - mMaxProgresstime = 20; + totalComputationRequired = totalComputationRemaining = scannerRecipe.mDuration * 20L; + mMaxProgresstime = 20;//const mEfficiencyIncrease = 10000; eRequiredData = (short) (scannerRecipe.mSpecialValue >>> 16); eAmpereFlow = (short) (scannerRecipe.mSpecialValue & 0xFFFF); @@ -216,26 +255,118 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa quantumStuff(true); return true; } - }//else{ - //todo implement molecular in depth info scan - //} + }else if(CustomItemList.scanContainer.isStackEqual(itemStack, false, true)) { + eRecipe=null; + if(researchEM.hasStacks()) { + objectsScanned = researchEM.takeAllToNewMap(); + cleanMassEM_EM(objectsScanned.getMass()); + + totalComputationRequired =0; + eRequiredData=0; + eAmpereFlow=objectsScanned.size() + TecTech.Rnd.next(objectsScanned.size()); + mEUt=-(int)V[8]; + + //get depth scan complexity array + { + int[] scanComplexityTemp = new int[20]; + for (int i = 0; i < 10; i++) { + scanComplexityTemp[i] = getParameterInInt(i, 0); + scanComplexityTemp[i + 10] = getParameterInInt(i, 1); + } + int maxDepth = 0; + for (int i = 0; i < 20; i++) { + if (scanComplexityTemp[i] != SCAN_DO_NOTHING) { + maxDepth = i; + if(!DEBUG_MODE) { + scanComplexityTemp[i] &= ~SCAN_GET_CLASS_TYPE; + } + addComputationRequirements(i+1,scanComplexityTemp[i]); + } + } + maxDepth+=1;//from index to len + scanComplexity = new int[maxDepth]; + System.arraycopy(scanComplexityTemp,0,scanComplexity,0,maxDepth); + } + + totalComputationRemaining = totalComputationRequired*=20; + mMaxProgresstime = 20;//const + mEfficiencyIncrease = 10000; + quantumStuff(true); + return true; + } + } } quantumStuff(false); objectResearched=null; - computationRequired=computationRemaining=0; - mMaxProgresstime=0; - mEfficiencyIncrease = 0; + totalComputationRemaining =0; return false; } + private void addComputationRequirements(int depthPlus, int capabilities){ + if(areBitsSet(SCAN_GET_NOMENCLATURE,capabilities)){ + totalComputationRequired +=depthPlus*5L; + eRequiredData+=depthPlus; + } + if(areBitsSet(SCAN_GET_DEPTH_LEVEL,capabilities)){ + totalComputationRequired +=depthPlus*10L; + eRequiredData+=depthPlus; + + } + if(areBitsSet(SCAN_GET_AMOUNT,capabilities)){ + totalComputationRequired +=depthPlus*64L; + eRequiredData+=depthPlus*8L; + + } + if(areBitsSet(SCAN_GET_CHARGE,capabilities)){ + totalComputationRequired +=depthPlus*128L; + eRequiredData+=depthPlus*4L; + + } + if(areBitsSet(SCAN_GET_MASS,capabilities)){ + totalComputationRequired +=depthPlus*256L; + eRequiredData+=depthPlus*4L; + + } + if(areBitsSet(SCAN_GET_ENERGY_LEVEL,capabilities)){ + totalComputationRequired +=depthPlus*512L; + eRequiredData+=depthPlus*16L; + + } + if(areBitsSet(SCAN_GET_TIMESPAN_INFO,capabilities)){ + totalComputationRequired +=depthPlus*1024L; + eRequiredData+=depthPlus*32L; + + } + if(areBitsSet(SCAN_GET_ENERGY_STATES,capabilities)){ + totalComputationRequired +=depthPlus*2048L; + eRequiredData+=depthPlus*32L; + + } + if(areBitsSet(SCAN_GET_COLOR,capabilities)){ + totalComputationRequired +=depthPlus*1024L; + eRequiredData+=depthPlus*48L; + + } + if(areBitsSet(SCAN_GET_AGE,capabilities)){ + totalComputationRequired +=depthPlus*2048L; + eRequiredData+=depthPlus*64L; + + } + if(areBitsSet(SCAN_GET_TIMESPAN_MULT,capabilities)){ + totalComputationRequired +=depthPlus*2048L; + eRequiredData+=depthPlus*64L; + + } + } + @Override public boolean onRunningTick(ItemStack aStack) { - if(computationRemaining<=0) { - computationRemaining=0; + if(totalComputationRemaining <=0) { + totalComputationRemaining =0; mProgresstime=mMaxProgresstime; return true; }else{ - computationRemaining-=eAvailableData; + totalComputationRemaining -=eAvailableData; mProgresstime=1; return super.onRunningTick(aStack); } @@ -251,10 +382,12 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa tNBT.setString("eMachineType", machineType); tNBT.setTag(E_RECIPE_ID, objectResearched.toNBT()); tNBT.setString("author", EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" + EnumChatFormatting.WHITE + ' ' + machineType+ " EM Recipe Generator"); + }else if(objectsScanned!=null && CustomItemList.scanContainer.isStackEqual(mInventory[1], false, true)){ + ElementalDefinitionScanStorage_EM.setContent(mInventory[1],objectsScanned,scanComplexity); } - quantumStuff(false); objectResearched=null; - computationRequired=computationRemaining=0; + totalComputationRemaining =0; + quantumStuff(false); } @Override @@ -267,13 +400,13 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa long storedEnergy = 0; long maxEnergy = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } } for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } @@ -292,25 +425,25 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, - "Computation Available: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET, + "Computation Available: " + EnumChatFormatting.GREEN + eAvailableData +EnumChatFormatting.RESET+" / "+EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET, "Computation Remaining:", - EnumChatFormatting.GREEN + Long.toString(computationRemaining / 20L) + EnumChatFormatting.RESET + " / " + - EnumChatFormatting.YELLOW + Long.toString(computationRequired / 20L) + EnumChatFormatting.GREEN + Long.toString(totalComputationRemaining / 20L) + EnumChatFormatting.RESET + " / " + + EnumChatFormatting.YELLOW + Long.toString(totalComputationRequired / 20L) }; } @Override public void onRemoval() { - super.onRemoval(); quantumStuff(false); + super.onRemoval(); } @Override public void stopMachine() { + quantumStuff(false); super.stopMachine(); - computationRequired=computationRemaining=0; + totalComputationRequired = totalComputationRemaining =0; objectResearched=null; - quantumStuff(false); } @@ -322,11 +455,13 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa int zDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetZ * 4+base.getZCoord(); Block block = base.getWorld().getBlock(xDir, yDir, zDir); if (shouldExist) { - if(block != null && block.getMaterial()== Material.air) - base.getWorld().setBlock(xDir, yDir, zDir, QuantumStuffBlock.INSTANCE,0,2); + if(block != null && block.getMaterial()== Material.air) { + base.getWorld().setBlock(xDir, yDir, zDir, QuantumStuffBlock.INSTANCE, 0, 2); + } } else { - if (block instanceof QuantumStuffBlock) - base.getWorld().setBlock(xDir, yDir, zDir, Blocks.air,0,2); + if (block instanceof QuantumStuffBlock) { + base.getWorld().setBlock(xDir, yDir, zDir, Blocks.air, 0, 2); + } } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java index c75453dc26..c259a8b7fa 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java @@ -47,8 +47,9 @@ public class GT_MetaTileEntity_EM_stabilizer extends GT_MetaTileEntity_Multibloc super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_stabilizer(this.mName); + return new GT_MetaTileEntity_EM_stabilizer(mName); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java index bfd2ffd3fe..e15d24243e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_switch.java @@ -2,11 +2,14 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.Vec3pos; +import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.dataFramework.QuantumDataPacket; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputData; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_OutputData; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -15,6 +18,7 @@ import gregtech.api.objects.GT_RenderedTexture; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import static com.github.technus.tectech.Util.StructureBuilder; import static com.github.technus.tectech.Util.V; @@ -35,7 +39,7 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas private static final Block[] blockType = new Block[]{sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{3}; private static final String[] addingMethods = new String[]{"addClassicToMachineList"}; - private static final short[] casingTextures = new short[]{textureOffset}; + private static final short[] casingTextures = new short[]{textureOffset+1}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT}; private static final byte[] blockMetaFallback = new byte[]{1}; private static final String[] description = new String[]{ @@ -52,14 +56,23 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas super(aName); } + public final static ResourceLocation activitySound=new ResourceLocation(Reference.MODID+":fx_hi_freq"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return activitySound; + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_switch(this.mName); + return new GT_MetaTileEntity_EM_switch(mName); } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][1], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][1], new GT_RenderedTexture(aActive ? GT_MetaTileEntity_MultiblockBase_EM.ScreenON : GT_MetaTileEntity_MultiblockBase_EM.ScreenOFF)}; } return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][1]}; } @@ -80,11 +93,13 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { short thingsActive = 0; - for (GT_MetaTileEntity_Hatch_InputData di : eInputData) - if (di.q != null) + for (GT_MetaTileEntity_Hatch_InputData di : eInputData) { + if (di.q != null) { thingsActive++; + } + } if (thingsActive > 0) { thingsActive += eOutputData.size(); @@ -94,30 +109,33 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas mEfficiencyIncrease = 10000; return true; } - mMaxProgresstime = 0; - mEfficiencyIncrease = 0; return false; } @Override public void outputAfterRecipe_EM() { - if (eOutputData.size() > 0) { + if (!eOutputData.isEmpty()) { double total = 0; double dest; double weight; for (int i = 0; i < 10; i++) {//each param pair dest= getParameterIn(i,1); weight= getParameterIn(i,0); - if (weight > 0 && dest >= 0) + if (weight > 0 && dest >= 0) { total += weight;//Total weighted div + } } - final Vec3pos pos = new Vec3pos(getBaseMetaTileEntity()); + Vec3pos pos = new Vec3pos(getBaseMetaTileEntity()); QuantumDataPacket pack = new QuantumDataPacket(pos, 0); - for (GT_MetaTileEntity_Hatch_InputData i : eInputData) { - if (i.q == null || i.q.contains(pos)) continue; - pack = pack.unifyPacketWith(i.q); - if (pack == null) return; + for (GT_MetaTileEntity_Hatch_InputData hatch : eInputData) { + if (hatch.q == null || hatch.q.contains(pos)) { + continue; + } + pack = pack.unifyPacketWith(hatch.q); + if (pack == null) { + return; + } } long remaining = pack.computation; @@ -126,8 +144,10 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas dest= getParameterIn(i,1); weight= getParameterIn(i,0); if (weight > 0 && dest >= 0) { - final int outIndex = (int)dest - 1; - if (outIndex < 0 || outIndex >= eOutputData.size()) continue; + int outIndex = (int)dest - 1; + if (outIndex < 0 || outIndex >= eOutputData.size()) { + continue; + } GT_MetaTileEntity_Hatch_OutputData out = eOutputData.get(outIndex); if(Double.isInfinite(total)){ if(Double.isInfinite(weight)){ @@ -135,14 +155,17 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas break; } }else{ - final long part = (long) Math.floor((pack.computation * weight) / total); + long part = (long) Math.floor(pack.computation * weight / total); if (part > 0) { remaining -= part; - if (remaining > 0) out.q = new QuantumDataPacket(pack, part); - else if (part + remaining > 0) { + if (remaining > 0) { + out.q = new QuantumDataPacket(pack, part); + } else if (part + remaining > 0) { out.q = new QuantumDataPacket(pack, part + remaining); break; - } else break; + } else { + break; + } } } } @@ -151,24 +174,30 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas } @Override - public void updateParameters_EM(boolean busy) { + public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { double weight, dest; for (int i = 0; i < 10; i++) { weight = getParameterIn(i, 0); - if (weight <= 0) { - setStatusOfParameterIn(i, 0, STATUS_TOO_LOW); - setStatusOfParameterIn(i, 1, STATUS_UNUSED); + if (weight < 0) { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); } else if (Double.isNaN(weight)) { - setStatusOfParameterIn(i, 0, STATUS_WRONG); - setStatusOfParameterIn(i, 1, STATUS_UNUSED); + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); } else { - setStatusOfParameterIn(i, 0, STATUS_OK); + setStatusOfParameterIn(i, 0, weight==0?STATUS_LOW:GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); dest = getParameterIn(i, 1); - if (dest < 0) setStatusOfParameterIn(i, 1, STATUS_TOO_LOW); - else if (dest == 0) setStatusOfParameterIn(i, 1, STATUS_LOW); - else if (dest > eOutputData.size()) setStatusOfParameterIn(i, 1, STATUS_TOO_HIGH); - else if (Double.isNaN(dest)) setStatusOfParameterIn(i, 1, STATUS_WRONG); - else setStatusOfParameterIn(i, 1, STATUS_OK); + if (dest < 0) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (dest == 0) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (dest > eOutputData.size()) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } else if (Double.isNaN(dest)) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } } } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java index 4bb1e6de3b..1623ee60ad 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java @@ -1,10 +1,13 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -14,6 +17,7 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import static com.github.technus.tectech.Util.StructureBuilder; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; @@ -65,8 +69,17 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo eDismantleBoom=true; } + public final static ResourceLocation activitySound=new ResourceLocation(Reference.MODID+":fx_noise"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return activitySound; + } + + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_transformer(this.mName); + return new GT_MetaTileEntity_EM_transformer(mName); } @Override @@ -86,7 +99,7 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "EMDisplay.png",true,false,false); + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png",true,false,false); } @Override @@ -94,9 +107,10 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo return description; } + @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][0], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][0], new GT_RenderedTexture(aActive ? GT_MetaTileEntity_MultiblockBase_EM.ScreenON : GT_MetaTileEntity_MultiblockBase_EM.ScreenOFF)}; } return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][0]}; } @@ -112,7 +126,7 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { if (ePowerPass) { mEfficiencyIncrease = 10000; mMaxProgresstime = 20; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java index c410bb289c..5fb232b256 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_wormhole.java @@ -64,8 +64,9 @@ public class GT_MetaTileEntity_EM_wormhole extends GT_MetaTileEntity_MultiblockB super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_EM_wormhole(this.mName); + return new GT_MetaTileEntity_EM_wormhole(mName); } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index b5ad2429e9..0ef0b04c17 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -3,9 +3,9 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.thing.metaTileEntity.IConstructable; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -35,10 +35,8 @@ import static gregtech.api.GregTech_API.sBlockCasings4; * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { - public final static int POWER_SETTING_DEFAULT=1000, TIMER_SETTING_DEFAULT=360; - private int powerSetting = POWER_SETTING_DEFAULT; - private int timerSetting = TIMER_SETTING_DEFAULT; - private int timerValue = 0; + public static final int POWER_SETTING_DEFAULT=1000, TIMER_SETTING_DEFAULT=360; + private int powerSetting,timerSetting,timerValue; private boolean hasBeenPausedThisCycle=false; private boolean flipped=false; @@ -80,8 +78,9 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock super(aName); } + @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_TM_microwave(this.mName); + return new GT_MetaTileEntity_TM_microwave(mName); } @Override @@ -101,7 +100,7 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "EMDisplay.png", false, false, true);//todo texture + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png", false, false, true);//todo texture } @Override @@ -135,8 +134,11 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public void construct(int stackSize, boolean hintsOnly) { - if((stackSize &0x1)==1) StructureBuilder(shape, blockType, blockMeta,2, 2, 0, getBaseMetaTileEntity(),hintsOnly); - else StructureBuilder(shapeFlipped, blockType, blockMeta,2, 1, 0, getBaseMetaTileEntity(),hintsOnly); + if((stackSize &0x1)==1) { + StructureBuilder(shape, blockType, blockMeta, 2, 2, 0, getBaseMetaTileEntity(), hintsOnly); + } else { + StructureBuilder(shapeFlipped, blockType, blockMeta, 2, 1, 0, getBaseMetaTileEntity(), hintsOnly); + } } @Override @@ -155,13 +157,11 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock } @Override - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { hasBeenPausedThisCycle =false; - if(noParametrizers){ - powerSetting=POWER_SETTING_DEFAULT; - timerSetting=TIMER_SETTING_DEFAULT; + if(powerSetting<300 || timerSetting<=0 || timerSetting>3000) { + return false; } - if(powerSetting<300 || timerSetting<=0 || timerSetting>3000) return false; if (timerValue <= 0) { timerValue=timerSetting; } @@ -174,7 +174,9 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock @Override public void outputAfterRecipe_EM() { - if(hasBeenPausedThisCycle) return;//skip timer and actions if paused + if(hasBeenPausedThisCycle) { + return;//skip timer and actions if paused + } timerValue--; IGregTechTileEntity mte=getBaseMetaTileEntity(); int xDirShift = ForgeDirection.getOrientation(mte.getBackFacing()).offsetX*2; @@ -217,8 +219,9 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock ((EntityItem) entity).delayBeforeCanPickup=2; ((EntityItem) entity).setDead(); } else if (entity instanceof EntityLivingBase) { - if(!GT_Utility.isWearingFullElectroHazmat((EntityLivingBase) entity)) + if(!GT_Utility.isWearingFullElectroHazmat((EntityLivingBase) entity)) { ((EntityLivingBase) entity).attackEntityFrom(microwaving, damagingFactor); + } } } } @@ -232,7 +235,7 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock damagingFactor>>=1; } while(damagingFactor>0); - mOutputItems=itemsToOutput.toArray(new ItemStack[0]); + mOutputItems= itemsToOutput.toArray(new ItemStack[itemsToOutput.size()]); if(timerValue<=0) { mte.getWorld().playSoundEffect(xPos,yPos,zPos, Reference.MODID+":microwave_ding", 1, 1); @@ -241,33 +244,55 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock } @Override - public void updateParameters_EM(boolean machineIsBusy) { + protected void parametersLoadDefault_EM() { + powerSetting = POWER_SETTING_DEFAULT; + timerSetting = TIMER_SETTING_DEFAULT; + setParameterPairIn_ClearOut(0,false, POWER_SETTING_DEFAULT, TIMER_SETTING_DEFAULT); + } + + @Override + protected void parametersInRead_EM() { + powerSetting = (int) getParameterIn(0, 0); + timerSetting = (int) getParameterIn(0, 1); + } + + @Override + public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { double powerParameter = getParameterIn(0, 0); - if (powerParameter < 300) setStatusOfParameterIn(0, 0, STATUS_TOO_LOW); - else if (powerParameter < 1000) setStatusOfParameterIn(0, 0, STATUS_LOW); - else if (powerParameter == 1000) setStatusOfParameterIn(0, 0, STATUS_OK); - else if (powerParameter == Double.POSITIVE_INFINITY) setStatusOfParameterIn(0, 0, STATUS_TOO_HIGH); - else if (Double.isNaN(powerParameter)) setStatusOfParameterIn(0, 0, STATUS_WRONG); - else setStatusOfParameterOut(0, 0, STATUS_HIGH); + if (powerParameter < 300) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (powerParameter < 1000) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (powerParameter == 1000) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else if (powerParameter == Double.POSITIVE_INFINITY) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } else if (Double.isNaN(powerParameter)) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else { + setStatusOfParameterOut(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + } double timerParameter = getParameterIn(0, 1); - if (timerParameter <= 1) setStatusOfParameterIn(0, 1, STATUS_TOO_LOW); - else if (timerParameter <= 3000) setStatusOfParameterIn(0, 0, STATUS_OK); - else if (Double.isNaN(timerParameter)) setStatusOfParameterIn(0, 1, STATUS_WRONG); - else setStatusOfParameterIn(0, 1, STATUS_TOO_HIGH); + if (timerParameter <= 1) { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (timerParameter <= 3000) { + setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else if (Double.isNaN(timerParameter)) { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else { + setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } setParameterOut(0, 0, timerValue); setParameterOut(0, 1, timerSetting - timerValue); - - if (machineIsBusy) return; - - powerSetting = (int) powerParameter; - timerSetting = (int) timerParameter; } @Override public boolean onRunningTick(ItemStack aStack) { - if(eSafeVoid) hasBeenPausedThisCycle =true; + if(eSafeVoid) { + hasBeenPausedThisCycle = true; + } return hasBeenPausedThisCycle || super.onRunningTick(aStack);//consume eu and other resources if not paused } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java index 5342c9bc51..b0b8a5a070 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_Container_MultiMachineEM.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.TecTech; import gregtech.api.gui.GT_ContainerMetaTile_Machine; import gregtech.api.gui.GT_Slot_Holo; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -37,37 +37,47 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { @Override public void addSlots(InventoryPlayer aInventoryPlayer) { addSlotToContainer(new Slot(mTileEntity, 1, 152, -21)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, -2, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 15, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 32, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, -2, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 15, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 32, false, false, 1)); } @Override public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex < 0) + if (aSlotIndex < 0) { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { - GT_MetaTileEntity_MultiblockBase_EM base = (GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity(); + } + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { + GT_MetaTileEntity_MultiblockBase_EM mte = (GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity(); + IGregTechTileEntity base = mte.getBaseMetaTileEntity(); switch (aSlotIndex) { case 1: if(ePowerPassButton) { - base.ePowerPass ^= true; + TecTech.proxy.playSound(base,"fx_click"); + mte.ePowerPass ^= true; if (!allowedToWorkButton) {//TRANSFORMER HACK - if (base.ePowerPass) base.getBaseMetaTileEntity().enableWorking(); - else base.getBaseMetaTileEntity().disableWorking(); + if (mte.ePowerPass) { + mte.getBaseMetaTileEntity().enableWorking(); + } else { + mte.getBaseMetaTileEntity().disableWorking(); + } } } break; case 2: - if(eSafeVoidButton) base.eSafeVoid ^= true; + if(eSafeVoidButton) { + TecTech.proxy.playSound(base,"fx_click"); + mte.eSafeVoid ^= true; + } break; case 3: if(allowedToWorkButton) { - if (base.getBaseMetaTileEntity().isAllowedToWork()) { - base.getBaseMetaTileEntity().disableWorking(); + TecTech.proxy.playSound(base,"fx_click"); + if (mte.getBaseMetaTileEntity().isAllowedToWork()) { + mte.getBaseMetaTileEntity().disableWorking(); } else { - base.getBaseMetaTileEntity().enableWorking(); + mte.getBaseMetaTileEntity().enableWorking(); } } break; @@ -79,22 +89,24 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null) || (this.eParamsInStatus == null)) + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null || eParamsInStatus == null) { return; - this.eParamsInStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eParamsInStatus; - this.eParamsOutStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eParamsOutStatus; - this.eCertainMode = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eCertainMode; - this.eCertainStatus = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eCertainStatus; - this.ePowerPass = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).ePowerPass; - this.eSafeVoid = ((GT_MetaTileEntity_MultiblockBase_EM) this.mTileEntity.getMetaTileEntity()).eSafeVoid; - this.allowedToWork = this.mTileEntity.isAllowedToWork(); + } + eParamsInStatus = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eParamsInStatus; + eParamsOutStatus = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eParamsOutStatus; + eCertainMode = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eCertainMode; + eCertainStatus = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eCertainStatus; + ePowerPass = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).ePowerPass; + eSafeVoid = ((GT_MetaTileEntity_MultiblockBase_EM) mTileEntity.getMetaTileEntity()).eSafeVoid; + allowedToWork = mTileEntity.isAllowedToWork(); - for (Object crafter : this.crafters) { + for (Object crafter : crafters) { ICrafting var1 = (ICrafting) crafter; int i = 100; - for (int j = 0; j < eParamsInStatus.length; j++) - var1.sendProgressBarUpdate(this, i++, eParamsInStatus[j] | (eParamsOutStatus[j] << 8)); - var1.sendProgressBarUpdate(this, 120, eCertainMode | (eCertainStatus << 8)); + for (int j = 0; j < eParamsInStatus.length; j++) { + var1.sendProgressBarUpdate(this, i++, eParamsInStatus[j] | eParamsOutStatus[j] << 8); + } + var1.sendProgressBarUpdate(this, 120, eCertainMode | eCertainStatus << 8); var1.sendProgressBarUpdate(this, 121, (ePowerPass ? 1 : 0) + (eSafeVoid ? 2 : 0) + (allowedToWork ? 4 : 0)); } } @@ -102,17 +114,19 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { @Override public void updateProgressBar(int par1, int par2) { super.updateProgressBar(par1, par2); - if (this.eParamsInStatus == null) return; + if (eParamsInStatus == null) { + return; + } if (par1 >= 100 && par1 < 120) { - this.eParamsInStatus[par1 - 100] = (byte) (par2 & 0xff); - this.eParamsOutStatus[par1 - 100] = (byte) (par2 >>> 8); + eParamsInStatus[par1 - 100] = (byte) (par2 & 0xff); + eParamsOutStatus[par1 - 100] = (byte) (par2 >>> 8); } else if (par1 == 120) { - this.eCertainMode = (byte) (par2 & 0xff); - this.eCertainStatus = (byte) (par2 >>> 8); + eCertainMode = (byte) (par2 & 0xff); + eCertainStatus = (byte) (par2 >>> 8); } else if (par1 == 121) { - this.ePowerPass = (par2 & 1) == 1; - this.eSafeVoid = (par2 & 2) == 2; - this.allowedToWork = (par2 & 4) == 4; + ePowerPass = (par2 & 1) == 1; + eSafeVoid = (par2 & 2) == 2; + allowedToWork = (par2 & 4) == 4; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java index 94a70f6e50..3456f22a05 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_GUIContainer_MultiMachineEM.java @@ -36,24 +36,33 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach fontRendererObj.drawString(mName, 10, -18, 16448255); if (mContainer != null) { - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 1) != 0) + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 1) != 0) { fontRendererObj.drawString("Pipe is loose.", 10, -10, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 2) != 0) + } + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 2) != 0) { fontRendererObj.drawString("Screws are loose.", 10, -2, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 4) != 0) + } + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 4) != 0) { fontRendererObj.drawString("Something is stuck.", 10, 6, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 8) != 0) + } + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 8) != 0) { fontRendererObj.drawString("Plating is dented.", 10, 14, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 16) != 0) + } + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 16) != 0) { fontRendererObj.drawString("Circuitry burned out.", 10, 22, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 32) != 0) + } + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 32) != 0) { fontRendererObj.drawString("That doesn't belong there.", 10, 30, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 64) != 0) + } + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 64) != 0) { fontRendererObj.drawString("Incomplete Structure.", 10, 38, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 128) != 0) + } + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 128) != 0) { fontRendererObj.drawString("Too Uncertain.", 10, 46, 16448255); - if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 256) != 0) + } + if ((((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode & 256) != 0) { fontRendererObj.drawString("Invalid Parameters.", 10, 54, 16448255); + } if (((GT_Container_MultiMachineEM) mContainer).mDisplayErrorCode == 0) { if (((GT_Container_MultiMachineEM) mContainer).mActive == 0) { @@ -74,40 +83,43 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach int y = (height - ySize) / 2; y -= 26; drawTexturedModalRect(x, y, 0, 0, xSize, ySize + 26); - if (this.mContainer != null && ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus != null) { + if (mContainer != null && ((GT_Container_MultiMachineEM) mContainer).eParamsInStatus != null) { counter = (byte) ((1 + counter) % 6); GL11.glColor4f(1f, 1f, 1f, 1f); - if(!ePowerPassButton) + if(!ePowerPassButton) { drawTexturedModalRect(x + 151, y + 23, 215, 23, 18, 18); - else if (((GT_Container_MultiMachineEM) mContainer).ePowerPass) + } else if (((GT_Container_MultiMachineEM) mContainer).ePowerPass) { drawTexturedModalRect(x + 151, y + 23, 183, 23, 18, 18); + } - if(!eSafeVoidButton) + if(!eSafeVoidButton) { drawTexturedModalRect(x + 151, y + 41, 215, 41, 18, 18); - else if (((GT_Container_MultiMachineEM) mContainer).eSafeVoid) + } else if (((GT_Container_MultiMachineEM) mContainer).eSafeVoid) { drawTexturedModalRect(x + 151, y + 41, 183, 41, 18, 18); + } - if(!allowedToWorkButton) + if(!allowedToWorkButton) { drawTexturedModalRect(x + 151, y + 57, 215, 57, 18, 18); - else if (((GT_Container_MultiMachineEM) mContainer).allowedToWork) + } else if (((GT_Container_MultiMachineEM) mContainer).allowedToWork) { drawTexturedModalRect(x + 151, y + 57, 183, 57, 18, 18); + } x += 11; y += 96; for (int i = 0; i < 20; ) { - byte j = (byte) (i >>> 1); - LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus[j]); - LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) this.mContainer).eParamsOutStatus[j]); - LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) this.mContainer).eParamsInStatus[j + 10]); - LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) this.mContainer).eParamsOutStatus[j + 10]); + byte b = (byte) (i >>> 1); + LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) mContainer).eParamsInStatus[b]); + LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) mContainer).eParamsOutStatus[b]); + LEDdrawP(x, y, i, 0, ((GT_Container_MultiMachineEM) mContainer).eParamsInStatus[b + 10]); + LEDdrawP(x, y, i++, 1, ((GT_Container_MultiMachineEM) mContainer).eParamsOutStatus[b + 10]); } - final short rU = 183, Vs = 77; + short rU = 183, Vs = 77; x += 140; y -= 19; - final byte state = ((GT_Container_MultiMachineEM) this.mContainer).eCertainStatus; - switch (((GT_Container_MultiMachineEM) this.mContainer).eCertainMode) { + byte state = ((GT_Container_MultiMachineEM) mContainer).eCertainStatus; + switch (((GT_Container_MultiMachineEM) mContainer).eCertainMode) { case 1://ooo oxo ooo drawTexturedModalRect(x + 6, y + 6, rU + (state == 0 ? 38 : 6), @@ -171,9 +183,9 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach } private void LEDdrawP(int x, int y, int i, int j, byte status) { - final int v = 192, su = 8, sv = 6, u = 11; + int v = 192, su = 8, sv = 6, u = 11; switch (status) { - case STATUS_WRONG: + case STATUS_WRONG: {//fallthrough if (counter < 2) { drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * j, su, sv); break; @@ -181,6 +193,7 @@ public class GT_GUIContainer_MultiMachineEM extends GT_GUIContainerMetaTile_Mach drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (8 + j), su, sv); break; } + } case STATUS_OK://ok drawTexturedModalRect(x + su * i, y + sv * j, u + su * i, v + sv * (4 + j), su, sv); break; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index 93197b504e..3ba4e103e0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -1,9 +1,8 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.base; -import com.github.technus.tectech.CommonValues; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.Util; import com.github.technus.tectech.Vec3pos; +import com.github.technus.tectech.auxiliary.Reference; import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalDefinitionStack; import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; @@ -23,11 +22,13 @@ import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.GT_Pollution; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; import java.lang.reflect.InvocationTargetException; @@ -45,20 +46,26 @@ import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texture * Created by danie_000 on 27.10.2016. */ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEntity_MultiBlockBase { - protected final static Map<String, Method> adderMethodMap = new HashMap<>(); + protected static final Map<String, Method> adderMethodMap = new HashMap<>(); private static Method adderMethod; protected cElementalInstanceStackMap[] outputEM; - public final static ItemStack[] nothingI = new ItemStack[0]; - public final static FluidStack[] nothingF = new FluidStack[0]; + public static final ItemStack[] nothingI = new ItemStack[0]; + public static final FluidStack[] nothingF = new FluidStack[0]; protected static Textures.BlockIcons.CustomIcon ScreenOFF; protected static Textures.BlockIcons.CustomIcon ScreenON; + + public final static ResourceLocation activitySound=new ResourceLocation(Reference.MODID+":fx_lo_freq"); + + @SideOnly(Side.CLIENT) + private SoundLoop activitySoundLoop; + protected ArrayList<GT_MetaTileEntity_Hatch_InputElemental> eInputHatches = new ArrayList<>(); protected ArrayList<GT_MetaTileEntity_Hatch_OutputElemental> eOutputHatches = new ArrayList<>(); - protected ArrayList<GT_MetaTileEntity_Hatch_MufflerElemental> eMufflerHatches = new ArrayList<>(); + protected ArrayList<GT_MetaTileEntity_Hatch_OverflowElemental> eMufflerHatches = new ArrayList<>(); protected ArrayList<GT_MetaTileEntity_Hatch_Param> eParamHatches = new ArrayList<>(); protected ArrayList<GT_MetaTileEntity_Hatch_Uncertainty> eUncertainHatches = new ArrayList<>(); protected ArrayList<GT_MetaTileEntity_Hatch_EnergyMulti> eEnergyMulti = new ArrayList<>(); @@ -75,7 +82,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt final byte[] eParamsInStatus = new byte[20];//LED status for I final byte[] eParamsOutStatus = new byte[20];//LED status for O - public final static byte STATUS_UNUSED = 0, + public static final byte STATUS_UNUSED = 0, STATUS_TOO_LOW = 1, STATUS_LOW = 2, STATUS_WRONG = 3, STATUS_OK = 4, STATUS_TOO_HIGH = 5, STATUS_HIGH = 6; @@ -103,13 +110,17 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //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 - public boolean checkRecipe_EM(ItemStack itemStack, boolean noParametrizers) { + public boolean checkRecipe_EM(ItemStack itemStack) { return false; } // My code handles AMPS, if you want overclocking just modify mEUt and mMaxProgressTime, leave amps as usual! // Set mEUt, Efficiencies, required computation, time, check input etc. - public void updateParameters_EM(boolean busy) { + protected void parametersInRead_EM(){ + + } + + public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { } // update status of parameters in guis and "machine state" // Called before check recipe, before outputting, and every second the machine is active @@ -122,7 +133,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt // (Well it can be overflowed if machine didn't finished, soft-hammered/disabled/not enough EU) // Setting available data processing - protected void hatchInit_EM() { + protected void hatchInit_EM(boolean mMachine) { }//For extra types of hatches initiation, LOOK HOW IT IS CALLED! onPostTick protected void extraExplosions_EM() { @@ -136,9 +147,12 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //Get Available data, Override only on data producers should return mAvailableData that is set in check recipe protected long getAvailableData_EM() { long result = 0; - final Vec3pos pos = new Vec3pos(getBaseMetaTileEntity()); - for (GT_MetaTileEntity_Hatch_InputData in : eInputData) - if (in.q != null) result += in.q.computationIfNotContained(pos); + Vec3pos pos = new Vec3pos(getBaseMetaTileEntity()); + for (GT_MetaTileEntity_Hatch_InputData in : eInputData) { + if (in.q != null) { + result += in.q.computationIfNotContained(pos); + } + } return result; } @@ -154,70 +168,122 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return 0; } - public int getPollutionPerTick_EM(ItemStack itemStack) { - return 0; + public float getExcessMassPerTick_EM(ItemStack itemStack) { + return 0f; + } + + //helper method so i don't have to set that params to nothing at all times + protected void afterRecipeCheckFailed(){ + if (outputEM != null) { + float mass = 0; + for (cElementalInstanceStackMap tree : outputEM) { + if (tree != null) { + mass += tree.getMass(); + } + } + if (mass > 0) { + if (eMufflerHatches.size() < 1) { + explodeMultiblock(); + } else { + mass /= eMufflerHatches.size(); + for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { + if (dump.addOverflowMatter(mass)) { + explodeMultiblock(); + } + } + } + } + outputEM = null; + } + + for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { + data.q = null; + } + + mOutputItems = null; + mOutputFluids = null; + mEfficiency = 0; + mEfficiencyIncrease = 0; + mProgresstime = 0; + //mMaxProgresstime = 0; //Done after this - cos it is VITAL! + eAvailableData = 0; + //getBaseMetaTileEntity().disableWorking(); + //hatchesStatusUpdate_EM(); //called always after recipe checks } - //triggered if machine is not allowed to work after completing a recipe + //triggered if machine is not allowed to work after completing a recipe, override to make it not shutdown for instance (like turbines). protected void notAllowedToWork_stopMachine_EM(){ stopMachine(); } //Override if needed but usually call super method at start! - //On machine stop - NOT called when softhammered to offline state! - it SHOULD cause a full stop like power failure does + //On machine stop - NOT called directly when softhammered to offline state! - it SHOULD cause a full stop like power failure does @Override public void stopMachine() { if (outputEM != null) { float mass = 0; - for (cElementalInstanceStackMap tree : outputEM) - mass += tree.getMass(); + for (cElementalInstanceStackMap tree : outputEM) { + if (tree != null) { + mass += tree.getMass(); + } + } if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); - else { + if (eMufflerHatches.size() < 1) { + explodeMultiblock(); + } else { mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); + for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { + if (dump.addOverflowMatter(mass)) { + explodeMultiblock(); + } + } } } outputEM = null; } - for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) + for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { data.q = null; + } mOutputItems = null; mOutputFluids = null; mEfficiency = 0; + mEfficiencyIncrease = 0; mProgresstime = 0; mMaxProgresstime = 0; - mEfficiencyIncrease = 0; - getBaseMetaTileEntity().disableWorking(); + eAvailableData = 0; hatchesStatusUpdate_EM(); + getBaseMetaTileEntity().disableWorking(); } @Override public String[] getDescription() { return new String[]{ - CommonValues.TEC_MARK_GENERAL, + TEC_MARK_GENERAL, "Nothing special just override me." }; } //RATHER LEAVE ALONE Section protected boolean areChunksAroundLoaded_EM(){ - if(isValidMetaTileEntity(this) && getBaseMetaTileEntity().isServerSide()){ + if(GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(this) && getBaseMetaTileEntity().isServerSide()){ IGregTechTileEntity base=getBaseMetaTileEntity(); return base.getWorld().doChunksNearChunkExist(base.getXCoord(),base.getYCoord(),base.getZCoord(),3); //todo check if it is actually checking if chunks are loaded - }else return false; + }else { + return false; + } } - public GT_MetaTileEntity_MultiblockBase_EM(int aID, String aName, String aNameRegional) { + protected GT_MetaTileEntity_MultiblockBase_EM(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); + parametersLoadDefault_EM(); } - public GT_MetaTileEntity_MultiblockBase_EM(String aName) { + protected GT_MetaTileEntity_MultiblockBase_EM(String aName) { super(aName); + parametersLoadDefault_EM(); } @Override @@ -227,7 +293,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public Object getClientGUI(int aID, InventoryPlayer aPlayerInventory, IGregTechTileEntity aBaseMetaTileEntity) { - return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, this.getLocalName(), "EMDisplay.png"); + return new GT_GUIContainer_MultiMachineEM(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "EMDisplay.png"); } @Override @@ -240,7 +306,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + } return new ITexture[]{Textures.BlockIcons.casingTexturePages[texturePage][4]}; } @@ -271,59 +339,69 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //Ensures compatibility if (mOutputItems != null) { aNBT.setInteger("mOutputItemsLength", mOutputItems.length); - for (int i = 0; i < mOutputItems.length; i++) + for (int i = 0; i < mOutputItems.length; i++) { if (mOutputItems[i] != null) { NBTTagCompound tNBT = new NBTTagCompound(); mOutputItems[i].writeToNBT(tNBT); aNBT.setTag("mOutputItem" + i, tNBT); } + } } //Ensures compatibility if (mOutputFluids != null) { aNBT.setInteger("mOutputFluidsLength", mOutputFluids.length); - for (int i = 0; i < mOutputFluids.length; i++) + for (int i = 0; i < mOutputFluids.length; i++) { if (mOutputFluids[i] != null) { NBTTagCompound tNBT = new NBTTagCompound(); mOutputFluids[i].writeToNBT(tNBT); aNBT.setTag("mOutputFluids" + i, tNBT); } + } } if (outputEM != null) { - aNBT.setInteger("outputStackCount", outputEM.length); + aNBT.setInteger("eOutputStackCount", outputEM.length); NBTTagCompound output = new NBTTagCompound(); - for (int i = 0; i < outputEM.length; i++) - output.setTag(Integer.toString(i), outputEM[i].toNBT()); + for (int i = 0; i < outputEM.length; i++) { + if (outputEM[i] != null) { + output.setTag(Integer.toString(i), outputEM[i].toNBT()); + } + } aNBT.setTag("outputEM", output); } else { - aNBT.setInteger("outputStackCount", 0); + aNBT.setInteger("eOutputStackCount", 0); aNBT.removeTag("outputEM"); } NBTTagCompound paramI = new NBTTagCompound(); - for (int i = 0; i < iParamsIn.length; i++) + for (int i = 0; i < iParamsIn.length; i++) { paramI.setInteger(Integer.toString(i), iParamsIn[i]); + } aNBT.setTag("eParamsIn", paramI); NBTTagCompound paramO = new NBTTagCompound(); - for (int i = 0; i < iParamsOut.length; i++) + for (int i = 0; i < iParamsOut.length; i++) { paramO.setInteger(Integer.toString(i), iParamsOut[i]); + } aNBT.setTag("eParamsOut", paramO); NBTTagCompound paramB = new NBTTagCompound(); - for (int i = 0; i < bParamsAreFloats.length; i++) + for (int i = 0; i < bParamsAreFloats.length; i++) { paramB.setBoolean(Integer.toString(i), bParamsAreFloats[i]); + } aNBT.setTag("eParamsB", paramB); NBTTagCompound paramIs = new NBTTagCompound(); - for (int i = 0; i < eParamsInStatus.length; i++) + for (int i = 0; i < eParamsInStatus.length; i++) { paramIs.setByte(Integer.toString(i), eParamsInStatus[i]); + } aNBT.setTag("eParamsInS", paramIs); NBTTagCompound paramOs = new NBTTagCompound(); - for (int i = 0; i < eParamsOutStatus.length; i++) + for (int i = 0; i < eParamsOutStatus.length; i++) { paramOs.setByte(Integer.toString(i), eParamsOutStatus[i]); + } aNBT.setTag("eParamsOutS", paramOs); } @@ -350,50 +428,64 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength"); if (aOutputItemsLength > 0) { mOutputItems = new ItemStack[aOutputItemsLength]; - for (int i = 0; i < mOutputItems.length; i++) + for (int i = 0; i < mOutputItems.length; i++) { mOutputItems[i] = GT_Utility.loadItem(aNBT, "mOutputItem" + i); + } } //Ensures compatibility int aOutputFluidsLength = aNBT.getInteger("mOutputFluidsLength"); if (aOutputFluidsLength > 0) { mOutputFluids = new FluidStack[aOutputFluidsLength]; - for (int i = 0; i < mOutputFluids.length; i++) + for (int i = 0; i < mOutputFluids.length; i++) { mOutputFluids[i] = GT_Utility.loadFluid(aNBT, "mOutputFluids" + i); + } } - final int outputLen = aNBT.getInteger("outputStackCount"); + int outputLen = aNBT.getInteger("eOutputStackCount"); if (outputLen > 0) { outputEM = new cElementalInstanceStackMap[outputLen]; - for (int i = 0; i < outputEM.length; i++) - try { - outputEM[i] = cElementalInstanceStackMap.fromNBT( - aNBT.getCompoundTag("outputEM").getCompoundTag(Integer.toString(i))); - } catch (tElementalException e) { - if (DEBUG_MODE) e.printStackTrace(); - outputEM[i] = new cElementalInstanceStackMap(); + NBTTagCompound compound=aNBT.getCompoundTag("outputEM"); + for (int i = 0; i < outputEM.length; i++) { + if (compound.hasKey(Integer.toString(i))) { + try { + outputEM[i] = cElementalInstanceStackMap.fromNBT(compound.getCompoundTag(Integer.toString(i))); + } catch (tElementalException e) { + if (DEBUG_MODE) { + e.printStackTrace(); + } + outputEM[i] = null; + } } - } else outputEM = new cElementalInstanceStackMap[0]; + } + } else { + outputEM = null; + } NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); - for (int i = 0; i < iParamsIn.length; i++) + for (int i = 0; i < iParamsIn.length; i++) { iParamsIn[i] = paramI.getInteger(Integer.toString(i)); + } NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); - for (int i = 0; i < iParamsOut.length; i++) + for (int i = 0; i < iParamsOut.length; i++) { iParamsOut[i] = paramO.getInteger(Integer.toString(i)); + } NBTTagCompound paramB = aNBT.getCompoundTag("eParamsB"); - for (int i = 0; i < bParamsAreFloats.length; i++) + for (int i = 0; i < bParamsAreFloats.length; i++) { bParamsAreFloats[i] = paramB.getBoolean(Integer.toString(i)); + } NBTTagCompound paramIs = aNBT.getCompoundTag("eParamsInS"); - for (int i = 0; i < eParamsInStatus.length; i++) + for (int i = 0; i < eParamsInStatus.length; i++) { eParamsInStatus[i] = paramIs.getByte(Integer.toString(i)); + } NBTTagCompound paramOs = aNBT.getCompoundTag("eParamsOutS"); - for (int i = 0; i < eParamsOutStatus.length; i++) + for (int i = 0; i < eParamsOutStatus.length; i++) { eParamsOutStatus[i] = paramOs.getByte(Integer.toString(i)); + } } private boolean cyclicUpdate() { @@ -405,6 +497,28 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } //Param methods + //called in creator + protected void parametersLoadDefault_EM(){ + //load default parameters with setParameterPairIn_ClearOut + } + + public final boolean setParameterPairIn_ClearOut(int hatchNo, boolean usesFloats, double value0, double value1) { + if (mMaxProgresstime > 0) { + return false; + } + bParamsAreFloats[hatchNo] = usesFloats; + if (usesFloats) { + iParamsIn[hatchNo] = Float.floatToIntBits((float) value0); + iParamsIn[hatchNo + 10] = Float.floatToIntBits((float) value1); + } else { + iParamsIn[hatchNo] = (int) value0; + iParamsIn[hatchNo + 10] = (int) value1; + } + iParamsOut[hatchNo] = 0; + iParamsOut[hatchNo + 10] = 0; + return true; + } + public final boolean isParametrizerUsingFloat(int hatchNo){ return bParamsAreFloats[hatchNo]; } @@ -414,12 +528,19 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } public final int getParameterInInt(int hatchNo, int paramID){ + if(bParamsAreFloats[hatchNo]) { + return (int) Float.intBitsToFloat(iParamsIn[hatchNo + 10 * paramID]); + } return iParamsIn[hatchNo+10*paramID]; } - public final float getParameterInFloat(int hatchNo, int paramID){ - return Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]); - } + //public final int getParameterInIntRaw(int hatchNo, int paramID){ + // return iParamsIn[hatchNo+10*paramID]; + //} + + //public final float getParameterInFloatRaw(int hatchNo, int paramID){ + // return Float.intBitsToFloat(iParamsIn[hatchNo+10*paramID]); + //} public final void setParameterOut(int hatchNo, int paramID, double value){ if(bParamsAreFloats[hatchNo]) { @@ -429,32 +550,24 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } - public final boolean setParameterOutInt(int hatchNo, int paramID, int value){ - if(bParamsAreFloats[hatchNo]) return false; - iParamsOut[hatchNo+10*paramID]=value; - return true; - } - - public final boolean setParameterOutFloat(int hatchNo, int paramID, float value){ - if(bParamsAreFloats[hatchNo]) { - iParamsOut[hatchNo + 10 * paramID] = Float.floatToIntBits(value); - return true; - } - return false; - } + //public final boolean setParameterOutInt(int hatchNo, int paramID, int value){ + // if(bParamsAreFloats[hatchNo]) return false; + // iParamsOut[hatchNo+10*paramID]=value; + // return true; + //} - public final byte getStatusOfParameterIn(int hatchNo, int paramID){ - return eParamsInStatus[hatchNo+10*paramID]; - } + //public final boolean setParameterOutFloat(int hatchNo, int paramID, float value){ + // if(bParamsAreFloats[hatchNo]) { + // iParamsOut[hatchNo + 10 * paramID] = Float.floatToIntBits(value); + // return true; + // } + // return false; + //} public final void setStatusOfParameterIn(int hatchNo, int paramID, byte status){ eParamsInStatus[hatchNo+10*paramID]=status; } - public final byte getStatusOfParameterOut(int hatchNo, int paramID){ - return eParamsOutStatus[hatchNo+10*paramID]; - } - public final void setStatusOfParameterOut(int hatchNo, int paramID, byte status){ eParamsOutStatus[hatchNo+10*paramID]=status; } @@ -485,8 +598,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt Block[] blockTypeFallback,//use numbers 0-9 for casing types byte[] blockMetaFallback,//use numbers 0-9 for casing types int horizontalOffset, int verticalOffset, int depthOffset) { - return StructureCheckerAdvanced(structure, blockType, blockMeta, - adderMethod, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, + return StructureCheckerAdvanced(structure, blockType, blockMeta, adderMethod, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), !mMachine); } @@ -495,7 +607,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { explodedThisTick=false; - if (mEfficiency < 0) mEfficiency = 0; + if (mEfficiency < 0) { + mEfficiency = 0; + } if (--mUpdate == 0 || --mStartUpCheck == 0 || cyclicUpdate() || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { mInputHatches.clear(); @@ -507,20 +621,38 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mMufflerHatches.clear(); mMaintenanceHatches.clear(); - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) - if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = -1; - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) - if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = -1; + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch_elemental)) { + hatch_elemental.id = -1; + } + } + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch_elemental)) { + hatch_elemental.id = -1; + } + } - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) - if (isValidMetaTileEntity(hatch_data)) hatch_data.id = -1; - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) - if (isValidMetaTileEntity(hatch_data)) hatch_data.id = -1; + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch_data)) { + hatch_data.id = -1; + } + } + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch_data)) { + hatch_data.id = -1; + } + } - for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) - if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(false); - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) - if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(false); + for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + hatch.getBaseMetaTileEntity().setActive(false); + } + } + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + hatch.getBaseMetaTileEntity().setActive(false); + } + } eUncertainHatches.clear(); eEnergyMulti.clear(); @@ -532,89 +664,131 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt eOutputData.clear(); eInputData.clear(); - if ((getBaseMetaTileEntity() instanceof BaseTileEntity)) + if (getBaseMetaTileEntity() instanceof BaseTileEntity) { ((BaseTileEntity) getBaseMetaTileEntity()).ignoreUnloadedChunks = mMachine; + } mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); if (!mMachine) { - if ((ePowerPass && getEUVar() > V[3]) || (eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM())) + if (ePowerPass && getEUVar() > V[3] || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) { explodeMultiblock(); - if (outputEM != null) - for (cElementalInstanceStackMap tree : outputEM) - if (tree.hasStacks()) explodeMultiblock(); + } + if (outputEM != null) { + for (cElementalInstanceStackMap tree : outputEM) { + if (tree != null && tree.hasStacks()) { + explodeMultiblock(); + } + } + } } - if (eUncertainHatches.size() > 1) mMachine = false; + if (eUncertainHatches.size() > 1) { + mMachine = false; + } if (mMachine) { short id = 1; - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) - if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = id++; + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch_elemental)) { + hatch_elemental.id = id++; + } + } id = 1; - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) - if (isValidMetaTileEntity(hatch_elemental)) hatch_elemental.id = id++; + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch_elemental)) { + hatch_elemental.id = id++; + } + } id = 1; - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) - if (isValidMetaTileEntity(hatch_data)) hatch_data.id = id++; + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eOutputData) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch_data)) { + hatch_data.id = id++; + } + } id = 1; - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) - if (isValidMetaTileEntity(hatch_data)) hatch_data.id = id++; + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch_data)) { + hatch_data.id = id++; + } + } - if (mEnergyHatches.size() > 0 || eEnergyMulti.size() > 0) { + if (!mEnergyHatches.isEmpty() || !eEnergyMulti.isEmpty()) { 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_Energy hatch : mEnergyHatches) { + if (GT_MetaTileEntity_MultiBlockBase.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(); + } + for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : eEnergyMulti) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + if (hatch.maxEUInput() < maxEUinputMin) { + maxEUinputMin = hatch.maxEUInput(); + } + if (hatch.maxEUInput() > maxEUinputMax) { + maxEUinputMax = hatch.maxEUInput(); + } } + } eMaxAmpereFlow = 0; //counts only full amps - for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) - if (isValidMetaTileEntity(hatch)) eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin; - for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : eEnergyMulti) - if (isValidMetaTileEntity(hatch)) - eMaxAmpereFlow += (hatch.maxEUInput() / maxEUinputMin) * hatch.Amperes; - if (this.getEUVar() > maxEUStore()) this.setEUVar(this.maxEUStore()); + for (GT_MetaTileEntity_Hatch_Energy hatch : mEnergyHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin; + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti hatch : eEnergyMulti) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin * hatch.Amperes; + } + } + if (getEUVar() > maxEUStore()) { + setEUVar(maxEUStore()); + } } else { maxEUinputMin = 0; maxEUinputMax = 0; eMaxAmpereFlow = 0; - this.setEUVar(0); + setEUVar(0); } - for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) - if (isValidMetaTileEntity(hatch)) hatch.getBaseMetaTileEntity().setActive(true); + for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { + hatch.getBaseMetaTileEntity().setActive(true); + } + } for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches){ - if (isValidMetaTileEntity(hatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch)) { hatch.getBaseMetaTileEntity().setActive(true); - if(hatch.param>=0) bParamsAreFloats[hatch.param]=hatch.isUsingFloats(); + if(hatch.param>=0) { + bParamsAreFloats[hatch.param] = hatch.isUsingFloats(); + } } } } else { maxEUinputMin = 0; maxEUinputMax = 0; eMaxAmpereFlow = 0; - this.setEUVar(0); + setEUVar(0); } - hatchInit_EM(); + hatchInit_EM(mMachine); } if (mStartUpCheck < 0) {//E if (mMachine) {//S - final byte Tick = (byte) (aTick % 20); - if (MULTI_PURGE_1_AT == Tick || MULTI_PURGE_2_AT == Tick) + byte Tick = (byte) (aTick % 20); + if (MULTI_PURGE_1_AT == Tick || MULTI_PURGE_2_AT == Tick) { purgeAllOverflowEM_EM(); - else if (MULTI_CHECK_AT == Tick) + } else if (MULTI_CHECK_AT == Tick) { for (GT_MetaTileEntity_Hatch_Maintenance tHatch : mMaintenanceHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (disableMaintenance) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.disableMaintenance) { mWrench = true; mScrewdriver = true; mSoftHammer = true; @@ -622,14 +796,27 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mSolderingTool = true; mCrowbar = true; } else { - if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) + if (tHatch.mAuto && !(mWrench && mScrewdriver && mSoftHammer && mHardHammer && mSolderingTool && mCrowbar)) { tHatch.autoMaintainance(); - if (tHatch.mWrench) mWrench = true; - if (tHatch.mScrewdriver) mScrewdriver = true; - if (tHatch.mSoftHammer) mSoftHammer = true; - if (tHatch.mHardHammer) mHardHammer = true; - if (tHatch.mSolderingTool) mSolderingTool = true; - if (tHatch.mCrowbar) mCrowbar = true; + } + if (tHatch.mWrench) { + mWrench = true; + } + if (tHatch.mScrewdriver) { + mScrewdriver = true; + } + if (tHatch.mSoftHammer) { + mSoftHammer = true; + } + if (tHatch.mHardHammer) { + mHardHammer = true; + } + if (tHatch.mSolderingTool) { + mSolderingTool = true; + } + if (tHatch.mCrowbar) { + mCrowbar = true; + } tHatch.mWrench = false; tHatch.mScrewdriver = false; @@ -640,17 +827,20 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } } - else if (MOVE_AT == Tick && eSafeVoid) { - for (GT_MetaTileEntity_Hatch_MufflerElemental voider : eMufflerHatches) { - if (voider.overflowMax < voider.getOverflowMatter()) continue; + } else if (MOVE_AT == Tick && eSafeVoid) { + for (GT_MetaTileEntity_Hatch_OverflowElemental voider : eMufflerHatches) { + if (voider.overflowMax < voider.getOverflowMatter()) { + continue; + } float remaining = voider.overflowMax - voider.getOverflowMatter(); for (GT_MetaTileEntity_Hatch_InputElemental in : eInputHatches) { for (cElementalInstanceStack instance : in.getContainerHandler().values()) { long qty = (long) Math.floor(remaining / instance.definition.getMass()); if (qty > 0) { qty = Math.min(qty, instance.amount); - if (voider.addOverflowMatter(instance.definition.getMass() * qty)) + if (voider.addOverflowMatter(instance.definition.getMass() * qty)) { voider.setOverflowMatter(voider.overflowMax); + } in.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); } } @@ -660,8 +850,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt long qty = (long)Math.floor(remaining / instance.definition.getMass()); if (qty > 0) { qty = Math.min(qty, instance.amount); - if (voider.addOverflowMatter(instance.definition.getMass() * qty)) + if (voider.addOverflowMatter(instance.definition.getMass() * qty)) { voider.setOverflowMatter(voider.overflowMax); + } out.getContainerHandler().removeAmount(false, new cElementalDefinitionStack(instance.definition, qty)); } } @@ -670,43 +861,52 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } if (getRepairStatus() >= minRepairStatus) {//S - if (MULTI_CHECK_AT == Tick) + if (MULTI_CHECK_AT == Tick) { hatchesStatusUpdate_EM(); + } //region power pass and controller charging {//DO long euVar; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (this.getEUVar() > this.getMinimumStoredEU()) break; - if (isValidMetaTileEntity(tHatch)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { euVar = tHatch.maxEUInput(); - if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) - this.setEUVar(this.getEUVar() + euVar); + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } } } for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { - if (this.getEUVar() > this.getMinimumStoredEU()) break; - if (isValidMetaTileEntity(tHatch)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { euVar = tHatch.maxEUInput() * tHatch.Amperes; - if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) - this.setEUVar(this.getEUVar() + euVar); + if (tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } } } if (ePowerPass) { for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { euVar = tHatch.maxEUOutput(); - if (tHatch.getBaseMetaTileEntity().getStoredEU() <= (tHatch.maxEUStore() - euVar) && - aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.min(euVar >> 7,1), false)) + if (tHatch.getBaseMetaTileEntity().getStoredEU() <= tHatch.maxEUStore() - euVar && + aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.min(euVar >> 7,1), false)) { tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + } } } for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { euVar = tHatch.maxEUOutput() * tHatch.Amperes; if (tHatch.getBaseMetaTileEntity().getStoredEU() <= tHatch.maxEUStore() - euVar && - aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.min(euVar >> 7,tHatch.Amperes), false)) + aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.min(euVar >> 7,tHatch.Amperes), false)) { tHatch.setEUVar(tHatch.getBaseMetaTileEntity().getStoredEU() + euVar); + } } } } @@ -715,8 +915,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) {//Start if (onRunningTick(mInventory[1])) {//Compute EU - if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) stopMachine(); - if (!polluteEnvironment_EM(getPollutionPerTick_EM(mInventory[1]))) stopMachine(); + cleanMassEM_EM(getExcessMassPerTick_EM(mInventory[1])); + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) { + stopMachine(); + } if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime && RECIPE_AT == Tick) {//progress increase and done hatchesStatusUpdate_EM(); @@ -724,15 +926,25 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt outputAfterRecipe_EM(); cleanOutputEM_EM(); - if (mOutputItems != null) for (ItemStack tStack : mOutputItems) - if (tStack != null) addOutput(tStack); + if (mOutputItems != null) { + for (ItemStack tStack : mOutputItems) { + if (tStack != null) { + addOutput(tStack); + } + } + } mOutputItems = null; if (mOutputFluids != null) { if (mOutputFluids.length == 1) { - for (FluidStack tStack : mOutputFluids) - if (tStack != null) addOutput(tStack); - } else if (mOutputFluids.length > 1) addFluidOutputs(mOutputFluids); + for (FluidStack tStack : mOutputFluids) { + if (tStack != null) { + addOutput(tStack); + } + } + } else if (mOutputFluids.length > 1) { + addFluidOutputs(mOutputFluids); + } } mOutputFluids = null; @@ -742,12 +954,15 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mEfficiencyIncrease = 0; if (aBaseMetaTileEntity.isAllowedToWork()) { if (checkRecipe(mInventory[1])) { - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); }else { - mMaxProgresstime=0; + afterRecipeCheckFailed(); + mMaxProgresstime=0;//Just to be sure... } updateSlots(); - } else notAllowedToWork_stopMachine_EM(); + } else { + notAllowedToWork_stopMachine_EM(); + } } }// else {//failed to consume power/resources - inside on running tick // stopMachine(); @@ -755,9 +970,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } else if (RECIPE_AT == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { if (aBaseMetaTileEntity.isAllowedToWork()) { if (checkRecipe(mInventory[1])) { - mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000))); + mEfficiency = Math.max(0, Math.min(mEfficiency + mEfficiencyIncrease, getMaxEfficiency(mInventory[1]) - (getIdealStatus() - getRepairStatus()) * 1000)); }else { - mMaxProgresstime=0; + afterRecipeCheckFailed(); + mMaxProgresstime=0;//Just to be sure... } updateSlots(); } //else notAllowedToWork_stopMachine_EM(); //it is already stopped here @@ -770,16 +986,34 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } - aBaseMetaTileEntity.setErrorDisplayID((aBaseMetaTileEntity.getErrorDisplayID() & -512) | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64) | ((eCertainStatus == 0) ? 0 : 128) | (eParameters ? 0 : 256)); + aBaseMetaTileEntity.setErrorDisplayID(aBaseMetaTileEntity.getErrorDisplayID() & -512 | (mWrench ? 0 : 1) | (mScrewdriver ? 0 : 2) | (mSoftHammer ? 0 : 4) | (mHardHammer ? 0 : 8) | (mSolderingTool ? 0 : 16) | (mCrowbar ? 0 : 32) | (mMachine ? 0 : 64) | (eCertainStatus == 0 ? 0 : 128) | (eParameters ? 0 : 256)); aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); boolean active = aBaseMetaTileEntity.isActive() && mPollution > 0; - for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) + for (GT_MetaTileEntity_Hatch_Muffler aMuffler : mMufflerHatches) { aMuffler.getBaseMetaTileEntity().setActive(active); + } + }else{ + soundMagic(getActivitySound()); } } - public boolean polluteEnvironment_EM(int aPollutionLevel) { - return true; //TODO + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound(){ + return activitySound; + } + + @SideOnly(Side.CLIENT) + protected void soundMagic(ResourceLocation activitySound){ + if(getBaseMetaTileEntity().isActive()){ + if(activitySoundLoop==null){ + activitySoundLoop =new SoundLoop(activitySound,getBaseMetaTileEntity(),false,true); + Minecraft.getMinecraft().getSoundHandler().playSound(activitySoundLoop); + } + }else { + if(activitySoundLoop!=null) { + activitySoundLoop = null; + } + } } @Deprecated @@ -791,8 +1025,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt protected void addFluidOutputs(FluidStack[] mOutputFluids) { int min=mOutputFluids.length>mOutputHatches.size()?mOutputHatches.size():mOutputFluids.length; for (int i = 0; i < min; ++i) { - if (this.mOutputHatches.get(i) != null && mOutputFluids[i] != null && isValidMetaTileEntity(this.mOutputHatches.get(i))) { - this.mOutputHatches.get(i).fill(mOutputFluids[i], true); + if (mOutputHatches.get(i) != null && mOutputFluids[i] != null && GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(mOutputHatches.get(i))) { + mOutputHatches.get(i).fill(mOutputFluids[i], true); } } } @@ -809,26 +1043,27 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public int getRepairStatus() { - return super.getRepairStatus() + ((eCertainStatus == 0) ? 1 : 0) + (this.eParameters ? 1 : 0); + return super.getRepairStatus() + (eCertainStatus == 0 ? 1 : 0) + (eParameters ? 1 : 0); } @Override public boolean onRunningTick(ItemStack aStack) { if (eRequiredData > eAvailableData) { - if(energyFlow(aStack,false)) + if(energyFlowOnRunningTick(aStack,false)) { stopMachine(); + } return false; } - return energyFlow(aStack,true); + return energyFlowOnRunningTick(aStack,true); } //new method - private boolean energyFlow(ItemStack aStack,boolean allowProduction) { - long temp = mEUt * eAmpereFlow;//quick scope sign - if (allowProduction && temp > 0) { - this.addEnergyOutput_EM((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); - } else if (temp < 0) { - if (!this.drainEnergyInput_EM(mEUt,(long) mEUt * getMaxEfficiency(aStack) / Math.max(1000L, this.mEfficiency), eAmpereFlow)) { + private boolean energyFlowOnRunningTick(ItemStack aStack, boolean allowProduction) { + long euFlow = mEUt * eAmpereFlow;//quick scope sign + if (allowProduction && euFlow > 0) { + addEnergyOutput_EM((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); + } else if (euFlow < 0) { + if (!drainEnergyInput_EM(mEUt,(long) mEUt * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency), eAmpereFlow)) { stopMachine(); return false; } @@ -837,22 +1072,22 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } //region energy - public final boolean energyFlowWithoutEffieciencyComputation(int eu,long ampere) { - long temp = eu * ampere;//quick scope sign - if (temp > 0) { - this.addEnergyOutput_EM(eu, ampere); - } else if (temp < 0) { - if (!this.drainEnergyInput_EM(eu,eu, ampere)) { - stopMachine(); - return false; - } - } - return true; - } + //public final boolean energyFlowWithoutEffieciencyComputation(int eu,long ampere) { + // long temp = eu * ampere;//quick scope sign + // if (temp > 0) { + // this.addEnergyOutput_EM(eu, ampere); + // } else if (temp < 0) { + // if (!this.drainEnergyInput_EM(eu,eu, ampere)) { + // stopMachine(); + // return false; + // } + // } + // return true; + //} @Override public final long maxEUStore() { - return (maxEUinputMin * eMaxAmpereFlow) << 3; + return maxEUinputMin * eMaxAmpereFlow << 3; } @Override @@ -873,30 +1108,46 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Deprecated @Override public final boolean addEnergyOutput(long EU) { - if (EU <= 0L) return true; - for (GT_MetaTileEntity_Hatch tHatch : eDynamoMulti) - if (isValidMetaTileEntity(tHatch)){ - if(tHatch.maxEUOutput()<EU) explodeMultiblock(); - if(tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU, false)) + if (EU <= 0L) { + return true; + } + for (GT_MetaTileEntity_Hatch tHatch : eDynamoMulti) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + if (tHatch.maxEUOutput() < EU) { + explodeMultiblock(); + } + if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU, false)) { return true; + } } - for (GT_MetaTileEntity_Hatch tHatch : mDynamoHatches) - if (isValidMetaTileEntity(tHatch)){ - if(tHatch.maxEUOutput()<EU) explodeMultiblock(); - if(tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU, false)) + } + for (GT_MetaTileEntity_Hatch tHatch : mDynamoHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + if (tHatch.maxEUOutput() < EU) { + explodeMultiblock(); + } + if (tHatch.getBaseMetaTileEntity().increaseStoredEnergyUnits(EU, false)) { return true; + } } + } return false; } private boolean addEnergyOutput_EM(long EU, long Amperes) { - if(EU<0) EU=-EU; - if(Amperes<0) Amperes=-Amperes; + if(EU<0) { + EU = -EU; + } + if(Amperes<0) { + Amperes = -Amperes; + } long euVar = EU * Amperes; long diff; for (GT_MetaTileEntity_Hatch_Dynamo tHatch : mDynamoHatches) { - if (isValidMetaTileEntity(tHatch)) { - if (tHatch.maxEUOutput() < EU) explodeMultiblock(); + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + if (tHatch.maxEUOutput() < EU) { + explodeMultiblock(); + } diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity().getStoredEU(); if (diff > 0) { if (euVar > diff) { @@ -910,8 +1161,10 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } for (GT_MetaTileEntity_Hatch_DynamoMulti tHatch : eDynamoMulti) { - if (isValidMetaTileEntity(tHatch)) { - if (tHatch.maxEUOutput() < EU) explodeMultiblock(); + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + if (tHatch.maxEUOutput() < EU) { + explodeMultiblock(); + } diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity().getStoredEU(); if (diff > 0) { if (euVar > diff) { @@ -930,29 +1183,41 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Deprecated @Override public final boolean drainEnergyInput(long EU) { - if (EU <= 0L) return true; - for (GT_MetaTileEntity_Hatch tHatch : eEnergyMulti) - if (isValidMetaTileEntity(tHatch) && tHatch.maxEUInput()>EU && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) + if (EU <= 0L) { + return true; + } + for (GT_MetaTileEntity_Hatch tHatch : eEnergyMulti) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch) && tHatch.maxEUInput() > EU && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) { return true; - for (GT_MetaTileEntity_Hatch tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch) && tHatch.maxEUInput()>EU && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) + } + } + for (GT_MetaTileEntity_Hatch tHatch : mEnergyHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch) && tHatch.maxEUInput() > EU && tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(EU, false)) { return true; + } + } return false; } - private boolean drainEnergyInput_EM(long EUt, long EUtEff, long Amperes) { - if(EUt<0) EUt=-EUt; - if(EUtEff<0) EUtEff=-EUtEff; - if(Amperes<0) Amperes=-Amperes; - long EUuse = EUtEff * Amperes; + private boolean drainEnergyInput_EM(long EUtTierVoltage, long EUtEffective, long Amperes) { + if(EUtTierVoltage<0) { + EUtTierVoltage = -EUtTierVoltage; + } + if(EUtEffective<0) { + EUtEffective = -EUtEffective; + } + if(Amperes<0) { + Amperes = -Amperes; + } + long EUuse = EUtEffective * Amperes; if (EUuse > getEUVar() || //not enough power - EUt > maxEUinputMax || //TIER IS BASED ON BEST HATCH! not total EUtEff input - ((EUt*Amperes) - 1) / maxEUinputMin + 1 > eMaxAmpereFlow) {// EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1! //if not too much A + EUtTierVoltage > maxEUinputMax || //TIER IS BASED ON BEST HATCH! not total EUtEffective input + (EUtTierVoltage*Amperes - 1) / maxEUinputMin + 1 > eMaxAmpereFlow) {// EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1! //if not too much A if (DEBUG_MODE) { - TecTech.Logger.debug("L1 " + EUuse + " " + getEUVar() + " " + (EUuse > getEUVar())); - TecTech.Logger.debug("L2 " + EUtEff + " " + maxEUinputMax + " " + (EUtEff > maxEUinputMax)); - TecTech.Logger.debug("L3 " + EUuse + " " + eMaxAmpereFlow); - TecTech.Logger.debug("L4 " + ((EUuse - 1) / maxEUinputMin + 1) + " " + eMaxAmpereFlow + " " + ((EUuse - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)); + TecTech.Logger.debug("L1 " + EUuse + ' ' + getEUVar() + ' ' + (EUuse > getEUVar())); + TecTech.Logger.debug("L2 " + EUtEffective + ' ' + maxEUinputMax + ' ' + (EUtEffective > maxEUinputMax)); + TecTech.Logger.debug("L3 " + EUuse + ' ' + eMaxAmpereFlow); + TecTech.Logger.debug("L4 " + ((EUuse - 1) / maxEUinputMin + 1) + ' ' + eMaxAmpereFlow + ' ' + ((EUuse - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)); } return false; } @@ -988,31 +1253,43 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override // same as gt sum of all hatches public final long getMaxInputVoltage() { long rVoltage = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.maxEUInput(); - for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) - if (isValidMetaTileEntity(tHatch)) rVoltage += tHatch.maxEUInput(); + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + rVoltage += tHatch.maxEUInput(); + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + rVoltage += tHatch.maxEUInput(); + } + } return rVoltage; } //new Method public final long getMaxInputEnergy(){ long energy = 0; - for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) - if (isValidMetaTileEntity(tHatch)) energy += tHatch.maxEUInput(); - for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) - if (isValidMetaTileEntity(tHatch)) energy += tHatch.maxEUInput() * tHatch.Amperes; + for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + energy += tHatch.maxEUInput(); + } + } + for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + energy += tHatch.maxEUInput() * tHatch.Amperes; + } + } return energy; } //new Method public final int getMaxEnergyInputTier_EM() { - return Util.getTier(maxEUinputMax); + return getTier(maxEUinputMax); } //new Method public final int getMinEnergyInputTier_EM() { - return Util.getTier(maxEUinputMin); + return getTier(maxEUinputMin); } public final long getMaxAmpereFlowAtMinTierOfEnergyHatches(){ @@ -1054,59 +1331,92 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt private void purgeAllOverflowEM_EM() { float mass = 0; for (GT_MetaTileEntity_Hatch_InputElemental tHatch : eInputHatches) { - if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } mass += tHatch.overflowMatter; tHatch.overflowMatter = 0; } for (GT_MetaTileEntity_Hatch_OutputElemental tHatch : eOutputHatches) { - if (isValidMetaTileEntity(tHatch)) tHatch.updateSlots(); + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { + tHatch.updateSlots(); + } mass += tHatch.overflowMatter; tHatch.overflowMatter = 0; } if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); + if (eMufflerHatches.size() < 1) { + explodeMultiblock(); + } mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); + for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { + if (dump.addOverflowMatter(mass)) { + explodeMultiblock(); + } + } } } public void cleanHatchContentEM_EM(GT_MetaTileEntity_Hatch_ElementalContainer target) { - if (target == null) return; + if (target == null) { + return; + } float mass = target.getContainerHandler().getMass(); if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); + if (eMufflerHatches.size() < 1) { + explodeMultiblock(); + } mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); + for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { + if (dump.addOverflowMatter(mass)) { + explodeMultiblock(); + } + } } } public void cleanStackEM_EM(cElementalInstanceStack target) { - if (target == null) return; + if (target == null) { + return; + } cleanMassEM_EM(target.getMass()); } public void cleanMassEM_EM(float mass) { if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); + if (eMufflerHatches.size() < 1) { + explodeMultiblock(); + } mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); + for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { + if (dump.addOverflowMatter(mass)) { + explodeMultiblock(); + } + } } } private void cleanOutputEM_EM() { - if (outputEM == null) return; + if (outputEM == null) { + return; + } float mass = 0; - for (cElementalInstanceStackMap map : outputEM) - mass = map.removeOverflow(0, 0); + for (cElementalInstanceStackMap map : outputEM) { + if (map != null) { + mass += map.getMass(); + } + } if (mass > 0) { - if (eMufflerHatches.size() < 1) explodeMultiblock(); + if (eMufflerHatches.size() < 1) { + explodeMultiblock(); + } mass /= eMufflerHatches.size(); - for (GT_MetaTileEntity_Hatch_MufflerElemental dump : eMufflerHatches) - if (dump.addOverflowMatter(mass)) explodeMultiblock(); + for (GT_MetaTileEntity_Hatch_OverflowElemental dump : eMufflerHatches) { + if (dump.addOverflowMatter(mass)) { + explodeMultiblock(); + } + } } outputEM = null; } @@ -1115,24 +1425,19 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public final boolean checkRecipe(ItemStack itemStack) {//do recipe checks, based on "machine content and state" hatchesStatusUpdate_EM(); - return checkRecipe_EM(itemStack, eParamHatches.size()==0); + boolean result= checkRecipe_EM(itemStack);//if had no - set default params + hatchesStatusUpdate_EM(); + return result; } private void hatchesStatusUpdate_EM() { - if(mMaxProgresstime==0) { - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { - if (!isValidMetaTileEntity(hatch) || hatch.param < 0) continue; - final int paramID = hatch.param; - bParamsAreFloats[hatch.param] = hatch.isUsingFloats(); - iParamsIn[paramID] = hatch.value0i; - iParamsIn[paramID + 10] = hatch.value1i; - hatch.input0i = iParamsOut[paramID]; - hatch.input1i = iParamsOut[paramID + 10]; - } - }else {//write only + boolean busy=mMaxProgresstime>0; + if (busy) {//write from buffer to hatches only for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { - if (!isValidMetaTileEntity(hatch) || hatch.param < 0) continue; - final int paramID = hatch.param; + if (!GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch) || hatch.param < 0) { + continue; + } + int paramID = hatch.param; if(bParamsAreFloats[hatch.param] == hatch.isUsingFloats()){ hatch.input0i = iParamsOut[paramID]; hatch.input1i = iParamsOut[paramID + 10]; @@ -1144,12 +1449,25 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt hatch.input1i = (int)Float.intBitsToFloat(iParamsOut[paramID + 10]); } } + parametersInRead_EM(); + } else {//if has nothing to do update all + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { + if (!GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(hatch) || hatch.param < 0) { + continue; + } + int paramID = hatch.param; + bParamsAreFloats[hatch.param] = hatch.isUsingFloats(); + iParamsIn[paramID] = hatch.value0i; + iParamsIn[paramID + 10] = hatch.value1i; + hatch.input0i = iParamsOut[paramID]; + hatch.input1i = iParamsOut[paramID + 10]; + } } - updateParameters_EM(mMaxProgresstime>0); - eAvailableData = getAvailableData_EM(); - - for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) + for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) { eCertainStatus = uncertainty.update(eCertainMode); + } + eAvailableData = getAvailableData_EM(); + parametersOutAndStatusesWrite_EM(busy); } @Override @@ -1169,10 +1487,12 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public final void explodeMultiblock() { - if(explodedThisTick)return; + if(explodedThisTick) { + return; + } explodedThisTick=true; if (!TecTech.ModConfig.BOOM_ENABLE) { - TecTech.proxy.broadcast("Multi Explode BOOM! " + getBaseMetaTileEntity().getXCoord() + " " + getBaseMetaTileEntity().getYCoord() + " " + getBaseMetaTileEntity().getZCoord()); + TecTech.proxy.broadcast("Multi Explode BOOM! " + getBaseMetaTileEntity().getXCoord() + ' ' + getBaseMetaTileEntity().getYCoord() + ' ' + getBaseMetaTileEntity().getZCoord()); StackTraceElement[] ste = Thread.currentThread().getStackTrace(); TecTech.proxy.broadcast("Multi Explode BOOM! " + ste[2].toString()); return; @@ -1180,23 +1500,57 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt extraExplosions_EM(); GT_Pollution.addPollution(getBaseMetaTileEntity(), 600000); mInventory[1] = null; - for (MetaTileEntity tTileEntity : mInputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mOutputBusses) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mDynamoHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : mMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : mEnergyHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : mMaintenanceHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : eParamHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : eInputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eOutputHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eMufflerHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eEnergyMulti) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eUncertainHatches) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : eDynamoMulti) tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); - for (MetaTileEntity tTileEntity : eInputData) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); - for (MetaTileEntity tTileEntity : eOutputData) tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + for (MetaTileEntity tTileEntity : mInputBusses) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : mOutputBusses) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : mInputHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : mOutputHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : mDynamoHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + } + for (MetaTileEntity tTileEntity : mMufflerHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : mEnergyHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + } + for (MetaTileEntity tTileEntity : mMaintenanceHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : eParamHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : eInputHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + } + for (MetaTileEntity tTileEntity : eOutputHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + } + for (MetaTileEntity tTileEntity : eMufflerHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + } + for (MetaTileEntity tTileEntity : eEnergyMulti) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + } + for (MetaTileEntity tTileEntity : eUncertainHatches) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : eDynamoMulti) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[14]); + } + for (MetaTileEntity tTileEntity : eInputData) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } + for (MetaTileEntity tTileEntity : eOutputData) { + tTileEntity.getBaseMetaTileEntity().doExplosion(V[9]); + } getBaseMetaTileEntity().doExplosion(V[15]); } @@ -1210,134 +1564,197 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt public void onRemoval() { try { if (eOutputHatches != null) { - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eOutputHatches) { hatch_elemental.id = -1; - for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) + } + for (GT_MetaTileEntity_Hatch_ElementalContainer hatch_elemental : eInputHatches) { hatch_elemental.id = -1; + } for (GT_MetaTileEntity_Hatch_OutputData hatch_data : eOutputData) { hatch_data.id = -1; hatch_data.q = null; } - for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) + for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) { hatch_data.id = -1; - for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) + } + for (GT_MetaTileEntity_Hatch_Uncertainty hatch : eUncertainHatches) { hatch.getBaseMetaTileEntity().setActive(false); - for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) + } + for (GT_MetaTileEntity_Hatch_Param hatch : eParamHatches) { hatch.getBaseMetaTileEntity().setActive(false); + } + } + if (ePowerPass && getEUVar()>V[3] || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) { + explodeMultiblock(); + } + if (outputEM != null) { + for (cElementalInstanceStackMap output : outputEM) { + if (output != null && output.hasStacks()) { + explodeMultiblock(); + } + } } - if ((ePowerPass && getEUVar()>V[3]) || (eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM())) explodeMultiblock(); - if (outputEM != null) - for (cElementalInstanceStackMap output : outputEM) - if (output.hasStacks()) explodeMultiblock(); } catch (Exception e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } //region adder methods @Override public final boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) { return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) - return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OverflowElemental) { + return eMufflerHatches.add((GT_MetaTileEntity_Hatch_OverflowElemental) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) { return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) { return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + } return false; } public final boolean addClassicToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) { return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputBus) { return mOutputBusses.add((GT_MetaTileEntity_Hatch_OutputBus) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_EnergyMulti) { return eEnergyMulti.add((GT_MetaTileEntity_Hatch_EnergyMulti) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_DynamoMulti) { return eDynamoMulti.add((GT_MetaTileEntity_Hatch_DynamoMulti) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) { return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputData) { return eOutputData.add((GT_MetaTileEntity_Hatch_OutputData) aMetaTileEntity); + } return false; } public final boolean addElementalToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) { return eInputHatches.add((GT_MetaTileEntity_Hatch_InputElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) - return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OverflowElemental) { + return eMufflerHatches.add((GT_MetaTileEntity_Hatch_OverflowElemental) aMetaTileEntity); + } return false; } public final boolean addClassicMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); @@ -1346,37 +1763,49 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } public final boolean addElementalMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) { + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OverflowElemental) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); + return eMufflerHatches.add((GT_MetaTileEntity_Hatch_OverflowElemental) aMetaTileEntity); } return false; } @Override public final boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Muffler) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mMufflerHatches.add((GT_MetaTileEntity_Hatch_Muffler) aMetaTileEntity); } - if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_MufflerElemental) { + if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OverflowElemental) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); - return eMufflerHatches.add((GT_MetaTileEntity_Hatch_MufflerElemental) aMetaTileEntity); + return eMufflerHatches.add((GT_MetaTileEntity_Hatch_OverflowElemental) aMetaTileEntity); } return false; } @Override public final boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); @@ -1397,9 +1826,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public final boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); @@ -1418,9 +1851,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Deprecated @Override public final boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); @@ -1435,9 +1872,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Deprecated @Override public final boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Dynamo) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mDynamoHatches.add((GT_MetaTileEntity_Hatch_Dynamo) aMetaTileEntity); @@ -1451,9 +1892,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //New Method public final boolean addEnergyIOToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Energy) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mEnergyHatches.add((GT_MetaTileEntity_Hatch_Energy) aMetaTileEntity); @@ -1475,9 +1920,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //NEW METHOD public final boolean addElementalInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputElemental) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); //((GT_MetaTileEntity_Hatch_Elemental) aMetaTileEntity).mRecipeMap = getRecipeMap(); @@ -1488,9 +1937,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //NEW METHOD public final boolean addElementalOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_OutputElemental) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return eOutputHatches.add((GT_MetaTileEntity_Hatch_OutputElemental) aMetaTileEntity); @@ -1500,9 +1953,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //NEW METHOD public final boolean addClassicInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap(); @@ -1518,9 +1975,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //NEW METHOD public final boolean addClassicOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Output) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mOutputHatches.add((GT_MetaTileEntity_Hatch_Output) aMetaTileEntity); @@ -1538,7 +1999,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return false; } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Param) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return eParamHatches.add((GT_MetaTileEntity_Hatch_Param) aMetaTileEntity); @@ -1552,7 +2015,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return false; } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Uncertainty) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return eUncertainHatches.add((GT_MetaTileEntity_Hatch_Uncertainty) aMetaTileEntity); @@ -1562,9 +2027,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public final boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); @@ -1582,9 +2051,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //NEW METHOD public final boolean addClassicMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Maintenance) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return mMaintenanceHatches.add((GT_MetaTileEntity_Hatch_Maintenance) aMetaTileEntity); @@ -1594,9 +2067,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt //NEW METHOD public final boolean addDataConnectorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - if (aTileEntity == null) return false; + if (aTileEntity == null) { + return false; + } IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); - if (aMetaTileEntity == null) return false; + if (aMetaTileEntity == null) { + return false; + } if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputData) { ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); return eInputData.add((GT_MetaTileEntity_Hatch_InputData) aMetaTileEntity); @@ -1633,7 +2110,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt adderMethodMap.put("addDataConnectorToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addDataConnectorToMachineList", IGregTechTileEntity.class, int.class)); adderMethod = GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addThing", String.class, IGregTechTileEntity.class, int.class); } catch (NoSuchMethodException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } } @@ -1642,7 +2121,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt try { return (boolean) adderMethodMap.get(methodName).invoke(this, igt, casing); } catch (InvocationTargetException | IllegalAccessException e) { - if (DEBUG_MODE) e.printStackTrace(); + if (DEBUG_MODE) { + e.printStackTrace(); + } } return false; } @@ -1652,13 +2133,13 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt long storedEnergy = 0; long maxEnergy = 0; for (GT_MetaTileEntity_Hatch_Energy tHatch : mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } } for (GT_MetaTileEntity_Hatch_EnergyMulti tHatch : eEnergyMulti) { - if (isValidMetaTileEntity(tHatch)) { + if (GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity(tHatch)) { storedEnergy += tHatch.getBaseMetaTileEntity().getStoredEU(); maxEnergy += tHatch.getBaseMetaTileEntity().getEUCapacity(); } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java new file mode 100644 index 0000000000..41bc0e5a37 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/MultiblockControl.java @@ -0,0 +1,75 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +/** + * Created by danie_000 on 23.12.2017. + */ + +public class MultiblockControl<T>{ + private final int[] controls=new int[7]; + private final boolean shouldExplode; + private final T values; + + public MultiblockControl(T values, int EUt, int amperes, int requiredData, int effIncrease, int maxProgressTime){ + this.values = values; + controls[0]=EUt; + controls[1]=amperes; + controls[2]=requiredData; + controls[3]=effIncrease; + controls[4]=maxProgressTime; + shouldExplode=false; + } + + public MultiblockControl(T values, int EUt, int amperes, int requiredData, int effIncrease, int maxProgressTime, int pollutionToAdd, float excessMass){ + this.values = values; + controls[0]=EUt; + controls[1]=amperes; + controls[2]=requiredData; + controls[3]=effIncrease; + controls[4]=maxProgressTime; + controls[5]=pollutionToAdd; + controls[6]=Float.floatToIntBits(excessMass); + shouldExplode=false; + } + + public MultiblockControl(float excessMass){ + this.values = null; + controls[6]=Float.floatToIntBits(excessMass); + shouldExplode=true; + } + + public T getValue() { + return values; + } + + public int getEUT(){ + return controls[0]; + } + + public int getAmperage(){ + return controls[1]; + } + + public int getRequiredData(){ + return controls[2]; + } + + public int getEffIncrease(){ + return controls[3]; + } + + public int getMaxProgressTime(){ + return controls[4]; + } + + public int getPollutionToAdd(){ + return controls[5]; + } + + public float getExcessMass(){ + return Float.intBitsToFloat(controls[6]); + } + + public boolean shouldExplode() { + return shouldExplode; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/SoundLoop.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/SoundLoop.java new file mode 100644 index 0000000000..338af1626e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/SoundLoop.java @@ -0,0 +1,57 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.base; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.MovingSound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +@SideOnly(Side.CLIENT) +public class SoundLoop extends MovingSound{ + private final boolean whileActive; + private final boolean whileInactive; + private final int worldID; + private boolean fadeMe=false; + + public SoundLoop(ResourceLocation p_i45104_1_, IGregTechTileEntity base, boolean stopWhenActive,boolean stopWhenInactive) { + super(p_i45104_1_); + this.whileActive = stopWhenActive; + this.whileInactive = stopWhenInactive; + xPosF=base.getXCoord(); + yPosF=base.getYCoord(); + zPosF=base.getZCoord(); + worldID=base.getWorld().provider.dimensionId; + repeat=true; + volume=0f; + } + + @Override + public void update() { + if(donePlaying) { + return; + } + if(fadeMe) { + volume-=0.05f; + if(volume<0){ + volume=0; + }else if(volume==0){ + donePlaying=true; + } + }else if(volume<1) { + volume += 0.05f; + } + World world=Minecraft.getMinecraft().thePlayer.worldObj; + donePlaying=world.provider.dimensionId!=worldID || + !world.checkChunksExist((int)xPosF,(int)yPosF,(int)zPosF,(int)xPosF,(int)yPosF,(int)zPosF); + if(donePlaying) return; + TileEntity tile= world.getTileEntity((int)xPosF,(int)yPosF,(int)zPosF); + if(!(tile instanceof IGregTechTileEntity)) { + donePlaying=true; + return; + } + fadeMe|=((IGregTechTileEntity) tile).isActive()?whileActive:whileInactive; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java new file mode 100644 index 0000000000..fe40178e88 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Centrifuge.java @@ -0,0 +1,254 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.elementalMatter.definitions.complex.atom.dAtomDefinition; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; + +import java.util.Arrays; +import java.util.Comparator; + +import static com.github.technus.tectech.Util.V; +import static com.github.technus.tectech.auxiliary.TecTechConfig.DEBUG_MODE; + +/** + * Created by danie_000 on 24.12.2017. + */ +public class Behaviour_Centrifuge implements GT_MetaTileEntity_EM_machine.Behaviour { + private final float radius, maxRPM, maxRCF, maxForce, maxCapacity; + private final byte tier; + + private static final double[/*tier+5*/][/*outputHatches+2*/] MIXING_FACTORS =new double[][]{ + {.45,.85,.95,1,1,}, + {.4 ,.75,.9,.95,1,}, + {.35,.45,.75,.9,.95,}, + {.25,.3,.45,.75,.9,}, + {.2,.25,.3,.45,.75,}, + {.1,.15,.2,.3,.45,}, + {.05,.1,.15,.2,.25,}, + {.01,.05,.1,.15,.2,}, + }; + + //6 to 12 recommended + public Behaviour_Centrifuge(int desiredTier) { + tier = (byte) desiredTier; + radius = 0.5f - (12 - tier) / 64f; + maxRCF = (float) (Math.pow(Math.E, tier) * 12); + maxRPM = (float) Math.sqrt(maxRCF / (0.001118 * radius)); + float maxSafeMass = dAtomDefinition.getSomethingHeavy().getMass() * (1 << tier); + maxForce = maxSafeMass * maxRCF;// (eV/c^2 * m/s) / g + maxCapacity = maxSafeMass * 4f * radius;// eV/c^2 + } + + @Override + public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + boolean check=true; + + te.setParameterOut(1, 0, radius * 1000);//in mm + te.setParameterOut(1, 1, maxRPM); + te.setParameterOut(2, 0, maxForce * 9.80665);// (eV/c^2 * m/s) + te.setParameterOut(2, 1, maxCapacity);// eV/c^2 + + double RPM = parametersToCheckAndFix[0]; + if (RPM > maxRPM) { + te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + te.setParameterOut(0, 0, maxRPM);//rpm + te.setParameterOut(0, 1, maxRCF);//rcf + check=false; + } else if (RPM > maxRPM / 3f * 2f) { + te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + } else if (RPM > maxRPM / 3f) { + te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else if (RPM > 0) { + te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (RPM <= 0) { + te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + te.setParameterOut(0, 0, 0);//rpm + te.setParameterOut(0, 1, 0);//rcf + check=false; + } else { + te.setStatusOfParameterIn(0, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + te.setParameterOut(0, 0, 0);//rpm + te.setParameterOut(0, 1, 0);//rcf + check=false; + } + + if(check) { + te.setParameterOut(0, 0, RPM); + te.setParameterOut(0, 1, getRCF(RPM)); + } + + double fractionCount = parametersToCheckAndFix[1]; + if (fractionCount > 6) { + parametersToCheckAndFix[1] = 6; + te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + check=false; + } else if (fractionCount >= 2) { + te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else if (fractionCount < 2) { + parametersToCheckAndFix[1] = 2; + te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + check=false; + } else { + te.setStatusOfParameterIn(0, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + check=false; + } + + te.setParameterOut(3,0,(int) (Math.pow(parametersToCheckAndFix[0] / maxRPM, 3f) * V[tier]));//max eut + te.setParameterOut(3,1,(int) (20 * (fractionCount - 1)));//max time + + return check; + } + + @Override + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + cElementalInstanceStackMap input = inputs[0]; + if (input == null || input.isEmpty()) return null;//nothing in only valid input + + cElementalInstanceStack[] stacks = input.values(); + + double inputMass = 0; + for (cElementalInstanceStack stack : stacks) { + inputMass += Math.abs(stack.getMass()); + } + float excessMass = 0; + while (inputMass > maxCapacity) { + cElementalInstanceStack randomStack = stacks[TecTech.Rnd.nextInt(stacks.length)]; + int amountToRemove = TecTech.Rnd.nextInt((int) randomStack.getAmount()) + 1; + randomStack.amount -= amountToRemove;//mutates the parent InstanceStackMap + if (randomStack.amount <= 0) { + input.remove(randomStack.definition); + } + float mass = Math.abs(randomStack.getDefinition().getMass()) * amountToRemove; + excessMass += mass; + inputMass -= mass; + } + + inputMass = Math.abs(input.getMass()); + + double RCF = getRCF(checkedAndFixedParameters[0]); + if (inputMass * RCF > maxForce) return new MultiblockControl<>(excessMass);//AND THEN IT EXPLODES + + // how many output hatches to use + int fractionCount = (int) checkedAndFixedParameters[1]; + cElementalInstanceStackMap[] outputs = new cElementalInstanceStackMap[fractionCount]; + for (int i = 0; i < fractionCount; i++) { + outputs[i] = new cElementalInstanceStackMap(); + } + + //mixing factor... + double mixingFactor=Math.min(1d-(RCF/maxRCF)*(1d-MIXING_FACTORS[tier-5][fractionCount-2]),1); + if(DEBUG_MODE){ + TecTech.Logger.info("mixingFactor "+mixingFactor); + } + + int mEut = (int) (Math.pow(checkedAndFixedParameters[0] / maxRPM, 3f) * V[tier]); + mEut = Math.max(mEut, 512); + mEut = -mEut; + int mTicks = (int) (20 * (inputMass / maxCapacity) * (fractionCount - 1)); + mTicks=Math.max(mTicks,20); + + + //take all from hatch handler and put into new map - this takes from hatch to inner data storage + stacks = input.takeAllToNewMap().values();//cleanup stacks + if (stacks.length > 1) { + Arrays.sort(stacks, new Comparator<cElementalInstanceStack>() { + @Override + public int compare(cElementalInstanceStack o1, cElementalInstanceStack o2) { + float m1 = o1.definition.getMass(); + float m2 = o2.definition.getMass(); + if (m1 < m2) return -1; + if (m1 > m2) return 1; + return o1.compareTo(o2); + } + }); + + double absMassPerOutput = 0;//"volume" + for (cElementalInstanceStack stack : stacks) { + double tempMass=Math.abs(stack.getMass()); + if(tempMass!=0) { + long amount = stack.amount; + stack.amount *= mixingFactor; + addRandomly(stack, outputs, fractionCount); + stack.amount = amount - stack.amount; + absMassPerOutput += tempMass; + } + } + //if(DEBUG_MODE){ + // TecTech.Logger.info("absMass "+absMassPerOutput); + //} + absMassPerOutput /= fractionCount; + if(DEBUG_MODE){ + TecTech.Logger.info("absMassPerOutput "+absMassPerOutput); + } + + nextFraction: + for (int fraction = 0; fraction < fractionCount - 1; fraction++) { + double remaining = absMassPerOutput; + for (int stackNo = 0; stackNo < stacks.length; stackNo++) { + if (stacks[stackNo] != null) { + double stackMass = Math.abs(stacks[stackNo].getMass()); + long amount = (long) (remaining/Math.abs(stacks[stackNo].definition.getMass())); + //if(DEBUG_MODE){ + // TecTech.Logger.info("stackMass "+stackMass); + // TecTech.Logger.info("defMass "+stacks[stackNo].definition.getMass()); + // TecTech.Logger.info("remaining "+remaining); + // TecTech.Logger.info("amountToMoveAvailable "+amount+"/"+stacks[stackNo].amount); + //} + if (stackMass == 0) { + addRandomly(stacks[stackNo], outputs, fractionCount); + stacks[stackNo] = null; + } else if (amount >= stacks[stackNo].amount) { + remaining -= stackMass; + outputs[fraction].putUnify(stacks[stackNo]); + stacks[stackNo] = null; + } else if (amount > 0) { + remaining -= amount * stacks[stackNo].definition.getMass(); + cElementalInstanceStack clone = stacks[stackNo].clone(); + clone.amount = amount; + outputs[fraction].putUnify(clone); + stacks[stackNo].amount-=amount; + //if(DEBUG_MODE){ + // TecTech.Logger.info("remainingAfter "+remaining); + // TecTech.Logger.info("amountCloneAfter "+clone.amount+"/"+stacks[stackNo].amount); + //} + } else { + continue nextFraction; + } + } + } + } + //add remaining + for (cElementalInstanceStack stack : stacks) { + if (stack != null) { + outputs[fractionCount - 1].putUnify(stack); + } + } + } else { + addRandomly(stacks[0], outputs, fractionCount); + } + return new MultiblockControl<>(outputs, mEut, 1, 0, 10000, mTicks, 0, excessMass); + } + + private double getRCF(double RPM) { + return RPM * RPM * radius * 0.001118; + } + + private void addRandomly(cElementalInstanceStack me, cElementalInstanceStackMap[] toThis, int fractionCount) { + long amountPerFraction = me.amount / fractionCount; + cElementalInstanceStack[] stacks = new cElementalInstanceStack[fractionCount]; + for (int i = 0; i < fractionCount; i++) { + stacks[i] = me.clone(); + stacks[i].amount = amountPerFraction; + toThis[i].putReplace(stacks[i]); + } + int remainingAmount = (int) (me.amount % fractionCount); + while (remainingAmount > 0) { + int amountToAdd = TecTech.Rnd.nextInt(remainingAmount) + 1; + stacks[TecTech.Rnd.nextInt(fractionCount)].amount += amountToAdd; + remainingAmount -= amountToAdd; + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java new file mode 100644 index 0000000000..236b79c85b --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Electrolyzer.java @@ -0,0 +1,24 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; + +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; + +/** + * Created by danie_000 on 24.12.2017. + */ +public class Behaviour_Electrolyzer implements GT_MetaTileEntity_EM_machine.Behaviour { + final int tier; + public Behaviour_Electrolyzer(int tier){ + this.tier=tier; + } + + @Override + public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + return false; + } + + @Override + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + return null; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java new file mode 100644 index 0000000000..1d28db92c8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_ElectromagneticSeparator.java @@ -0,0 +1,219 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.elementalMatter.core.stacks.cElementalInstanceStack; +import com.github.technus.tectech.elementalMatter.definitions.complex.atom.dAtomDefinition; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; + +import static com.github.technus.tectech.Util.V; + +/** + * Created by danie_000 on 24.12.2017. + */ +public class Behaviour_ElectromagneticSeparator implements GT_MetaTileEntity_EM_machine.Behaviour { + private final byte tier; + private final int ticks; + private final byte precisionFull; + private final byte precisionMinimal; + private final float maxCapacity; + private final long maxCharge; + private final int offsetMax; + + public Behaviour_ElectromagneticSeparator(int desiredTier){ + tier=(byte) desiredTier; + ticks =Math.max(20,(1<<(12-desiredTier))*20); + maxCapacity= dAtomDefinition.getSomethingHeavy().getMass()*(2<<tier); + maxCharge=144*(1<<(tier-5)); + switch (tier){ + case 12: + precisionFull=1; + precisionMinimal =1; + break; + case 11: + precisionFull=2; + precisionMinimal =1; + break; + case 10: + precisionFull=3; + precisionMinimal =1; + break; + case 9: + precisionFull=3; + precisionMinimal =2; + break; + case 8: + precisionFull=3; + precisionMinimal =3; + break; + case 7: + precisionFull=6; + precisionMinimal =3; + break; + case 6: + precisionFull=12; + precisionMinimal =3; + break; + case 5: + precisionFull=24; + precisionMinimal =6; + break; + default: precisionFull= precisionMinimal =Byte.MAX_VALUE; + } + offsetMax=1<<((tier-8)<<1); + } + + @Override + public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + boolean check=true; + + te.setParameterOut(0,0,precisionFull); + te.setParameterOut(0,1,precisionMinimal); + te.setParameterOut(1,0,offsetMax); + te.setParameterOut(2,0,maxCharge); + te.setParameterOut(2,1,maxCapacity); + te.setParameterOut(3,0,V[tier]); + te.setParameterOut(3,1,ticks); + + double full=parametersToCheckAndFix[0]; + if(Double.isInfinite(full) && full>0) { + te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + check=false; + }else if(full>precisionFull){ + te.setStatusOfParameterIn(0,0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + }else if(full==precisionFull){ + te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + }else if(full<precisionFull){ + te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + check=false; + }else { + te.setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + check=false; + } + + double minimal=parametersToCheckAndFix[1]; + if(Double.isInfinite(minimal) && minimal>0) { + te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + check=false; + }else if(minimal>precisionMinimal){ + if(minimal>full){ + te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + check=false; + }else { + te.setStatusOfParameterIn(0,1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + } + }else if(minimal==precisionMinimal){ + if(minimal>full){ + te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + check=false; + }else { + te.setStatusOfParameterIn(0,1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } + }else if(minimal<precisionMinimal){ + te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + check=false; + }else { + te.setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + check=false; + } + + double offset=parametersToCheckAndFix[2]; + if(offset>offsetMax){ + te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + check=false; + }else if(offset>0){ + te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_HIGH); + }else if(offset==0){ + te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + }else if(offset>=-offsetMax){ + te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + }else if(offset<-offsetMax){ + te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + check=false; + }else { + te.setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + check=false; + } + + return check; + } + + @Override + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + cElementalInstanceStackMap input = inputs[0]; + if (input == null || input.isEmpty()) return null;//nothing in only valid input + + cElementalInstanceStack[] stacks = input.values(); + + double inputMass = 0; + for (cElementalInstanceStack stack : stacks) { + inputMass += Math.abs(stack.getMass()); + } + float excessMass = 0; + while (inputMass > maxCapacity) { + cElementalInstanceStack randomStack = stacks[TecTech.Rnd.nextInt(stacks.length)]; + int amountToRemove = TecTech.Rnd.nextInt((int) randomStack.getAmount()) + 1; + randomStack.amount -= amountToRemove;//mutates the parent InstanceStackMap + if (randomStack.amount <= 0) { + input.remove(randomStack.definition); + } + float mass = Math.abs(randomStack.getDefinition().getMass()) * amountToRemove; + excessMass += mass; + inputMass -= mass; + } + + long totalCharge=Math.abs(input.getCharge()); + if (totalCharge>maxCharge) return new MultiblockControl<>(excessMass);//AND THEN IT EXPLODES + + int mEut=(int)(((double)totalCharge/(double) maxCharge)*V[tier]); + mEut = Math.max(mEut, 512); + int mTicks=(int)(ticks*(inputMass/maxCapacity)); + mTicks=Math.max(mTicks,20); + + cElementalInstanceStackMap[] outputs = new cElementalInstanceStackMap[3]; + for (int i = 0; i < 3; i++) { + outputs[i] = new cElementalInstanceStackMap(); + } + + double offsetIn=checkedAndFixedParameters[2]; + double precisionFullIn=checkedAndFixedParameters[0]; + double precisionMinimalIn=checkedAndFixedParameters[1]; + double levelsCountPlus1=precisionFullIn-precisionMinimalIn+1; + + //take all from hatch handler and put into new map - this takes from hatch to inner data storage + stacks = input.takeAllToNewMap().values();//cleanup stacks + for(cElementalInstanceStack stack:stacks){ + double charge=stack.definition.getCharge()-offsetIn; + if(charge<precisionMinimalIn && charge>-precisionMinimalIn){ + outputs[1].putReplace(stack); + }else if(charge>=precisionFullIn){ + outputs[2].putReplace(stack); + }else if(charge<=-precisionFullIn){ + outputs[0].putReplace(stack); + }else{ + long amount=(long)(stack.amount*((Math.abs(charge)-precisionMinimalIn+1)/levelsCountPlus1));//todo check + if(amount>=stack.amount){ + if(charge>0){ + outputs[2].putReplace(stack); + }else { + outputs[0].putReplace(stack); + } + }else { + cElementalInstanceStack clone=stack.clone(); + clone.amount-=amount; + outputs[1].putReplace(clone); + + stack.amount=amount; + if(charge>0){ + outputs[2].putReplace(stack); + }else { + outputs[0].putReplace(stack); + } + } + } + } + + return new MultiblockControl<>(outputs, mEut, 1+((int)Math.abs(offsetIn))/3, 0, 10000, mTicks, 0, excessMass); + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java new file mode 100644 index 0000000000..1cca03ec17 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_PrecisionLaser.java @@ -0,0 +1,24 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; + +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; + +/** + * Created by danie_000 on 24.12.2017. + */ +public class Behaviour_PrecisionLaser implements GT_MetaTileEntity_EM_machine.Behaviour { + final int tier; + public Behaviour_PrecisionLaser(int tier){ + this.tier=tier; + } + + @Override + public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + return false; + } + + @Override + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + return null; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java new file mode 100644 index 0000000000..09249a3d95 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Recycler.java @@ -0,0 +1,24 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; + +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; + +/** + * Created by danie_000 on 24.12.2017. + */ +public class Behaviour_Recycler implements GT_MetaTileEntity_EM_machine.Behaviour { + final int tier; + public Behaviour_Recycler(int tier){ + this.tier=tier; + } + + @Override + public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + return false; + } + + @Override + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + return null; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java new file mode 100644 index 0000000000..020a71da5c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/Behaviour_Scanner.java @@ -0,0 +1,24 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; + +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; + +/** + * Created by danie_000 on 24.12.2017. + */ +public class Behaviour_Scanner implements GT_MetaTileEntity_EM_machine.Behaviour { + final int tier; + public Behaviour_Scanner(int tier){ + this.tier=tier; + } + + @Override + public boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix) { + return false; + } + + @Override + public MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters) { + return null; + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java new file mode 100644 index 0000000000..032d4e48a8 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java @@ -0,0 +1,355 @@ +package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; + +import com.github.technus.tectech.CommonValues; +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.Util; +import com.github.technus.tectech.elementalMatter.core.cElementalInstanceStackMap; +import com.github.technus.tectech.thing.block.QuantumGlassBlock; +import com.github.technus.tectech.thing.block.QuantumStuffBlock; +import com.github.technus.tectech.thing.metaTileEntity.IConstructable; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; +import com.github.technus.tectech.thing.metaTileEntity.multi.base.MultiblockControl; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.BitSet; +import java.util.HashMap; + +import static com.github.technus.tectech.Util.StructureBuilder; +import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; +import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { + + public static final String machine = "EM Machinery"; + + //region structure + private static final String[][] shape = new String[][]{ + {"B0", "A ", "0 - 0", "A ", "B0",}, + {"A000", "00000", "00.00", "00000", "A000",}, + {"A121", "1---1", "2---2", "1---1", "A121",}, + {"A131", "1---1", "3-A-3", "1---1", "A131",}, + {"A121", "1---1", "2---2", "1---1", "A121",}, + {"A000", "00000", "00-00", "00000", "A000",}, + {"B0", "A!!!", "0!!!0", "A!!!", "B0",},}; + private static final Block[] blockType = new Block[]{sBlockCasingsTT, QuantumGlassBlock.INSTANCE, sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{4, 0, 5, 6}; + private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private static final short[] casingTextures = new short[]{textureOffset, textureOffset + 4}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{0, 4}; + private static final String[] description = new String[]{ + EnumChatFormatting.AQUA + "Hint Details:", + "1 - Classic Hatches or High Power Casing", + "2 - Elemental Hatches or Molecular Casing",}; + //endregion + + public GT_MetaTileEntity_EM_machine(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public GT_MetaTileEntity_EM_machine(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GT_MetaTileEntity_EM_machine(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 2, 1); + } + + @Override + public void construct(int stackSize, boolean hintsOnly) { + StructureBuilder(shape, blockType, blockMeta, 2, 2, 1, getBaseMetaTileEntity(), hintsOnly); + } + + @Override + public String[] getStructureDescription(int stackSize) { + return description; + } + + @Override + public String[] getDescription() { + return new String[]{CommonValues.TEC_MARK_EM, "Processing quantum matter since...", EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "the time u started using it."}; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if(aBaseMetaTileEntity.isServerSide()) { + quantumStuff(aBaseMetaTileEntity.isActive()); + } + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if(aBaseMetaTileEntity.isActive() && (aTick & 0x2)==0 && aBaseMetaTileEntity.isClientSide()){ + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX*2+aBaseMetaTileEntity.getXCoord(); + int yDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetY*2+aBaseMetaTileEntity.getYCoord(); + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ*2+aBaseMetaTileEntity.getZCoord(); + aBaseMetaTileEntity.getWorld().markBlockRangeForRenderUpdate(xDir,yDir,zDir,xDir,yDir,zDir); + } + } + + @Override + public void onRemoval() { + quantumStuff(false); + super.onRemoval(); + } + + @Override + public boolean checkRecipe_EM(ItemStack itemStack) { + Behaviour currentBehaviour = GT_MetaTileEntity_EM_machine.map.get(new Util.TT_ItemStack(itemStack)); + //TecTech.Logger.info("Looking for "+new Util.TT_ItemStack(itemStack).toString()); + if (currentBehaviour == null) { + setStatusOfParameterIn(0,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + setStatusOfParameterIn(0,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + setStatusOfParameterIn(1,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + setStatusOfParameterIn(1,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + setStatusOfParameterIn(2,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + setStatusOfParameterIn(2,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + setStatusOfParameterIn(3,0,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + setStatusOfParameterIn(3,1,GT_MetaTileEntity_MultiblockBase_EM.STATUS_UNUSED); + return false; + } + //mux input + double[] parameters = new double[]{getParameterIn(0, 0), getParameterIn(0, 1), getParameterIn(1, 0), getParameterIn(1, 1), getParameterIn(2, 0), getParameterIn(2, 1), getParameterIn(3, 0), getParameterIn(3, 1)}; + if (!currentBehaviour.setAndCheckParametersOutAndStatuses(this, parameters)) { + return false; + } + + cElementalInstanceStackMap[] handles = new cElementalInstanceStackMap[6]; + int pointer = getParameterInInt(4, 0) - 1; + if (pointer >= 0 && pointer < eInputHatches.size()) { + handles[0] = eInputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(4, 1) - 1; + if (pointer >= 0 && pointer < eInputHatches.size()) { + handles[1] = eInputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(5, 0) - 1; + if (pointer >= 0 && pointer < eInputHatches.size()) { + handles[2] = eInputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(5, 1) - 1; + if (pointer >= 0 && pointer < eInputHatches.size()) { + handles[3] = eInputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(6, 0) - 1; + if (pointer >= 0 && pointer < eInputHatches.size()) { + handles[4] = eInputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(6, 1) - 1; + if (pointer >= 0 && pointer < eInputHatches.size()) { + handles[5] = eInputHatches.get(pointer).getContainerHandler(); + } + + for (int i = 1; i < 6; i++) { + if (handles[i] != null) { + for (int j = 0; j < i; j++) { + if (handles[i] == handles[j]) { + return false; + } + } + } + } + + MultiblockControl<cElementalInstanceStackMap[]> control = currentBehaviour.process(handles, parameters); + if (control == null) { + return false; + } + cleanMassEM_EM(control.getExcessMass()); + if (control.shouldExplode()) { + explodeMultiblock(); + return false; + } + //update other parameters + outputEM = control.getValue(); + mEUt = control.getEUT(); + eAmpereFlow = control.getAmperage(); + mMaxProgresstime = control.getMaxProgressTime(); + eRequiredData = control.getRequiredData(); + mEfficiencyIncrease = control.getEffIncrease(); + boolean polluted=polluteEnvironment(control.getPollutionToAdd()); + quantumStuff(polluted); + return polluted; + } + + @Override + protected void afterRecipeCheckFailed() { + quantumStuff(false); + super.afterRecipeCheckFailed(); + } + + @Override + public void outputAfterRecipe_EM() { + if (outputEM == null) return; + cElementalInstanceStackMap[] handles = new cElementalInstanceStackMap[6]; + int pointer = getParameterInInt(7, 0) - 1; + if (pointer >= 0 && pointer < eOutputHatches.size()) { + handles[0] = eOutputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(7, 1) - 1; + if (pointer >= 0 && pointer < eOutputHatches.size()) { + handles[1] = eOutputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(8, 0) - 1; + if (pointer >= 0 && pointer < eOutputHatches.size()) { + handles[2] = eOutputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(8, 1) - 1; + if (pointer >= 0 && pointer < eOutputHatches.size()) { + handles[3] = eOutputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(9, 0) - 1; + if (pointer >= 0 && pointer < eOutputHatches.size()) { + handles[4] = eOutputHatches.get(pointer).getContainerHandler(); + } + pointer = getParameterInInt(9, 1) - 1; + if (pointer >= 0 && pointer < eOutputHatches.size()) { + handles[5] = eOutputHatches.get(pointer).getContainerHandler(); + } + //output + for (int i = 0; i < 6 && i < outputEM.length; i++) { + if (handles[i] != null && outputEM[i] != null && outputEM[i].hasStacks()) { + handles[i].putUnifyAll(outputEM[i]); + outputEM[i] = null; + } + } + quantumStuff(false); + //all other are handled by base multi block code - cleaning is automatic + } + + @Override + public void stopMachine() { + quantumStuff(false); + super.stopMachine(); + } + + @Override + protected void parametersLoadDefault_EM() {//default routing table + setParameterPairIn_ClearOut(4, false, 1, 2);//I + setParameterPairIn_ClearOut(5, false, 3, 4);//I + setParameterPairIn_ClearOut(6, false, 5, 6);//I + + setParameterPairIn_ClearOut(7, false, 1, 2);//O + setParameterPairIn_ClearOut(8, false, 3, 4);//O + setParameterPairIn_ClearOut(9, false, 5, 6);//O + } + + @Override + public void parametersOutAndStatusesWrite_EM(boolean machineBusy) { + int pointer; + { + BitSet checkArray = new BitSet(); + for (int i = 4; i <= 6; i++) { + pointer = getParameterInInt(i, 0); + if (Double.isNaN(pointer)) { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else if (pointer <= 0) { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + }//else if(pointer==0) + // setStatusOfParameterIn(i,0,STATUS_LOW); + else if (pointer <= eInputHatches.size()) { + if (checkArray.get(pointer)) { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + checkArray.set(pointer); + } + } else { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } + pointer = getParameterInInt(i, 1); + if (Double.isNaN(pointer)) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else if (pointer < 0) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (pointer == 0) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (pointer <= eInputHatches.size()) { + if (checkArray.get(pointer)) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + checkArray.set(pointer); + } + } else { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } + } + } + { + for (int i = 7; i <= 9; i++) { + pointer = getParameterInInt(i, 0); + if (Double.isNaN(pointer)) { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else if (pointer < 0) { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (pointer == 0) { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (pointer <= eOutputHatches.size()) { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else { + setStatusOfParameterIn(i, 0, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } + pointer = getParameterInInt(i, 1); + if (Double.isNaN(pointer)) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_WRONG); + } else if (pointer < 0) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_LOW); + } else if (pointer == 0) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_LOW); + } else if (pointer <= eOutputHatches.size()) { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_OK); + } else { + setStatusOfParameterIn(i, 1, GT_MetaTileEntity_MultiblockBase_EM.STATUS_TOO_HIGH); + } + } + } + } + + private static final HashMap<Util.TT_ItemStack, Behaviour> map = new HashMap<>(); + + public static void registerBehaviour(Behaviour behaviour, ItemStack is) { + map.put(new Util.TT_ItemStack(is), behaviour); + TecTech.Logger.info("Registered EM machine behaviour "+behaviour.getClass().getSimpleName()+' '+new Util.TT_ItemStack(is).toString()); + } + + public interface Behaviour { + boolean setAndCheckParametersOutAndStatuses(GT_MetaTileEntity_EM_machine te, double[] parametersToCheckAndFix); + + MultiblockControl<cElementalInstanceStackMap[]> process(cElementalInstanceStackMap[] inputs, double[] checkedAndFixedParameters); + } + + private void quantumStuff(boolean shouldExist){ + IGregTechTileEntity base=getBaseMetaTileEntity(); + if(base!=null && base.getWorld()!=null) { + int xDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetX * 2+base.getXCoord(); + int yDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetY * 2+base.getYCoord(); + int zDir = ForgeDirection.getOrientation(base.getBackFacing()).offsetZ * 2+base.getZCoord(); + Block block = base.getWorld().getBlock(xDir, yDir, zDir); + if (shouldExist) { + if(block != null && block.getMaterial()== Material.air) { + base.getWorld().setBlock(xDir, yDir, zDir, QuantumStuffBlock.INSTANCE, 0, 2); + } + } else { + if (block instanceof QuantumStuffBlock) { + base.getWorld().setBlock(xDir, yDir, zDir, Blocks.air, 0, 2); + } + } + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/other todo b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/other todo index b255c2013c..7059fdf6fd 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/other todo +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/other todo @@ -34,3 +34,5 @@ iterative halflife formula: =prev qty* 2^(-t diff / t half) + +actual ion cannons diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java index f3f07a2149..ded80ee73e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_Data.java @@ -111,30 +111,34 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements iConn if ((aTick & 31) == 31) { mConnections = 0; connectionCount = 0; - if (aBaseMetaTileEntity.getColorization() < 0) return; - for (byte i = 0, j; i < 6; i++) { - j = GT_Utility.getOppositeSide(i); - //if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { - TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); + if (aBaseMetaTileEntity.getColorization() < 0) { + return; + } + for (byte b0 = 0, b1; b0 < 6; b0++) { + b1 = GT_Utility.getOppositeSide(b0); + //if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(b0).alwaysLookConnected(b0, aBaseMetaTileEntity.getCoverIDAtSide(b0), aBaseMetaTileEntity.getCoverDataAtSide(b0), aBaseMetaTileEntity)) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(b0); if (tTileEntity instanceof IColoredTileEntity) { //if (aBaseMetaTileEntity.getColorization() >= 0) { byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); - if (tColor != aBaseMetaTileEntity.getColorization()) continue; + if (tColor != aBaseMetaTileEntity.getColorization()) { + continue; + } //} } - if (tTileEntity instanceof iConnectsToDataPipe && (((iConnectsToDataPipe) tTileEntity).canConnect(j))) { - mConnections |= (1 << i); + if (tTileEntity instanceof iConnectsToDataPipe && ((iConnectsToDataPipe) tTileEntity).canConnect(b1)) { + mConnections |= 1 << b0; connectionCount++; } else if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof iConnectsToDataPipe) { - if (//((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || - ((iConnectsToDataPipe) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).canConnect(j)) { - mConnections |= (1 << i); + if (//((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(b1).alwaysLookConnected(b1, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(b1), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(b1), ((IGregTechTileEntity) tTileEntity)) || + ((iConnectsToDataPipe) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).canConnect(b1)) { + mConnections |= 1 << b0; connectionCount++; } } //} //else { - // mConnections |= (1 << i); + // mConnections |= (1 << b0); // if (mOld != mConnections) { // connectionCount++; // mOld = mConnections; @@ -155,18 +159,26 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements iConn @Override public iConnectsToDataPipe getNext(iConnectsToDataPipe source) { - if (connectionCount != 2) return null; - for (byte s = 0; s < 6; s++) { - if ((mConnections & (1 << s)) == 0) continue;//if not connected continue - final IGregTechTileEntity next = getBaseMetaTileEntity().getIGregTechTileEntityAtSide(s); - if (next == null) continue; - final IMetaTileEntity meta = next.getMetaTileEntity(); + if (connectionCount != 2) { + return null; + } + for (byte b = 0; b < 6; b++) { + if ((mConnections & 1 << b) == 0) { + continue;//if not connected continue + } + IGregTechTileEntity next = getBaseMetaTileEntity().getIGregTechTileEntityAtSide(b); + if (next == null) { + continue; + } + IMetaTileEntity meta = next.getMetaTileEntity(); if (meta instanceof iConnectsToDataPipe && meta != source) { - if (meta instanceof GT_MetaTileEntity_Hatch_InputData) + if (meta instanceof GT_MetaTileEntity_Hatch_InputData) { return (iConnectsToDataPipe) meta; + } if (meta instanceof GT_MetaTileEntity_Pipe_Data && - ((GT_MetaTileEntity_Pipe_Data) meta).connectionCount == 2) + ((GT_MetaTileEntity_Pipe_Data) meta).connectionCount == 2) { return (iConnectsToDataPipe) meta; + } } } return null; @@ -190,19 +202,33 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements iConn if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;} byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; - if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f; - if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f; - if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f; - if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f; - if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f; - if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f; + if((tConn & 1 << ForgeDirection.DOWN.ordinal()) != 0) { + tSide0 = 0f; + } + if((tConn & 1 << ForgeDirection.UP.ordinal()) != 0) { + tSide1 = 1f; + } + if((tConn & 1 << ForgeDirection.NORTH.ordinal()) != 0) { + tSide2 = 0f; + } + if((tConn & 1 << ForgeDirection.SOUTH.ordinal()) != 0) { + tSide3 = 1f; + } + if((tConn & 1 << ForgeDirection.WEST.ordinal()) != 0) { + tSide4 = 0f; + } + if((tConn & 1 << ForgeDirection.EAST.ordinal()) != 0) { + tSide5 = 1f; + } return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); } @Override public float getThickNess() { - if(GT_Mod.instance.isClientSide() && GT_Client.hideValue==1) return 0.0625F; + if(GT_Mod.instance.isClientSide() && GT_Client.hideValue==1) { + return 0.0625F; + } return 0.375f; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java index f8b5e5476d..3d1b5f6fb9 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/pipe/GT_MetaTileEntity_Pipe_EM.java @@ -110,30 +110,34 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements iConnec if ((aTick & 31) == 31) { mConnections = 0; connectionCount = 0; - if (aBaseMetaTileEntity.getColorization() < 0) return; - for (byte i = 0, j; i < 6; i++) { - j = GT_Utility.getOppositeSide(i); - //if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(i).alwaysLookConnected(i, aBaseMetaTileEntity.getCoverIDAtSide(i), aBaseMetaTileEntity.getCoverDataAtSide(i), aBaseMetaTileEntity)) { - TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); + if (aBaseMetaTileEntity.getColorization() < 0) { + return; + } + for (byte b0 = 0, b1; b0 < 6; b0++) { + b1 = GT_Utility.getOppositeSide(b0); + //if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(b0).alwaysLookConnected(b0, aBaseMetaTileEntity.getCoverIDAtSide(b0), aBaseMetaTileEntity.getCoverDataAtSide(b0), aBaseMetaTileEntity)) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(b0); if (tTileEntity instanceof IColoredTileEntity) { //if (aBaseMetaTileEntity.getColorization() >= 0) { byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); - if (tColor != aBaseMetaTileEntity.getColorization()) continue; + if (tColor != aBaseMetaTileEntity.getColorization()) { + continue; + } //} } - if (tTileEntity instanceof iConnectsToEMpipe && (((iConnectsToEMpipe) tTileEntity).canConnect(j))) { - mConnections |= (1 << i); + if (tTileEntity instanceof iConnectsToEMpipe && ((iConnectsToEMpipe) tTileEntity).canConnect(b1)) { + mConnections |= 1 << b0; connectionCount++; } else if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof iConnectsToEMpipe) { - if (//((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(j).alwaysLookConnected(j, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(j), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(j), ((IGregTechTileEntity) tTileEntity)) || - ((iConnectsToEMpipe) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).canConnect(j)) { - mConnections |= (1 << i); + if (//((IGregTechTileEntity) tTileEntity).getCoverBehaviorAtSide(b1).alwaysLookConnected(b1, ((IGregTechTileEntity) tTileEntity).getCoverIDAtSide(b1), ((IGregTechTileEntity) tTileEntity).getCoverDataAtSide(b1), ((IGregTechTileEntity) tTileEntity)) || + ((iConnectsToEMpipe) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()).canConnect(b1)) { + mConnections |= 1 << b0; connectionCount++; } } //} //else { - // mConnections |= (1 << i); + // mConnections |= (1 << b0); // if (mOld != mConnections) { // connectionCount++; // mOld = mConnections; @@ -170,19 +174,33 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements iConnec if(getBaseMetaTileEntity().getCoverIDAtSide((byte) 5) != 0){tSide0=tSide2=0;tSide1=tSide3=tSide5=1;} byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; - if((tConn & (1 << ForgeDirection.DOWN.ordinal()) ) != 0) tSide0 = 0f; - if((tConn & (1 << ForgeDirection.UP.ordinal()) ) != 0) tSide1 = 1f; - if((tConn & (1 << ForgeDirection.NORTH.ordinal())) != 0) tSide2 = 0f; - if((tConn & (1 << ForgeDirection.SOUTH.ordinal())) != 0) tSide3 = 1f; - if((tConn & (1 << ForgeDirection.WEST.ordinal()) ) != 0) tSide4 = 0f; - if((tConn & (1 << ForgeDirection.EAST.ordinal()) ) != 0) tSide5 = 1f; + if((tConn & 1 << ForgeDirection.DOWN.ordinal()) != 0) { + tSide0 = 0f; + } + if((tConn & 1 << ForgeDirection.UP.ordinal()) != 0) { + tSide1 = 1f; + } + if((tConn & 1 << ForgeDirection.NORTH.ordinal()) != 0) { + tSide2 = 0f; + } + if((tConn & 1 << ForgeDirection.SOUTH.ordinal()) != 0) { + tSide3 = 1f; + } + if((tConn & 1 << ForgeDirection.WEST.ordinal()) != 0) { + tSide4 = 0f; + } + if((tConn & 1 << ForgeDirection.EAST.ordinal()) != 0) { + tSide5 = 1f; + } return AxisAlignedBB.getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); } @Override public float getThickNess() { - if(GT_Mod.instance.isClientSide() && GT_Client.hideValue==1) return 0.0625F; + if(GT_Mod.instance.isClientSide() && GT_Client.hideValue==1) { + return 0.0625F; + } return 0.5f; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java index cfb0794142..dd50ba289d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugPowerGenerator.java @@ -50,7 +50,7 @@ public class GT_MetaTileEntity_DebugPowerGenerator extends GT_MetaTileEntity_Tie @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], (aSide != aFacing) ? (aActive? GT_MetaTileEntity_Hatch_DynamoMulti.overlay[mTier]: GT_MetaTileEntity_Hatch_EnergyMulti.overlay[mTier]) : GENNY}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], aSide != aFacing ? aActive? GT_MetaTileEntity_Hatch_DynamoMulti.overlay[mTier]: GT_MetaTileEntity_Hatch_EnergyMulti.overlay[mTier] : GENNY}; } @Override @@ -111,7 +111,9 @@ public class GT_MetaTileEntity_DebugPowerGenerator extends GT_MetaTileEntity_Tie @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } aBaseMetaTileEntity.openGUI(aPlayer); return true; } @@ -129,8 +131,7 @@ public class GT_MetaTileEntity_DebugPowerGenerator extends GT_MetaTileEntity_Tie @Override public String[] getDescription() { return new String[]{ - CommonValues.TEC_MARK_GENERAL, - this.mDescription, + CommonValues.TEC_MARK_GENERAL, mDescription, EnumChatFormatting.BLUE + "Infinite Producer/Consumer", EnumChatFormatting.BLUE + "Since i wanted one..." }; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java index b78ea6e572..653fcd6a3e 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/GT_MetaTileEntity_DebugStructureWriter.java @@ -26,7 +26,7 @@ import static com.github.technus.tectech.Util.StructureWriter; */ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_TieredMachineBlock { private static GT_RenderedTexture MARK; - public short numbers[] = new short[6]; + public short[] numbers = new short[6]; public boolean size = false; public String[] result = new String[]{"Undefined"}; @@ -52,7 +52,7 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { - return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], (aSide != aFacing) ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : MARK}; + return new ITexture[]{Textures.BlockIcons.MACHINE_CASINGS[mTier][aColorIndex + 1], aSide != aFacing ? new GT_RenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : MARK}; } @Override @@ -102,23 +102,27 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isAllowedToWork()) { - result = StructureWriter(this.getBaseMetaTileEntity(), numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], false); - for (String s : result) + result = StructureWriter(getBaseMetaTileEntity(), numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], false); + for (String s : result) { TecTech.Logger.info(s); + } aBaseMetaTileEntity.disableWorking(); } } @Override public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - result = StructureWriter(this.getBaseMetaTileEntity(), numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], true); - for (String s : result) + result = StructureWriter(getBaseMetaTileEntity(), numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], true); + for (String s : result) { TecTech.Logger.info(s); + } } @Override public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { - if (aBaseMetaTileEntity.isClientSide()) return true; + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } aBaseMetaTileEntity.openGUI(aPlayer); //if (TecTechConfig.DEBUG_MODE && aPlayer.getHeldItem() != null) // TecTech.Logger.info("UnlocalizedName: " + getUniqueIdentifier(aPlayer.getHeldItem())); @@ -143,8 +147,7 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti @Override public String[] getDescription() { return new String[]{ - CommonValues.TEC_MARK_GENERAL, - this.mDescription, + CommonValues.TEC_MARK_GENERAL, mDescription, EnumChatFormatting.BLUE + "Prints Multiblock NonTE structure check code", EnumChatFormatting.BLUE + "ABC axises aligned to machine front" }; diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPowerGenerator.java index f799a7b56f..9d7c5293b3 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPowerGenerator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugPowerGenerator.java @@ -12,8 +12,6 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.Iterator; - public class GT_Container_DebugPowerGenerator extends GT_ContainerMetaTile_Machine { public int EUT=0,AMP=0; @@ -24,25 +22,25 @@ public class GT_Container_DebugPowerGenerator @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 59, false, false, 1)); } @Override @@ -50,57 +48,57 @@ public class GT_Container_DebugPowerGenerator if (aSlotIndex < 0) { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { GT_MetaTileEntity_DebugPowerGenerator dpg = (GT_MetaTileEntity_DebugPowerGenerator) mTileEntity.getMetaTileEntity(); switch (aSlotIndex) { case 0: - dpg.EUT -= (aShifthold == 1 ? 512 : 64); + dpg.EUT -= aShifthold == 1 ? 512 : 64; break; case 1: - dpg.EUT /= (aShifthold == 1 ? 512 : 64); + dpg.EUT /= aShifthold == 1 ? 512 : 64; break; case 2: - dpg.AMP -= (aShifthold == 1 ? 512 : 64); + dpg.AMP -= aShifthold == 1 ? 512 : 64; break; case 3: - dpg.AMP /= (aShifthold == 1 ? 512 : 64); + dpg.AMP /= aShifthold == 1 ? 512 : 64; break; case 4: - dpg.EUT -= (aShifthold == 1 ? 16 : 1); + dpg.EUT -= aShifthold == 1 ? 16 : 1; break; case 5: - dpg.EUT /= (aShifthold == 1 ? 16 : 2); + dpg.EUT /= aShifthold == 1 ? 16 : 2; break; case 6: - dpg.AMP -= (aShifthold == 1 ? 16 : 1); + dpg.AMP -= aShifthold == 1 ? 16 : 1; break; case 7: - dpg.AMP /= (aShifthold == 1 ? 16 : 2); + dpg.AMP /= aShifthold == 1 ? 16 : 2; break; case 8: - dpg.EUT += (aShifthold == 1 ? 512 : 64); + dpg.EUT += aShifthold == 1 ? 512 : 64; break; case 9: - dpg.EUT *= (aShifthold == 1 ? 512 : 64); + dpg.EUT *= aShifthold == 1 ? 512 : 64; break; case 10: - dpg.AMP += (aShifthold == 1 ? 512 : 64); + dpg.AMP += aShifthold == 1 ? 512 : 64; break; case 11: - dpg.AMP *= (aShifthold == 1 ? 512 : 64); + dpg.AMP *= aShifthold == 1 ? 512 : 64; break; case 12: - dpg.EUT += (aShifthold == 1 ? 16 : 1); + dpg.EUT += aShifthold == 1 ? 16 : 1; break; case 13: - dpg.EUT *= (aShifthold == 1 ? 16 : 2); + dpg.EUT *= aShifthold == 1 ? 16 : 2; break; case 14: - dpg.AMP += (aShifthold == 1 ? 16 : 1); + dpg.AMP += aShifthold == 1 ? 16 : 1; break; case 15: - dpg.AMP *= (aShifthold == 1 ? 16 : 2); + dpg.AMP *= aShifthold == 1 ? 16 : 2; break; default: return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } @@ -113,7 +111,7 @@ public class GT_Container_DebugPowerGenerator @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { return; } @@ -121,9 +119,8 @@ public class GT_Container_DebugPowerGenerator EUT=dpg.EUT; AMP=dpg.AMP; - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); + for (Object crafter : crafters) { + ICrafting var1 = (ICrafting) crafter; var1.sendProgressBarUpdate(this, 100, EUT & 0xFFFF); var1.sendProgressBarUpdate(this, 101, EUT >>> 16); var1.sendProgressBarUpdate(this, 102, AMP & 0xFFFF); @@ -131,21 +128,22 @@ public class GT_Container_DebugPowerGenerator } } + @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { super.updateProgressBar(par1, par2); switch (par1) { case 100: - this.EUT = (this.EUT & 0xFFFF0000 | par2); + EUT = EUT & 0xFFFF0000 | par2; break; case 101: - this.EUT = (this.EUT & 0xFFFF | par2 << 16); + EUT = EUT & 0xFFFF | par2 << 16; break; case 102: - this.AMP = (this.AMP & 0xFFFF0000 | par2); + AMP = AMP & 0xFFFF0000 | par2; break; case 103: - this.AMP = (this.AMP & 0xFFFF | par2 << 16); + AMP = AMP & 0xFFFF | par2 << 16; break; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugStructureWriter.java index ff37e1d626..ba41d75c98 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugStructureWriter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugStructureWriter.java @@ -12,12 +12,10 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import java.util.Iterator; - public class GT_Container_DebugStructureWriter extends GT_ContainerMetaTile_Machine { public boolean size = false; - public short numbers[] = new short[6]; + public short[] numbers = new short[6]; public GT_Container_DebugStructureWriter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); @@ -25,25 +23,25 @@ public class GT_Container_DebugStructureWriter @Override public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 8, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 8, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 26, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 26, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 152, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 152, 59, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 5, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 23, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 41, false, false, 1)); - addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, 2, 134, 59, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 5, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 23, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 41, false, false, 1)); + addSlotToContainer(new GT_Slot_Holo(mTileEntity, 2, 134, 59, false, false, 1)); } @Override @@ -51,46 +49,48 @@ public class GT_Container_DebugStructureWriter if (aSlotIndex < 0) { return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); } - Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); - if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { + Slot tSlot = (Slot) inventorySlots.get(aSlotIndex); + if (tSlot != null && mTileEntity.getMetaTileEntity() != null) { GT_MetaTileEntity_DebugStructureWriter dsw = (GT_MetaTileEntity_DebugStructureWriter) mTileEntity.getMetaTileEntity(); - if (dsw.numbers == null) return null; + if (dsw.numbers == null) { + return null; + } switch (aSlotIndex) { case 0: - dsw.numbers[size ? 3 : 0] -= (aShifthold == 1 ? 512 : 64); + dsw.numbers[size ? 3 : 0] -= aShifthold == 1 ? 512 : 64; return null; case 1: - dsw.numbers[size ? 4 : 1] -= (aShifthold == 1 ? 512 : 64); + dsw.numbers[size ? 4 : 1] -= aShifthold == 1 ? 512 : 64; return null; case 2: - dsw.numbers[size ? 5 : 2] -= (aShifthold == 1 ? 512 : 64); + dsw.numbers[size ? 5 : 2] -= aShifthold == 1 ? 512 : 64; return null; case 4: - dsw.numbers[size ? 3 : 0] -= (aShifthold == 1 ? 16 : 1); + dsw.numbers[size ? 3 : 0] -= aShifthold == 1 ? 16 : 1; return null; case 5: - dsw.numbers[size ? 4 : 1] -= (aShifthold == 1 ? 16 : 1); + dsw.numbers[size ? 4 : 1] -= aShifthold == 1 ? 16 : 1; return null; case 6: - dsw.numbers[size ? 5 : 2] -= (aShifthold == 1 ? 16 : 1); + dsw.numbers[size ? 5 : 2] -= aShifthold == 1 ? 16 : 1; return null; case 8: - dsw.numbers[size ? 3 : 0] += (aShifthold == 1 ? 512 : 64); + dsw.numbers[size ? 3 : 0] += aShifthold == 1 ? 512 : 64; return null; case 9: - dsw.numbers[size ? 4 : 1] += (aShifthold == 1 ? 512 : 64); + dsw.numbers[size ? 4 : 1] += aShifthold == 1 ? 512 : 64; return null; case 10: - dsw.numbers[size ? 5 : 2] += (aShifthold == 1 ? 512 : 64); + dsw.numbers[size ? 5 : 2] += aShifthold == 1 ? 512 : 64; return null; case 12: - dsw.numbers[size ? 3 : 0] += (aShifthold == 1 ? 16 : 1); + dsw.numbers[size ? 3 : 0] += aShifthold == 1 ? 16 : 1; return null; case 13: - dsw.numbers[size ? 4 : 1] += (aShifthold == 1 ? 16 : 1); + dsw.numbers[size ? 4 : 1] += aShifthold == 1 ? 16 : 1; return null; case 14: - dsw.numbers[size ? 5 : 2] += (aShifthold == 1 ? 16 : 1); + dsw.numbers[size ? 5 : 2] += aShifthold == 1 ? 16 : 1; return null; case 3: case 7: @@ -106,39 +106,41 @@ public class GT_Container_DebugStructureWriter @Override public void detectAndSendChanges() { super.detectAndSendChanges(); - if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { + if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) { return; } GT_MetaTileEntity_DebugStructureWriter dsw = (GT_MetaTileEntity_DebugStructureWriter) mTileEntity.getMetaTileEntity(); - if (numbers != null) - System.arraycopy(dsw.numbers, 0, this.numbers, 0, dsw.numbers.length); - this.size = dsw.size; + if (numbers != null) { + System.arraycopy(dsw.numbers, 0, numbers, 0, dsw.numbers.length); + } + size = dsw.size; - Iterator var2 = this.crafters.iterator(); - while (var2.hasNext()) { - ICrafting var1 = (ICrafting) var2.next(); + for (Object crafter : crafters) { + ICrafting var1 = (ICrafting) crafter; if (numbers != null) { - var1.sendProgressBarUpdate(this, 100, this.numbers[0]); - var1.sendProgressBarUpdate(this, 101, this.numbers[1]); - var1.sendProgressBarUpdate(this, 102, this.numbers[2]); - var1.sendProgressBarUpdate(this, 103, this.numbers[3]); - var1.sendProgressBarUpdate(this, 104, this.numbers[4]); - var1.sendProgressBarUpdate(this, 105, this.numbers[5]); + var1.sendProgressBarUpdate(this, 100, numbers[0]); + var1.sendProgressBarUpdate(this, 101, numbers[1]); + var1.sendProgressBarUpdate(this, 102, numbers[2]); + var1.sendProgressBarUpdate(this, 103, numbers[3]); + var1.sendProgressBarUpdate(this, 104, numbers[4]); + var1.sendProgressBarUpdate(this, 105, numbers[5]); } - var1.sendProgressBarUpdate(this, 106, this.size ? 1 : 0); + var1.sendProgressBarUpdate(this, 106, size ? 1 : 0); } } + @Override @SideOnly(Side.CLIENT) public void updateProgressBar(int par1, int par2) { super.updateProgressBar(par1, par2); switch (par1) { case 106: - this.size = par2 == 1; + size = par2 == 1; break; default: - if (numbers != null && par1 >= 100 && par1 <= 105) - this.numbers[par1 - 100] = (short) par2; + if (numbers != null && par1 >= 100 && par1 <= 105) { + numbers[par1 - 100] = (short) par2; + } break; } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java index 6946e2320e..9e6dcf1f09 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugPowerGenerator.java @@ -13,21 +13,23 @@ public class GT_GUIContainer_DebugPowerGenerator extends GT_GUIContainerMetaTile super(new GT_Container_DebugPowerGenerator(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Teleporter.png"); } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString("PowerThing", 46, 8, 16448255); - if (this.mContainer != null) { + fontRendererObj.drawString("PowerThing", 46, 8, 16448255); + if (mContainer != null) { GT_Container_DebugPowerGenerator dpg = (GT_Container_DebugPowerGenerator) mContainer; - this.fontRendererObj.drawString("EUT: " + dpg.EUT, 46, 24, 16448255); - this.fontRendererObj.drawString("TIER: " + VN[Util.getTier(dpg.EUT<0?-dpg.EUT:dpg.EUT)], 46, 32, 16448255); - this.fontRendererObj.drawString("AMP: " + dpg.AMP, 46, 40, 16448255); - this.fontRendererObj.drawString("SUM: " + (long)dpg.AMP*dpg.EUT, 46, 48, 16448255); + fontRendererObj.drawString("EUT: " + dpg.EUT, 46, 24, 16448255); + fontRendererObj.drawString("TIER: " + VN[Util.getTier(dpg.EUT<0?-dpg.EUT:dpg.EUT)], 46, 32, 16448255); + fontRendererObj.drawString("AMP: " + dpg.AMP, 46, 40, 16448255); + fontRendererObj.drawString("SUM: " + (long)dpg.AMP*dpg.EUT, 46, 48, 16448255); } } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugStructureWriter.java index 2192017c6c..8e42e25324 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugStructureWriter.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_GUIContainer_DebugStructureWriter.java @@ -11,22 +11,26 @@ public class GT_GUIContainer_DebugStructureWriter extends GT_GUIContainerMetaTil super(new GT_Container_DebugStructureWriter(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "Teleporter.png"); } + @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { - this.fontRendererObj.drawString("StructPrint", 46, 8, 16448255); - if (this.mContainer != null) { + fontRendererObj.drawString("StructPrint", 46, 8, 16448255); + if (mContainer != null) { GT_Container_DebugStructureWriter dsw = (GT_Container_DebugStructureWriter) mContainer; - if (dsw.numbers == null) return; - this.fontRendererObj.drawString(dsw.size ? "Size" : "Offset", 46, 16, 16448255); - this.fontRendererObj.drawString("A: " + dsw.numbers[dsw.size ? 3 : 0], 46, 24, 16448255); - this.fontRendererObj.drawString("B: " + dsw.numbers[dsw.size ? 4 : 1], 46, 32, 16448255); - this.fontRendererObj.drawString("C: " + dsw.numbers[dsw.size ? 5 : 2], 46, 40, 16448255); + if (dsw.numbers == null) { + return; + } + fontRendererObj.drawString(dsw.size ? "Size" : "Offset", 46, 16, 16448255); + fontRendererObj.drawString("A: " + dsw.numbers[dsw.size ? 3 : 0], 46, 24, 16448255); + fontRendererObj.drawString("B: " + dsw.numbers[dsw.size ? 4 : 1], 46, 32, 16448255); + fontRendererObj.drawString("C: " + dsw.numbers[dsw.size ? 5 : 2], 46, 40, 16448255); } } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { super.drawGuiContainerBackgroundLayer(par1, par2, par3); - int x = (this.width - this.xSize) / 2; - int y = (this.height - this.ySize) / 2; - drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + drawTexturedModalRect(x, y, 0, 0, xSize, ySize); } } diff --git a/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java b/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java index faf251536f..e9d8694957 100644 --- a/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java +++ b/src/main/java/com/github/technus/tectech/thing/tileEntity/ReactorSimTileEntity.java @@ -18,27 +18,16 @@ import net.minecraftforge.fluids.FluidStack; public class ReactorSimTileEntity extends TileEntityNuclearReactorElectric { private boolean hadRedstone =true; - public ReactorSimTileEntity() { - super(); - //this.updateTicker = IC2.random.nextInt(this.getTickRate()); - //this.inputTank = new FluidTank(10000); - //this.outputTank = new FluidTank(10000); - //this.reactorSlot = new InvSlotReactor(this, "reactor", 0, 54); - //this.coolantinputSlot = new InvSlotConsumableLiquidByList(this, "coolantinputSlot", 55, InvSlot.Access.I, 1, InvSlot.InvSide.ANY, InvSlotConsumableLiquid.OpType.Drain, BlocksItems.getFluid(InternalName.fluidCoolant)); - //this.hotcoolinputSlot = new InvSlotConsumableLiquidByTank(this, "hotcoolinputSlot", 56, InvSlot.Access.I, 1, InvSlot.InvSide.ANY, InvSlotConsumableLiquid.OpType.Fill, this.outputTank); - //this.coolantoutputSlot = new InvSlotOutput(this, "coolantoutputSlot", 57, 1); - //this.hotcoolantoutputSlot = new InvSlotOutput(this, "hotcoolantoutputSlot", 58, 1); - } - @Override public void onLoaded() { super.onLoaded(); - if(IC2.platform.isSimulating() && this.addedToEnergyNet) { + if(IC2.platform.isSimulating() && addedToEnergyNet) { MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); //this.addedToEnergyNet = false; } } + @Override public void onUnloaded() { addedToEnergyNet=false; super.onUnloaded(); @@ -100,7 +89,7 @@ public class ReactorSimTileEntity extends TileEntityNuclearReactorElectric { @Override public double getReactorEUEnergyOutput() { - return (double)(this.getReactorEnergyOutput() * 5.0F * ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear")); + return (double)(getReactorEnergyOutput() * 5.0F * ConfigUtil.getFloat(MainConfig.get(), "balance/energy/generator/nuclear")); } //public List<TileEntity> getSubTiles() { @@ -153,10 +142,11 @@ public class ReactorSimTileEntity extends TileEntityNuclearReactorElectric { @Override protected void updateEntityServer() { - if(this.updateTicker++ % this.getTickRate() == 0) { - if (!worldObj.isRemote && this.worldObj.doChunksNearChunkExist(this.xCoord, this.yCoord, this.zCoord, 2)) { - if(hadRedstone && !receiveredstone()) hadRedstone=false; - else if(!hadRedstone && receiveredstone()){ + if(updateTicker++ % getTickRate() == 0) { + if (!worldObj.isRemote && worldObj.doChunksNearChunkExist(xCoord, yCoord, zCoord, 2)) { + if(hadRedstone && !receiveredstone()) { + hadRedstone = false; + } else if(!hadRedstone && receiveredstone()){ doUpdates(); hadRedstone=true; } @@ -203,10 +193,10 @@ public class ReactorSimTileEntity extends TileEntityNuclearReactorElectric { @Override public boolean calculateHeatEffects() { - if(this.heat >= 4000 && IC2.platform.isSimulating()) { - float power = (float)this.heat / (float)this.maxHeat; + if(heat >= 4000 && IC2.platform.isSimulating()) { + float power = (float) heat / (float) maxHeat; if(power >= 1.0F) { - this.explode();//ding + explode();//ding return true; } else { //int[] coord; diff --git a/src/main/java/openmodularturrets/blocks/turretbases/TurretBaseEM.java b/src/main/java/openmodularturrets/blocks/turretbases/TurretBaseEM.java index 02d9c59cfe..d79ab16f12 100644 --- a/src/main/java/openmodularturrets/blocks/turretbases/TurretBaseEM.java +++ b/src/main/java/openmodularturrets/blocks/turretbases/TurretBaseEM.java @@ -19,12 +19,11 @@ public class TurretBaseEM extends BlockAbstractTurretBase { public static TurretBaseEM INSTANCE; public TurretBaseEM(){ - super(); setCreativeTab(TecTech.mainTab); - this.setResistance(16); - this.setBlockName("turretBaseEM"); - this.setStepSound(Block.soundTypeMetal); - this.setBlockTextureName(Reference.MODID+":turretBaseEM"); + setResistance(16); + setBlockName("turretBaseEM"); + setStepSound(Block.soundTypeMetal); + setBlockTextureName(Reference.MODID+":turretBaseEM"); } @Override @@ -32,9 +31,10 @@ public class TurretBaseEM extends BlockAbstractTurretBase { return new TileTurretBaseEM(MaxCharge,MaxIO); } + @Override public void registerBlockIcons(IIconRegister p_149651_1_) { super.registerBlockIcons(p_149651_1_); - this.blockIcon = p_149651_1_.registerIcon(Reference.MODID+":turretBaseEM"); + blockIcon = p_149651_1_.registerIcon(Reference.MODID+":turretBaseEM"); } public static void run() { diff --git a/src/main/java/openmodularturrets/blocks/turretbases/TurretBaseItemEM.java b/src/main/java/openmodularturrets/blocks/turretbases/TurretBaseItemEM.java index c7b3b547c0..61f877e81b 100644 --- a/src/main/java/openmodularturrets/blocks/turretbases/TurretBaseItemEM.java +++ b/src/main/java/openmodularturrets/blocks/turretbases/TurretBaseItemEM.java @@ -14,10 +14,11 @@ import java.util.List; * Created by Bass on 28/07/2017. */ public class TurretBaseItemEM extends ItemBlock { - public TurretBaseItemEM(Block b) { - super(b); + public TurretBaseItemEM(Block block) { + super(block); } + @Override public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { list.add(CommonValues.TEC_MARK_EM); list.add(""); diff --git a/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadEM.java b/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadEM.java index 90318ef390..e7746a8291 100644 --- a/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadEM.java +++ b/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadEM.java @@ -20,12 +20,12 @@ public class TurretHeadEM extends Block implements ITileEntityProvider { public TurretHeadEM(){ super(Material.glass); - this.setCreativeTab(TecTech.mainTab); - this.setBlockUnbreakable(); - this.setResistance(6000000.0F); - this.setStepSound(Block.soundTypeMetal); - this.setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 1F, 0.8F); - this.setBlockName("turretHeadEM"); + setCreativeTab(TecTech.mainTab); + setBlockUnbreakable(); + setResistance(6000000.0F); + setStepSound(Block.soundTypeMetal); + setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 1F, 0.8F); + setBlockName("turretHeadEM"); //this.setBlockTextureName(Reference.MODID+":turretHeadEM"); } diff --git a/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java b/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java index 742e7b94fe..db3c089e47 100644 --- a/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java +++ b/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadItemEM.java @@ -19,23 +19,24 @@ import static com.github.technus.tectech.CommonValues.TEC_MARK_EM; public class TurretHeadItemEM extends ItemBlock { private static final DecimalFormat df = new DecimalFormat("0.0"); - public TurretHeadItemEM(Block b) { - super(b); + public TurretHeadItemEM(Block block) { + super(block); } + @Override public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List list, boolean p_77624_4_) { list.add(TEC_MARK_EM); list.add(""); list.add(EnumChatFormatting.GOLD + "--" + StatCollector.translateToLocal("tooltip.info") + "--"); - list.add(StatCollector.translateToLocal("tooltip.tier") + ": " + EnumChatFormatting.WHITE + "5"); + list.add(StatCollector.translateToLocal("tooltip.tier") + ": " + EnumChatFormatting.WHITE + '5'); list.add(StatCollector.translateToLocal("tooltip.range") + ": " + EnumChatFormatting.WHITE + ConfigHandler.getLaserTurretSettings().getRange()); list.add(StatCollector.translateToLocal("tooltip.accuracy") + ": " + EnumChatFormatting.WHITE + StatCollector.translateToLocal("turret.accuracy.high")); list.add(StatCollector.translateToLocal("tooltip.ammo") + ": " + EnumChatFormatting.WHITE + StatCollector.translateToLocal("turret.ammo.4")); list.add(StatCollector.translateToLocal("tooltip.tierRequired") + ": " + EnumChatFormatting.WHITE + StatCollector.translateToLocal("base.tier.5")); list.add(""); list.add(EnumChatFormatting.DARK_PURPLE + "--" + StatCollector.translateToLocal("tooltip.damage.label") + "--"); - list.add(StatCollector.translateToLocal("tooltip.damage.stat") + ": " + EnumChatFormatting.WHITE + (float)ConfigHandler.getLaserTurretSettings().getDamage() / 2.0F + " " + StatCollector.translateToLocal("tooltip.health")); - list.add(StatCollector.translateToLocal("tooltip.aoe") + ": " + EnumChatFormatting.WHITE + "0"); + list.add(StatCollector.translateToLocal("tooltip.damage.stat") + ": " + EnumChatFormatting.WHITE + (float)ConfigHandler.getLaserTurretSettings().getDamage() / 2.0F + ' ' + StatCollector.translateToLocal("tooltip.health")); + list.add(StatCollector.translateToLocal("tooltip.aoe") + ": " + EnumChatFormatting.WHITE + '0'); list.add(StatCollector.translateToLocal("tooltip.firerate") + ": " + EnumChatFormatting.WHITE + df.format((double)(20.0F / (float)ConfigHandler.getLaserTurretSettings().getFireRate()))); list.add(StatCollector.translateToLocal("tooltip.energy.stat") + ": " + EnumChatFormatting.WHITE + ConfigHandler.getLaserTurretSettings().getPowerUsage() + " RF"); list.add(""); diff --git a/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadItemRenderEM.java b/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadItemRenderEM.java index 6a46c627f2..4760e2b16e 100644 --- a/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadItemRenderEM.java +++ b/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadItemRenderEM.java @@ -17,21 +17,24 @@ public class TurretHeadItemRenderEM implements IItemRenderer { public TurretHeadItemRenderEM(TurretHeadRenderEM turretRenderer, TileTurretHeadEM turretTileEntity) { this.turretRenderer = turretRenderer; this.turretTileEntity = turretTileEntity; - this.model = new ModelLaserTurret(); + model = new ModelLaserTurret(); } + @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } + @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return true; } + @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { GL11.glPushMatrix(); GL11.glTranslated(-0.5D, -0.5D, -0.5D); - this.turretRenderer.renderTileEntityAt(this.turretTileEntity, 0.0D, 0.0D, 0.0D, 0.0F); + turretRenderer.renderTileEntityAt(turretTileEntity, 0.0D, 0.0D, 0.0D, 0.0F); GL11.glPopMatrix(); } } diff --git a/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadRenderEM.java b/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadRenderEM.java index f0aa331645..23379b9585 100644 --- a/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadRenderEM.java +++ b/src/main/java/openmodularturrets/blocks/turretheads/TurretHeadRenderEM.java @@ -5,7 +5,4 @@ import openmodularturrets.client.render.renderers.blockitem.LaserTurretRenderer; /** * Created by Bass on 28/07/2017. */ -public class TurretHeadRenderEM extends LaserTurretRenderer { - public TurretHeadRenderEM() { - } -} +public class TurretHeadRenderEM extends LaserTurretRenderer {} diff --git a/src/main/java/openmodularturrets/entity/projectiles/projectileEM.java b/src/main/java/openmodularturrets/entity/projectiles/projectileEM.java index e857d748e7..53e6186a25 100644 --- a/src/main/java/openmodularturrets/entity/projectiles/projectileEM.java +++ b/src/main/java/openmodularturrets/entity/projectiles/projectileEM.java @@ -51,11 +51,18 @@ public class projectileEM extends TurretProjectile { cElementalInstanceStack consumeFromThis=avalableEM.get(TecTech.Rnd.nextInt(avalableEM.size())); massFactor =consumeFromThis.definition.getMass()/ dHadronDefinition.hadron_n_.getMass(); - if(consumeFromThis.definition.getType()>1 || consumeFromThis.definition.getType()<-1) exotic = true; - if(consumeFromThis.definition.getType()<0) antiMatter = true; + if(consumeFromThis.definition.getType()>1 || consumeFromThis.definition.getType()<-1) { + exotic = true; + } + if(consumeFromThis.definition.getType()<0) { + antiMatter = true; + } - if (consumeFromThis.definition.getCharge() == 0) this.gravity = massFactor/100f; - else this.gravity = Math.min(0.0025F/Math.abs(consumeFromThis.definition.getCharge()),massFactor/100f); + if (consumeFromThis.definition.getCharge() == 0) { + gravity = massFactor / 100f; + } else { + gravity = Math.min(0.0025F / Math.abs(consumeFromThis.definition.getCharge()), massFactor / 100f); + } avalableEM.removeAmount(false,consumeFromThis.definition.getStackForm(1)); } @@ -65,13 +72,14 @@ public class projectileEM extends TurretProjectile { //todo add more subspace pollution } + @Override protected void onImpact(MovingObjectPosition movingobjectposition) { - if(this.ticksExisted > 1) { + if(ticksExisted > 1) { if(movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { - Block hitBlock = this.worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); + Block hitBlock = worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ); if(hitBlock != null){ if (hitBlock.getMaterial().isSolid() && TecTech.ModConfig.ENABLE_TURRET_EXPLOSIONS && antiMatter) { - this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "openmodularturrets:laserHit", ConfigHandler.getTurretSoundVolume(), TecTech.Rnd.nextFloat() + 0.5F); + worldObj.playSoundEffect(posX, posY, posZ, "openmodularturrets:laserHit", ConfigHandler.getTurretSoundVolume(), TecTech.Rnd.nextFloat() + 0.5F); GT_Utility.sendSoundToPlayers(worldObj, GregTech_API.sSoundList.get(209), 1.0F, -1.0F, movingobjectposition.blockX, movingobjectposition.blockY, @@ -79,28 +87,32 @@ public class projectileEM extends TurretProjectile { worldObj.createExplosion(null, movingobjectposition.blockX + 0.5D, movingobjectposition.blockY + 0.5D, - movingobjectposition.blockZ + 0.5D, (exotic?10:1) * TecTech.ModConfig.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped?(amp_level*.1f)+1:1) * (ticksExisted/250f), true); + movingobjectposition.blockZ + 0.5D, (exotic?10:1) * TecTech.ModConfig.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? amp_level*.1f +1:1) * (ticksExisted/250f), true); } else { return; } } } - if(movingobjectposition.entityHit != null && !this.worldObj.isRemote) { - this.worldObj.playSoundEffect(this.posX, this.posY, this.posZ, "openmodularturrets:laserHit", ConfigHandler.getTurretSoundVolume(), TecTech.Rnd.nextFloat() + 0.5F); - if(movingobjectposition.entityHit != null && !this.worldObj.isRemote) { - float damage = (exotic?10:1) * TecTech.ModConfig.TURRET_DAMAGE_FACTOR * massFactor * (isAmped?(amp_level*.1f)+1:1); + if(movingobjectposition.entityHit != null && !worldObj.isRemote) { + worldObj.playSoundEffect(posX, posY, posZ, "openmodularturrets:laserHit", ConfigHandler.getTurretSoundVolume(), TecTech.Rnd.nextFloat() + 0.5F); + if(movingobjectposition.entityHit != null && !worldObj.isRemote) { + float damage = (exotic?10:1) * TecTech.ModConfig.TURRET_DAMAGE_FACTOR * massFactor * (isAmped? amp_level*.1f +1:1); if(movingobjectposition.entityHit instanceof EntityPlayer) { - if(this.canDamagePlayer((EntityPlayer)movingobjectposition.entityHit)) { + if(canDamagePlayer((EntityPlayer)movingobjectposition.entityHit)) { movingobjectposition.entityHit.setFire((exotic?10:1)*2); movingobjectposition.entityHit.attackEntityFrom(new NormalDamageSource("laser"), damage); - if(antiMatter) movingobjectposition.entityHit.hurtResistantTime = 0; + if(antiMatter) { + movingobjectposition.entityHit.hurtResistantTime = 0; + } } } else { movingobjectposition.entityHit.setFire((exotic?10:1)*2); movingobjectposition.entityHit.attackEntityFrom(new NormalDamageSource("laser"), damage); - if(antiMatter) movingobjectposition.entityHit.hurtResistantTime = 0; + if(antiMatter) { + movingobjectposition.entityHit.hurtResistantTime = 0; + } } if (TecTech.ModConfig.ENABLE_TURRET_EXPLOSIONS && antiMatter) { @@ -111,17 +123,18 @@ public class projectileEM extends TurretProjectile { worldObj.createExplosion(null, movingobjectposition.entityHit.posX, movingobjectposition.entityHit.posY, - movingobjectposition.entityHit.posZ, (exotic?10:1) * TecTech.ModConfig.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped?(amp_level*.1f)+1:1) * (ticksExisted/250f), true); + movingobjectposition.entityHit.posZ, (exotic?10:1) * TecTech.ModConfig.TURRET_EXPLOSION_FACTOR * massFactor * (isAmped? amp_level*.1f +1:1) * (ticksExisted/250f), true); } } } - this.setDead(); + setDead(); } } + @Override public void onEntityUpdate() { - if(this.ticksExisted >= 75) { - this.setDead(); + if(ticksExisted >= 75) { + setDead(); } } } diff --git a/src/main/java/openmodularturrets/entity/projectiles/projectileRenderEM.java b/src/main/java/openmodularturrets/entity/projectiles/projectileRenderEM.java index 0fb915e035..9faeb02da6 100644 --- a/src/main/java/openmodularturrets/entity/projectiles/projectileRenderEM.java +++ b/src/main/java/openmodularturrets/entity/projectiles/projectileRenderEM.java @@ -18,11 +18,8 @@ import org.lwjgl.opengl.GL11; public class projectileRenderEM extends Render { private static final ResourceLocation textures = new ResourceLocation(Reference.MODID + ":textures/entity/projectileEM.png"); - public projectileRenderEM() { - } - private void render(projectileEM entity, double par2, double par4, double par6, float par9) { - this.bindEntityTexture(entity); + bindEntityTexture(entity); GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4 + 0.3F, (float)par6); GL11.glRotatef(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); @@ -37,8 +34,8 @@ public class projectileRenderEM extends Render { GL11.glEnable('\u803a'); float f11 = - par9; if(f11 > 0.0F) { - float i = -MathHelper.sin(f11 * 3.0F) * f11; - GL11.glRotatef(i, 0.0F, 0.0F, 1.0F); + float f = -MathHelper.sin(f11 * 3.0F) * f11; + GL11.glRotatef(f, 0.0F, 0.0F, 1.0F); } GL11.glDisable(2896); @@ -64,10 +61,12 @@ public class projectileRenderEM extends Render { GL11.glPopMatrix(); } + @Override protected ResourceLocation getEntityTexture(Entity par1Entity) { return textures; } + @Override public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { render((projectileEM)par1Entity, par2, par4, par6, par9); } diff --git a/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java b/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java index 343a1e5ebd..286f12d853 100644 --- a/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java +++ b/src/main/java/openmodularturrets/tileentity/turret/TileTurretHeadEM.java @@ -19,48 +19,55 @@ import openmodularturrets.util.TurretHeadUtil; public class TileTurretHeadEM extends TurretHead{ private cElementalInstanceStackMap hatchContentPointer; - public TileTurretHeadEM() { - } - + @Override public int getTurretRange() { return ConfigHandler.getLaserTurretSettings().getRange()<<1; } + @Override public int getTurretPowerUsage() { return ConfigHandler.getLaserTurretSettings().getPowerUsage()<<4; } + @Override public int getTurretFireRate() { return (int)Math.ceil(ConfigHandler.getLaserTurretSettings().getFireRate()/2f); } + @Override public double getTurretAccuracy() { return (int)Math.ceil(ConfigHandler.getLaserTurretSettings().getAccuracy() / 10.0F); } @Override public void updateEntity() { - if(!worldObj.isRemote && base instanceof TileTurretBaseEM) - hatchContentPointer =((TileTurretBaseEM) base).getContainerHandler(); + if(!worldObj.isRemote && base instanceof TileTurretBaseEM) { + hatchContentPointer = ((TileTurretBaseEM) base).getContainerHandler(); + } super.updateEntity(); } + @Override public boolean requiresAmmo() { return hatchContentPointer == null || !hatchContentPointer.hasStacks(); } + @Override public boolean requiresSpecificAmmo() { return true;//to enable failure in shooting when there is no EM to use } + @Override public Item getAmmo() { return DebugElementalInstanceContainer_EM.INSTANCE;//Placeholder item that cannot be achieved, yet still usable for debug } + @Override public final TurretProjectile createProjectile(World world, Entity target, ItemStack ammo) { return new projectileEM(world, TurretHeadUtil.getTurretBase(worldObj, xCoord, yCoord, zCoord), hatchContentPointer); } + @Override public String getLaunchSoundEffect() { return "laser"; } diff --git a/src/main/java/openmodularturrets/tileentity/turretbase/TileTurretBaseEM.java b/src/main/java/openmodularturrets/tileentity/turretbase/TileTurretBaseEM.java index acecfb4a37..7bb87c8826 100644 --- a/src/main/java/openmodularturrets/tileentity/turretbase/TileTurretBaseEM.java +++ b/src/main/java/openmodularturrets/tileentity/turretbase/TileTurretBaseEM.java @@ -16,6 +16,7 @@ public class TileTurretBaseEM extends TurretBaseTierFiveTileEntity { super(MaxEnergyStorage, MaxIO); } + @Override @Optional.Method( modid = "OpenComputers" ) @@ -27,28 +28,34 @@ public class TileTurretBaseEM extends TurretBaseTierFiveTileEntity { World worldIn = getWorldObj(); TileEntity te; if ((te = worldIn.getTileEntity(xCoord + 1, yCoord, zCoord)) instanceof IGregTechTileEntity && - ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) + ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) { return getFromHatch((GT_MetaTileEntity_Hatch_InputElemental) ((IGregTechTileEntity) te).getMetaTileEntity()); + } if ((te = worldIn.getTileEntity(xCoord - 1, yCoord, zCoord)) instanceof IGregTechTileEntity && - ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) + ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) { return getFromHatch((GT_MetaTileEntity_Hatch_InputElemental) ((IGregTechTileEntity) te).getMetaTileEntity()); + } if ((te = worldIn.getTileEntity(xCoord, yCoord + 1, zCoord)) instanceof IGregTechTileEntity && - ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) + ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) { return getFromHatch((GT_MetaTileEntity_Hatch_InputElemental) ((IGregTechTileEntity) te).getMetaTileEntity()); + } if ((te = worldIn.getTileEntity(xCoord, yCoord - 1, zCoord)) instanceof IGregTechTileEntity && - ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) + ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) { return getFromHatch((GT_MetaTileEntity_Hatch_InputElemental) ((IGregTechTileEntity) te).getMetaTileEntity()); + } if ((te = worldIn.getTileEntity(xCoord, yCoord, zCoord + 1)) instanceof IGregTechTileEntity && - ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) + ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) { return getFromHatch((GT_MetaTileEntity_Hatch_InputElemental) ((IGregTechTileEntity) te).getMetaTileEntity()); + } if ((te = worldIn.getTileEntity(xCoord, yCoord, zCoord - 1)) instanceof IGregTechTileEntity && - ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) + ((IGregTechTileEntity) te).getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_InputElemental) { return getFromHatch((GT_MetaTileEntity_Hatch_InputElemental) ((IGregTechTileEntity) te).getMetaTileEntity()); + } return null; } diff --git a/src/main/resources/TecTechIcon.png b/src/main/resources/TecTechIcon.png Binary files differnew file mode 100644 index 0000000000..2e07b61e40 --- /dev/null +++ b/src/main/resources/TecTechIcon.png diff --git a/src/main/resources/TecTechIconSmall.png b/src/main/resources/TecTechIconSmall.png Binary files differnew file mode 100644 index 0000000000..e49439f14d --- /dev/null +++ b/src/main/resources/TecTechIconSmall.png diff --git a/src/main/resources/assets/tectech/sounds.json b/src/main/resources/assets/tectech/sounds.json index 73c9e62808..c4049f5f02 100644 --- a/src/main/resources/assets/tectech/sounds.json +++ b/src/main/resources/assets/tectech/sounds.json @@ -3,5 +3,45 @@ "category": "block", "subtitle": "tectech.subtitle.microwave_ding", "sounds": [{"name": "microwave_ding","stream": false}] + }, + "fx_alarm": { + "category": "block", + "subtitle": "tectech.subtitle.fx_alarm", + "sounds": [{"name": "fx_alarm","stream": false}] + }, + "fx_click": { + "category": "block", + "subtitle": "tectech.subtitle.fx_click", + "sounds": [{"name": "fx_click","stream": false}] + }, + "fx_lo_freq": { + "category": "block", + "subtitle": "tectech.subtitle.fx_lo_freq", + "sounds": [{"name": "fx_lo_freq","stream": false}] + }, + "fx_mid_freq": { + "category": "block", + "subtitle": "tectech.subtitle.fx_mid_freq", + "sounds": [{"name": "fx_mid_freq","stream": false}] + }, + "fx_hi_freq": { + "category": "block", + "subtitle": "tectech.subtitle.fx_hi_freq", + "sounds": [{"name": "fx_hi_freq","stream": false}] + }, + "fx_noise": { + "category": "block", + "subtitle": "tectech.subtitle.fx_noise", + "sounds": [{"name": "fx_noise","stream": false}] + }, + "fx_woo_uu": { + "category": "block", + "subtitle": "tectech.subtitle.fx_woo_uu", + "sounds": [{"name": "fx_woo_uu","stream": false}] + }, + "fx_whooum": { + "category": "block", + "subtitle": "tectech.subtitle.fx_whooum", + "sounds": [{"name": "fx_whooum","stream": false}] } }
\ No newline at end of file diff --git a/src/main/resources/assets/tectech/sounds/fx_alarm.ogg b/src/main/resources/assets/tectech/sounds/fx_alarm.ogg Binary files differnew file mode 100644 index 0000000000..6156f6b1eb --- /dev/null +++ b/src/main/resources/assets/tectech/sounds/fx_alarm.ogg diff --git a/src/main/resources/assets/tectech/sounds/fx_click.ogg b/src/main/resources/assets/tectech/sounds/fx_click.ogg Binary files differnew file mode 100644 index 0000000000..3211d0d12e --- /dev/null +++ b/src/main/resources/assets/tectech/sounds/fx_click.ogg diff --git a/src/main/resources/assets/tectech/sounds/fx_hi_freq.ogg b/src/main/resources/assets/tectech/sounds/fx_hi_freq.ogg Binary files differnew file mode 100644 index 0000000000..bb21d14ea5 --- /dev/null +++ b/src/main/resources/assets/tectech/sounds/fx_hi_freq.ogg diff --git a/src/main/resources/assets/tectech/sounds/fx_lo_freq.ogg b/src/main/resources/assets/tectech/sounds/fx_lo_freq.ogg Binary files differnew file mode 100644 index 0000000000..8eab2d92e2 --- /dev/null +++ b/src/main/resources/assets/tectech/sounds/fx_lo_freq.ogg diff --git a/src/main/resources/assets/tectech/sounds/fx_mid_freq.ogg b/src/main/resources/assets/tectech/sounds/fx_mid_freq.ogg Binary files differnew file mode 100644 index 0000000000..b16d1297f4 --- /dev/null +++ b/src/main/resources/assets/tectech/sounds/fx_mid_freq.ogg diff --git a/src/main/resources/assets/tectech/sounds/fx_noise.ogg b/src/main/resources/assets/tectech/sounds/fx_noise.ogg Binary files differnew file mode 100644 index 0000000000..0bb3a58dc0 --- /dev/null +++ b/src/main/resources/assets/tectech/sounds/fx_noise.ogg diff --git a/src/main/resources/assets/tectech/sounds/fx_whooum.ogg b/src/main/resources/assets/tectech/sounds/fx_whooum.ogg Binary files differnew file mode 100644 index 0000000000..4e9331924d --- /dev/null +++ b/src/main/resources/assets/tectech/sounds/fx_whooum.ogg diff --git a/src/main/resources/assets/tectech/sounds/fx_woo_uu.ogg b/src/main/resources/assets/tectech/sounds/fx_woo_uu.ogg Binary files differnew file mode 100644 index 0000000000..51a35371a1 --- /dev/null +++ b/src/main/resources/assets/tectech/sounds/fx_woo_uu.ogg diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayItem.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayItem.png Binary files differnew file mode 100644 index 0000000000..dc9794a424 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayItem.png diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen1.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen1.png Binary files differnew file mode 100644 index 0000000000..e1e659718c --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen1.png diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen2.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen2.png Binary files differnew file mode 100644 index 0000000000..fd29923b87 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen2.png diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen3.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen3.png Binary files differnew file mode 100644 index 0000000000..0dbe68fba6 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen3.png diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen4.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen4.png Binary files differnew file mode 100644 index 0000000000..a9488280c1 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen4.png diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen5.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen5.png Binary files differnew file mode 100644 index 0000000000..6cefaa0186 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen5.png diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen6.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen6.png Binary files differnew file mode 100644 index 0000000000..90cb09abac --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen6.png diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen7.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen7.png Binary files differnew file mode 100644 index 0000000000..6a11d2df4a --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen7.png diff --git a/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen8.png b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen8.png Binary files differnew file mode 100644 index 0000000000..bbe69099c2 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/scanDisplayScreen8.png diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index f480667560..f7fc68f278 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,15 +1,15 @@ [ { - "modid": "examplemod", - "name": "Example Mod", - "description": "Example placeholder mod.", + "modid": "tectech", + "name": "TecTech", + "description": "TecTech - Tec Technology Interdimensional! Replace UUMatter with something overly complicated and annoying! (GT5u Addon)", "version": "${version}", "mcversion": "${mcversion}", "url": "", "updateUrl": "", - "authorList": ["ExampleDude"], + "authorList": ["_Technus_"], "credits": "The Forge and FML guys, for making this example", - "logoFile": "", + "logoFile": "TecTechIcon.png", "screenshots": [], "dependencies": [] } |