From 60d5c5d814e3b0600c9052dad605aa801b69adab Mon Sep 17 00:00:00 2001 From: Technus Date: Sat, 13 May 2017 21:34:22 +0200 Subject: Near to finish another refactor. --- .../java/com/github/technus/tectech/TecTech.java | 43 +-- src/main/java/com/github/technus/tectech/Util.java | 399 ++++++++++++++------- .../technus/tectech/auxiliary/TecTechConfig.java | 2 +- .../tectech/dataFramework/quantumDataPacket.java | 65 ++-- .../elementalMatter/classes/cElementalDecay.java | 10 +- .../classes/cElementalDefinition.java | 50 +-- .../classes/cElementalDefinitionStack.java | 46 +-- .../classes/cElementalDefinitionStackMap.java | 26 +- .../classes/cElementalInstanceStack.java | 51 +-- .../classes/cElementalInstanceStackMap.java | 72 +++- .../cElementalMutableDefinitionStackMap.java | 46 ++- .../classes/cElementalPrimitive.java | 26 +- .../classes/cElementalStackMap.java | 64 ++-- .../elementalMatter/classes/rElementalRecipe.java | 30 +- .../classes/rElementalRecipeMap.java | 64 ++++ .../classes/rElementalRecipeTree.java | 60 ---- .../classes/tElementalRecipeCollision.java | 10 + .../definitions/dAtomDefinition.java | 34 +- .../definitions/dComplexAspectDefinition.java | 135 ------- .../definitions/dHadronDefinition.java | 24 +- .../definitions/ePrimalAspectDefinition.java | 38 -- .../interfaces/iElementalDefinition.java | 6 +- .../definitions/dComplexAspectDefinition.java | 136 +++++++ .../definitions/ePrimalAspectDefinition.java | 38 ++ .../technus/tectech/loader/MachineLoader.java | 12 +- .../github/technus/tectech/loader/MainLoader.java | 4 +- .../technus/tectech/loader/RecipeLoader.java | 2 + .../technus/tectech/loader/ThingsLoader.java | 1 - .../technus/tectech/thing/CustomItemList.java | 4 +- .../tectech/thing/block/QuantumGlassBlock.java | 8 +- .../tectech/thing/block/QuantumGlassItem.java | 2 +- .../tectech/thing/casing/GT_Item_CasingsTT.java | 2 +- .../technus/tectech/thing/item/DebugBuilder.java | 8 +- .../tectech/thing/item/DebugContainer_EM.java | 12 +- .../GT_MetaTileEntity_Hatch_DataConnector.java | 22 +- ...GT_MetaTileEntity_Hatch_ElementalContainer.java | 7 +- .../hatch/GT_MetaTileEntity_Hatch_Holder.java | 6 +- .../hatch/GT_MetaTileEntity_Hatch_InputData.java | 4 +- .../hatch/GT_MetaTileEntity_Hatch_OutputData.java | 35 +- .../hatch/GT_MetaTileEntity_Hatch_Rack.java | 203 +++++------ .../hatch/GT_MetaTileEntity_Hatch_Uncertainty.java | 18 +- .../hatch/gui/GT_Container_Holder.java | 12 +- .../hatch/gui/GT_Container_Rack.java | 20 +- .../hatch/gui/GT_GUIContainer_Holder.java | 2 +- .../hatch/gui/GT_GUIContainer_Rack.java | 4 +- .../multi/GT_MetaTileEntity_EM_bhg.java | 6 +- .../multi/GT_MetaTileEntity_EM_collider.java | 50 +-- .../multi/GT_MetaTileEntity_EM_computer.java | 167 ++++----- .../multi/GT_MetaTileEntity_EM_decay.java | 32 +- .../multi/GT_MetaTileEntity_EM_dequantizer.java | 22 +- .../multi/GT_MetaTileEntity_EM_infuser.java | 84 +++-- .../multi/GT_MetaTileEntity_EM_junction.java | 18 +- .../multi/GT_MetaTileEntity_EM_quantizer.java | 22 +- .../multi/GT_MetaTileEntity_EM_research.java | 49 +-- .../multi/GT_MetaTileEntity_EM_scanner.java | 26 +- .../multi/GT_MetaTileEntity_EM_switch.java | 28 +- .../multi/GT_MetaTileEntity_EM_transformer.java | 2 +- .../multi/GT_MetaTileEntity_EM_wormhole.java | 4 +- .../multi/GT_MetaTileEntity_MultiblockBase_EM.java | 79 ++-- .../multi/gui/GT_Container_MultiMachineEM.java | 2 +- .../tectech/thing/metaTileEntity/multi/other todo | 4 +- .../pipe/GT_MetaTileEntity_Pipe_Data.java | 55 ++- .../pipe/GT_MetaTileEntity_Pipe_EM.java | 31 +- .../GT_MetaTileEntity_DebugStructureWriter.java | 38 +- .../gui/GT_Container_DebugStructureWriter.java | 45 +-- .../gui/GT_GUIContainer_DebugStructureWriter.java | 12 +- .../java/com/github/technus/tectech/vec3pos.java | 46 ++- 67 files changed, 1467 insertions(+), 1218 deletions(-) create mode 100644 src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeMap.java delete mode 100644 src/main/java/com/github/technus/tectech/elementalMatter/classes/rElementalRecipeTree.java create mode 100644 src/main/java/com/github/technus/tectech/elementalMatter/classes/tElementalRecipeCollision.java delete mode 100644 src/main/java/com/github/technus/tectech/elementalMatter/definitions/dComplexAspectDefinition.java delete mode 100644 src/main/java/com/github/technus/tectech/elementalMatter/definitions/ePrimalAspectDefinition.java create mode 100644 src/main/java/com/github/technus/tectech/elementalMatter/magicAddon/definitions/dComplexAspectDefinition.java create mode 100644 src/main/java/com/github/technus/tectech/elementalMatter/magicAddon/definitions/ePrimalAspectDefinition.java (limited to 'src/main/java') 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 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 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=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 output=new ArrayList<>(); + List 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'@') { + } 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 trace=new TreeSet<>(); + public long computation = 0; + public Set 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 nbtCreationBind = new HashMap<>();//creator methods in subclasses + protected static Method addCreatorFromNBT(byte b, Method m) { return nbtCreationBind.put(b, m); } @@ -38,40 +39,31 @@ 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 in) { - map = new TreeMap<>(); - for (cElementalDefinitionStack stack : in.values()) - map.put(stack.definition, stack); + public cElementalDefinitionStackMap(TreeMap 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 getRawMap() { - return toMutable().getRawMap(); + @Deprecated//BETTER TO JUST MAKE A MUTABLE VERSION AND DO SHIT ON IT + public TreeMap 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((iE