diff options
author | Technus <daniel112092@gmail.com> | 2017-05-13 21:34:22 +0200 |
---|---|---|
committer | Technus <daniel112092@gmail.com> | 2017-05-13 21:34:22 +0200 |
commit | 60d5c5d814e3b0600c9052dad605aa801b69adab (patch) | |
tree | 861c2855f28758ccc7ffed865cd91d099471059b /src/main | |
parent | 11992faf1ea711a8eb56370b498259c48bfe4237 (diff) | |
download | GT5-Unofficial-60d5c5d814e3b0600c9052dad605aa801b69adab.tar.gz GT5-Unofficial-60d5c5d814e3b0600c9052dad605aa801b69adab.tar.bz2 GT5-Unofficial-60d5c5d814e3b0600c9052dad605aa801b69adab.zip |
Near to finish another refactor.
Diffstat (limited to 'src/main')
65 files changed, 1301 insertions, 1052 deletions
diff --git a/src/main/java/com/github/technus/tectech/TecTech.java b/src/main/java/com/github/technus/tectech/TecTech.java index 78cc01eca9..01ac9077f3 100644 --- a/src/main/java/com/github/technus/tectech/TecTech.java +++ b/src/main/java/com/github/technus/tectech/TecTech.java @@ -44,9 +44,9 @@ public class TecTech { public static TecTechConfig ModConfig; public static XSTR Rnd = null; public static CreativeTabs mainTab = null; - private static boolean oneTimeFix=false; + private static boolean oneTimeFix = false; - public static boolean hasCOFH=false; + public static boolean hasCOFH = false; public static void AddLoginError(String pMessage) { if (Module_AdminErrorLogs != null) @@ -76,7 +76,7 @@ public class TecTech { @EventHandler public void PostLoad(FMLPostInitializationEvent PostEvent) { - hasCOFH=Loader.isModLoaded(Reference.COFHCORE); + hasCOFH = Loader.isModLoaded(Reference.COFHCORE); GTCustomLoader = new MainLoader(); GTCustomLoader.things(); @@ -111,37 +111,38 @@ public class TecTech { } @EventHandler - public void onServerAboutToStart(FMLServerAboutToStartEvent ev){ - if(!oneTimeFix) { - oneTimeFix=true; + public void onServerAboutToStart(FMLServerAboutToStartEvent ev) { + if (!oneTimeFix) { + oneTimeFix = true; if (ModConfig.NERF_FUSION) FixBrokenFusionRecipes(); } } - private void FixBrokenFusionRecipes(){ - HashMap<Fluid,Fluid> binds=new HashMap<>(); - for(Materials m:Materials.values()){ - FluidStack p=m.getPlasma(1); - if( p!=null) { - if(TecTechConfig.DEBUG_MODE) TecTech.Logger.info("Found Plasma of "+m.name()); + private void FixBrokenFusionRecipes() { + HashMap<Fluid, Fluid> binds = new HashMap<>(); + for (Materials m : Materials.values()) { + FluidStack p = m.getPlasma(1); + if (p != null) { + if (TecTechConfig.DEBUG_MODE) TecTech.Logger.info("Found Plasma of " + m.name()); 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)) { + -m.mElement.mProtons >= Materials.Iron.mElement.mProtons || + m.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons || + -m.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons)) { if (TecTechConfig.DEBUG_MODE) TecTech.Logger.info("Attempting to bind " + m.name()); 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()); + 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(TecTechConfig.DEBUG_MODE) TecTech.Logger.info("Nerfing Recipe "+r.mFluidOutputs[0].getUnlocalizedName()); - r.mFluidOutputs[0]=new FluidStack(f,r.mFluidInputs[0].amount); + for (GT_Recipe r : GT_Recipe.GT_Recipe_Map.sFusionRecipes.mRecipeList) { + Fluid f = binds.get(r.mFluidOutputs[0].getFluid()); + if (f != null) { + if (TecTechConfig.DEBUG_MODE) + TecTech.Logger.info("Nerfing Recipe " + r.mFluidOutputs[0].getUnlocalizedName()); + r.mFluidOutputs[0] = new FluidStack(f, r.mFluidInputs[0].amount); } } } diff --git a/src/main/java/com/github/technus/tectech/Util.java b/src/main/java/com/github/technus/tectech/Util.java index 154ed10eba..4335791e77 100644 --- a/src/main/java/com/github/technus/tectech/Util.java +++ b/src/main/java/com/github/technus/tectech/Util.java @@ -26,7 +26,7 @@ public class Util { public static String intToString(int number, int groupSize) { StringBuilder result = new StringBuilder(); - for(int i = 31; i >= 0 ; i--) { + for (int i = 31; i >= 0; i--) { int mask = 1 << i; result.append((number & mask) != 0 ? "1" : "0"); @@ -46,8 +46,8 @@ public class Util { int horizontalOffset, int verticalOffset, int depthOffset, IGregTechTileEntity aBaseMetaTileEntity, boolean forceCheck) { - World world=aBaseMetaTileEntity.getWorld(); - if(world.isRemote)return false; + World world = aBaseMetaTileEntity.getWorld(); + if (world.isRemote) return false; //TE Rotation byte facing = aBaseMetaTileEntity.getFrontFacing(); @@ -70,21 +70,46 @@ public class Util { } else { //get x y z from rotation switch (facing) {//translation - case 4: x = aBaseMetaTileEntity.getXCoord()+c; z = aBaseMetaTileEntity.getZCoord()+a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 3: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()-c; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 5: x = aBaseMetaTileEntity.getXCoord()-c; z = aBaseMetaTileEntity.getZCoord()-a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 2: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()+c; y = aBaseMetaTileEntity.getYCoord()+b; break; + case 4: + x = aBaseMetaTileEntity.getXCoord() + c; + z = aBaseMetaTileEntity.getZCoord() + a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 3: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() - c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 5: + x = aBaseMetaTileEntity.getXCoord() - c; + z = aBaseMetaTileEntity.getZCoord() - a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 2: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() + c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; //Things get odd if the block faces up or down... - case 1: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()+b; y = aBaseMetaTileEntity.getYCoord()-c; break;//similar to 3 - case 0: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()-b; y = aBaseMetaTileEntity.getYCoord()+c; break;//similar to 2 - default: return false; + case 1: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() + b; + y = aBaseMetaTileEntity.getYCoord() - c; + break;//similar to 3 + case 0: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() - b; + y = aBaseMetaTileEntity.getYCoord() + c; + break;//similar to 2 + default: + return false; } //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 + 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) @@ -108,7 +133,7 @@ public class Util { return false; } } - }else if (forceCheck) return false; + } else if (forceCheck) return false; a++;//block in horizontal layer } } @@ -133,13 +158,13 @@ public class Util { int horizontalOffset, int verticalOffset, int depthOffset, IGregTechTileEntity aBaseMetaTileEntity, boolean forceCheck) { - World world=aBaseMetaTileEntity.getWorld(); - if(world.isRemote)return false; + World world = aBaseMetaTileEntity.getWorld(); + if (world.isRemote) return false; //TE Rotation byte facing = aBaseMetaTileEntity.getFrontFacing(); IGregTechTileEntity igt; - IMetaTileEntity imt=aBaseMetaTileEntity.getMetaTileEntity(); + IMetaTileEntity imt = aBaseMetaTileEntity.getMetaTileEntity(); int x, y, z, a, b, c, pointer; //a,b,c - relative to block face! @@ -155,26 +180,51 @@ public class Util { for (char block : __structure.toCharArray()) {//left to right if (block > '@') {//characters allow to skip check a-1 skip, b-2 skips etc. a += block - '@'; - //} else if (block < '+') {//used to mark THINGS - // a++; + //} else if (block < '+') {//used to mark THINGS + // a++; } else { //get x y z from rotation switch (facing) {//translation - case 4: x = aBaseMetaTileEntity.getXCoord()+c; z = aBaseMetaTileEntity.getZCoord()+a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 3: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()-c; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 5: x = aBaseMetaTileEntity.getXCoord()-c; z = aBaseMetaTileEntity.getZCoord()-a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 2: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()+c; y = aBaseMetaTileEntity.getYCoord()+b; break; + case 4: + x = aBaseMetaTileEntity.getXCoord() + c; + z = aBaseMetaTileEntity.getZCoord() + a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 3: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() - c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 5: + x = aBaseMetaTileEntity.getXCoord() - c; + z = aBaseMetaTileEntity.getZCoord() - a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 2: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() + c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; //Things get odd if the block faces up or down... - case 1: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()+b; y = aBaseMetaTileEntity.getYCoord()-c; break;//similar to 3 - case 0: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()-b; y = aBaseMetaTileEntity.getYCoord()+c; break;//similar to 2 - default: return false; + case 1: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() + b; + y = aBaseMetaTileEntity.getYCoord() - c; + break;//similar to 3 + case 0: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() - b; + y = aBaseMetaTileEntity.getYCoord() + c; + break;//similar to 2 + default: + return false; } //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 + 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) @@ -185,7 +235,7 @@ public class Util { return false; break; default://check for block (countable) - if((pointer = block - '0') >= 0) { + if ((pointer = block - '0') >= 0) { //countable air -> net.minecraft.block.BlockAir if (world.getBlock(x, y, z) != blockType[pointer]) { if (TecTechConfig.DEBUG_MODE) @@ -197,10 +247,10 @@ public class Util { 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){ - igt=aBaseMetaTileEntity.getIGregTechTileEntity(x,y,z); + } else if ((pointer = block - ' ') >= 0) { + igt = aBaseMetaTileEntity.getIGregTechTileEntity(x, y, z); try { - if(igt==null || !(boolean) adder.invoke(imt,addingMethods[pointer],igt,casingTextures[pointer])){ + if (igt == null || !(boolean) adder.invoke(imt, addingMethods[pointer], igt, casingTextures[pointer])) { if (world.getBlock(x, y, z) != blockTypeFallback[pointer]) { if (TecTechConfig.DEBUG_MODE) TecTech.Logger.info("Fallback-struct-block-error " + x + " " + y + " " + z + " / " + a + " " + b + " " + c + " / " + world.getBlock(x, y, z).getUnlocalizedName() + " " + blockTypeFallback[pointer].getUnlocalizedName()); @@ -212,13 +262,13 @@ public class Util { return false; } } - }catch (InvocationTargetException | IllegalAccessException e){ - if(TecTechConfig.DEBUG_MODE) e.printStackTrace(); + } catch (InvocationTargetException | IllegalAccessException e) { + if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); return false; } } } - }else if (forceCheck) return false; + } else if (forceCheck) return false; a++;//block in horizontal layer } } @@ -236,8 +286,8 @@ public class Util { IGregTechTileEntity aBaseMetaTileEntity) { //TE Rotation byte facing = aBaseMetaTileEntity.getFrontFacing(); - World world=aBaseMetaTileEntity.getWorld(); - if(world.isRemote)return false; + World world = aBaseMetaTileEntity.getWorld(); + if (world.isRemote) return false; int x, y, z, a, b, c; //a,b,c - relative to block face! @@ -257,32 +307,57 @@ public class Util { } else { //get x y z from rotation switch (facing) {//translation - case 4: x = aBaseMetaTileEntity.getXCoord()+c; z = aBaseMetaTileEntity.getZCoord()+a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 3: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()-c; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 5: x = aBaseMetaTileEntity.getXCoord()-c; z = aBaseMetaTileEntity.getZCoord()-a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 2: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()+c; y = aBaseMetaTileEntity.getYCoord()+b; break; + case 4: + x = aBaseMetaTileEntity.getXCoord() + c; + z = aBaseMetaTileEntity.getZCoord() + a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 3: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() - c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 5: + x = aBaseMetaTileEntity.getXCoord() - c; + z = aBaseMetaTileEntity.getZCoord() - a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 2: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() + c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; //Things get odd if the block faces up or down... - case 1: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()+b; y = aBaseMetaTileEntity.getYCoord()-c; break;//similar to 3 - case 0: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()-b; y = aBaseMetaTileEntity.getYCoord()+c; break;//similar to 2 - default: return false; + case 1: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() + b; + y = aBaseMetaTileEntity.getYCoord() - c; + break;//similar to 3 + case 0: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() - b; + y = aBaseMetaTileEntity.getYCoord() + c; + break;//similar to 2 + default: + return false; } //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 + if (world.blockExists(x, y, z)) {//this actually checks if the chunk is loaded switch (block) { case '-'://must be air - world.setBlock(x,y,z,Blocks.air,0,2); + world.setBlock(x, y, z, Blocks.air, 0, 2); break; case '+'://must not be air - world.setBlock(x,y,z,Blocks.wool,15,2); + world.setBlock(x, y, z, Blocks.wool, 15, 2); break; default: {//check for block (countable) int pointer = block - '0'; //countable air -> net.minecraft.block.BlockAir - world.setBlock(x,y,z,blockType[pointer],blockMeta[pointer],2); + world.setBlock(x, y, z, blockType[pointer], blockMeta[pointer], 2); } } } @@ -298,13 +373,13 @@ public class Util { public static String[] StructureWriter(IGregTechTileEntity aBaseMetaTileEntity, int horizontalOffset, int verticalOffset, int depthOffset, - int horizontalSize, int verticalSize, int depthSize, boolean ignoreAir){ + int horizontalSize, int verticalSize, int depthSize, boolean ignoreAir) { //TE Rotation byte facing = aBaseMetaTileEntity.getFrontFacing(); - World world=aBaseMetaTileEntity.getWorld(); - if(world.isRemote)return new String[]{"Not at Client m8"}; + World world = aBaseMetaTileEntity.getWorld(); + if (world.isRemote) return new String[]{"Not at Client m8"}; - ItemStack[] array=new ItemStack[10]; + ItemStack[] array = new ItemStack[10]; int x, y, z, a, b, c; //a,b,c - relative to block face! @@ -313,40 +388,65 @@ public class Util { //perform your duties - #1 - count block types c = -depthOffset; - for (int cz=0;cz<depthSize;cz++) {//front to back + for (int cz = 0; cz < depthSize; cz++) {//front to back b = verticalOffset; - for (int by=0;by<verticalSize;by++) {//top to bottom + for (int by = 0; by < verticalSize; by++) {//top to bottom a = -horizontalOffset; - for (int az=0;az<horizontalSize;az++) {//left to right + for (int az = 0; az < horizontalSize; az++) {//left to right //get x y z from rotation switch (facing) {//translation - case 4: x = aBaseMetaTileEntity.getXCoord()+c; z = aBaseMetaTileEntity.getZCoord()+a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 3: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()-c; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 5: x = aBaseMetaTileEntity.getXCoord()-c; z = aBaseMetaTileEntity.getZCoord()-a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 2: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()+c; y = aBaseMetaTileEntity.getYCoord()+b; break; + case 4: + x = aBaseMetaTileEntity.getXCoord() + c; + z = aBaseMetaTileEntity.getZCoord() + a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 3: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() - c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 5: + x = aBaseMetaTileEntity.getXCoord() - c; + z = aBaseMetaTileEntity.getZCoord() - a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 2: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() + c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; //Things get odd if the block faces up or down... - case 1: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()+b; y = aBaseMetaTileEntity.getYCoord()-c; break;//similar to 3 - case 0: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()-b; y = aBaseMetaTileEntity.getYCoord()+c; break;//similar to 2 - default: return new String[]{"Invalid rotation"}; + case 1: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() + b; + y = aBaseMetaTileEntity.getYCoord() - c; + break;//similar to 3 + case 0: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() - b; + y = aBaseMetaTileEntity.getYCoord() + c; + break;//similar to 2 + default: + return new String[]{"Invalid rotation"}; } //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); - int meta=world.getBlockMetadata(x,y,z); - - if(!block.hasTileEntity(meta) && block.getMaterial()!=Material.air) { - boolean err=true; - final ItemStack is=new ItemStack(block, 1, meta); - for(int i=0;i<array.length;i++){ - if(array[i]==null){ - array[i]=is; - err=false; + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if (!block.hasTileEntity(meta) && block.getMaterial() != Material.air) { + boolean err = true; + final ItemStack is = new ItemStack(block, 1, meta); + for (int i = 0; i < array.length; i++) { + if (array[i] == null) { + array[i] = is; + err = false; break; - } else if(is.getItem()==array[i].getItem() && is.getItemDamage()==array[i].getItemDamage()){ - err=false; + } else if (is.getItem() == array[i].getItem() && is.getItemDamage() == array[i].getItemDamage()) { + err = false; break; } } @@ -360,25 +460,25 @@ public class Util { c++;//depth } - List<String> output=new ArrayList<>(); + 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[]"); output.add(""); - for(int i=0;i<array.length;i++){ - if(array[i]!=null) { - output.add(i+": "+array[i].getDisplayName()); + for (int i = 0; i < array.length; i++) { + if (array[i] != null) { + output.add(i + ": " + array[i].getDisplayName()); } } output.add(""); output.add("ID[]: Block[] BlockMetaID[]"); output.add(""); - for(int i=0;i<array.length;i++){ - if(array[i]!=null) { - output.add(i+": "+array[i].getItem().getUnlocalizedName()+" "+array[i].getItemDamage()); + for (int i = 0; i < array.length; i++) { + if (array[i] != null) { + output.add(i + ": " + array[i].getItem().getUnlocalizedName() + " " + array[i].getItemDamage()); } } output.add(""); @@ -386,85 +486,110 @@ public class Util { //perform your duties - #2 - write strings output.add("{"); c = -depthOffset; - for (int cz=0;cz<depthSize;cz++) {//front to back + for (int cz = 0; cz < depthSize; cz++) {//front to back b = verticalOffset; - String addMe="{"; - for (int by=0;by<verticalSize;by++) {//top to bottom + String addMe = "{"; + for (int by = 0; by < verticalSize; by++) {//top to bottom a = -horizontalOffset; - String line=""; - for (int az=0;az<horizontalSize;az++) {//left to right + String line = ""; + for (int az = 0; az < horizontalSize; az++) {//left to right //get x y z from rotation switch (facing) {//translation - case 4: x = aBaseMetaTileEntity.getXCoord()+c; z = aBaseMetaTileEntity.getZCoord()+a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 3: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()-c; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 5: x = aBaseMetaTileEntity.getXCoord()-c; z = aBaseMetaTileEntity.getZCoord()-a; y = aBaseMetaTileEntity.getYCoord()+b; break; - case 2: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()+c; y = aBaseMetaTileEntity.getYCoord()+b; break; + case 4: + x = aBaseMetaTileEntity.getXCoord() + c; + z = aBaseMetaTileEntity.getZCoord() + a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 3: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() - c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 5: + x = aBaseMetaTileEntity.getXCoord() - c; + z = aBaseMetaTileEntity.getZCoord() - a; + y = aBaseMetaTileEntity.getYCoord() + b; + break; + case 2: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() + c; + y = aBaseMetaTileEntity.getYCoord() + b; + break; //Things get odd if the block faces up or down... - case 1: x = aBaseMetaTileEntity.getXCoord()+a; z = aBaseMetaTileEntity.getZCoord()+b; y = aBaseMetaTileEntity.getYCoord()-c; break;//similar to 3 - case 0: x = aBaseMetaTileEntity.getXCoord()-a; z = aBaseMetaTileEntity.getZCoord()-b; y = aBaseMetaTileEntity.getYCoord()+c; break;//similar to 2 - default: return new String[]{"Invalid rotation"}; + case 1: + x = aBaseMetaTileEntity.getXCoord() + a; + z = aBaseMetaTileEntity.getZCoord() + b; + y = aBaseMetaTileEntity.getYCoord() - c; + break;//similar to 3 + case 0: + x = aBaseMetaTileEntity.getXCoord() - a; + z = aBaseMetaTileEntity.getZCoord() - b; + y = aBaseMetaTileEntity.getYCoord() + c; + break;//similar to 2 + default: + return new String[]{"Invalid rotation"}; } //Check block - Block block=world.getBlock(x,y,z); - int meta=world.getBlockMetadata(x,y,z); - - if(a==0 && b==0 && c==0){ - line+='+'; - }else if(block.getMaterial()==Material.air){ - line+='-'; - }else if(block.hasTileEntity(meta)){ - line+='*'; - }else{ - ItemStack stack=new ItemStack(block,1,meta); - String str="?";//OH YEAH NPEs - for(int i=0;i<array.length;i++){ - if(array[i]!=null && stack.getItem()==array[i].getItem() && stack.getItemDamage()==array[i].getItemDamage()) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); + + if (a == 0 && b == 0 && c == 0) { + line += '+'; + } else if (block.getMaterial() == Material.air) { + line += '-'; + } else if (block.hasTileEntity(meta)) { + line += '*'; + } else { + ItemStack stack = new ItemStack(block, 1, meta); + String str = "?";//OH YEAH NPEs + for (int i = 0; i < array.length; i++) { + if (array[i] != null && stack.getItem() == array[i].getItem() && stack.getItemDamage() == array[i].getItemDamage()) { str = Integer.toString(i); break; } } - line+=str; + line += str; } a++;//block in horizontal layer } - if(ignoreAir) { + if (ignoreAir) { String l = ""; - char temp='@'; + char temp = '@'; for (char ch : line.toCharArray()) { - if(ch=='-'){ - temp+=1; - if(temp=='~') { + if (ch == '-') { + temp += 1; + if (temp == '~') { l += '~'; - temp='@'; + temp = '@'; } - }else{ - if(temp>'@') { + } else { + if (temp > '@') { l += temp; - temp='@'; + temp = '@'; } - l+=ch; + l += 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 (l.length() > 0 && l.toCharArray()[l.length() - 1] == '~') + l = l.substring(0, l.length() - 1); + if (l.length() == 0) + l = "E,"; + else { + l = "\"" + l + "\","; } - addMe+=l; - }else { - if(line.length()==0) - line="E,"; - else{ - line="\""+line+"\","; + addMe += l; + } else { + if (line.length() == 0) + line = "E,"; + else { + line = "\"" + line + "\","; } - addMe+=line; + addMe += line; } b--;//horizontal layer } - output.add(addMe+"},"); + output.add(addMe + "},"); c++;//depth } output.add("}"); @@ -569,7 +694,7 @@ public class Util { return true; } - public static String getUniqueIdentifier(ItemStack is){ - return GameRegistry.findUniqueIdentifierFor(is.getItem()).modId+":"+is.getUnlocalizedName(); + public static String getUniqueIdentifier(ItemStack is) { + return GameRegistry.findUniqueIdentifierFor(is.getItem()).modId + ":" + is.getUnlocalizedName(); } } diff --git a/src/main/java/com/github/technus/tectech/auxiliary/TecTechConfig.java b/src/main/java/com/github/technus/tectech/auxiliary/TecTechConfig.java index 036d7d6784..633bbc5097 100644 --- a/src/main/java/com/github/technus/tectech/auxiliary/TecTechConfig.java +++ b/src/main/java/com/github/technus/tectech/auxiliary/TecTechConfig.java @@ -11,7 +11,7 @@ public class TecTechConfig extends ConfigManager { public boolean ModAdminErrorLogs_Enabled; - //final static to allow compiler to remove the debug code when this is false + //final static to allow compiler to remove the debug code when this is false public static final boolean DEBUG_MODE = true; public boolean BOOM_ENABLE; public boolean NERF_FUSION; 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 9e304b1694..30f26a6caf 100644 --- a/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java +++ b/src/main/java/com/github/technus/tectech/dataFramework/quantumDataPacket.java @@ -3,6 +3,7 @@ package com.github.technus.tectech.dataFramework; import com.github.technus.tectech.vec3pos; import net.minecraft.nbt.NBTTagCompound; +import java.util.LinkedHashSet; import java.util.Set; import java.util.TreeSet; @@ -10,67 +11,67 @@ import java.util.TreeSet; * Created by Tec on 05.04.2017. */ public class quantumDataPacket { - public static byte maxHistory =64; + public static byte maxHistory = 64; - public long computation=0; - public Set<vec3pos> trace=new TreeSet<>(); + public long computation = 0; + public Set<vec3pos> trace = new LinkedHashSet<>(); - public quantumDataPacket(vec3pos pos,long computation){ - this.computation=computation; + public quantumDataPacket(vec3pos pos, long computation) { + this.computation = computation; trace.add(pos); } - public quantumDataPacket(quantumDataPacket q,long computation){ - this.computation=computation; + public quantumDataPacket(quantumDataPacket q, long computation) { + this.computation = computation; trace.addAll(q.trace); } - public quantumDataPacket(NBTTagCompound nbt){ - computation=nbt.getLong("qComputation"); - for(int i=0;i<nbt.getByte("qHistory");i++){ + public quantumDataPacket(NBTTagCompound nbt) { + computation = nbt.getLong("qComputation"); + for (int i = 0; i < nbt.getByte("qHistory"); i++) { trace.add(new vec3pos( - nbt.getInteger("qX"+i), - nbt.getShort("qY"+i), - nbt.getInteger("qZ"+i) + nbt.getInteger("qX" + i), + nbt.getShort("qY" + i), + nbt.getInteger("qZ" + i) )); } } - public NBTTagCompound toNbt(){ - NBTTagCompound nbt=new NBTTagCompound(); - nbt.setLong("qComputation",computation); - nbt.setByte("qHistory", (byte)trace.size()); - int i=0; - for(vec3pos v:trace){ - nbt.setInteger("qX"+i,v.x); - nbt.setShort("qY"+i,v.y); - nbt.setInteger("qZ"+i,v.z); + public NBTTagCompound toNbt() { + NBTTagCompound nbt = new NBTTagCompound(); + nbt.setLong("qComputation", computation); + nbt.setByte("qHistory", (byte) trace.size()); + int i = 0; + for (vec3pos v : trace) { + nbt.setInteger("qX" + i, v.x); + nbt.setShort("qY" + i, v.y); + nbt.setInteger("qZ" + i, v.z); i++; } return nbt; } - public boolean contains(vec3pos v){ + public boolean contains(vec3pos v) { return trace.contains(v); } - public boolean check(){ - return trace.size()<=maxHistory; + public boolean check() { + return trace.size() <= maxHistory; } - public quantumDataPacket unifyTraceWith(quantumDataPacket p){ + public quantumDataPacket unifyTraceWith(quantumDataPacket p) { trace.addAll(p.trace); - return check()?this:null; + return check() ? this : null; } - public quantumDataPacket unifyPacketWith(quantumDataPacket p){ - computation+=p.computation; + public quantumDataPacket unifyPacketWith(quantumDataPacket p) { + computation += p.computation; trace.addAll(p.trace); - return check()?this:null; + return check() ? this : null; } - public long computationIfNotContained(vec3pos pos){ - if(trace.contains(pos))return 0; + public long computationIfNotContained(vec3pos pos) { + if (trace.contains(pos)) return 0; return computation; } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDecay.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDecay.java index 7891c273ba..19d3b1566b 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDecay.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDecay.java @@ -12,7 +12,7 @@ public final class cElementalDecay { //Or cast null into ARRAY type but this static is more convenient!!! public static final cElementalDecay[] noProduct = new cElementalDecay[0]; //this in turn can be used to tell that the thing should just vanish - public final cElementalMutableDefinitionStackMap outputStacks; + public final cElementalDefinitionStackMap outputStacks; public final float probability; public cElementalDecay(iElementalDefinition... outSafe) { @@ -24,7 +24,7 @@ public final class cElementalDecay { for (int i = 0; i < outArr.length; i++) { outArr[i] = new cElementalDefinitionStack(outSafe[i], 1); } - this.outputStacks = new cElementalMutableDefinitionStackMap(outArr); + this.outputStacks = new cElementalDefinitionStackMap(outArr); this.probability = probability; } @@ -33,15 +33,15 @@ public final class cElementalDecay { } public cElementalDecay(float probability, cElementalDefinitionStack... out) { - this.outputStacks = new cElementalMutableDefinitionStackMap(out); + this.outputStacks = new cElementalDefinitionStackMap(out); this.probability = probability; } - public cElementalDecay(cElementalMutableDefinitionStackMap tree) { + public cElementalDecay(cElementalDefinitionStackMap tree) { this(2F, tree); } - public cElementalDecay(float probability, cElementalMutableDefinitionStackMap tree) { + public cElementalDecay(float probability, cElementalDefinitionStackMap tree) { this.outputStacks = tree; this.probability = probability; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinition.java index 8cf92f20fd..88c4fb7f8b 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinition.java @@ -20,6 +20,7 @@ public abstract class cElementalDefinition implements iElementalDefinition { //add text based creators for recipe formula input? private static final Map<Byte, Method> nbtCreationBind = new HashMap<>();//creator methods in subclasses + protected static Method addCreatorFromNBT(byte b, Method m) { return nbtCreationBind.put(b, m); } @@ -39,39 +40,30 @@ public abstract class cElementalDefinition implements iElementalDefinition { } @Override - public final boolean equals(Object obj) { - if (obj instanceof iElementalDefinition) - return compareTo((iElementalDefinition) obj) == 0; - if (obj instanceof iHasElementalDefinition) - return compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; - return false; - } - - @Override public int compareTo(iElementalDefinition o) { - if (getClassType() == o.getClassType()) { - //only of the internal def stacks!!! - //that allows neat check if the same thing and - //top hierarchy amount can be used to store amount info - return compareDefinitionStacksWithAmount(getSubParticles().values(), o.getSubParticles().values()); - } - return compareClasses(o); + final int classCompare = compareClassID(o); + if (classCompare != 0) return classCompare; + + //only of the internal def stacks!!! + //that allows neat check if the same thing and + //top hierarchy amount can be used to store amount info + return compareInnerContentsWithAmounts(getSubParticles().values(), o.getSubParticles().values()); } - public final int compareClasses(iElementalDefinition obj) { + public final int compareClassID(iElementalDefinition obj) { return ((int) getClassType()) - obj.getClassType(); } //use only for nested operations! - private static int compareDefinitionStacksWithAmount(cElementalDefinitionStack[] tc, cElementalDefinitionStack[] sc) { + private static int compareInnerContentsWithAmounts(cElementalDefinitionStack[] tc, cElementalDefinitionStack[] sc) { if (tc == null) { if (sc == null) return 0; else return -1; } if (sc == null) return 1; - if (tc.length > sc.length) return 1; - if (tc.length < sc.length) return -1; + final 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); @@ -84,11 +76,19 @@ public abstract class cElementalDefinition implements iElementalDefinition { } @Override - public int hashCode() { - int hash=Integer.MIN_VALUE+getSubParticles().size(); - int i=9; - for(cElementalDefinitionStack s:getSubParticles().values()){ - hash+=s.hashCode()*(i++); + public final boolean equals(Object obj) { + if (obj instanceof iElementalDefinition) + return compareTo((iElementalDefinition) obj) == 0; + 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(); } return hash; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinitionStack.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinitionStack.java index daaa0ebc2c..66da8e4eb4 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinitionStack.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinitionStack.java @@ -9,7 +9,7 @@ import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveD /** * Created by danie_000 on 20.11.2016. */ -public final class cElementalDefinitionStack implements iHasElementalDefinition {//TODO unify checks for amount? +public final class cElementalDefinitionStack implements iHasElementalDefinition { public final iElementalDefinition definition; public final int amount; @@ -41,20 +41,6 @@ public final class cElementalDefinitionStack implements iHasElementalDefinition return definition.getMass() * amount; } - @Override - public int compareTo(iHasElementalDefinition o) { - return definition.compareTo(o.getDefinition()); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof iElementalDefinition) - return definition.compareTo((iElementalDefinition) obj) == 0; - if (obj instanceof iHasElementalDefinition) - return definition.compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; - return false; - } - public NBTTagCompound toNBT() { NBTTagCompound nbt = new NBTTagCompound(); nbt.setTag("d", definition.toNBT()); @@ -68,15 +54,33 @@ public final class cElementalDefinitionStack implements iHasElementalDefinition nbt.getInteger("q")); } - public cElementalDefinitionStack unifyIntoNew(cElementalDefinitionStack... other) { - if (other == null) return this; - int i = amount; + public cElementalDefinitionStack addAmountIntoNewInstance(int amount) { + return new cElementalDefinitionStack(definition, amount + this.amount); + } + + public cElementalDefinitionStack addAmountIntoNewInstance(cElementalDefinitionStack... other) { + if (other == null || other.length == 0) return this; + int i = 0; for (cElementalDefinitionStack stack : other) - if (stack != null) - i += stack.amount; - return new cElementalDefinitionStack(definition, i); + i += stack.amount; + return addAmountIntoNewInstance(i); + } + + @Override + public int compareTo(iHasElementalDefinition o) { + return definition.compareTo(o.getDefinition()); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof iElementalDefinition) + return definition.compareTo((iElementalDefinition) obj) == 0; + if (obj instanceof iHasElementalDefinition) + return definition.compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; + return false; } + //Amount shouldn't be hashed if this is just indicating amount and not structure @Override public int hashCode() { return definition.hashCode(); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinitionStackMap.java index 436f37eccc..0b9aefa8fb 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinitionStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalDefinitionStackMap.java @@ -3,7 +3,6 @@ package com.github.technus.tectech.elementalMatter.classes; import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; import net.minecraft.nbt.NBTTagCompound; -import java.util.Map; import java.util.TreeMap; import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveDefinition.nbtE__; @@ -11,26 +10,29 @@ import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveD /** * Created by Tec on 12.05.2017. */ -public final class cElementalDefinitionStackMap/*IMMUTABLE*/ extends cElementalStackMap { +public final class cElementalDefinitionStackMap/*IMMUTABLE*/ extends cElementalStackMap {//Target class for construction of definitions/recipes //Constructors + Clone, all make a whole new OBJ. + public static final cElementalDefinitionStackMap empty = new cElementalDefinitionStackMap(); + + private cElementalDefinitionStackMap() { + map = new TreeMap<>(); + } @Deprecated public cElementalDefinitionStackMap(iElementalDefinition... in) { - map=new TreeMap<>(); + map = new TreeMap<>(); for (iElementalDefinition definition : in) map.put(definition, new cElementalDefinitionStack(definition, 1)); } public cElementalDefinitionStackMap(cElementalDefinitionStack... in) { - map=new TreeMap<>(); + map = new TreeMap<>(); for (cElementalDefinitionStack stack : in) map.put(stack.definition, stack); } - public cElementalDefinitionStackMap(Map<iElementalDefinition, cElementalDefinitionStack> in) { - map = new TreeMap<>(); - for (cElementalDefinitionStack stack : in.values()) - map.put(stack.definition, stack); + public cElementalDefinitionStackMap(TreeMap<iElementalDefinition, cElementalDefinitionStack> in) { + map = new TreeMap<>(in); } //IMMUTABLE DON'T NEED IT @@ -39,14 +41,14 @@ public final class cElementalDefinitionStackMap/*IMMUTABLE*/ extends cElementalS return this; } - public cElementalMutableDefinitionStackMap toMutable() { + public cElementalMutableDefinitionStackMap constructMutable() { return new cElementalMutableDefinitionStackMap(map); } @Override - @Deprecated - public Map<iElementalDefinition,cElementalDefinitionStack> getRawMap() { - return toMutable().getRawMap(); + @Deprecated//BETTER TO JUST MAKE A MUTABLE VERSION AND DO SHIT ON IT + public TreeMap<iElementalDefinition, cElementalDefinitionStack> getRawMap() { + return constructMutable().getRawMap(); } public static cElementalDefinitionStackMap fromNBT(NBTTagCompound nbt) throws tElementalException { diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStack.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStack.java index 2a2c6d12e1..b511813757 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStack.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStack.java @@ -10,7 +10,7 @@ import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveD /** * Created by danie_000 on 22.10.2016. */ -public final class cElementalInstanceStack implements iHasElementalDefinition {//TODO unify checks for amount? +public final class cElementalInstanceStack implements iHasElementalDefinition { public final iElementalDefinition definition; //energy - if positive then particle should try to decay public int energy; @@ -49,14 +49,14 @@ public final class cElementalInstanceStack implements iHasElementalDefinition {/ } //Clone proxy - private cElementalInstanceStack(cElementalInstanceStack stack){ - definition=stack.definition; - energy=stack.energy; - color=stack.color; - age=stack.age; - amount=stack.amount; - lifeTime=stack.lifeTime; - lifeTimeMult=stack.lifeTimeMult; + private cElementalInstanceStack(cElementalInstanceStack stack) { + definition = stack.definition; + energy = stack.energy; + color = stack.color; + age = stack.age; + amount = stack.amount; + lifeTime = stack.lifeTime; + lifeTimeMult = stack.lifeTimeMult; } @Override @@ -91,12 +91,12 @@ 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; + if (this.color < 0 || this.color > 2) return this.color; return this.color = (byte) (TecTech.Rnd.nextInt(3)); } @@ -208,20 +208,6 @@ public final class cElementalInstanceStack implements iHasElementalDefinition {/ } } - @Override - public int compareTo(iHasElementalDefinition o) {//use for unification - return definition.compareTo(o.getDefinition()); - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof iElementalDefinition) - return definition.compareTo((iElementalDefinition) obj) == 0; - if (obj instanceof iHasElementalDefinition) - return definition.compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; - return false; - } - public cElementalInstanceStack unifyIntoThis(cElementalInstanceStack... instances) { if (instances == null) return this; //returns with the definition from the first object passed @@ -268,6 +254,21 @@ public final class cElementalInstanceStack implements iHasElementalDefinition {/ } @Override + public int compareTo(iHasElementalDefinition o) {//use for unification + return definition.compareTo(o.getDefinition()); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof iElementalDefinition) + return definition.compareTo((iElementalDefinition) obj) == 0; + if (obj instanceof iHasElementalDefinition) + return definition.compareTo(((iHasElementalDefinition) obj).getDefinition()) == 0; + return false; + } + + //Amount shouldn't be hashed if this is just indicating amount and not structure, DOES NOT CARE ABOUT INSTANCE INFO + @Override public int hashCode() { return definition.hashCode(); } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStackMap.java index ebbd80c07b..bde93295ad 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalInstanceStackMap.java @@ -5,6 +5,8 @@ import com.github.technus.tectech.elementalMatter.interfaces.iHasElementalDefini import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -14,7 +16,7 @@ import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveD * Created by danie_000 on 22.01.2017. */ public final class cElementalInstanceStackMap implements Comparable<cElementalInstanceStackMap> { - private Map<iElementalDefinition, cElementalInstanceStack> map = new TreeMap<>(); + private TreeMap<iElementalDefinition, cElementalInstanceStack> map = new TreeMap<>(); //Constructors public cElementalInstanceStackMap() { @@ -36,11 +38,11 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } } - private cElementalInstanceStackMap(Map<iElementalDefinition, cElementalInstanceStack> inSafe) { + private cElementalInstanceStackMap(TreeMap<iElementalDefinition, cElementalInstanceStack> inSafe) { this(true, inSafe); } - private cElementalInstanceStackMap(boolean clone, Map<iElementalDefinition, cElementalInstanceStack> in) { + private cElementalInstanceStackMap(boolean clone, TreeMap<iElementalDefinition, cElementalInstanceStack> in) { if (clone) { for (cElementalInstanceStack instance : in.values()) { map.put(instance.definition, instance.clone()); @@ -59,24 +61,32 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn } @Override - public final cElementalInstanceStackMap clone(){ + public final cElementalInstanceStackMap clone() { return new cElementalInstanceStackMap(map); } - @Deprecated - public Map<iElementalDefinition,cElementalInstanceStack> getRawMap() { - return map; + public final cElementalStackMap toDefinitionMapForComparison() { + cElementalDefinitionStack[] list = new cElementalDefinitionStack[map.size()]; + int i = 0; + for (cElementalInstanceStack stack : map.values()) { + list[i++] = new cElementalDefinitionStack(stack.definition, stack.amount); + } + return new cElementalMutableDefinitionStackMap(list); } - @Override - public int compareTo(cElementalInstanceStackMap o) { - if (map.size() != o.map.size()) return map.size() - o.map.size(); - 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; + @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)); } - return 0; + if (mutable) return new cElementalMutableDefinitionStackMap(newMap); + return new cElementalDefinitionStackMap(newMap); + } + + @Deprecated + public Map<iElementalDefinition, cElementalInstanceStack> getRawMap() { + return map; } //Removers @@ -176,7 +186,7 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn return removeAllAmounts(testOnly, stacks); } - public boolean removeAllAmounts(boolean testOnly, cElementalMutableDefinitionStackMap container) { + public boolean removeAllAmounts(boolean testOnly, cElementalStackMap container) { return removeAllAmounts(testOnly, container.values()); } @@ -362,4 +372,34 @@ public final class cElementalInstanceStackMap implements Comparable<cElementalIn 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; + 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; + } + return 0; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof cElementalInstanceStackMap) + return compareTo((cElementalInstanceStackMap) obj) == 0; + if (obj instanceof cElementalStackMap) + return toDefinitionMapForComparison().compareTo((cElementalStackMap) obj) == 0; + return false; + } + + @Override + public int hashCode() {//Internal amounts should be also hashed + int hash = -(map.size() << 4); + for (cElementalInstanceStack s : map.values()) { + hash += s.definition.hashCode(); + } + return hash; + } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalMutableDefinitionStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalMutableDefinitionStackMap.java index 8e62b47647..dae1365ea1 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalMutableDefinitionStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalMutableDefinitionStackMap.java @@ -12,42 +12,40 @@ import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveD /** * Created by danie_000 on 22.01.2017. */ -public final class cElementalMutableDefinitionStackMap extends cElementalStackMap { +public final class cElementalMutableDefinitionStackMap extends cElementalStackMap {//Transient class for construction of definitions/recipes //Constructors + Clone, all make a whole new OBJ. public cElementalMutableDefinitionStackMap() { - map=new TreeMap<>(); + map = new TreeMap<>(); } @Deprecated public cElementalMutableDefinitionStackMap(iElementalDefinition... in) { - map=new TreeMap<>(); + map = new TreeMap<>(); for (iElementalDefinition definition : in) map.put(definition, new cElementalDefinitionStack(definition, 1)); } public cElementalMutableDefinitionStackMap(cElementalDefinitionStack... in) { - map=new TreeMap<>(); + map = new TreeMap<>(); for (cElementalDefinitionStack stack : in) map.put(stack.definition, stack); } - public cElementalMutableDefinitionStackMap(Map<iElementalDefinition, cElementalDefinitionStack> in) { - this(true,in); + public cElementalMutableDefinitionStackMap(TreeMap<iElementalDefinition, cElementalDefinitionStack> in) { + this(true, in); } - public cElementalMutableDefinitionStackMap(boolean clone, Map<iElementalDefinition, cElementalDefinitionStack> in) { + public cElementalMutableDefinitionStackMap(boolean clone, TreeMap<iElementalDefinition, cElementalDefinitionStack> in) { if (clone) { - map = new TreeMap<>(); - for (cElementalDefinitionStack stack : in.values()) - map.put(stack.definition, stack); + map = new TreeMap<>(in); } else { map = in; } } @Override - public cElementalMutableDefinitionStackMap clone(){ + public cElementalMutableDefinitionStackMap clone() { return new cElementalMutableDefinitionStackMap(map); } @@ -57,7 +55,7 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa @Override @Deprecated - public Map<iElementalDefinition,cElementalDefinitionStack> getRawMap() { + public TreeMap<iElementalDefinition, cElementalDefinitionStack> getRawMap() { return map; } @@ -159,7 +157,7 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa return removeAllAmounts(testOnly, stacks); } - public boolean removeAllAmounts(boolean testOnly, cElementalMutableDefinitionStackMap container) { + public boolean removeAllAmounts(boolean testOnly, cElementalStackMap container) { return removeAllAmounts(testOnly, container.values()); } @@ -177,13 +175,13 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa this.map.put(defStack.definition, defStack); } - public void putReplaceAll(cElementalMutableDefinitionStackMap inContainerUnsafe) { + public void putReplaceAll(cElementalStackMap inContainerUnsafe) { this.map.putAll(inContainerUnsafe.map); } //Put unify public cElementalDefinitionStack putUnify(cElementalDefinitionStack def) { - return map.put(def.definition, def.unifyIntoNew(map.get(def.definition))); + return map.put(def.definition, def.addAmountIntoNewInstance(map.get(def.definition))); } @Deprecated @@ -207,7 +205,7 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa putUnify(in); } - public void putUnifyAll(cElementalMutableDefinitionStackMap containerUnsafe) { + public void putUnifyAll(cElementalStackMap containerUnsafe) { for (cElementalDefinitionStack in : containerUnsafe.map.values()) putUnify(in); } @@ -221,4 +219,20 @@ public final class cElementalMutableDefinitionStackMap extends cElementalStackMa } return new cElementalMutableDefinitionStackMap(defStacks); } + + //stackUp + @Deprecated + public static cElementalMutableDefinitionStackMap stackUpMap(iElementalDefinition... in) { + final cElementalMutableDefinitionStackMap inTree = new cElementalMutableDefinitionStackMap(); + for (iElementalDefinition def : in) { + inTree.putUnify(new cElementalDefinitionStack(def, 1)); + } + return inTree; + } + + public static cElementalMutableDefinitionStackMap stackUpMap(cElementalDefinitionStack... in) { + final cElementalMutableDefinitionStackMap inTree = new cElementalMutableDefinitionStackMap(); + inTree.putUnifyAll(in); + return inTree; + } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalPrimitive.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalPrimitive.java index 7e86852c34..ed5d8624ba 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalPrimitive.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalPrimitive.java @@ -36,7 +36,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { public final byte color; //-1/-2/-3 anti matter generations, +1/+2/+3 matter generations, 0 self anti public final byte type; - + private cElementalPrimitive anti;//IMMUTABLE private cElementalDecay[] elementalDecays; private byte naturalDecayInstant; @@ -123,7 +123,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } @Override - public final cElementalMutableDefinitionStackMap getSubParticles() { + public final cElementalDefinitionStackMap getSubParticles() { return null; } @@ -151,8 +151,8 @@ public abstract class cElementalPrimitive extends cElementalDefinition { } public static iElementalDefinition fromNBT(NBTTagCompound content) { - iElementalDefinition primitive= bindsBO.get(content.getInteger("c")); - return primitive==null?null__:primitive; + iElementalDefinition primitive = bindsBO.get(content.getInteger("c")); + return primitive == null ? null__ : primitive; } @Override @@ -160,6 +160,14 @@ public abstract class cElementalPrimitive extends cElementalDefinition { return -128; } + public static void run() { + try { + cElementalDefinition.addCreatorFromNBT(nbtType, cElementalPrimitive.class.getMethod("fromNBT", NBTTagCompound.class)); + } catch (Exception e) { + if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); + } + } + @Override public final int compareTo(iElementalDefinition o) { if (getClassType() == o.getClassType()) { @@ -168,15 +176,7 @@ public abstract class cElementalPrimitive extends cElementalDefinition { if (ID < oID) return -1; return 0; } - return compareClasses(o); - } - - public static void run() { - try { - cElementalDefinition.addCreatorFromNBT(nbtType, cElementalPrimitive.class.getMethod("fromNBT", NBTTagCompound.class)); - } catch (Exception e) { - if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); - } + return compareClassID(o); } @Override diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalStackMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalStackMap.java index 192a3b24d0..6c130e0d8e 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalStackMap.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/cElementalStackMap.java @@ -4,31 +4,19 @@ import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinitio import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; -import java.util.Map; - -import static com.github.technus.tectech.elementalMatter.definitions.cPrimitiveDefinition.nbtE__; +import java.util.TreeMap; /** * Created by Tec on 12.05.2017. */ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { - protected Map<iElementalDefinition, cElementalDefinitionStack> map; - - public int compareTo(cElementalStackMap o) { - if (map.size() != o.map.size()) return map.size() - o.map.size(); - cElementalDefinitionStack[] 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; - } - return 0; - } + protected TreeMap<iElementalDefinition, cElementalDefinitionStack> map; @Override public abstract cElementalStackMap clone(); @Deprecated - public abstract Map<iElementalDefinition,cElementalDefinitionStack> getRawMap(); + public abstract TreeMap<iElementalDefinition, cElementalDefinitionStack> getRawMap(); //Getters public final cElementalDefinitionStack getDefinitionStack(iElementalDefinition def) { @@ -72,22 +60,6 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { return map.size() > 0; } - //stackUp - @Deprecated - public static cElementalMutableDefinitionStackMap stackUpTree(iElementalDefinition... in) { - final cElementalMutableDefinitionStackMap inTree = new cElementalMutableDefinitionStackMap(); - for (iElementalDefinition def : in) { - inTree.putUnify(new cElementalDefinitionStack(def, 1)); - } - return inTree; - } - - public static cElementalMutableDefinitionStackMap stackUpTree(cElementalDefinitionStack... in) { - final cElementalMutableDefinitionStackMap inTree = new cElementalMutableDefinitionStackMap(); - inTree.putUnifyAll(in); - return inTree; - } - //NBT public final NBTTagCompound getInfoNBT() { final NBTTagCompound nbt = new NBTTagCompound(); @@ -113,4 +85,34 @@ abstract class cElementalStackMap implements Comparable<cElementalStackMap> { 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; + 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; + } + return 0; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof cElementalStackMap) + return compareTo((cElementalStackMap) obj) == 0; + if (obj instanceof cElementalInstanceStackMap) + return compareTo(((cElementalInstanceStackMap) obj).toDefinitionMapForComparison()) == 0; + return false; + } + + @Override + public 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(); + } + return hash; + } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipe.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipe.java index c8222ef583..4bd94bf5b4 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipe.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipe.java @@ -7,24 +7,24 @@ import net.minecraftforge.fluids.FluidStack; * Created by Tec on 02.03.2017. */ public class rElementalRecipe implements Comparable<rElementalRecipe> { - public final cElementalMutableDefinitionStackMap inEM; - public final cElementalMutableDefinitionStackMap outEM; + public final short ID; + public final cElementalDefinitionStackMap inEM; + public final cElementalDefinitionStackMap outEM; public final ItemStack[] outItems; public final FluidStack[] outFluids; public Object[] extension = null; - public final short comparableID; public rElementalRecipe( - cElementalMutableDefinitionStackMap inEMnotNull, - short comparableID, - cElementalMutableDefinitionStackMap outEM, + cElementalDefinitionStackMap inEM,//not null plz + short id, + cElementalDefinitionStackMap outEM, ItemStack[] outItems, FluidStack[] outFluids) { - this.inEM = inEMnotNull; - this.comparableID=comparableID;//allows multiple recipes with the same input EM + this.inEM = inEM; 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... } public rElementalRecipe extend(Object... data) { @@ -34,13 +34,19 @@ public class rElementalRecipe implements Comparable<rElementalRecipe> { @Override public int compareTo(rElementalRecipe o) { - final int compare=inEM.compareTo(o.inEM); - if(compare!=0)return compare; - return (int)comparableID-o.comparableID; + final int compare = inEM.compareTo(o.inEM); + return compare != 0 ? compare : (int) ID - o.ID; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof rElementalRecipe) + return compareTo((rElementalRecipe) obj) == 0; + return false; } @Override public int hashCode() { - return comparableID; + return inEM.hashCode(); } } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeMap.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeMap.java new file mode 100644 index 0000000000..6301127472 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeMap.java @@ -0,0 +1,64 @@ +package com.github.technus.tectech.elementalMatter.classes; + +import java.util.HashMap; +import java.util.Map; +import java.util.TreeMap; + +/** + * Created by Tec on 02.03.2017. + */ +public class rElementalRecipeMap {//TODO FIX + //Multimap for multiple recipes from the same thing - you know parameters might differ the output + private final HashMap<cElementalDefinitionStackMap, HashMap<Short, rElementalRecipe>> recipes; + + public rElementalRecipeMap() { + recipes = new HashMap<>(); + } + + public rElementalRecipe put(rElementalRecipe in) { + HashMap<Short, rElementalRecipe> r = recipes.get(in.inEM); + if (r == null) { + r = new HashMap<>(); + recipes.put(in.inEM, r); + } + return r.put(in.ID, in);//IF THIS RETURN SHIT, it means that inputs are using the exact same types of matter as input - (non amount wise collision) + //It is either bad, or unimportant if you use different id's + } + + public void putAll(rElementalRecipe... contents) { + for (rElementalRecipe recipe : contents) + put(recipe); + } + + public rElementalRecipe remove(cElementalInstanceStackMap map, short id) { + return recipes.get(map).remove(id); + } + + public HashMap<Short, rElementalRecipe> remove(cElementalInstanceStackMap map) { + return recipes.remove(map); + } + + //Recipe founding should not check amounts + + public HashMap<Short, rElementalRecipe> findExact(cElementalStackMap in) { + return recipes.get(in);//suspicious but ok + } + + public HashMap<Short, rElementalRecipe> findExact(cElementalInstanceStackMap in) { + return recipes.get(in);//suspicious but ok + } + + public HashMap<Short, rElementalRecipe> findMatch(cElementalMutableDefinitionStackMap in) { + for (cElementalDefinitionStackMap requirement : recipes.keySet()) + if (in.removeAllAmounts(true, requirement)) + return recipes.get(requirement); + 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); + return null; + } +} diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeTree.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeTree.java deleted file mode 100644 index 0834d2e49e..0000000000 --- a/src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeTree.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.github.technus.tectech.elementalMatter.classes; - -import java.util.Map; -import java.util.TreeMap; - -/** - * Created by Tec on 02.03.2017. - */ -public class rElementalRecipeTree { - //Multimap for multiple recipes from the same thing - you know parameters might differ the output - private TreeMap<cElementalMutableDefinitionStackMap, Map<Short,rElementalRecipe> > recipes = new TreeMap<>(); - - public rElementalRecipeTree() {} - - public rElementalRecipe put(rElementalRecipe in) { - Map<Short, rElementalRecipe> r=recipes.get(in.inEM); - if(r==null){ - r=new TreeMap<>(); - recipes.put(in.inEM,r); - } - return r.put(in.comparableID, in); - } - - public void putAll(rElementalRecipe... contents) { - for (rElementalRecipe recipe : contents) - put(recipe); - } - - public Map<Short,rElementalRecipe> findExact(cElementalMutableDefinitionStackMap in) { - return recipes.get(in); - } - - public Map<Short,rElementalRecipe> findTopMatch(cElementalMutableDefinitionStackMap in) { - for (cElementalMutableDefinitionStackMap requirement : recipes.descendingKeySet()) - if (in.removeAllAmounts(true, requirement)) - return recipes.get(requirement); - return null; - } - - public Map<Short,rElementalRecipe> findTopMatch(cElementalInstanceStackMap in, boolean testOnly) { - for (cElementalMutableDefinitionStackMap requirement : recipes.descendingKeySet()) - if (in.removeAllAmounts(testOnly, requirement)) - return recipes.get(requirement); - return null; - } - - public Map<Short,rElementalRecipe> findBottomMatch(cElementalMutableDefinitionStackMap in) { - for (cElementalMutableDefinitionStackMap requirement : recipes.keySet()) - if (in.removeAllAmounts(true, requirement)) - return recipes.get(requirement); - return null; - } - - public Map<Short,rElementalRecipe> findBottomMatch(cElementalInstanceStackMap in, boolean testOnly) { - for (cElementalMutableDefinitionStackMap requirement : recipes.keySet()) - if (in.removeAllAmounts(testOnly, requirement)) - return recipes.get(requirement); - return null; - } -} diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/classes/tElementalRecipeCollision.java b/src/main/java/com/github/technus/tectech/elementalMatter/classes/tElementalRecipeCollision.java new file mode 100644 index 0000000000..a7ffa8c808 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/elementalMatter/classes/tElementalRecipeCollision.java @@ -0,0 +1,10 @@ +package com.github.technus.tectech.elementalMatter.classes; + +/** + * Created by danie_000 on 19.11.2016. + */ +public final class tElementalRecipeCollision extends Exception { + public tElementalRecipeCollision(String message) { + super(message); + } +} diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dAtomDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dAtomDefinition.java index 9086ea80eb..70c869c8ea 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dAtomDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dAtomDefinition.java @@ -11,14 +11,14 @@ import net.minecraftforge.fluids.FluidStack; import java.util.*; -import static com.github.technus.tectech.elementalMatter.classes.cElementalMutableDefinitionStackMap.stackUpTree; +import static com.github.technus.tectech.elementalMatter.classes.cElementalMutableDefinitionStackMap.stackUpMap; import static com.github.technus.tectech.elementalMatter.definitions.eBosonDefinition.boson_Y__; import static com.github.technus.tectech.elementalMatter.definitions.eBosonDefinition.deadEnd; /** * Created by danie_000 on 18.11.2016. */ -public final class dAtomDefinition extends cElementalDefinition { +public final class dAtomDefinition extends cElementalDefinition {//TODO Optimize map i/o public static final Map<dAtomDefinition, ItemStack> itemBinds = new TreeMap<>(); public static final Map<dAtomDefinition, FluidStack> fluidBinds = new TreeMap<>(); @@ -48,7 +48,7 @@ public final class dAtomDefinition extends cElementalDefinition { public final int isotope; public final int element; - private final cElementalMutableDefinitionStackMap elementalStacks;//CLONED I/O + private final cElementalDefinitionStackMap elementalStacks;//CLONED I/O //stable is rawLifeTime>=10^9 @@ -57,29 +57,29 @@ public final class dAtomDefinition extends cElementalDefinition { @Deprecated public dAtomDefinition(iElementalDefinition... things) throws tElementalException { - this(false, true, stackUpTree(things)); + this(false, true, stackUpMap(things).toImmutable()); } @Deprecated private dAtomDefinition(boolean check, iElementalDefinition... things) throws tElementalException { - this(false, check, stackUpTree(things)); + this(false, check, stackUpMap(things).toImmutable()); } public dAtomDefinition(cElementalDefinitionStack... things) throws tElementalException { - this(false, true, stackUpTree(things)); + this(false, true, stackUpMap(things).toImmutable()); } private dAtomDefinition(boolean check, cElementalDefinitionStack... things) throws tElementalException { - this(false, check, stackUpTree(things)); + this(false, check, stackUpMap(things).toImmutable()); } - public dAtomDefinition(cElementalMutableDefinitionStackMap things) throws tElementalException { - this(true, true, things); + public dAtomDefinition(cElementalDefinitionStackMap things) throws tElementalException { + this(false, true, things); } - private dAtomDefinition(boolean clone, boolean check, cElementalMutableDefinitionStackMap things) throws tElementalException { + private dAtomDefinition(boolean clone, boolean check, cElementalDefinitionStackMap things) throws tElementalException { if (check && !canTheyBeTogether(things)) throw new tElementalException("Atom Definition error"); - this.elementalStacks = clone?things.clone():things; + this.elementalStacks = clone ? things.clone() : things; float mass = 0; int cLeptons = 0; @@ -191,7 +191,7 @@ public final class dAtomDefinition extends cElementalDefinition { return rawLifeTime; } - private static boolean canTheyBeTogether(cElementalMutableDefinitionStackMap stacks) { + private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { boolean nuclei = false; for (cElementalDefinitionStack stack : stacks.values()) if (stack.definition instanceof dHadronDefinition) { @@ -274,7 +274,7 @@ public final class dAtomDefinition extends cElementalDefinition { } @Override - public cElementalMutableDefinitionStackMap getSubParticles() { + public cElementalDefinitionStackMap getSubParticles() { return elementalStacks.clone(); } @@ -306,7 +306,7 @@ public final class dAtomDefinition extends cElementalDefinition { try { return new cElementalDecay[]{ new cElementalDecay(0.5f, this), - new cElementalDecay(0.5f, new cElementalDefinitionStack(new dAtomDefinition(tree), 1), emit), + new cElementalDecay(0.5f, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable()), 1), emit), deadEnd }; } catch (Exception e) { @@ -322,7 +322,7 @@ public final class dAtomDefinition extends cElementalDefinition { try { return new cElementalDecay[]{ new cElementalDecay(0.5f, this), - new cElementalDecay(0.5f, new cElementalDefinitionStack(new dAtomDefinition(tree), 1), alpha), + new cElementalDecay(0.5f, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable()), 1), alpha), deadEnd }; } catch (Exception e) { @@ -339,7 +339,7 @@ public final class dAtomDefinition extends cElementalDefinition { tree.putUnify(dHadronDefinition.hadron_p1); return new cElementalDecay[]{ new cElementalDecay(0.5f, this), - new cElementalDecay(0.5f, new cElementalDefinitionStack(new dAtomDefinition(tree), 1), eLeptonDefinition.lepton_e1, eNeutrinoDefinition.lepton_Ve_1), + new cElementalDecay(0.5f, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable()), 1), eLeptonDefinition.lepton_e1, eNeutrinoDefinition.lepton_Ve_1), deadEnd }; } catch (Exception e) { @@ -356,7 +356,7 @@ public final class dAtomDefinition extends cElementalDefinition { tree.putUnify(dHadronDefinition.hadron_n1); return new cElementalDecay[]{ new cElementalDecay(0.5f, this), - new cElementalDecay(0.5f, new cElementalDefinitionStack(new dAtomDefinition(tree), 1), eLeptonDefinition.lepton_e_1, eNeutrinoDefinition.lepton_Ve1), + new cElementalDecay(0.5f, new cElementalDefinitionStack(new dAtomDefinition(tree.toImmutable()), 1), eLeptonDefinition.lepton_e_1, eNeutrinoDefinition.lepton_Ve1), deadEnd }; } catch (Exception e) { diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dHadronDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dHadronDefinition.java index dadd3e7c79..723d71d6ea 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dHadronDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dHadronDefinition.java @@ -11,13 +11,13 @@ import java.util.ArrayList; import java.util.Map; import java.util.TreeMap; -import static com.github.technus.tectech.elementalMatter.classes.cElementalMutableDefinitionStackMap.stackUpTree; +import static com.github.technus.tectech.elementalMatter.classes.cElementalMutableDefinitionStackMap.stackUpMap; import static com.github.technus.tectech.elementalMatter.definitions.eBosonDefinition.boson_Y__; /** * Created by danie_000 on 17.11.2016. */ -public final class dHadronDefinition extends cElementalDefinition { +public final class dHadronDefinition extends cElementalDefinition {//TODO Optimize map i/o public static final Map<dHadronDefinition, ItemStack> itemBinds = new TreeMap<>(); public static final Map<dHadronDefinition, FluidStack> fluidBinds = new TreeMap<>(); @@ -37,31 +37,31 @@ public final class dHadronDefinition extends cElementalDefinition { public final byte type; //private final FluidStack fluidThing; //private final ItemStack itemThing; - private final cElementalMutableDefinitionStackMap quarkStacks; + private final cElementalDefinitionStackMap quarkStacks; @Deprecated public dHadronDefinition(eQuarkDefinition... quarks) throws tElementalException { - this(true, stackUpTree(quarks)); + this(true, stackUpMap(quarks).toImmutable()); } @Deprecated private dHadronDefinition(boolean check, eQuarkDefinition... quarks) throws tElementalException { - this(check, stackUpTree(quarks)); + this(check, stackUpMap(quarks).toImmutable()); } public dHadronDefinition(cElementalDefinitionStack... quarks) throws tElementalException { - this(true, stackUpTree(quarks)); + this(true, stackUpMap(quarks).toImmutable()); } private dHadronDefinition(boolean check, cElementalDefinitionStack... quarks) throws tElementalException { - this(check, stackUpTree(quarks)); + this(check, stackUpMap(quarks).toImmutable()); } - public dHadronDefinition(cElementalMutableDefinitionStackMap quarks) throws tElementalException { + public dHadronDefinition(cElementalDefinitionStackMap quarks) throws tElementalException { this(true, quarks); } - private dHadronDefinition(boolean check, cElementalMutableDefinitionStackMap quarks) throws tElementalException { + private dHadronDefinition(boolean check, cElementalDefinitionStackMap quarks) throws tElementalException { if (check && !canTheyBeTogether(quarks)) throw new tElementalException("Hadron Definition error"); this.quarkStacks = quarks; @@ -97,7 +97,7 @@ public final class dHadronDefinition extends cElementalDefinition { } //public but u can just try{}catch(){} the constructor it still calls this method - private static boolean canTheyBeTogether(cElementalMutableDefinitionStackMap stacks) { + private static boolean canTheyBeTogether(cElementalDefinitionStackMap stacks) { int amount = 0; for (cElementalDefinitionStack quarks : stacks.values()) { if (!(quarks.definition instanceof eQuarkDefinition)) return false; @@ -155,7 +155,7 @@ public final class dHadronDefinition extends cElementalDefinition { } @Override - public cElementalMutableDefinitionStackMap getSubParticles() { + public cElementalDefinitionStackMap getSubParticles() { return quarkStacks; } @@ -254,7 +254,7 @@ public final class dHadronDefinition extends cElementalDefinition { for (cElementalDefinitionStack stack : quarkStacks.values()) anti.putReplace(new cElementalDefinitionStack(stack.definition.getAnti(), stack.amount)); try { - return new dHadronDefinition(anti); + return new dHadronDefinition(anti.toImmutable()); } catch (tElementalException e) { if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); return null; diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/interfaces/iElementalDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/interfaces/iElementalDefinition.java index cff7bd9697..5a2746dbf0 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/interfaces/iElementalDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/interfaces/iElementalDefinition.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.elementalMatter.interfaces; import com.github.technus.tectech.elementalMatter.classes.cElementalDecay; +import com.github.technus.tectech.elementalMatter.classes.cElementalDefinitionStackMap; import com.github.technus.tectech.elementalMatter.classes.cElementalMutableDefinitionStackMap; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -9,7 +10,8 @@ import net.minecraftforge.fluids.FluidStack; /** * Created by danie_000 on 11.11.2016. */ -public interface iElementalDefinition extends Comparable<iElementalDefinition> { +public interface iElementalDefinition extends Comparable<iElementalDefinition> {//IMMUTABLE + //Nomenclature String getName(); @@ -37,7 +39,7 @@ public interface iElementalDefinition extends Comparable<iElementalDefinition> { float getRawLifeTime();//defined in static fields or generated - cElementalMutableDefinitionStackMap getSubParticles();//contents... null if none + cElementalDefinitionStackMap getSubParticles();//contents... null if none ItemStack materializesIntoItem(); diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dComplexAspectDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/magicAddon/definitions/dComplexAspectDefinition.java index 033f611a07..f0dea5b14b 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/dComplexAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/magicAddon/definitions/dComplexAspectDefinition.java @@ -1,7 +1,8 @@ -package com.github.technus.tectech.elementalMatter.definitions; +package com.github.technus.tectech.elementalMatter.magicAddon.definitions; import com.github.technus.tectech.auxiliary.TecTechConfig; import com.github.technus.tectech.elementalMatter.classes.*; +import com.github.technus.tectech.elementalMatter.definitions.eBosonDefinition; import com.github.technus.tectech.elementalMatter.interfaces.iElementalDefinition; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -12,15 +13,15 @@ import static com.github.technus.tectech.elementalMatter.classes.cElementalDecay /** * Created by Tec on 06.05.2017. */ -public final class dComplexAspectDefinition extends cElementalDefinition { +public final class dComplexAspectDefinition extends cElementalDefinition {//TODO Optimize map i/o //TODO aspect binding private static final byte nbtType = (byte) 'c'; - private final cElementalMutableDefinitionStackMap aspectStacks; + private final cElementalDefinitionStackMap aspectStacks; - public dComplexAspectDefinition(cElementalDefinitionStack[] tree) throws tElementalException{//todo constructors - aspectStacks=new cElementalMutableDefinitionStackMap(); + public dComplexAspectDefinition(cElementalDefinitionStack[] tree) throws tElementalException {//todo constructors + aspectStacks = cElementalDefinitionStackMap.empty; } @Override @@ -81,7 +82,7 @@ public final class dComplexAspectDefinition extends cElementalDefinition { } @Override - public cElementalMutableDefinitionStackMap getSubParticles() { + public cElementalDefinitionStackMap getSubParticles() { return aspectStacks; } diff --git a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/ePrimalAspectDefinition.java b/src/main/java/com/github/technus/tectech/elementalMatter/magicAddon/definitions/ePrimalAspectDefinition.java index 38b23b7b37..9e11fe0022 100644 --- a/src/main/java/com/github/technus/tectech/elementalMatter/definitions/ePrimalAspectDefinition.java +++ b/src/main/java/com/github/technus/tectech/elementalMatter/magicAddon/definitions/ePrimalAspectDefinition.java @@ -1,4 +1,4 @@ -package com.github.technus.tectech.elementalMatter.definitions; +package com.github.technus.tectech.elementalMatter.magicAddon.definitions; import static com.github.technus.tectech.elementalMatter.classes.cElementalDecay.noDecay; import com.github.technus.tectech.elementalMatter.classes.cElementalPrimitive; 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 c7a346803b..f806e12d29 100644 --- a/src/main/java/com/github/technus/tectech/loader/MachineLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MachineLoader.java @@ -190,7 +190,7 @@ public class MachineLoader implements Runnable { Machine_Multi_Collider.set(new GT_MetaTileEntity_EM_collider(15340, "multimachine.em.collider", "Matter Collider").getStackForm(1L)); - Machine_Multi_Infuser.set(new GT_MetaTileEntity_EM_infuser(15350,"multimachine.em.infuser","Energy Infuser").getStackForm(1)); + Machine_Multi_Infuser.set(new GT_MetaTileEntity_EM_infuser(15350, "multimachine.em.infuser", "Energy Infuser").getStackForm(1)); Machine_Multi_EMmachine.set(new GT_MetaTileEntity_EM_machine(15360, "multimachine.em.processing", "Quantum Processing Machine").getStackForm(1L)); @@ -200,8 +200,8 @@ public class MachineLoader implements Runnable { Machine_Multi_Wormhole.set(new GT_MetaTileEntity_EM_wormhole(15390, "multimachine.em.wormhole", "Wormhole").getStackForm(1L)); - Machine_Multi_Decay.set(new GT_MetaTileEntity_EM_decay(15400,"multimachine.em.decay","Decay Generator").getStackForm(1L)); - Machine_Multi_Annihilation.set(new GT_MetaTileEntity_EM_annihilation(15405,"multimachine.em.annihilation","Annihilation Generator").getStackForm(1L)); + Machine_Multi_Decay.set(new GT_MetaTileEntity_EM_decay(15400, "multimachine.em.decay", "Decay Generator").getStackForm(1L)); + Machine_Multi_Annihilation.set(new GT_MetaTileEntity_EM_annihilation(15405, "multimachine.em.annihilation", "Annihilation Generator").getStackForm(1L)); Machine_Multi_BHG.set(new GT_MetaTileEntity_EM_bhg(15410, "multimachine.em.blackholegenerator", "Black Hole Generator").getStackForm(1L)); @@ -216,8 +216,8 @@ public class MachineLoader implements Runnable { dataIn_Hatch.set(new GT_MetaTileEntity_Hatch_InputData(15440, "hatch.datain.tier.07", "Optical Slave Connector", 7).getStackForm(1L)); dataOut_Hatch.set(new GT_MetaTileEntity_Hatch_OutputData(15441, "hatch.dataout.tier.07", "Optical Master Connector", 7).getStackForm(1L)); - rack_Hatch.set(new GT_MetaTileEntity_Hatch_Rack(15450,"hatch.rack.tier.08","Computer Rack",8,"4 Slot Rack").getStackForm(1L)); - holder_Hatch.set(new GT_MetaTileEntity_Hatch_Holder(15451,"hatch.holder.tier.09","Object Holder",8,"For Research Station").getStackForm(1L)); + rack_Hatch.set(new GT_MetaTileEntity_Hatch_Rack(15450, "hatch.rack.tier.08", "Computer Rack", 8, "4 Slot Rack").getStackForm(1L)); + holder_Hatch.set(new GT_MetaTileEntity_Hatch_Holder(15451, "hatch.holder.tier.09", "Object Holder", 8, "For Research Station").getStackForm(1L)); // =================================================================================================== // Pipes @@ -230,6 +230,6 @@ public class MachineLoader implements Runnable { // DebugStuff // =================================================================================================== - Machine_DebugWriter.set(new GT_MetaTileEntity_DebugStructureWriter(15499,"debug.tt.writer","Debug Structure Writer",15).getStackForm(1L)); + Machine_DebugWriter.set(new GT_MetaTileEntity_DebugStructureWriter(15499, "debug.tt.writer", "Debug Structure Writer", 15).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 3e79ebfce5..4b3ea41da2 100644 --- a/src/main/java/com/github/technus/tectech/loader/MainLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/MainLoader.java @@ -9,8 +9,6 @@ import com.github.technus.tectech.thing.item.DebugContainer_EM; import static com.github.technus.tectech.TecTech.mainTab; public class MainLoader {//TODO add checks for - is mod loaded dreamcraft to enable higher tier machinery. (above UV), or implement a check for GT tier values. - public MainLoader() {} - public void things() { CasingLoader casingLoader = new CasingLoader(); casingLoader.run(); @@ -31,7 +29,7 @@ public class MainLoader {//TODO add checks for - is mod loaded dreamcraft to ena TecTech.Logger.info("Recipe Init Done"); } - public void registerThingsInTabs(){ + public void registerThingsInTabs() { QuantumGlassBlock.INSTANCE.setCreativeTab(mainTab); GT_Container_CasingsTT.sBlockCasingsTT.setCreativeTab(mainTab); DebugContainer_EM.INSTANCE.setCreativeTab(mainTab); 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 53220e0d61..7362706fae 100644 --- a/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/RecipeLoader.java @@ -2,6 +2,8 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.elementalMatter.classes.cElementalPrimitive; import com.github.technus.tectech.elementalMatter.definitions.*; +import com.github.technus.tectech.elementalMatter.magicAddon.definitions.dComplexAspectDefinition; +import com.github.technus.tectech.elementalMatter.magicAddon.definitions.ePrimalAspectDefinition; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Rack; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_computer; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; 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 75ac7b616a..c827c1ee24 100644 --- a/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ThingsLoader.java @@ -10,7 +10,6 @@ import com.github.technus.tectech.thing.item.DebugContainer_EM; */ public class ThingsLoader implements Runnable { public void run() { - QuantumGlassBlock.run(); TecTech.Logger.info("Quantum Glass registered"); 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 03105efbb8..936c95a5ae 100644 --- a/src/main/java/com/github/technus/tectech/thing/CustomItemList.java +++ b/src/main/java/com/github/technus/tectech/thing/CustomItemList.java @@ -12,7 +12,7 @@ import static gregtech.api.enums.GT_Values.W; public enum CustomItemList implements IItemContainer { Machine_DebugWriter, - EMpipe,DATApipe,rack_Hatch,holder_Hatch, + EMpipe, DATApipe, rack_Hatch, holder_Hatch, eM_dynamomulti4_UV, eM_dynamomulti16_UV, eM_dynamomulti64_UV, eM_dynamomulti4_UHV, eM_dynamomulti16_UHV, eM_dynamomulti64_UHV, eM_dynamomulti4_UEV, eM_dynamomulti16_UEV, eM_dynamomulti64_UEV, @@ -29,7 +29,7 @@ public enum CustomItemList implements IItemContainer { eM_out_UV, eM_out_UHV, eM_out_UEV, eM_out_UIV, eM_out_UMV, eM_out_UXV, eM_muffler_UV, eM_muffler_UHV, eM_muffler_UEV, eM_muffler_UIV, eM_muffler_UMV, eM_muffler_UXV, Parametrizer_Hatch, Uncertainty_Hatch, UncertaintyX_Hatch, dataIn_Hatch, dataOut_Hatch, - eM_Containment, eM_Containment_Field, eM_Containment_Advanced, eM_Coil, eM_Teleportation, eM_Dimensional, eM_Ultimate_Containment,eM_Ultimate_Containment_Advanced,eM_Ultimate_Containment_Field,eM_Spacetime, eM_Computer_Casing, eM_Computer_Bus, eM_Computer_Vent, eM_Hollow, eM_Power, + eM_Containment, eM_Containment_Field, eM_Containment_Advanced, eM_Coil, eM_Teleportation, eM_Dimensional, eM_Ultimate_Containment, eM_Ultimate_Containment_Advanced, eM_Ultimate_Containment_Field, eM_Spacetime, eM_Computer_Casing, eM_Computer_Bus, eM_Computer_Vent, eM_Hollow, eM_Power, debugBlock, Machine_Multi_MatterToEM, Machine_Multi_EMToMatter, Machine_Multi_EMjunction, Machine_Multi_Transformer, Machine_Multi_Computer, Machine_Multi_Infuser, Machine_Multi_Switch, 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 852c750a15..7e2a0d6111 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 @@ -83,9 +83,9 @@ public final class QuantumGlassBlock extends BlockBase { stuff = this.blockIcon; } - public static void run(){ - INSTANCE=new QuantumGlassBlock(); - GameRegistry.registerBlock(INSTANCE,QuantumGlassItem.class,INSTANCE.getUnlocalizedName()); - GregTech_API.registerMachineBlock(INSTANCE,-1); + public static void run() { + INSTANCE = new QuantumGlassBlock(); + GameRegistry.registerBlock(INSTANCE, QuantumGlassItem.class, INSTANCE.getUnlocalizedName()); + GregTech_API.registerMachineBlock(INSTANCE, -1); } } 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 45931cabc6..f3c8db2873 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,7 +16,7 @@ import static com.github.technus.tectech.CommonValues.tecMark; public class QuantumGlassItem extends ItemBlock { public static QuantumGlassItem INSTANCE; - public QuantumGlassItem(Block b){ + public QuantumGlassItem(Block b) { super(b); } 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 eb25c6fc29..605dcd87e3 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 @@ -22,7 +22,7 @@ public class GT_Item_CasingsTT @Override public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { aList.add(tecMark); - switch(aStack.getItemDamage()){ + switch (aStack.getItemDamage()) { case 0://"High Power Casing" aList.add("Well suited for high power applications."); aList.add(EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "The power levels are rising!"); diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugBuilder.java b/src/main/java/com/github/technus/tectech/thing/item/DebugBuilder.java index 87df7d05ad..c0ecf3b7c0 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/DebugBuilder.java +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugBuilder.java @@ -23,7 +23,7 @@ import static com.github.technus.tectech.auxiliary.Reference.MODID; public class DebugBuilder extends Item { public static DebugBuilder INSTANCE; - DebugBuilder(){ + DebugBuilder() { super(); setMaxStackSize(1); setUnlocalizedName("em.debugBuilder"); @@ -49,11 +49,11 @@ public class DebugBuilder extends Item { public void addInformation(ItemStack aStack, EntityPlayer ep, List aList, boolean boo) { aList.add(CommonValues.tecMark); aList.add("Constructs Multiblocks"); - aList.add(EnumChatFormatting.BLUE+"Quantity Matters"); + aList.add(EnumChatFormatting.BLUE + "Quantity Matters"); } - public static void run(){ - INSTANCE=new DebugBuilder(); + public static void run() { + INSTANCE = new DebugBuilder(); GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); } } diff --git a/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java b/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java index 6c0d944610..df5f509ece 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/item/DebugContainer_EM.java @@ -29,7 +29,7 @@ import static com.github.technus.tectech.auxiliary.Reference.MODID; public class DebugContainer_EM extends Item { public static DebugContainer_EM INSTANCE; - DebugContainer_EM(){ + DebugContainer_EM() { super(); setMaxStackSize(1); setUnlocalizedName("em.debugContainer"); @@ -74,26 +74,26 @@ public class DebugContainer_EM extends Item { aList.add(CommonValues.tecMark); try { NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT!=null && tNBT.hasKey("info")) { + if (tNBT != null && tNBT.hasKey("info")) { aList.add("Contains:"); Collections.addAll(aList, cElementalInstanceStackMap.infoFromNBT(tNBT.getCompoundTag("info"))); } else { aList.add("Container for elemental matter"); - aList.add(EnumChatFormatting.BLUE+"Right click on elemental hatches"); + aList.add(EnumChatFormatting.BLUE + "Right click on elemental hatches"); } } catch (Exception e) { aList.add("---Unexpected Termination---"); } } - public static void run(){ - INSTANCE=new DebugContainer_EM(); + public static void run() { + INSTANCE = new DebugContainer_EM(); GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); } @Override public void getSubItems(Item item, CreativeTabs tab, List list) { - ItemStack that=new ItemStack(this,1); + ItemStack that = new ItemStack(this, 1); that.setTagCompound(new NBTTagCompound()); list.add(that); } 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 dbc2d94a2a..663a55dedd 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 @@ -62,23 +62,23 @@ 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) - aNBT.setTag("eDATA",q.toNbt()); + 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")) - q=new quantumDataPacket(aNBT.getCompoundTag("eDATA")); + if (aNBT.hasKey("eDATA")) + q = new quantumDataPacket(aNBT.getCompoundTag("eDATA")); } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (aBaseMetaTileEntity.isServerSide()) { - if (moveAt == aTick%20) { - if(q==null){ + if (moveAt == aTick % 20) { + if (q == null) { getBaseMetaTileEntity().setActive(false); } else { getBaseMetaTileEntity().setActive(true); @@ -139,13 +139,13 @@ 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), + "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), + "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_ElementalContainer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/GT_MetaTileEntity_Hatch_ElementalContainer.java index a4043a4ea1..414ed0b390 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 @@ -114,7 +114,7 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta GT_MetaTileEntity_Hatch_MufflerElemental aMetaTileEntity = (GT_MetaTileEntity_Hatch_MufflerElemental) tGTTileEntity.getMetaTileEntity(); aMetaTileEntity.overflowMatter += overflowMatter; overflowMatter = 0F; - deathDelay=3;//needed in some cases like repetitive failures. Should be 4 since there is -- at end but meh... + deathDelay = 3;//needed in some cases like repetitive failures. Should be 4 since there is -- at end but meh... if (aMetaTileEntity.overflowMatter > aMetaTileEntity.overflowMax) { if (TecTech.ModConfig.BOOM_ENABLE) tGTTileEntity.doExplosion(V[14]); else @@ -129,13 +129,14 @@ public abstract class GT_MetaTileEntity_Hatch_ElementalContainer extends GT_Meta deathDelay--; } } else if (moveAt == Tick) { - if(content.hasStacks())moveAround(aBaseMetaTileEntity); + if (content.hasStacks()) moveAround(aBaseMetaTileEntity); getBaseMetaTileEntity().setActive(content.hasStacks()); } } } - public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) {} + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + } @Override public cElementalInstanceStackMap getContainerHandler() { 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 e5f00eb2e5..3cfb4fb23d 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 @@ -63,7 +63,7 @@ public class GT_MetaTileEntity_Hatch_Holder extends GT_MetaTileEntity_Hatch impl @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Holder(mName,mTier,mDescription,mTextures); + return new GT_MetaTileEntity_Hatch_Holder(mName, mTier, mDescription, mTextures); } @Override @@ -73,7 +73,7 @@ public class GT_MetaTileEntity_Hatch_Holder extends GT_MetaTileEntity_Hatch impl @Override public boolean isFacingValid(byte aFacing) { - return aFacing>=2; + return aFacing >= 2; } @Override @@ -114,7 +114,7 @@ public class GT_MetaTileEntity_Hatch_Holder extends GT_MetaTileEntity_Hatch impl //else if(heat>0) // aPlayer.addChatComponentMessage(new ChatComponentText("It is still warm...")); //else - aBaseMetaTileEntity.openGUI(aPlayer); + aBaseMetaTileEntity.openGUI(aPlayer); return true; } 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 e42d6348ac..2d5a0a3b6b 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,7 @@ 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 7288d182c4..afaadef072 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 @@ -47,32 +47,33 @@ public class GT_MetaTileEntity_Hatch_OutputData extends GT_MetaTileEntity_Hatch_ @Override public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { - iConnectsToDataPipe current=this,source=this,next; - int range=0; - while((next=current.getNext(source))!=null && range++<1000){ - if(next instanceof GT_MetaTileEntity_Hatch_InputData){ - ((GT_MetaTileEntity_Hatch_InputData) next).q=q; - ((GT_MetaTileEntity_Hatch_InputData) next).delDelay=true; + iConnectsToDataPipe current = this, source = this, next; + int range = 0; + while ((next = current.getNext(source)) != null && range++ < 1000) { + if (next instanceof GT_MetaTileEntity_Hatch_InputData) { + ((GT_MetaTileEntity_Hatch_InputData) next).q = q; + ((GT_MetaTileEntity_Hatch_InputData) next).delDelay = true; break; } - source=current; current=next; + source = current; + current = next; } - q=null; + q = null; } @Override public iConnectsToDataPipe getNext(iConnectsToDataPipe source/*==this*/) { - IGregTechTileEntity base=getBaseMetaTileEntity(); - byte color=base.getColorization(); + IGregTechTileEntity base = getBaseMetaTileEntity(); + byte color = base.getColorization(); if (color < 0) return null; - IGregTechTileEntity next=base.getIGregTechTileEntityAtSide(base.getFrontFacing()); - 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()) + IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); + 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()) return (iConnectsToDataPipe) meta; - if(meta instanceof GT_MetaTileEntity_Pipe_Data + if (meta instanceof GT_MetaTileEntity_Pipe_Data /*&& ((GT_MetaTileEntity_Pipe_Data) meta).connectionCount==2*/)//Checked later return (iConnectsToDataPipe) meta; } 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 c6b4361321..3a78974b89 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 @@ -33,9 +33,9 @@ import static com.github.technus.tectech.Util.getUniqueIdentifier; public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implements machineTT { private static Textures.BlockIcons.CustomIcon EM_R; 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<>(); + public int heat = 0; + private float overClock = 1, overVolt = 1; + private static Map<String, component> 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); @@ -48,7 +48,7 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - aNBT.setInteger("eHeat",heat); + aNBT.setInteger("eHeat", heat); aNBT.setFloat("eOverClock", overClock); aNBT.setFloat("eOverVolt", overVolt); } @@ -56,9 +56,9 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - heat=aNBT.getInteger("eHeat"); - overClock =aNBT.getFloat("eOverClock"); - overVolt =aNBT.getFloat("eOverVolt"); + heat = aNBT.getInteger("eHeat"); + overClock = aNBT.getFloat("eOverClock"); + overVolt = aNBT.getFloat("eOverVolt"); } @Override @@ -80,7 +80,7 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_Hatch_Rack(mName,mTier,mDescription,mTextures); + return new GT_MetaTileEntity_Hatch_Rack(mName, mTier, mDescription, mTextures); } @Override @@ -90,7 +90,7 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @Override public boolean isFacingValid(byte aFacing) { - return aFacing>=2; + return aFacing >= 2; } @Override @@ -105,13 +105,13 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @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(); } @@ -133,17 +133,17 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem //else if(heat>0) // aPlayer.addChatComponentMessage(new ChatComponentText("It is still warm...")); //else - aBaseMetaTileEntity.openGUI(aPlayer); + aBaseMetaTileEntity.openGUI(aPlayer); return true; } - 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(tickingComponents) { + 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 (tickingComponents) { if (this.heat > comp.maxHeat) { mInventory[i] = null; continue; @@ -153,14 +153,14 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem 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; + } else { + computation += comp.computation * overclock; } } - if(tickingComponents) { - this.heat+=Math.ceil(heat); + if (tickingComponents) { + this.heat += Math.ceil(heat); } - return (int)Math.floor(computation); + return (int) Math.floor(computation); } @Override @@ -168,17 +168,18 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem return 1; } - public int tickComponents(float oc,float ov) { - if(oc>3+TecTech.Rnd.nextFloat() || ov>2+TecTech.Rnd.nextFloat()) getBaseMetaTileEntity().setToFire(); - overClock =oc; overVolt =ov; - return getComputationPower(overClock, overVolt,true); + public int tickComponents(float oc, float ov) { + if (oc > 3 + TecTech.Rnd.nextFloat() || ov > 2 + TecTech.Rnd.nextFloat()) getBaseMetaTileEntity().setToFire(); + overClock = oc; + overVolt = ov; + return getComputationPower(overClock, overVolt, true); } @Override public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if(aBaseMetaTileEntity.isServerSide()){ - if(aTick%20==multiCheckAt){ - if(this.heat>0) { + if (aBaseMetaTileEntity.isServerSide()) { + if (aTick % 20 == multiCheckAt) { + if (this.heat > 0) { float heatC = 0; for (int i = 0; i < mInventory.length; i++) { if (mInventory[i] == null || mInventory[i].stackSize != 1) continue; @@ -186,19 +187,19 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem if (comp == null) continue; if (this.heat > comp.maxHeat) { mInventory[i] = null; - } else if (comp.heat<0) { - heatC += comp.heat * (this.heat/10000); + } else if (comp.heat < 0) { + heatC += comp.heat * (this.heat / 10000); } } this.heat += Math.max(-this.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) this.heat = -10000; } } } @@ -212,7 +213,7 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @Override public int getSizeInventory() {//HACK TO NOT DROP CONTENTS!!! - return heat>500 || getBaseMetaTileEntity().isActive()?0:mInventory.length; + return heat > 500 || getBaseMetaTileEntity().isActive() ? 0 : mInventory.length; } @Override @@ -232,79 +233,79 @@ public class GT_MetaTileEntity_Hatch_Rack extends GT_MetaTileEntity_Hatch implem @Override public String[] getInfoData() { 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==0? --> ((heat+9)/10) = 0 - //Heat==1-10? --> 1 + "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==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 - - 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); + 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 + + 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); } - 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 + 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 } } - public static class component implements Comparable<component>{ + public static class component implements Comparable<component> { private final String unlocalizedName; - private final float heat,coEff,computation,maxHeat; + private final float heat, coEff, computation, maxHeat; private final boolean subZero; - component(ItemStack is,float computation,float heat, float coEff,float maxHeat, boolean subZero){ - this(getUniqueIdentifier(is),computation,heat,coEff,maxHeat,subZero); + component(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){ - unlocalizedName=is; - this.heat=heat; - this.coEff=coEff; - this.computation=computation; - this.maxHeat=maxHeat; - this.subZero=subZero; - componentBinds.put(unlocalizedName,this); - if(TecTechConfig.DEBUG_MODE) TecTech.Logger.info("Component registered: "+unlocalizedName); + component(String is, float computation, float heat, float coEff, float maxHeat, boolean subZero) { + unlocalizedName = is; + this.heat = heat; + this.coEff = coEff; + this.computation = computation; + this.maxHeat = maxHeat; + this.subZero = subZero; + componentBinds.put(unlocalizedName, this); + if (TecTechConfig.DEBUG_MODE) TecTech.Logger.info("Component registered: " + unlocalizedName); } @Override 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 d7bcd2006a..93b488b76e 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 @@ -72,7 +72,7 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch if (aBaseMetaTileEntity.isServerSide() && (aTick & 15) == 0) { if (mode == 0) { aBaseMetaTileEntity.setActive(false); - status=-128; + status = -128; } else { aBaseMetaTileEntity.setActive(true); shift(); @@ -177,10 +177,10 @@ public class GT_MetaTileEntity_Hatch_Uncertainty extends GT_MetaTileEntity_Hatch private boolean balanceCheck(int sideLenY, short... masses) { float inequality = 0; - for (int i = 0; i < masses.length>>1; i++) { - inequality += Math.abs(masses[i]-masses[masses.length-i-1]); + 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() { @@ -258,11 +258,11 @@ 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; - matrix[i] += j==0?1:0; - if(matrix[i]<0) matrix[i]=0; - else if (matrix[i]>1000) matrix[i]=999; + final 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; } public byte update(int newMode) { 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 72da3d6b34..f77b7339bd 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 @@ -35,37 +35,37 @@ public class GT_Container_Holder extends GT_ContainerMetaTile_Machine { @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_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_Container_Rack.java index 747c962ad8..0d891c1296 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 @@ -17,7 +17,7 @@ import java.util.Iterator; * Created by Tec on 09.04.2017. */ public class GT_Container_Rack extends GT_ContainerMetaTile_Machine { - public boolean heat=false; + public boolean heat = false; public GT_Container_Rack(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); @@ -44,12 +44,12 @@ public class GT_Container_Rack extends GT_ContainerMetaTile_Machine { if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { return; } - this.heat = ((GT_MetaTileEntity_Hatch_Rack) this.mTileEntity.getMetaTileEntity()).heat>0; + this.heat = ((GT_MetaTileEntity_Hatch_Rack) this.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); + var1.sendProgressBarUpdate(this, 100, this.heat ? 1 : 0); } } @@ -58,7 +58,7 @@ public class GT_Container_Rack extends GT_ContainerMetaTile_Machine { super.updateProgressBar(par1, par2); switch (par1) { case 100: - this.heat = par2!=0; + this.heat = par2 != 0; return; } //TODO TEST!!! @@ -67,37 +67,37 @@ public class GT_Container_Rack extends GT_ContainerMetaTile_Machine { @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_GUIContainer_Holder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Holder.java index a13e180edb..596d8f5420 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 @@ -25,7 +25,7 @@ public class GT_GUIContainer_Holder extends GT_GUIContainerMetaTile_Machine { 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) + 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_Rack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/hatch/gui/GT_GUIContainer_Rack.java index d232cfa80d..e4dc042772 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 @@ -25,9 +25,9 @@ public class GT_GUIContainer_Rack extends GT_GUIContainerMetaTile_Machine { 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) + 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/multi/GT_MetaTileEntity_EM_bhg.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_bhg.java index b8a47256a4..d4d6594061 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 @@ -71,7 +71,7 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E @Override public void construct(int qty) { - StructureBuilder(shape,blockType,blockMeta,7,7,0,this.getBaseMetaTileEntity()); + StructureBuilder(shape, blockType, blockMeta, 7, 7, 0, this.getBaseMetaTileEntity()); } @Override @@ -84,9 +84,9 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+12], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 12], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+12]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 12]}; } @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 bfc4396be9..2d85d63339 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 @@ -25,7 +25,7 @@ import static gregtech.api.enums.GT_Values.E; public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockBase_EM implements constructableTT { private static Textures.BlockIcons.CustomIcon ScreenOFF; private static Textures.BlockIcons.CustomIcon ScreenON; - private byte eTier =0; + private byte eTier = 0; //region Structure //use multi A energy inputs, use less power the longer it runs @@ -102,7 +102,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB GT_Container_CasingsTT.sBlockCasingsTT, GT_Container_CasingsTT.sBlockCasingsTT }; - private static final byte[] blockMeta = new byte[]{3,7,0,9,3,9}; + private static final byte[] blockMeta = new byte[]{3, 7, 0, 9, 3, 9}; private static final Block[] blockType2 = new Block[]{ GT_Container_CasingsTT.sBlockCasingsTT, @@ -112,7 +112,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB GT_Container_CasingsTT.sBlockCasingsTT, GT_Container_CasingsTT.sBlockCasingsTT }; - private static final byte[] blockMeta2 = new byte[]{3,6,0,8,5,9}; + private static final byte[] blockMeta2 = new byte[]{3, 6, 0, 8, 5, 9}; //endregion public GT_MetaTileEntity_EM_collider(int aID, String aName, String aNameRegional) { @@ -137,9 +137,9 @@ public class GT_MetaTileEntity_EM_collider 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.CASING_BLOCKS[textureOffset+4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+4]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 4]}; } @Override @@ -151,40 +151,46 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - eTier =aNBT.getByte("eTier"); + eTier = aNBT.getByte("eTier"); } @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - if(iGregTechTileEntity.getBlockOffset(0,-1,0)!=GT_Container_CasingsTT.sBlockCasingsTT){ - eTier =0; + if (iGregTechTileEntity.getBlockOffset(0, -1, 0) != GT_Container_CasingsTT.sBlockCasingsTT) { + eTier = 0; return false; - } else if(iGregTechTileEntity.getMetaIDOffset(0,-1,0)==3) { - eTier =1; - } else if(iGregTechTileEntity.getMetaIDOffset(0,-1,0)==5) { - eTier =2; + } else if (iGregTechTileEntity.getMetaIDOffset(0, -1, 0) == 3) { + eTier = 1; + } else if (iGregTechTileEntity.getMetaIDOffset(0, -1, 0) == 5) { + eTier = 2; } else { - eTier =0; + eTier = 0; return false; } - + boolean test; - switch (eTier){ - case 1:test=EM_StructureCheck(shape,blockType,blockMeta,0,-2,28); break; - case 2:test=EM_StructureCheck(shape,blockType2,blockMeta2,0,-2,28); break; - default: eTier = 0; return false; + switch (eTier) { + case 1: + test = EM_StructureCheck(shape, blockType, blockMeta, 0, -2, 28); + break; + case 2: + test = EM_StructureCheck(shape, blockType2, blockMeta2, 0, -2, 28); + break; + default: + eTier = 0; + return false; } - if(test) return true; + if (test) return true; eTier = 0; return false; } @Override public void construct(int qty) { - if((qty&1)==0) - StructureBuilder(shape,blockType,blockMeta,0,-2,28,this.getBaseMetaTileEntity()); - else StructureBuilder(shape,blockType2,blockMeta2,0,-2,28,this.getBaseMetaTileEntity()); + if ((qty & 1) == 0) + StructureBuilder(shape, blockType, blockMeta, 0, -2, 28, this.getBaseMetaTileEntity()); + else StructureBuilder(shape, blockType2, blockMeta2, 0, -2, 28, this.getBaseMetaTileEntity()); } @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 5f873ad87f..63de676b59 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 @@ -29,20 +29,20 @@ import static gregtech.api.enums.GT_Values.V; * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockBase_EM { - private final ArrayList<GT_MetaTileEntity_Hatch_Rack> eRacks=new ArrayList<>(); - private int maxTemp=0; + private final ArrayList<GT_MetaTileEntity_Hatch_Rack> eRacks = new ArrayList<>(); + private int maxTemp = 0; //region Structure - private static final String[][] front = new String[][]{{"A ","A ","A+ ","A ",},}; - private static final String[][] terminator = new String[][]{{"A ","A ","A ","A ",},}; - private static final String[][] cap = new String[][]{{"-01","A22","A22","-01",},}; - private static final String[][] slice = new String[][]{{"-01","A!2","A!2","-01",},}; - private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{2,1,3}; - private static final String[] addingMethods = new String[]{"addToMachineList","addRackToMachineList"}; - private static final byte[] casingTextures = new byte[]{textureOffset+1,textureOffset+3}; - private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT,sBlockCasingsTT}; - private static final byte[] blockMetaFallback = new byte[]{1,3}; + private static final String[][] front = new String[][]{{"A ", "A ", "A+ ", "A ",},}; + private static final String[][] terminator = new String[][]{{"A ", "A ", "A ", "A ",},}; + private static final String[][] cap = new String[][]{{"-01", "A22", "A22", "-01",},}; + private static final String[][] slice = new String[][]{{"-01", "A!2", "A!2", "-01",},}; + private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{2, 1, 3}; + private static final String[] addingMethods = new String[]{"addToMachineList", "addRackToMachineList"}; + private static final byte[] casingTextures = new byte[]{textureOffset + 1, textureOffset + 3}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{1, 3}; //endregion public GT_MetaTileEntity_EM_computer(int aID, String aName, String aNameRegional) { @@ -64,36 +64,36 @@ public class GT_MetaTileEntity_EM_computer 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.CASING_BLOCKS[textureOffset+3], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 3], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+3]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 3]}; } @Override public boolean EM_checkRecipe(ItemStack itemStack) { - eAvailableData=0; - maxTemp=0; - short thingsActive=0; + eAvailableData = 0; + maxTemp = 0; + short thingsActive = 0; int rackComputation; for (GT_MetaTileEntity_Hatch_Rack r : eRacks) { - if(!isValidMetaTileEntity(r))continue; - if(r.heat>maxTemp)maxTemp=r.heat; - rackComputation= r.tickComponents(eParamsIn[0],eParamsIn[10]); - if(rackComputation>0){ - eAvailableData+=rackComputation; - thingsActive+=4; + if (!isValidMetaTileEntity(r)) continue; + if (r.heat > maxTemp) maxTemp = r.heat; + rackComputation = r.tickComponents(eParamsIn[0], eParamsIn[10]); + if (rackComputation > 0) { + eAvailableData += rackComputation; + thingsActive += 4; } r.getBaseMetaTileEntity().setActive(true); } for (GT_MetaTileEntity_Hatch_InputData di : eInputData) - if(di.q!=null)//ok for power losses + if (di.q != null)//ok for power losses thingsActive++; - if(thingsActive>0 && eCertainStatus==0){ - thingsActive+=eOutputData.size(); - mEUt = -(int) (V[8]*eParamsIn[10]); + if (thingsActive > 0 && eCertainStatus == 0) { + thingsActive += eOutputData.size(); + mEUt = -(int) (V[8] * eParamsIn[10]); eAmpereFlow = 1 + (thingsActive >> 2); mMaxProgresstime = 20; mEfficiencyIncrease = 10000; @@ -112,47 +112,47 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB @Override public void EM_checkParams() { - if(eParamsIn[0]<=0) - eParamsInStatus[0]=PARAM_TOO_LOW; - else if(eParamsIn[0]<1) - eParamsInStatus[0]=PARAM_LOW; - else if(eParamsIn[0]==1) - eParamsInStatus[0]=PARAM_OK; - else if(eParamsIn[0]<=3) - eParamsInStatus[0]=PARAM_HIGH; - else eParamsInStatus[0]=PARAM_TOO_HIGH; - - if(eParamsIn[10]<=0.7f) - eParamsInStatus[10]=PARAM_TOO_LOW; - else if(eParamsIn[10]<0.8f) - eParamsInStatus[10]=PARAM_LOW; - else if(eParamsIn[10]<=1.2f) - eParamsInStatus[10]=PARAM_OK; - else if(eParamsIn[10]<=2) - eParamsInStatus[10]=PARAM_HIGH; - else eParamsInStatus[10]=PARAM_TOO_HIGH; - - eParamsOut[0]=maxTemp; - eParamsOut[10]=eAvailableData; - - if(maxTemp<-10000) - eParamsOutStatus[0]=PARAM_TOO_LOW; - else if(maxTemp<0) - eParamsOutStatus[0]=PARAM_LOW; - else if (maxTemp==0) - eParamsOutStatus[0]=PARAM_OK; - else if(maxTemp<=5000) - eParamsOutStatus[0]=PARAM_HIGH; - else eParamsOutStatus[0]=PARAM_TOO_HIGH; + if (eParamsIn[0] <= 0) + eParamsInStatus[0] = PARAM_TOO_LOW; + else if (eParamsIn[0] < 1) + eParamsInStatus[0] = PARAM_LOW; + else if (eParamsIn[0] == 1) + eParamsInStatus[0] = PARAM_OK; + else if (eParamsIn[0] <= 3) + eParamsInStatus[0] = PARAM_HIGH; + else eParamsInStatus[0] = PARAM_TOO_HIGH; + + if (eParamsIn[10] <= 0.7f) + eParamsInStatus[10] = PARAM_TOO_LOW; + else if (eParamsIn[10] < 0.8f) + eParamsInStatus[10] = PARAM_LOW; + else if (eParamsIn[10] <= 1.2f) + eParamsInStatus[10] = PARAM_OK; + else if (eParamsIn[10] <= 2) + eParamsInStatus[10] = PARAM_HIGH; + else eParamsInStatus[10] = PARAM_TOO_HIGH; + + eParamsOut[0] = maxTemp; + eParamsOut[10] = eAvailableData; + + if (maxTemp < -10000) + eParamsOutStatus[0] = PARAM_TOO_LOW; + else if (maxTemp < 0) + eParamsOutStatus[0] = PARAM_LOW; + else if (maxTemp == 0) + eParamsOutStatus[0] = PARAM_OK; + else if (maxTemp <= 5000) + eParamsOutStatus[0] = PARAM_HIGH; + else eParamsOutStatus[0] = PARAM_TOO_HIGH; } @Override public void EM_outputFunction() { - if(eOutputData.size()>0) { - final vec3pos pos=new vec3pos(getBaseMetaTileEntity()); + 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; + if (i.q == null || i.q.contains(pos)) continue; pack = pack.unifyPacketWith(i.q); if (pack == null) return; } @@ -160,42 +160,47 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB pack.computation /= eOutputData.size(); for (GT_MetaTileEntity_Hatch_OutputData o : eOutputData) - o.q=pack; + o.q = pack; } } @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 protected void EM_stopMachine() { - for(GT_MetaTileEntity_Hatch_Rack r:eRacks) + for (GT_MetaTileEntity_Hatch_Rack r : eRacks) r.getBaseMetaTileEntity().setActive(false); } @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - for(GT_MetaTileEntity_Hatch_Rack rack:eRacks) + for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) if (isValidMetaTileEntity(rack)) rack.getBaseMetaTileEntity().setActive(false); eRacks.clear(); - if(!EM_StructureCheckAdvanced(front,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,2,0))return false; - if(!EM_StructureCheckAdvanced(cap,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,2,-1))return false; - byte i=-2,slices=4; - for(;i>-16;){ - if(!EM_StructureCheckAdvanced(slice,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,2,i))break; + if (!EM_StructureCheckAdvanced(front, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, 0)) + return false; + if (!EM_StructureCheckAdvanced(cap, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, -1)) + return false; + byte i = -2, slices = 4; + for (; i > -16; ) { + if (!EM_StructureCheckAdvanced(slice, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, i)) + break; slices++; i--; } - if(slices>16)return false; - if(!EM_StructureCheckAdvanced(cap,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,2,++i))return false; - if(!EM_StructureCheckAdvanced(terminator,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,2,--i))return false; - eCertainMode=(byte)Math.min(slices/3,5); - for(GT_MetaTileEntity_Hatch_Rack rack:eRacks) + if (slices > 16) return false; + if (!EM_StructureCheckAdvanced(cap, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, ++i)) + return false; + if (!EM_StructureCheckAdvanced(terminator, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, --i)) + return false; + eCertainMode = (byte) Math.min(slices / 3, 5); + for (GT_MetaTileEntity_Hatch_Rack rack : eRacks) if (isValidMetaTileEntity(rack)) rack.getBaseMetaTileEntity().setActive(iGregTechTileEntity.isActive()); return eUncertainHatches.size() == 1; @@ -210,14 +215,14 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB public String[] getDescription() { return new String[]{ CommonValues.tecMark, - Util.intToString(TecTech.Rnd.nextInt(),8), + Util.intToString(TecTech.Rnd.nextInt(), 8), EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + "You need it to process the number above" }; } @Override public boolean isFacingValid(byte aFacing) { - return aFacing>=2; + return aFacing >= 2; } //NEW METHOD @@ -232,11 +237,11 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB return false; } - public static void run(){ + public static void run() { try { adderMethodMap.put("addRackToMachineList", GT_MetaTileEntity_EM_computer.class.getMethod("addRackToMachineList", IGregTechTileEntity.class, int.class)); - }catch (NoSuchMethodException e){ - if(TecTechConfig.DEBUG_MODE) e.printStackTrace(); + } catch (NoSuchMethodException e) { + if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); } } } 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 30bdbc8609..27e873af98 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 @@ -15,22 +15,22 @@ import static com.github.technus.tectech.thing.casing.GT_Container_CasingsTT.sBl public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase_EM { //region structure private static final String[][] shape = new String[][]{ - {"0C0","A ","A + ","A ","0C0",}, - {"00000","00000","00000","00000","00000",}, - {"0C0","A!!!","A!0!","A!!!","0C0",}, - {"00000","01110","01110","01110","00000",}, - {"0\"\"\"0","\"111\"","\"111\"","\"111\"","0\"\"\"0",}, - {"00000","01110","01110","01110","00000",}, - {"0C0","A!!!","A!0!","A!!!","0C0",}, - {"00000","00000","00000","00000","00000",}, - {"0C0","A ","A ","A ","0C0",}, + {"0C0", "A ", "A + ", "A ", "0C0",}, + {"00000", "00000", "00000", "00000", "00000",}, + {"0C0", "A!!!", "A!0!", "A!!!", "0C0",}, + {"00000", "01110", "01110", "01110", "00000",}, + {"0\"\"\"0", "\"111\"", "\"111\"", "\"111\"", "0\"\"\"0",}, + {"00000", "01110", "01110", "01110", "00000",}, + {"0C0", "A!!!", "A!0!", "A!!!", "0C0",}, + {"00000", "00000", "00000", "00000", "00000",}, + {"0C0", "A ", "A ", "A ", "0C0",}, }; - private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{4,8}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList","addElementalToMachineList","addElementalMufflerToMachineList"}; - private static final byte[] casingTextures = new byte[]{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 Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{4, 8}; + private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList", "addElementalMufflerToMachineList"}; + private static final byte[] casingTextures = new byte[]{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}; //endregion public GT_MetaTileEntity_EM_decay(int aID, String aName, String aNameRegional) { @@ -47,7 +47,7 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return EM_StructureCheckAdvanced(shape,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,2,2,0); + return EM_StructureCheckAdvanced(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 2, 2, 0); } @Override 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 75d3b74626..ac862b855a 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 @@ -25,17 +25,17 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo //region Structure //use multi A energy inputs, use less power the longer it runs private static final String[][] shape = new String[][]{ - {"!!!","!+!","!!!",}, - {"010","111","010",}, - {"\"\"\"","\"1\"","\"\"\"",}, - {"121","2 2","121",}, + {"!!!", "!+!", "!!!",}, + {"010", "111", "010",}, + {"\"\"\"", "\"1\"", "\"\"\"",}, + {"121", "2 2", "121",}, }; - private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT,QuantumGlassBlock.INSTANCE}; - private static final byte[] blockMeta = new byte[]{0,4,0}; - private static final String[] addingMethods = new String[]{"addElementalInputToMachineList","addClassicToMachineList","addElementalMufflerToMachineList"}; - private static final byte[] casingTextures = new byte[]{textureOffset+4,textureOffset,textureOffset+4}; - private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT}; - private static final byte[] blockMetaFallback = new byte[]{4,0,4}; + private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, QuantumGlassBlock.INSTANCE}; + private static final byte[] blockMeta = new byte[]{0, 4, 0}; + private static final String[] addingMethods = new String[]{"addElementalInputToMachineList", "addClassicToMachineList", "addElementalMufflerToMachineList"}; + private static final byte[] casingTextures = new byte[]{textureOffset + 4, textureOffset, textureOffset + 4}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{4, 0, 4}; //endregion public GT_MetaTileEntity_EM_dequantizer(int aID, String aName, String aNameRegional) { @@ -52,7 +52,7 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return EM_StructureCheckAdvanced(shape,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,1,0); + return EM_StructureCheckAdvanced(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 1, 0); } @Override 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 e01e3e364d..9ae9883265 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 @@ -23,12 +23,12 @@ import static gregtech.api.GregTech_API.mEUtoRF; public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBase_EM { //region Structure private static final String[][] shape = new String[][]{ - {" ","000","1+1","000"," ",}, - {" ","010","111","010"," ",}, - {" ","000","111","000"," ",}, + {" ", "000", "1+1", "000", " ",}, + {" ", "010", "111", "010", " ",}, + {" ", "000", "111", "000", " ",}, }; - private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{7,4}; + private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{7, 4}; private static final String[] addingMethods = new String[]{"addClassicToMachineList"}; private static final byte[] casingTextures = new byte[]{textureOffset}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT}; @@ -37,17 +37,17 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa public GT_MetaTileEntity_EM_infuser(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); - minRepairStatus=(byte) getIdealStatus(); + minRepairStatus = (byte) getIdealStatus(); } public GT_MetaTileEntity_EM_infuser(String aName) { super(aName); - minRepairStatus=(byte) getIdealStatus(); + minRepairStatus = (byte) getIdealStatus(); } @Override public boolean isFacingValid(byte aFacing) { - return aFacing>=2; + return aFacing >= 2; } public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { @@ -56,28 +56,28 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return EM_StructureCheckAdvanced(shape,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,2,0); + return EM_StructureCheckAdvanced(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 2, 0); } @Override public boolean EM_checkRecipe(ItemStack itemStack) { - if (itemStack!=null && itemStack.stackSize==1) { - Item ofThis=itemStack.getItem(); - if(ofThis instanceof IElectricItem){ + if (itemStack != null && itemStack.stackSize == 1) { + Item ofThis = itemStack.getItem(); + if (ofThis instanceof IElectricItem) { mEfficiencyIncrease = 10000; mMaxProgresstime = 20; - eDismatleBoom=true; + eDismatleBoom = true; return true; - }else if(TecTech.hasCOFH && ofThis instanceof IEnergyContainerItem){ + } else if (TecTech.hasCOFH && ofThis instanceof IEnergyContainerItem) { mEfficiencyIncrease = 10000; mMaxProgresstime = 20; - eDismatleBoom=true; + eDismatleBoom = true; return true; } } mEfficiencyIncrease = 0; mMaxProgresstime = 0; - eDismatleBoom=false; + eDismatleBoom = false; eAmpereFlow = 0; mEUt = 0; return false; @@ -85,15 +85,15 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public void EM_outputFunction() { - ItemStack itemStack=mInventory[1]; - if (itemStack!=null && itemStack.stackSize==1) { - Item ofThis=itemStack.getItem(); - if(ofThis instanceof IElectricItem){ - if(doChargeItemStack((IElectricItem) ofThis,itemStack)==0) + ItemStack itemStack = mInventory[1]; + if (itemStack != null && itemStack.stackSize == 1) { + Item ofThis = itemStack.getItem(); + if (ofThis instanceof IElectricItem) { + if (doChargeItemStack((IElectricItem) ofThis, itemStack) == 0) this.getBaseMetaTileEntity().disableWorking(); return; - }else if(TecTech.hasCOFH && ofThis instanceof IEnergyContainerItem){ - if(doChargeItemStackRF((IEnergyContainerItem) ofThis,itemStack)==0) + } else if (TecTech.hasCOFH && ofThis instanceof IEnergyContainerItem) { + if (doChargeItemStackRF((IEnergyContainerItem) ofThis, itemStack) == 0) this.getBaseMetaTileEntity().disableWorking(); return; } @@ -104,7 +104,7 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa @Override public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if ((aTick & 31) == 31) { - eSafeVoid=false; + eSafeVoid = false; } } @@ -119,36 +119,34 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa }; } - private long doChargeItemStack(IElectricItem item, ItemStack stack) - { + 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); - long remove=(long)Math.ceil( + double euDiff = item.getMaxCharge(stack) - ElectricItem.manager.getCharge(stack); + if (euDiff > 0) this.setEUVar(this.getEUVar() - this.getEUVar() >> 5); + long remove = (long) Math.ceil( ElectricItem.manager.charge(stack, - Math.min(euDiff,this.getEUVar()) - ,item.getTier(stack),true,false)); - this.setEUVar(this.getEUVar()-remove); - if(this.getEUVar()<0)this.setEUVar(0); + Math.min(euDiff, this.getEUVar()) + , item.getTier(stack), true, false)); + this.setEUVar(this.getEUVar() - remove); + if (this.getEUVar() < 0) this.setEUVar(0); return remove; - } catch( Exception e ) { - if(TecTechConfig.DEBUG_MODE) + } catch (Exception e) { + if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); } return 0; } - private long doChargeItemStackRF(IEnergyContainerItem item, ItemStack stack ) - { + 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), this.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); + 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); return RF; - } catch( Exception e ) { + } catch (Exception e) { if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); } 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 7ad4b57ab8..27392663c6 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 @@ -22,17 +22,17 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB //region Structure //use multi A energy inputs, use less power the longer it runs private static final String[][] shape = new String[][]{ - {" "," + "," ",}, - {"000","000","000",}, - {"!!!","!0!","!!!",}, - {"!!!","!!!","!!!",}, + {" ", " + ", " ",}, + {"000", "000", "000",}, + {"!!!", "!0!", "!!!",}, + {"!!!", "!!!", "!!!",}, }; private static final Block[] blockType = new Block[]{sBlockCasingsTT}; private static final byte[] blockMeta = new byte[]{4}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList","addElementalToMachineList"}; - private static final byte[] casingTextures = new byte[]{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[] addingMethods = new String[]{"addClassicToMachineList", "addElementalToMachineList"}; + private static final byte[] casingTextures = new byte[]{textureOffset, textureOffset + 4}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{0, 4}; //endregion public GT_MetaTileEntity_EM_junction(int aID, String aName, String aNameRegional) { @@ -49,7 +49,7 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return EM_StructureCheckAdvanced(shape,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,1,0); + return EM_StructureCheckAdvanced(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 1, 0); } @Override 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 579b3c8f3a..87fae176e9 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 @@ -41,17 +41,17 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock //region Structure //use multi A energy inputs, use less power the longer it runs private static final String[][] shape = new String[][]{ - {"!!!","!+!","!!!",}, - {"010","101","010",}, - {"\"\"\"","\"0\"","\"\"\"",}, - {"202","0 0","202",}, + {"!!!", "!+!", "!!!",}, + {"010", "101", "010",}, + {"\"\"\"", "\"0\"", "\"\"\"",}, + {"202", "0 0", "202",}, }; - private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT,QuantumGlassBlock.INSTANCE}; - private static final byte[] blockMeta = new byte[]{4,0,0}; - private static final String[] addingMethods = new String[]{"addElementalOutputToMachineList","addClassicToMachineList","addElementalMufflerToMachineList"}; - private static final byte[] casingTextures = new byte[]{textureOffset+4,textureOffset,textureOffset+4}; - private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT}; - private static final byte[] blockMetaFallback = new byte[]{4,0,4}; + private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, QuantumGlassBlock.INSTANCE}; + private static final byte[] blockMeta = new byte[]{4, 0, 0}; + private static final String[] addingMethods = new String[]{"addElementalOutputToMachineList", "addClassicToMachineList", "addElementalMufflerToMachineList"}; + private static final byte[] casingTextures = new byte[]{textureOffset + 4, textureOffset, textureOffset + 4}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{4, 0, 4}; //endregion public GT_MetaTileEntity_EM_quantizer(int aID, String aName, String aNameRegional) { @@ -68,7 +68,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return EM_StructureCheckAdvanced(shape,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,1,0); + return EM_StructureCheckAdvanced(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 1, 0); } @Override 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 aa0d9d3a64..8ea6ac0258 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 @@ -27,24 +27,24 @@ import static gregtech.api.enums.GT_Values.V; * Created by danie_000 on 17.12.2016. */ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockBase_EM { - private final ArrayList<GT_MetaTileEntity_Hatch_Holder> eHolders=new ArrayList<>(); + private final ArrayList<GT_MetaTileEntity_Hatch_Holder> eHolders = new ArrayList<>(); //region structure private static final String[][] shape = new String[][]{ - {E,"000",E,E,E,"000",E,}, - {"A0","010","A1","A!","A1","010","A0",}, - {"A0","010",E,E,E,"010","A0",}, - {"000","010",E,E,E,"010","000",}, - {"000","212","010","0+0","010","212","000",}, - {"000","212","111","111","111","212","000",}, - {"000","222"," "," "," ","222","000",}, + {E, "000", E, E, E, "000", E,}, + {"A0", "010", "A1", "A!", "A1", "010", "A0",}, + {"A0", "010", E, E, E, "010", "A0",}, + {"000", "010", E, E, E, "010", "000",}, + {"000", "212", "010", "0+0", "010", "212", "000",}, + {"000", "212", "111", "111", "111", "212", "000",}, + {"000", "222", " ", " ", " ", "222", "000",}, }; - private static final Block[] blockType = new Block[]{sBlockCasingsTT,sBlockCasingsTT, sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{1,3,2}; - private static final String[] addingMethods = new String[]{"addClassicToMachineList","addHolderToMachineList"}; - private static final byte[] casingTextures = new byte[]{textureOffset+3,textureOffset+3}; + private static final Block[] blockType = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{1, 3, 2}; + private static final String[] addingMethods = new String[]{"addClassicToMachineList", "addHolderToMachineList"}; + private static final byte[] casingTextures = new byte[]{textureOffset + 3, textureOffset + 3}; private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, Blocks.air}; - private static final byte[] blockMetaFallback = new byte[]{3,0}; + private static final byte[] blockMetaFallback = new byte[]{3, 0}; //endregion public GT_MetaTileEntity_EM_research(int aID, String aName, String aNameRegional) { @@ -61,14 +61,15 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB @Override public boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - for(GT_MetaTileEntity_Hatch_Holder rack:eHolders) + for (GT_MetaTileEntity_Hatch_Holder rack : eHolders) if (isValidMetaTileEntity(rack)) rack.getBaseMetaTileEntity().setActive(false); eHolders.clear(); - if(!EM_StructureCheckAdvanced(shape,blockType,blockMeta,addingMethods,casingTextures,blockTypeFallback,blockMetaFallback,1,3,4)) return false; + if (!EM_StructureCheckAdvanced(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 3, 4)) + return false; - for(GT_MetaTileEntity_Hatch_Holder rack:eHolders) + for (GT_MetaTileEntity_Hatch_Holder rack : eHolders) if (isValidMetaTileEntity(rack)) rack.getBaseMetaTileEntity().setActive(iGregTechTileEntity.isActive()); return eHolders.size() == 1; @@ -89,15 +90,15 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB @Override public boolean isFacingValid(byte aFacing) { - return aFacing>=2; + return aFacing >= 2; } @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+3], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 3], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+3]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 3]}; } @Override @@ -113,13 +114,13 @@ 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 protected void EM_stopMachine() { - for(GT_MetaTileEntity_Hatch_Holder r:eHolders) + for (GT_MetaTileEntity_Hatch_Holder r : eHolders) r.getBaseMetaTileEntity().setActive(false); } @@ -135,11 +136,11 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB return false; } - public static void run(){ + public static void run() { try { adderMethodMap.put("addHolderToMachineList", GT_MetaTileEntity_EM_research.class.getMethod("addHolderToMachineList", IGregTechTileEntity.class, int.class)); - }catch (NoSuchMethodException e){ - if(TecTechConfig.DEBUG_MODE) e.printStackTrace(); + } catch (NoSuchMethodException e) { + if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); } } } 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 326f52e88f..219bbc5fbd 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 @@ -17,25 +17,25 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa //region structure private static final String[][] shape = new String[][]{ - {" "," 222 "," 2+2 "," 222 "," ",}, - {"00000","00000","00000","00000","00000",}, - {"00100","01110","11111","01110","00100",}, - {"01110","1C1","1C1","1C1","01110",}, - {"01110","1C1","1C1","1C1","01110",}, - {"01110","1C1","1C1","1C1","01110",}, - {"00100","01110","11\"11","01110","00100",}, - {"!!!!!","!000!","!0#0!","!000!","!!!!!",}, + {" ", " 222 ", " 2+2 ", " 222 ", " ",}, + {"00000", "00000", "00000", "00000", "00000",}, + {"00100", "01110", "11111", "01110", "00100",}, + {"01110", "1C1", "1C1", "1C1", "01110",}, + {"01110", "1C1", "1C1", "1C1", "01110",}, + {"01110", "1C1", "1C1", "1C1", "01110",}, + {"00100", "01110", "11\"11", "01110", "00100",}, + {"!!!!!", "!000!", "!0#0!", "!000!", "!!!!!",}, }; - private static final Block[] blockType = new Block[]{sBlockCasingsTT, QuantumGlassBlock.INSTANCE,sBlockCasingsTT}; - private static final byte[] blockMeta = new byte[]{4,0,0}; + private static final Block[] blockType = new Block[]{sBlockCasingsTT, QuantumGlassBlock.INSTANCE, sBlockCasingsTT}; + private static final byte[] blockMeta = new byte[]{4, 0, 0}; private static final String[] addingMethods = new String[]{ "addClassicToMachineList", "addElementalMufflerToMachineList", "addElementalOutputToMachineList", "addElementalInputToMachineList"}; - private static final byte[] casingTextures = new byte[]{textureOffset,textureOffset+4,textureOffset+4,textureOffset+4}; - private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT,sBlockCasingsTT}; - private static final byte[] blockMetaFallback = new byte[]{0,4,4,4}; + private static final byte[] casingTextures = new byte[]{textureOffset, textureOffset + 4, textureOffset + 4, textureOffset + 4}; + private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT, sBlockCasingsTT}; + private static final byte[] blockMetaFallback = new byte[]{0, 4, 4, 4}; //endregion public GT_MetaTileEntity_EM_scanner(int aID, String aName, String aNameRegional) { 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 5e181cc4f6..66058ec3a3 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 @@ -36,9 +36,9 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas @Override public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+1], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 1], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+1]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 1]}; } @Override @@ -53,9 +53,9 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas for (int h = -1; h < 2; h++) { if ((i != 0 || j != 0 || h != 0)/*exclude center*/ && (xDir + i != 0 || yDir + h != 0 || zDir + j != 0)/*exclude this*/) { IGregTechTileEntity tTileEntity = iGregTechTileEntity.getIGregTechTileEntityOffset(xDir + i, yDir + h, zDir + j); - if (!addEnergyIOToMachineList(tTileEntity, textureOffset+1) && - (!addDataConnectorToMachineList(tTileEntity,textureOffset+1)) && - (!addMaintenanceToMachineList(tTileEntity,textureOffset+1))) { + if (!addEnergyIOToMachineList(tTileEntity, textureOffset + 1) && + (!addDataConnectorToMachineList(tTileEntity, textureOffset + 1)) && + (!addMaintenanceToMachineList(tTileEntity, textureOffset + 1))) { if (iGregTechTileEntity.getBlockOffset(xDir + i, yDir + h, zDir + j) != sBlockCasingsTT || iGregTechTileEntity.getMetaIDOffset(xDir + i, yDir + h, zDir + j) != 1) { return false; @@ -70,13 +70,13 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas @Override public boolean EM_checkRecipe(ItemStack itemStack) { - short thingsActive=0; + short thingsActive = 0; for (GT_MetaTileEntity_Hatch_InputData di : eInputData) - if(di.q!=null) + if (di.q != null) thingsActive++; - if(thingsActive>0){ - thingsActive+=eOutputData.size(); + if (thingsActive > 0) { + thingsActive += eOutputData.size(); mEUt = -(int) V[7]; eAmpereFlow = 1 + (thingsActive >> 2); mMaxProgresstime = 20; @@ -90,7 +90,7 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas @Override public void EM_outputFunction() { - if(eOutputData.size()>0) { + if (eOutputData.size() > 0) { float total = 0; for (int i = 0; i < 10; i++) {//each param pair if (eParamsIn[i] > 0 && eParamsIn[i + 10] >= 0) @@ -106,16 +106,16 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas if (pack == null) return; } - long remaining=pack.computation; + long remaining = pack.computation; for (int i = 0; i < 10; i++) { if (eParamsIn[i] > 0) { final int outIndex = (int) (eParamsIn[i + 10]) - 1; if (outIndex < 0 || outIndex > eOutputData.size()) continue; GT_MetaTileEntity_Hatch_OutputData out = eOutputData.get(outIndex); - final long part=(long) ((pack.computation * eParamsIn[i]) / total); - if(part>0) { - remaining-=part; + final long part = (long) ((pack.computation * eParamsIn[i]) / total); + if (part > 0) { + remaining -= part; if (remaining > 0) out.q = new quantumDataPacket(pack, part); else if (part + remaining > 0) { 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 e56c860854..df8fc702b0 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 @@ -102,7 +102,7 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if ((aTick & 31) == 31) { ePowerPass = aBaseMetaTileEntity.isAllowedToWork(); - eSafeVoid=false; + eSafeVoid = false; } } 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 c8f72bbe1e..11bf4dff44 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 @@ -51,9 +51,9 @@ public class GT_MetaTileEntity_EM_wormhole 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.CASING_BLOCKS[textureOffset+4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+4]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 4]}; } @Override diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java index 783590d64c..d7e6634a86 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_MultiblockBase_EM.java @@ -48,7 +48,7 @@ import static gregtech.api.enums.GT_Values.VN; * Created by danie_000 on 27.10.2016. */ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEntity_MultiBlockBase implements machineTT { - protected final static Map<String,Method> adderMethodMap =new HashMap<>(); + protected final static Map<String, Method> adderMethodMap = new HashMap<>(); public static Method adderMethod; protected cElementalInstanceStackMap[] outputEM = new cElementalInstanceStackMap[0]; @@ -58,7 +58,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt protected static Textures.BlockIcons.CustomIcon ScreenOFF; protected static Textures.BlockIcons.CustomIcon ScreenON; - protected final static int textureOffset=96; + protected final static int textureOffset = 96; public ArrayList<GT_MetaTileEntity_Hatch_InputElemental> eInputHatches = new ArrayList<>(); public ArrayList<GT_MetaTileEntity_Hatch_OutputElemental> eOutputHatches = new ArrayList<>(); @@ -84,7 +84,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt private long maxEUinputMin = 0, maxEUinputMax = 0; public long eAmpereFlow = 1; public long eRequiredData = 0; - protected long eAvailableData=0; + protected long eAvailableData = 0; //init param states in constructor, or implement it in checkrecipe/outputfunction @@ -99,20 +99,27 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt // 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 EM_checkParams() {} + public void EM_checkParams() { + } // update status of parameters in guis and "machine state" // Called before check recipe, before outputting, and every second the machine is active - public void EM_outputFunction() {} + public void EM_outputFunction() { + } // based on "machine state" do output, // this must move to outputEM to EM output hatches // and can also modify output items/fluids/EM, remaining EM is NOT overflowed. // (Well it can be overflowed if machine didn't finished, soft-hammered/disabled/not enough EU) // Setting available data processing - protected void EM_extraHatchInitHook(){}//For extra types of hatches initiation, LOOK HOW IT IS CALLED! onPostTick - protected void EM_extraExplosions(){}//For that extra hatches explosions, and maybe some MOORE EXPLOSIONS - protected void EM_stopMachine(){}//On machine stop + protected void EM_extraHatchInitHook() { + }//For extra types of hatches initiation, LOOK HOW IT IS CALLED! onPostTick + + protected void EM_extraExplosions() { + }//For that extra hatches explosions, and maybe some MOORE EXPLOSIONS + + protected void EM_stopMachine() { + }//On machine stop //machine structure check protected boolean EM_checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { @@ -121,17 +128,17 @@ 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 EM_getAvailableData() { - 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); + 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); return result; } //Extra hook on cyclic updates (not really needed for machines smaller than 1 chunk) //BUT NEEDED WHEN - machine blocks are not touching each other ot they don't implement IMachineBlockUpdateable (ex. air) - protected boolean EM_cyclicUpdate(){ - return mUpdate<=-1000;//set to false to disable cyclic update + protected boolean EM_cyclicUpdate() { + return mUpdate <= -1000;//set to false to disable cyclic update //default is once per 50s; mUpdate is decremented every tick } @@ -165,9 +172,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { if (aSide == aFacing) { - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 4], new GT_RenderedTexture(aActive ? ScreenON : ScreenOFF)}; } - return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset+4]}; + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[textureOffset + 4]}; } @Override @@ -314,9 +321,9 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt return 0; } - private boolean cyclicUpdate(){ - if(EM_cyclicUpdate()){ - mUpdate=0; + private boolean cyclicUpdate() { + if (EM_cyclicUpdate()) { + mUpdate = 0; return true; } return false; @@ -324,7 +331,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public final boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return EM_checkMachine(iGregTechTileEntity,itemStack); + return EM_checkMachine(iGregTechTileEntity, itemStack); } @Override @@ -631,7 +638,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt @Override public boolean onRunningTick(ItemStack aStack) { - if(eRequiredData>0 && eRequiredData>eAvailableData) return false; + if (eRequiredData > 0 && eRequiredData > eAvailableData) return false; if (this.mEUt > 0) { this.EMaddEnergyOutput((long) mEUt * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); return true; @@ -780,8 +787,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt mEfficiencyIncrease = 0; getBaseMetaTileEntity().disableWorking(); - for(GT_MetaTileEntity_Hatch_OutputData data:eOutputData) { - data.q=null; + for (GT_MetaTileEntity_Hatch_OutputData data : eOutputData) { + data.q = null; } float mass = 0; @@ -868,7 +875,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } EM_checkParams(); - eAvailableData= EM_getAvailableData(); + eAvailableData = EM_getAvailableData(); for (GT_MetaTileEntity_Hatch_Uncertainty uncertainty : eUncertainHatches) eCertainStatus = uncertainty.update(eCertainMode); @@ -1323,7 +1330,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt " Efficiency: " + EnumChatFormatting.YELLOW + Float.toString(mEfficiency / 100.0F) + EnumChatFormatting.RESET + " %", "PowerPass: " + EnumChatFormatting.BLUE + ePowerPass + EnumChatFormatting.RESET + " SafeVoid: " + EnumChatFormatting.BLUE + eSafeVoid, - "Computation: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET +" / "+EnumChatFormatting.YELLOW+eRequiredData+EnumChatFormatting.RESET + "Computation: " + EnumChatFormatting.GREEN + eAvailableData + EnumChatFormatting.RESET + " / " + EnumChatFormatting.YELLOW + eRequiredData + EnumChatFormatting.RESET }; } @@ -1339,8 +1346,8 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt String[][] structure,//0-9 casing, +- air no air, a-z ignore Block[] blockType,//use numbers 0-9 for casing types byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset){ - return StructureChecker(structure,blockType,blockMeta,horizontalOffset,verticalOffset,depthOffset,getBaseMetaTileEntity(),!mMachine); + int horizontalOffset, int verticalOffset, int depthOffset) { + return StructureChecker(structure, blockType, blockMeta, horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), !mMachine); } public final boolean EM_StructureCheckAdvanced( @@ -1351,7 +1358,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt byte[] casingTextures, Block[] blockTypeFallback,//use numbers 0-9 for casing types byte[] blockMetaFallback,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset){ + int horizontalOffset, int verticalOffset, int depthOffset) { return StructureCheckerAdvanced(structure, blockType, blockMeta, adderMethod, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, horizontalOffset, verticalOffset, depthOffset, getBaseMetaTileEntity(), !mMachine); @@ -1375,7 +1382,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt hatch_elemental.id = -1; for (GT_MetaTileEntity_Hatch_OutputData hatch_data : eOutputData) { hatch_data.id = -1; - hatch_data.q=null; + hatch_data.q = null; } for (GT_MetaTileEntity_Hatch_DataConnector hatch_data : eInputData) hatch_data.id = -1; @@ -1396,7 +1403,7 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt } } - public static void run(){ + public static void run() { try { adderMethodMap.put("addToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addToMachineList", IGregTechTileEntity.class, int.class)); adderMethodMap.put("addClassicToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicToMachineList", IGregTechTileEntity.class, int.class)); @@ -1418,18 +1425,18 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt adderMethodMap.put("addMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); adderMethodMap.put("addClassicMaintenanceToMachineList", GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addClassicMaintenanceToMachineList", IGregTechTileEntity.class, int.class)); 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(TecTechConfig.DEBUG_MODE) e.printStackTrace(); + adderMethod = GT_MetaTileEntity_MultiblockBase_EM.class.getMethod("addThing", String.class, IGregTechTileEntity.class, int.class); + } catch (NoSuchMethodException e) { + if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); } } //CALLBACK - public final boolean addThing(String methodName,IGregTechTileEntity igt,int casing){ + public final boolean addThing(String methodName, IGregTechTileEntity igt, int casing) { try { return (boolean) adderMethodMap.get(methodName).invoke(this, igt, casing); - }catch (InvocationTargetException | IllegalAccessException e){ - if(TecTechConfig.DEBUG_MODE) e.printStackTrace(); + } catch (InvocationTargetException | IllegalAccessException e) { + if (TecTechConfig.DEBUG_MODE) e.printStackTrace(); } return false; } diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_Container_MultiMachineEM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_Container_MultiMachineEM.java index 5965edc3cb..e104829340 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_Container_MultiMachineEM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/gui/GT_Container_MultiMachineEM.java @@ -47,7 +47,7 @@ public class GT_Container_MultiMachineEM extends GT_ContainerMetaTile_Machine { base.eSafeVoid ^= true; break; case 3: - if(base.getBaseMetaTileEntity().isAllowedToWork()) { + if (base.getBaseMetaTileEntity().isAllowedToWork()) { base.getBaseMetaTileEntity().disableWorking(); } else { base.getBaseMetaTileEntity().enableWorking(); 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 e8732c11f9..8bc860ab84 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 @@ -3,4 +3,6 @@ research station forcefields colorizer -> aka colorable 'bloodmoon' in a box gravity wells/entity accelerators -reverse expand ore processing by scanning ores XD
\ No newline at end of file +reverse expand ore processing by scanning ores XD +quark laseration +color separator
\ No newline at end of file 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 88bb4e409a..39338da80f 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 @@ -107,7 +107,7 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements iConn @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - onPostTick(aBaseMetaTileEntity,31); + onPostTick(aBaseMetaTileEntity, 31); } @Override @@ -120,24 +120,23 @@ public class GT_MetaTileEntity_Pipe_Data extends MetaPipeEntity implements iConn 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 (tTileEntity instanceof IColoredTileEntity) { - //if (aBaseMetaTileEntity.getColorization() >= 0) { - byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); - if (tColor != aBaseMetaTileEntity.getColorization()) continue; - //} - } - if (tTileEntity instanceof iConnectsToDataPipe && (((iConnectsToDataPipe) tTileEntity).canConnect(j))) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); + if (tTileEntity instanceof IColoredTileEntity) { + //if (aBaseMetaTileEntity.getColorization() >= 0) { + byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if (tColor != aBaseMetaTileEntity.getColorization()) continue; + //} + } + if (tTileEntity instanceof iConnectsToDataPipe && (((iConnectsToDataPipe) tTileEntity).canConnect(j))) { + mConnections |= (1 << i); + 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); 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); - connectionCount++; - } - } + } //} //else { // mConnections |= (1 << i); @@ -161,18 +160,18 @@ 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(meta instanceof iConnectsToDataPipe && meta!=source){ - if(meta instanceof GT_MetaTileEntity_Hatch_InputData) - return (iConnectsToDataPipe)meta; - if(meta instanceof GT_MetaTileEntity_Pipe_Data && - ((GT_MetaTileEntity_Pipe_Data) meta).connectionCount==2) - return (iConnectsToDataPipe)meta; + 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 (meta instanceof iConnectsToDataPipe && meta != source) { + if (meta instanceof GT_MetaTileEntity_Hatch_InputData) + return (iConnectsToDataPipe) meta; + if (meta instanceof GT_MetaTileEntity_Pipe_Data && + ((GT_MetaTileEntity_Pipe_Data) meta).connectionCount == 2) + return (iConnectsToDataPipe) meta; } } return null; 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 0c3c68d811..f3d49ec35a 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 @@ -106,7 +106,7 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements iConnec @Override public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { - onPostTick(aBaseMetaTileEntity,31); + onPostTick(aBaseMetaTileEntity, 31); } @Override @@ -119,24 +119,23 @@ public class GT_MetaTileEntity_Pipe_EM extends MetaPipeEntity implements iConnec 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 (tTileEntity instanceof IColoredTileEntity) { - //if (aBaseMetaTileEntity.getColorization() >= 0) { - byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); - if (tColor != aBaseMetaTileEntity.getColorization()) continue; - //} - } - if (tTileEntity instanceof iConnectsToEMpipe && (((iConnectsToEMpipe) tTileEntity).canConnect(j))) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(i); + if (tTileEntity instanceof IColoredTileEntity) { + //if (aBaseMetaTileEntity.getColorization() >= 0) { + byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if (tColor != aBaseMetaTileEntity.getColorization()) continue; + //} + } + if (tTileEntity instanceof iConnectsToEMpipe && (((iConnectsToEMpipe) tTileEntity).canConnect(j))) { + mConnections |= (1 << i); + 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); 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); - connectionCount++; - } - } + } //} //else { // mConnections |= (1 << i); 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 acea205723..9da90a7cc1 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,9 +26,9 @@ import static com.github.technus.tectech.Util.getUniqueIdentifier; */ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_TieredMachineBlock { private static Textures.BlockIcons.CustomIcon MARK; - public short numbers[]=new short[6]; - public boolean size=false; - public String[] result=new String[]{"Undefined"}; + public short numbers[] = new short[6]; + public boolean size = false; + public String[] result = new String[]{"Undefined"}; public GT_MetaTileEntity_DebugStructureWriter(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, "Scans Blocks Around"); @@ -40,7 +40,7 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti @Override public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GT_MetaTileEntity_DebugStructureWriter(mName,mTier,mDescription,mTextures); + return new GT_MetaTileEntity_DebugStructureWriter(mName, mTier, mDescription, mTextures); } @Override @@ -81,15 +81,15 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti @Override public void saveNBTData(NBTTagCompound aNBT) { - for(int i=0;i<numbers.length;i++){ - aNBT.setShort("eData"+i,numbers[i]); + for (int i = 0; i < numbers.length; i++) { + aNBT.setShort("eData" + i, numbers[i]); } } @Override public void loadNBTData(NBTTagCompound aNBT) { - for(int i=0;i<numbers.length;i++){ - numbers[i]=aNBT.getShort("eData"+i); + for (int i = 0; i < numbers.length; i++) { + numbers[i] = aNBT.getShort("eData" + i); } } @@ -100,10 +100,10 @@ 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); - if(TecTechConfig.DEBUG_MODE) - for(String s:result) + if (aBaseMetaTileEntity.isAllowedToWork()) { + result = StructureWriter(this.getBaseMetaTileEntity(), numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], false); + if (TecTechConfig.DEBUG_MODE) + for (String s : result) TecTech.Logger.info(s); aBaseMetaTileEntity.disableWorking(); } @@ -111,9 +111,9 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti @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); - if(TecTechConfig.DEBUG_MODE) - for(String s:result) + result = StructureWriter(this.getBaseMetaTileEntity(), numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], true); + if (TecTechConfig.DEBUG_MODE) + for (String s : result) TecTech.Logger.info(s); } @@ -121,8 +121,8 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { if (aBaseMetaTileEntity.isClientSide()) return true; aBaseMetaTileEntity.openGUI(aPlayer); - if(TecTechConfig.DEBUG_MODE && aPlayer.getHeldItem()!=null) - TecTech.Logger.info("UnlocalizedName: "+ getUniqueIdentifier(aPlayer.getHeldItem())); + if (TecTechConfig.DEBUG_MODE && aPlayer.getHeldItem() != null) + TecTech.Logger.info("UnlocalizedName: " + getUniqueIdentifier(aPlayer.getHeldItem())); return true; } @@ -146,8 +146,8 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti return new String[]{ CommonValues.tecMark, this.mDescription, - EnumChatFormatting.BLUE+"Prints Multiblock NonTE structure check code", - EnumChatFormatting.BLUE+"ABC axises aligned to machine front" + 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_DebugStructureWriter.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/single/gui/GT_Container_DebugStructureWriter.java index bec3676ce1..ff37e1d626 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 @@ -16,8 +16,9 @@ import java.util.Iterator; public class GT_Container_DebugStructureWriter extends GT_ContainerMetaTile_Machine { - public boolean size=false; - public short numbers[]=new short[6]; + public boolean size = false; + public short numbers[] = new short[6]; + public GT_Container_DebugStructureWriter(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { super(aInventoryPlayer, aTileEntity); } @@ -52,44 +53,44 @@ public class GT_Container_DebugStructureWriter } Slot tSlot = (Slot) this.inventorySlots.get(aSlotIndex); if ((tSlot != null) && (this.mTileEntity.getMetaTileEntity() != null)) { - GT_MetaTileEntity_DebugStructureWriter dsw=(GT_MetaTileEntity_DebugStructureWriter)mTileEntity.getMetaTileEntity(); - if(dsw.numbers==null)return null; + GT_MetaTileEntity_DebugStructureWriter dsw = (GT_MetaTileEntity_DebugStructureWriter) mTileEntity.getMetaTileEntity(); + 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: @@ -108,15 +109,15 @@ public class GT_Container_DebugStructureWriter if ((this.mTileEntity.isClientSide()) || (this.mTileEntity.getMetaTileEntity() == null)) { return; } - GT_MetaTileEntity_DebugStructureWriter dsw=(GT_MetaTileEntity_DebugStructureWriter)mTileEntity.getMetaTileEntity(); - if(numbers!=null) + 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; Iterator var2 = this.crafters.iterator(); while (var2.hasNext()) { ICrafting var1 = (ICrafting) var2.next(); - if(numbers!=null) { + if (numbers != null) { var1.sendProgressBarUpdate(this, 100, this.numbers[0]); var1.sendProgressBarUpdate(this, 101, this.numbers[1]); var1.sendProgressBarUpdate(this, 102, this.numbers[2]); @@ -124,7 +125,7 @@ public class GT_Container_DebugStructureWriter var1.sendProgressBarUpdate(this, 104, this.numbers[4]); var1.sendProgressBarUpdate(this, 105, this.numbers[5]); } - var1.sendProgressBarUpdate(this, 106, this.size?1:0); + var1.sendProgressBarUpdate(this, 106, this.size ? 1 : 0); } } @@ -133,10 +134,10 @@ public class GT_Container_DebugStructureWriter super.updateProgressBar(par1, par2); switch (par1) { case 106: - this.size = par2==1; + this.size = par2 == 1; break; default: - if(numbers!=null && par1>=100 && par1<=105) + if (numbers != null && par1 >= 100 && par1 <= 105) this.numbers[par1 - 100] = (short) par2; break; } 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 6a129fa5d6..2192017c6c 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 @@ -14,12 +14,12 @@ public class GT_GUIContainer_DebugStructureWriter extends GT_GUIContainerMetaTil protected void drawGuiContainerForegroundLayer(int par1, int par2) { this.fontRendererObj.drawString("StructPrint", 46, 8, 16448255); if (this.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); + 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); } } diff --git a/src/main/java/com/github/technus/tectech/vec3pos.java b/src/main/java/com/github/technus/tectech/vec3pos.java index 922ce5d66e..fe2670be89 100644 --- a/src/main/java/com/github/technus/tectech/vec3pos.java +++ b/src/main/java/com/github/technus/tectech/vec3pos.java @@ -1,34 +1,50 @@ package com.github.technus.tectech; +import cofh.lib.util.position.BlockPosition; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.world.ChunkPosition; /** * Created by Tec on 05.04.2017. */ public class vec3pos implements Comparable<vec3pos> { - public final int x,z; + public final int x, z; public final short y; - public vec3pos(int x,short y, int z){ - this.x=x; - this.y=y; - this.z=z; + public vec3pos(int x, short y, int z) { + this.x = x; + this.y = y; + this.z = z; } - public vec3pos(IGregTechTileEntity te){ - this.x=te.getXCoord(); - this.y=te.getYCoord(); - this.z=te.getZCoord(); + public vec3pos(IGregTechTileEntity te) { + this.x = te.getXCoord(); + this.y = te.getYCoord(); + this.z = te.getZCoord(); } @Override public int compareTo(vec3pos o) { - if(y>o.y) return 1; - if(y<o.y) return -1; - if(x>o.x) return 1; - if(x<o.x) return -1; - if(z>o.z) return 1; - if(z<o.z) return -1; + if (y > o.y) return 1; + if (y < o.y) return -1; + if (x > o.x) return 1; + if (x < o.x) return -1; + if (z > o.z) return 1; + if (z < o.z) return -1; return 0; } + + @Override + public boolean equals(Object obj) { + if(obj instanceof vec3pos){ + vec3pos v=(vec3pos) obj; + return x==v.x && z==v.z && y==v.y; + } + return false; + } + + @Override + public int hashCode() { + return x*524288+z*256+y; + } } |