diff options
Diffstat (limited to 'src/main/java')
47 files changed, 1409 insertions, 676 deletions
diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java index eb9b97deee..df5054ab4a 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaDequantizer.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; @@ -11,7 +11,7 @@ import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -143,7 +143,7 @@ public class GT_MetaTileEntity_EM_essentiaDequantizer extends GT_MetaTileEntity_ } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java index 0259aec7a7..d48c345e8e 100644 --- a/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java +++ b/src/main/java/com/github/technus/tectech/compatibility/thaumcraft/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_essentiaQuantizer.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.compatibility.thaumcraft.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.ePrimalAspectDefinition; @@ -11,7 +11,7 @@ import com.github.technus.tectech.thing.casing.TT_Container_Casings; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.GT_MetaTileEntity_EM_quantizer; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -147,7 +147,7 @@ public class GT_MetaTileEntity_EM_essentiaQuantizer extends GT_MetaTileEntity_Mu } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java b/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java index 93752cc02f..665889dc1f 100644 --- a/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java +++ b/src/main/java/com/github/technus/tectech/loader/ConstructableLoader.java @@ -2,7 +2,7 @@ package com.github.technus.tectech.loader; import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; import com.github.technus.tectech.mechanics.constructable.IMultiblockInfoContainer; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import gregtech.common.tileentities.machines.multi.GT_MetaTileEntity_ElectricBlastFurnace; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -39,7 +39,7 @@ public class ConstructableLoader implements Runnable { } @Override - public String[] getDescription(int stackSize) { + public String[] getDescription(ItemStack stackSize) { return desc; } }); diff --git a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java index 5c8c902484..2a93bcc540 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java +++ b/src/main/java/com/github/technus/tectech/mechanics/alignment/enumerable/ExtendedFacing.java @@ -12,7 +12,6 @@ import static com.github.technus.tectech.mechanics.alignment.IAlignment.FLIPS_CO import static com.github.technus.tectech.mechanics.alignment.IAlignment.ROTATIONS_COUNT; import static java.lang.Math.abs; import static java.util.Arrays.stream; -import static java.util.stream.Collectors.reducing; import static java.util.stream.Collectors.toMap; public enum ExtendedFacing { @@ -144,32 +143,32 @@ public enum ExtendedFacing { switch (direction){ case DOWN: a= ForgeDirection.WEST; - b= ForgeDirection.NORTH; + b= ForgeDirection.SOUTH; c= ForgeDirection.UP; break; case UP: a= ForgeDirection.EAST; - b= ForgeDirection.NORTH; + b= ForgeDirection.SOUTH; c= ForgeDirection.DOWN; break; case NORTH: a= ForgeDirection.WEST; - b= ForgeDirection.UP; + b= ForgeDirection.DOWN; c= ForgeDirection.SOUTH; break; case SOUTH: a= ForgeDirection.EAST; - b= ForgeDirection.UP; + b= ForgeDirection.DOWN; c= ForgeDirection.NORTH; break; case WEST: a= ForgeDirection.SOUTH; - b= ForgeDirection.UP; + b= ForgeDirection.DOWN; c= ForgeDirection.EAST; break; case EAST: a= ForgeDirection.NORTH; - b= ForgeDirection.UP; + b= ForgeDirection.DOWN; c= ForgeDirection.WEST; break; default:throw new RuntimeException("Is impossible..."); @@ -187,7 +186,7 @@ public enum ExtendedFacing { default:throw new RuntimeException("Even more impossible..."); } switch (rotation) { - case COUNTER_CLOCKWISE: { + case CLOCKWISE: { ForgeDirection _a=a; a =b; b =_a.getOpposite(); @@ -197,7 +196,7 @@ public enum ExtendedFacing { a=a.getOpposite(); b=b.getOpposite(); break; - case CLOCKWISE: { + case COUNTER_CLOCKWISE: { ForgeDirection _a=a; a =b.getOpposite(); b =_a; diff --git a/src/main/java/com/github/technus/tectech/mechanics/constructable/IConstructable.java b/src/main/java/com/github/technus/tectech/mechanics/constructable/IConstructable.java index d7c3c86098..1de0381f1f 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/constructable/IConstructable.java +++ b/src/main/java/com/github/technus/tectech/mechanics/constructable/IConstructable.java @@ -11,6 +11,6 @@ public interface IConstructable { void construct(ItemStack stackSize, boolean hintsOnly); @SideOnly(Side.CLIENT) - String[] getStructureDescription(int stackSize); + String[] getStructureDescription(ItemStack stackSize); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/constructable/IMultiblockInfoContainer.java b/src/main/java/com/github/technus/tectech/mechanics/constructable/IMultiblockInfoContainer.java index 29769fafb8..2506342f72 100644 --- a/src/main/java/com/github/technus/tectech/mechanics/constructable/IMultiblockInfoContainer.java +++ b/src/main/java/com/github/technus/tectech/mechanics/constructable/IMultiblockInfoContainer.java @@ -26,5 +26,5 @@ public interface IMultiblockInfoContainer { void construct(ItemStack stackSize, boolean hintsOnly, TileEntity tileEntity, ExtendedFacing aSide); @SideOnly(Side.CLIENT) - String[] getDescription(int stackSize); + String[] getDescription(ItemStack stackSize); } diff --git a/src/main/java/com/github/technus/tectech/mechanics/constructable/Structure.java b/src/main/java/com/github/technus/tectech/mechanics/constructable/Structure.java deleted file mode 100644 index 00ffb32525..0000000000 --- a/src/main/java/com/github/technus/tectech/mechanics/constructable/Structure.java +++ /dev/null @@ -1,526 +0,0 @@ -package com.github.technus.tectech.mechanics.constructable; - -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import com.github.technus.tectech.thing.casing.TT_Container_Casings; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static gregtech.api.enums.GT_Values.E; - -public class Structure { - private static final Pattern matchE_ = Pattern.compile("(E,(E,)+)"); - - private Structure(){} - - //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller - //This only checks for REGULAR BLOCKS! - public static boolean checker( - String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR-1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - IHatchAdder[] addingMethods, - short[] 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, - IGregTechTileEntity aBaseMetaTileEntity, - ExtendedFacing extendedFacing, - boolean forceCheck) { - World world = aBaseMetaTileEntity.getWorld(); - if (world.isRemote) { - return false; - } - //TE Rotation - if(extendedFacing==null){ - extendedFacing=ExtendedFacing.of(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing())); - } - - IGregTechTileEntity igt; - - int[] xyz =new int[3]; - int[] abc =new int[3]; - int pointer; - int baseX = aBaseMetaTileEntity.getXCoord(), - baseZ = aBaseMetaTileEntity.getZCoord(), - baseY = aBaseMetaTileEntity.getYCoord(); - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - //yPos - absolute height of checked block - - //perform your duties - abc[2] = -depthOffset; - for (String[] _structure : structure) {//front to back - abc[1] = verticalOffset; - for (String __structure : _structure) {//top to bottom - abc[0] = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block < ' ') {//Control chars allow skipping - abc[1] -= block; - break; - } else if (block > '@') {//characters allow to skip check A-1 skip, B-2 skips etc. - abc[0] += block - '@'; - }//else if (block < '+')//used to mark THINGS - // a++; - else if (block == '.') { - abc[0]++; - } else { - //get x y z from rotation - extendedFacing.getWorldOffset(abc,xyz); - xyz[0]+=baseX; - xyz[1]+=baseY; - xyz[2]+=baseZ; - - //that must be here since in some cases other axis (b,c) controls y - if (xyz[1] < 0 || xyz[1] >= 256) { - return false; - } - - //Check block - if (world.blockExists(xyz[0], xyz[1], xyz[2])) {//this actually checks if the chunk is loaded at this pos - switch (block) { - case '-'://must be air - if (world.getBlock(xyz[0], xyz[1], xyz[2]).getMaterial() != Material.air) { - return false; - } - break; - case '+'://must not be air - if (world.getBlock(xyz[0], xyz[1], xyz[2]).getMaterial() == Material.air) { - return false; - } - break; - default://check for block (countable) - if ((pointer = block - '0') >= 0) { - //countable air -> net.minecraft.block.BlockAir - if (world.getBlock(xyz[0], xyz[1], xyz[2]) != blockType[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-block-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + world.getBlock(xyz[0], xyz[1], xyz[2]).getUnlocalizedName() + ' ' + blockType[pointer].getUnlocalizedName()); - } - return false; - } - if (world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) != blockMeta[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Struct-meta-id-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) + ' ' + blockMeta[pointer]); - } - return false; - } - } else //noinspection ConstantConditions - if ((pointer = block - ' ') >= 0) { - igt = aBaseMetaTileEntity.getIGregTechTileEntity(xyz[0], xyz[1], xyz[2]); - if (igt == null || !addingMethods[pointer].apply(igt, casingTextures[pointer])) { - if (world.getBlock(xyz[0], xyz[1], xyz[2]) != blockTypeFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-struct-block-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + world.getBlock(xyz[0], xyz[1], xyz[2]).getUnlocalizedName() + ' ' + (blockTypeFallback[pointer] == null ? "null" : blockTypeFallback[pointer].getUnlocalizedName())); - } - return false; - } - if (world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) != blockMetaFallback[pointer]) { - if (DEBUG_MODE) { - TecTech.LOGGER.info("Fallback-Struct-meta-id-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) + ' ' + blockMetaFallback[pointer]); - } - return false; - } - } - } - } - } else if (forceCheck) { - return false; - } - abc[0]++;//block in horizontal layer - } - } - abc[1]--;//horizontal layer - } - abc[2]++;//depth - } - return true; - } - - public static boolean builder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - IGregTechTileEntity tileEntity, ExtendedFacing extendedFacing, boolean hintsOnly) { - return builder(structure, blockType, blockMeta, horizontalOffset, verticalOffset, depthOffset, - tileEntity.getWorld(),tileEntity.getXCoord(),tileEntity.getYCoord(),tileEntity.getZCoord(), - extendedFacing, hintsOnly); - } - - public static boolean builder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - TileEntity tileEntity, ExtendedFacing extendedFacing, boolean hintsOnly) { - return builder(structure, blockType, blockMeta, horizontalOffset, verticalOffset, depthOffset, - tileEntity.getWorldObj(),tileEntity.xCoord,tileEntity.yCoord,tileEntity.zCoord, - extendedFacing, hintsOnly); - } - - public static boolean builder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks - Block[] blockType,//use numbers 0-9 for casing types - byte[] blockMeta,//use numbers 0-9 for casing types - int horizontalOffset, int verticalOffset, int depthOffset, - World world,int baseX,int baseZ,int baseY, ExtendedFacing extendedFacing, boolean hintsOnly) { - if (world==null || (!world.isRemote && hintsOnly)) { - return false; - } - - //TE Rotation - int[] xyz =new int[3]; - int[] abc =new int[3]; - int pointer; - - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - - //perform your duties - abc[2] = -depthOffset; - for (String[] _structure : structure) {//front to back - abc[1] = verticalOffset; - for (String __structure : _structure) {//top to bottom - abc[0] = -horizontalOffset; - for (char block : __structure.toCharArray()) {//left to right - if (block < ' ') {//Control chars allow skipping - abc[1] -= block; - break; - } - if (block > '@')//characters allow to skip check a-1 skip, b-2 skips etc. - { - abc[0] += block - '@'; - }//else if (block < '+')//used to mark THINGS - // a++; - else if (block == '.')// this TE - { - abc[0]++; - } else { - //get x y z from rotation - extendedFacing.getWorldOffset(abc,xyz); - xyz[0]+=baseX; - xyz[1]+=baseY; - xyz[2]+=baseZ; - - //that must be here since in some cases other axis (b,c) controls y - if (xyz[1] < 0 || xyz[1] >= 256) { - return false; - } - - //Check block - if (world.blockExists(xyz[0], xyz[1], xyz[2])) {//this actually checks if the chunk is loaded - if (hintsOnly) { - switch (block) { - case '-'://must be air - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 13); - break; - case '+'://must not be air - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 14); - break; - default: //check for block - if ((pointer = block - '0') >= 0) { - if (world.getBlock(xyz[0], xyz[1], xyz[2]) != blockType[pointer] || world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) != blockMeta[pointer]) { - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], blockType[pointer], blockMeta[pointer]); - } - } else if ((pointer = block - ' ') >= 0) { - if (pointer >= 0 && pointer < 12) { - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, pointer); - } else { - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 12); - } - } else { - TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 15); - } - } - } else { - switch (block) { - case '-'://must be air - world.setBlock(xyz[0], xyz[1], xyz[2], Blocks.air, 0, 2); - break; - case '+'://must not be air - world.setBlock(xyz[0], xyz[1], xyz[2], TT_Container_Casings.sBlockCasingsTT, 14, 2); - break; - default: //check for block - if ((pointer = block - '0') >= 0) { - world.setBlock(xyz[0], xyz[1], xyz[2], blockType[pointer], blockMeta[pointer], 2); - } else if (block - ' ' < 0) { - world.setBlock(xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 15, 2); - } //else { - //switch(pointer){ - // case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: - // world.setBlock(x, y, z, TT_Container_Casings.sHintCasingsTT, pointer, 2); break; - // default:world.setBlock(x, y, z, TT_Container_Casings.sHintCasingsTT, 12, 2); - //} - //} - } - } - } - abc[0]++;//block in horizontal layer - } - } - abc[1]--;//horizontal layer - } - abc[2]++;//depth - } - return true; - } - - - public static String[] writer(IGregTechTileEntity aBaseMetaTileEntity, - int horizontalOffset, int verticalOffset, int depthOffset, - 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"}; - } - - ItemStack[] array = new ItemStack[10]; - - int x, y, z, a, b, c; - int - baseX = aBaseMetaTileEntity.getXCoord(), - baseZ = aBaseMetaTileEntity.getZCoord(), - baseY = aBaseMetaTileEntity.getYCoord(); - //a,b,c - relative to block face! - //x,y,z - relative to block position on map! - //yPos - absolute height of checked block - - //perform your duties - #1 - count block types - c = -depthOffset; - for (int cz = 0; cz < depthSize; cz++) {//front to back - b = verticalOffset; - for (int by = 0; by < verticalSize; by++) {//top to bottom - a = -horizontalOffset; - for (int az = 0; az < horizontalSize; az++) {//left to right - //get x y z from rotation - switch (facing) {//translation - case 4: - x = baseX + c; - z = baseZ + a; - y = baseY + b; - break; - case 3: - x = baseX + a; - z = baseZ - c; - y = baseY + b; - break; - case 5: - x = baseX - c; - z = baseZ - a; - y = baseY + b; - break; - case 2: - x = baseX - a; - z = baseZ + c; - y = baseY + b; - break; - //Things get odd if the block faces up or down... - case 1: - x = baseX + a; - z = baseZ + b; - y = baseY - c; - break;//similar to 3 - case 0: - x = baseX - a; - z = baseZ - b; - y = baseY + 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"}; - } - - //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; - 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; - break; - } - } - if (err) { - return new String[]{"Too much different blocks"}; - } - } - - a++;//block in horizontal layer - } - b--;//horizontal layer - } - c++;//depth - } - - List<String> output = new ArrayList<>(); - - 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()); - } - } - 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()); - } - } - output.add(""); - output.add("String[][]"); - //perform your duties - #2 - write strings - output.add("{"); - c = -depthOffset; - for (int cz = 0; cz < depthSize; cz++) {//front to back - b = verticalOffset; - StringBuilder addMe = new StringBuilder().append('{'); - for (int by = 0; by < verticalSize; by++) {//top to bottom - a = -horizontalOffset; - StringBuilder line = new StringBuilder(); - for (int az = 0; az < horizontalSize; az++) {//left to right - //get x y z from rotation - switch (facing) {//translation - case 4: - x = baseX + c; - z = baseZ + a; - y = baseY + b; - break; - case 3: - x = baseX + a; - z = baseZ - c; - y = baseY + b; - break; - case 5: - x = baseX - c; - z = baseZ - a; - y = baseY + b; - break; - case 2: - x = baseX - a; - z = baseZ + c; - y = baseY + b; - break; - //Things get odd if the block faces up or down... - case 1: - x = baseX + a; - z = baseZ + b; - y = baseY - c; - break;//similar to 3 - case 0: - x = baseX - a; - z = baseZ - b; - y = baseY + 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.append('.'); - } else if (block.getMaterial() == Material.air) { - line.append('-'); - } else if (block.hasTileEntity(meta)) { - line.append('*'); - } 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.append(str); - } - a++;//block in horizontal layer - } - if (ignoreAir) { - StringBuilder builder = new StringBuilder(); - char temp = '@'; - for (char ch : line.toString().toCharArray()) { - if (ch == '-') { - temp += 1; - if (temp == '~') { - builder.append('~'); - temp = '@'; - } - } else { - if (temp > '@') { - builder.append(temp); - temp = '@'; - } - builder.append(ch); - } - } - while (builder.length() > 0 && builder.charAt(builder.length() - 1) == '~') { - builder.deleteCharAt(builder.length() - 1); - } - if (builder.length() == 0) { - builder.append("E,"); - } else { - builder.insert(0, '"'); - builder.append('"').append(','); - } - addMe.append(builder); - } else { - if (line.length() == 0) { - line.append("E,"); - } else { - line.insert(0, '"'); - line.append('"').append(','); - } - addMe.append(line); - } - b--;//horizontal layer - } - //region less verbose - addMe.append('}').append(','); - String builtStr = addMe.toString().replaceAll("(E,)+(?=})", E/*Remove Empty strings at end*/); - Matcher matcher = matchE_.matcher(builtStr); - while (matcher.find()) { - byte lenEE = (byte) (matcher.group(1).length() >> 1); - builtStr = builtStr.replaceFirst("E,(E,)+", "\"\\\\u00" + String.format("%02X", lenEE - 1) + "\","); - //builtStr=builtStr.replaceFirst("E,(E,)+\"","\"\\\\u00"+String.format("%02X", lenEE)); - } - //endregion - output.add(builtStr); - c++;//depth - } - output.add("}"); - return output.toArray(new String[0]); - } -} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockAdder.java new file mode 100644 index 0000000000..3dda99fed2 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockAdder.java @@ -0,0 +1,14 @@ +package com.github.technus.tectech.mechanics.structure; + + +import net.minecraft.block.Block; + +public interface IBlockAdder { + /** + * Callback on block added + * @param block block attempted to add + * @param meta meta of block attempted to add + * @return is structure still valid + */ + boolean apply(Block block, Integer meta); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockPosConsumer.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockPosConsumer.java new file mode 100644 index 0000000000..c3ea2d3e3f --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IBlockPosConsumer.java @@ -0,0 +1,7 @@ +package com.github.technus.tectech.mechanics.structure; + +import net.minecraft.world.World; + +public interface IBlockPosConsumer { + void consume(World world, int x, int y, int z); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IHatchAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IHatchAdder.java new file mode 100644 index 0000000000..10d4c398ec --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IHatchAdder.java @@ -0,0 +1,14 @@ +package com.github.technus.tectech.mechanics.structure; + + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public interface IHatchAdder { + /** + * Callback to add hatch + * @param iGregTechTileEntity hatch + * @param aShort requested texture index, or null if not... + * @return managed to add hatch (structure still valid) + */ + boolean apply(IGregTechTileEntity iGregTechTileEntity, Short aShort); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java new file mode 100644 index 0000000000..656151dc86 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureDefinition.java @@ -0,0 +1,137 @@ +package com.github.technus.tectech.mechanics.structure; + +import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; +import net.minecraft.world.World; + +public interface IStructureDefinition<T> { + /** + * Used internally + * @param name same name as for other methods here + * @return the array of elements to process + */ + IStructureElementProvider<T>[] getElementsFor(String name); + + default boolean check(T object,String piece, World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC, + boolean forceCheckAllBlocks){ + return iterate(object,getElementsFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, + basePositionA, basePositionB, basePositionC,false,forceCheckAllBlocks); + } + + default boolean hints(T object,String piece, World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC) { + return iterate(object,getElementsFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, + basePositionA, basePositionB, basePositionC,true,null); + } + + default boolean build(T object,String piece, World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC) { + return iterate(object,getElementsFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, + basePositionA, basePositionB, basePositionC,false,null); + } + + default boolean buildOrHints(T object,String piece, World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC, + boolean hintsOnly){ + return iterate(object,getElementsFor(piece), world, extendedFacing, basePositionX, basePositionY, basePositionZ, + basePositionA, basePositionB, basePositionC,hintsOnly,null); + } + + static <T> boolean iterate(T object, IStructureElementProvider<T>[] elements, World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC, + boolean hintsOnly, Boolean checkBlocksIfNotNullForceCheckAllIfTrue){ + if(world.isRemote ^ hintsOnly){ + return false; + } + + //change base position to base offset + basePositionA=-basePositionA; + basePositionB=-basePositionB; + basePositionC=-basePositionC; + + int[] abc = new int[]{basePositionA,basePositionB,basePositionC}; + int[] xyz = new int[3]; + + if(checkBlocksIfNotNullForceCheckAllIfTrue!=null){ + if(checkBlocksIfNotNullForceCheckAllIfTrue){ + for (IStructureElementProvider<T> elementProvider : elements) { + IStructureElement<T> element=elementProvider.getStructureElement(object); + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + if(!element.check(object, world, xyz[0], xyz[1], xyz[2])){ + return false; + } + }else { + return false; + } + + abc[0] =(element.resetA()?basePositionA:abc[0])+element.getStepA(); + abc[1] =(element.resetB()?basePositionA:abc[1])+element.getStepB(); + abc[2] =(element.resetC()?basePositionA:abc[2])+element.getStepC(); + } + } else { + for (IStructureElementProvider<T> elementProvider : elements) { + IStructureElement<T> element=elementProvider.getStructureElement(object); + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + if(!element.check(object, world, xyz[0], xyz[1], xyz[2])){ + return false; + } + } + + abc[0] =(element.resetA()?basePositionA:abc[0])+element.getStepA(); + abc[1] =(element.resetB()?basePositionA:abc[1])+element.getStepB(); + abc[2] =(element.resetC()?basePositionA:abc[2])+element.getStepC(); + } + } + }else { + if(hintsOnly) { + for (IStructureElementProvider<T> elementProvider : elements) { + IStructureElement<T> element=elementProvider.getStructureElement(object); + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + element.spawnHint(object, world, xyz[0], xyz[1], xyz[2]); + } + + abc[0] =(element.resetA()?basePositionA:abc[0])+element.getStepA(); + abc[1] =(element.resetB()?basePositionA:abc[1])+element.getStepB(); + abc[2] =(element.resetC()?basePositionA:abc[2])+element.getStepC(); + } + } else { + for (IStructureElementProvider<T> elementProvider : elements) { + IStructureElement<T> element=elementProvider.getStructureElement(object); + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += basePositionX; + xyz[1] += basePositionY; + xyz[2] += basePositionZ; + + if (world.blockExists(xyz[0], xyz[1], xyz[2])) { + element.placeBlock(object, world, xyz[0], xyz[1], xyz[2]); + } + + abc[0] =(element.resetA()?basePositionA:abc[0])+element.getStepA(); + abc[1] =(element.resetB()?basePositionA:abc[1])+element.getStepB(); + abc[2] =(element.resetC()?basePositionA:abc[2])+element.getStepC(); + } + } + } + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java new file mode 100644 index 0000000000..d33eac4119 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElement.java @@ -0,0 +1,47 @@ +package com.github.technus.tectech.mechanics.structure; + +import net.minecraft.world.World; + +/** + * Use StructureUtility to instantiate + */ +public interface IStructureElement<T> extends IStructureElementProvider<T> { + boolean check(T t,World world,int x,int y,int z); + + default boolean spawnHint(T t,World world,int x,int y,int z){ + return false; + } + + default boolean placeBlock(T t,World world,int x,int y,int z){ + return false; + } + + default int getStepA(){ + return 1; + } + + default int getStepB(){ + return 0; + } + + default int getStepC(){ + return 0; + } + + default boolean resetA(){ + return false; + } + + default boolean resetB(){ + return false; + } + + default boolean resetC(){ + return false; + } + + @Override + default IStructureElement<T> getStructureElement(T object){ + return this; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementProvider.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementProvider.java new file mode 100644 index 0000000000..b38c2164c3 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureElementProvider.java @@ -0,0 +1,5 @@ +package com.github.technus.tectech.mechanics.structure; + +public interface IStructureElementProvider<T> { + IStructureElement<T> getStructureElement(T object); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureFallback.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureFallback.java new file mode 100644 index 0000000000..354aaf60e9 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureFallback.java @@ -0,0 +1,40 @@ +package com.github.technus.tectech.mechanics.structure; + +import net.minecraft.world.World; + +/** + * Use StructureUtility to instantiate + */ +public interface IStructureFallback<T> extends IStructureElement<T> { + IStructureElement<T>[] fallbacks(); + + @Override + default boolean check(T t, World world, int x, int y, int z){ + for (IStructureElement<T> fallback : fallbacks()) { + if (fallback.check(t, world, x, y, z)) { + return true; + } + } + return false; + } + + @Override + default boolean spawnHint(T t, World world, int x, int y, int z) { + for (IStructureElement<T> fallback : fallbacks()) { + if (fallback.spawnHint(t, world, x, y, z)) { + return true; + } + } + return false; + } + + @Override + default boolean placeBlock(T t, World world, int x, int y, int z) { + for (IStructureElement<T> fallback : fallbacks()) { + if (fallback.placeBlock(t, world, x, y, z)) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureFallbackProvider.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureFallbackProvider.java new file mode 100644 index 0000000000..c0c24eaec4 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureFallbackProvider.java @@ -0,0 +1,40 @@ +package com.github.technus.tectech.mechanics.structure; + +import net.minecraft.world.World; + +/** + * Use StructureUtility to instantiate + */ +public interface IStructureFallbackProvider<T> extends IStructureElement<T> { + IStructureElementProvider<T>[] fallbacks(); + + @Override + default boolean check(T t,World world, int x, int y, int z){ + for (IStructureElementProvider<T> fallback : fallbacks()) { + if (fallback.getStructureElement(t).check(t, world, x, y, z)) { + return true; + } + } + return false; + } + + @Override + default boolean spawnHint(T t,World world, int x, int y, int z) { + for (IStructureElementProvider<T> fallback : fallbacks()) { + if (fallback.getStructureElement(t).spawnHint(t, world, x, y, z)) { + return true; + } + } + return false; + } + + @Override + default boolean placeBlock(T t,World world, int x, int y, int z) { + for (IStructureElementProvider<T> fallback : fallbacks()) { + if (fallback.getStructureElement(t).placeBlock(t, world, x, y, z)) { + return true; + } + } + return false; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java new file mode 100644 index 0000000000..bba3dc5239 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/IStructureNavigate.java @@ -0,0 +1,23 @@ +package com.github.technus.tectech.mechanics.structure; + +import net.minecraft.world.World; + +/** + * Use StructureUtility to instantiate + */ +public interface IStructureNavigate<T> extends IStructureElement<T> { + @Override + default boolean check(T t, World world, int x, int y, int z){ + return true; + } + + @Override + default boolean spawnHint(T t, World world, int x, int y, int z) { + return true; + } + + @Override + default boolean placeBlock(T t, World world, int x, int y, int z) { + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/ITileAdder.java b/src/main/java/com/github/technus/tectech/mechanics/structure/ITileAdder.java new file mode 100644 index 0000000000..9d983e1c4d --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/ITileAdder.java @@ -0,0 +1,12 @@ +package com.github.technus.tectech.mechanics.structure; + +import net.minecraft.tileentity.TileEntity; + +public interface ITileAdder { + /** + * Callback to add hatch + * @param tileEntity tile + * @return managed to add hatch (structure still valid) + */ + boolean apply(TileEntity tileEntity); +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/Structure.java b/src/main/java/com/github/technus/tectech/mechanics/structure/Structure.java new file mode 100644 index 0000000000..77c47ad19e --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/Structure.java @@ -0,0 +1,265 @@ +package com.github.technus.tectech.mechanics.structure; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; +import com.github.technus.tectech.thing.casing.TT_Container_Casings; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.regex.Pattern; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; + +@Deprecated +public class Structure { + private static final Pattern MATCH_E = Pattern.compile("(E,(E,)+)"); + + private Structure(){} + + //Check Machine Structure based on string[][] (effectively char[][][]), ond offset of the controller + //This only checks for REGULAR BLOCKS! + public static boolean checker( + String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR-1 blocks + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + IHatchAdder[] addingMethods, + short[] 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, + IGregTechTileEntity aBaseMetaTileEntity, + ExtendedFacing extendedFacing, + boolean forceCheck) { + World world = aBaseMetaTileEntity.getWorld(); + if (world.isRemote) { + return false; + } + //TE Rotation + if (extendedFacing == null) { + extendedFacing = ExtendedFacing.of(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing())); + } + + IGregTechTileEntity igt; + + int[] xyz = new int[3]; + int[] abc = new int[3]; + int pointer; + int baseX = aBaseMetaTileEntity.getXCoord(), + baseZ = aBaseMetaTileEntity.getZCoord(), + baseY = aBaseMetaTileEntity.getYCoord(); + //a,b,c - relative to block face! + //x,y,z - relative to block position on map! + //yPos - absolute height of checked block + + //perform your duties + abc[2] = -depthOffset; + for (String[] _structure : structure) {//front to back + abc[1] = -verticalOffset; + for (String __structure : _structure) {//top to bottom + abc[0] = -horizontalOffset; + for (char block : __structure.toCharArray()) {//left to right + if (block < ' ') { + //Control chars allow skipping + abc[1] += block; + break; + } else if (block > '@') { + //characters allow to skip check A-1 skip, B-2 skips etc. + abc[0] += block - '@'; + }//else if (block < '+')//used to mark THINGS + // a++; + else if (block == '.') { + abc[0]++; + } else { + //get x y z from rotation + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += baseX; + xyz[1] += baseY; + xyz[2] += baseZ; + + //that must be here since in some cases other axis (b,c) controls y + if (xyz[1] < 0 || xyz[1] >= 256) { + return false; + } + + //Check block + if (world.blockExists(xyz[0], xyz[1], xyz[2])) {//this actually checks if the chunk is loaded at this pos + switch (block) { + case '-'://must be air + if (world.getBlock(xyz[0], xyz[1], xyz[2]).getMaterial() != Material.air) { + return false; + } + break; + case '+'://must not be air + if (world.getBlock(xyz[0], xyz[1], xyz[2]).getMaterial() == Material.air) { + return false; + } + break; + default://check for block (countable) + if ((pointer = block - '0') >= 0) { + //countable air -> net.minecraft.block.BlockAir + if (world.getBlock(xyz[0], xyz[1], xyz[2]) != blockType[pointer]) { + if (DEBUG_MODE) { + TecTech.LOGGER.info("Struct-block-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + world.getBlock(xyz[0], xyz[1], xyz[2]).getUnlocalizedName() + ' ' + blockType[pointer].getUnlocalizedName()); + } + return false; + } + if (world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) != blockMeta[pointer]) { + if (DEBUG_MODE) { + TecTech.LOGGER.info("Struct-meta-id-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) + ' ' + blockMeta[pointer]); + } + return false; + } + } else if ((pointer = block - ' ') >= 0) { + igt = aBaseMetaTileEntity.getIGregTechTileEntity(xyz[0], xyz[1], xyz[2]); + if (igt == null || !addingMethods[pointer].apply(igt, casingTextures[pointer])) { + if (world.getBlock(xyz[0], xyz[1], xyz[2]) != blockTypeFallback[pointer]) { + if (DEBUG_MODE) { + TecTech.LOGGER.info("Fallback-struct-block-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + world.getBlock(xyz[0], xyz[1], xyz[2]).getUnlocalizedName() + ' ' + (blockTypeFallback[pointer] == null ? "null" : blockTypeFallback[pointer].getUnlocalizedName())); + } + return false; + } + if (world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) != blockMetaFallback[pointer]) { + if (DEBUG_MODE) { + TecTech.LOGGER.info("Fallback-Struct-meta-id-error " + xyz[0] + ' ' + xyz[1] + ' ' + xyz[2] + " / " + abc[0] + ' ' + abc[1] + ' ' + abc[2] + " / " + world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) + ' ' + blockMetaFallback[pointer]); + } + return false; + } + } + } + } + } else if (forceCheck) { + return false; + } + abc[0]++;//block in horizontal layer + } + } + abc[1]++;//horizontal layer + } + abc[2]++;//depth + } + return true; + } + + public static boolean builder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + int horizontalOffset, int verticalOffset, int depthOffset, + IGregTechTileEntity tileEntity, ExtendedFacing extendedFacing, boolean hintsOnly) { + return builder(structure, blockType, blockMeta, horizontalOffset, verticalOffset, depthOffset, + tileEntity.getWorld(), tileEntity.getXCoord(), tileEntity.getYCoord(), tileEntity.getZCoord(), + extendedFacing, hintsOnly); + } + + public static boolean builder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + int horizontalOffset, int verticalOffset, int depthOffset, + TileEntity tileEntity, ExtendedFacing extendedFacing, boolean hintsOnly) { + return builder(structure, blockType, blockMeta, horizontalOffset, verticalOffset, depthOffset, + tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, + extendedFacing, hintsOnly); + } + + public static boolean builder(String[][] structure,//0-9 casing, +- air no air, A... ignore 'A'-CHAR+1 blocks + Block[] blockType,//use numbers 0-9 for casing types + byte[] blockMeta,//use numbers 0-9 for casing types + int horizontalOffset, int verticalOffset, int depthOffset, + World world, int baseX, int baseY, int baseZ, ExtendedFacing extendedFacing, boolean hintsOnly) { + if (world == null || (!world.isRemote && hintsOnly)) { + return false; + } + + //TE Rotation + int[] xyz = new int[3]; + int[] abc = new int[3]; + int pointer; + + //a,b,c - relative to block face! + //x,y,z - relative to block position on map! + + //perform your duties + abc[2] = -depthOffset; + for (String[] _structure : structure) {//front to back + abc[1] = -verticalOffset; + for (String __structure : _structure) {//top to bottom + abc[0] = -horizontalOffset; + for (char block : __structure.toCharArray()) {//left to right + if (block < ' ') {//Control chars allow skipping + abc[1] += block; + break; + } + if (block > '@')//characters allow to skip check a-1 skip, b-2 skips etc. + { + abc[0] += block - '@'; + }//else if (block < '+')//used to mark THINGS + // a++; + else if (block == '.')// this TE + { + abc[0]++; + } else { + //get x y z from rotation + extendedFacing.getWorldOffset(abc, xyz); + xyz[0] += baseX; + xyz[1] += baseY; + xyz[2] += baseZ; + + //that must be here since in some cases other axis (b,c) controls y + if (xyz[1] < 0 || xyz[1] >= 256) { + return false; + } + + //Check block + if (world.blockExists(xyz[0], xyz[1], xyz[2])) {//this actually checks if the chunk is loaded + if (hintsOnly) { + switch (block) { + case '-'://must be air + TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 13); + break; + case '+'://must not be air + TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 14); + break; + default: //check for block + if ((pointer = block - '0') >= 0) { + if (world.getBlock(xyz[0], xyz[1], xyz[2]) != blockType[pointer] || world.getBlockMetadata(xyz[0], xyz[1], xyz[2]) != blockMeta[pointer]) { + TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], blockType[pointer], blockMeta[pointer]); + } + } else if ((pointer = block - ' ') >= 0) { + if (pointer < 12) { + TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, pointer); + } else { + TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 12); + } + } else { + TecTech.proxy.hint_particle(world, xyz[0], xyz[1], xyz[2], TT_Container_Casings.sHintCasingsTT, 15); + } + } + } else { + switch (block) { + case '-'://must be air + world.setBlock(xyz[0], xyz[1], xyz[2], Blocks.air, 0, 2); + break; + case '+'://must not be air + world.setBlock(xyz[0], xyz[1], xyz[2], TT_Container_Casings.sBlockCasingsTT, 14, 2); + break; + default: //check for block + if ((pointer = block - '0') >= 0) { + world.setBlock(xyz[0], xyz[1], xyz[2], blockType[pointer], blockMeta[pointer], 2); + } + } + } + } + abc[0]++;//block in horizontal layer + } + } + abc[1]++;//horizontal layer + } + abc[2]++;//depth + } + return true; + } +} diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java new file mode 100644 index 0000000000..52386d8373 --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureDefinition.java @@ -0,0 +1,170 @@ +package com.github.technus.tectech.mechanics.structure; + +import java.util.*; + +import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; +import static com.github.technus.tectech.mechanics.structure.StructureUtility.*; + +public class StructureDefinition<T> implements IStructureDefinition<T> { + private final Map<Character, IStructureElementProvider<T>> elements; + private final Map<String, String> shapes; + private final Map<String, IStructureElementProvider<T>[]> compiled; + + public static <B> Builder<B> builder() { + return new Builder<>(); + } + + private StructureDefinition( + Map<Character, IStructureElementProvider<T>> elements, + Map<String, String> shapes, + Map<String, IStructureElementProvider<T>[]> compiled) { + this.elements =elements; + this.shapes=shapes; + this.compiled =compiled; + } + + public static class Builder<T> { + private static final char A='\uA000'; + private static final char B='\uB000'; + private static final char C='\uC000'; + private static final char D='\uD000'; + private final Map<Character, IStructureElementProvider<T>> elements; + private final Map<String, String> shapes; + + private Builder() { + elements = new HashMap<>(); + shapes = new HashMap<>(); + } + + public Map<Character, IStructureElementProvider<T>> getElements() { + return elements; + } + + public Map<String, String> getShapes() { + return shapes; + } + + /** + * Adds shape + * +- is air/no air checks + * space bar is skip + * . is also skip (but marks controller position, optional and logically it is a space...) + * rest needs to be defined + * + * next char is next block(a) + * next string is next line(a,b) + * next string[] is next slice(a,b,c) + * + * char A000-FFFF range is reserved for generated skips + * @param name unlocalized/code name + * @param structurePiece generated or written struct - DO NOT STORE IT ANYWHERE, or at least set them to null afterwards + * @return this builder + */ + public Builder<T> addShape(String name, String[][] structurePiece) { + StringBuilder builder = new StringBuilder(); + if (structurePiece.length > 0) { + for (String[] strings : structurePiece) { + if (strings.length > 0) { + for (String string : strings) { + builder.append(string).append(B); + } + builder.setLength(builder.length() - 1); + } + builder.append(C); + } + builder.setLength(builder.length() - 1); + } + int a=0,b=0,c=0; + char d=D; + for (int i = 0; i < builder.length(); i++) { + char ch = builder.charAt(i); + if(ch ==' ' || ch =='.'){ + builder.setCharAt(i,A); + } + if(ch==A){ + a++; + }else if(ch==B){ + a=0; + b++; + }else if(ch==C){ + a=0; + b=0; + c++; + }else if(a!=0 || b!=0 || c!=0){ + builder.setCharAt(i-1,d); + addElement(d,step(a,b,c)); + a=0; + b=0; + c=0; + d++; + } + } + + String built = builder.toString().replaceAll("[\\uA000\\uB000\\uC000]",""); + + if(built.contains("+")){ + addElement('+',notAir()); + } + if (built.contains("-")) { + addElement('-', isAir()); + } + shapes.put(name, built); + return this; + } + + public Builder<T> addElement(Character name, IStructureElementProvider<T> structurePiece) { + elements.put(name, structurePiece); + return this; + } + + public IStructureDefinition<T> build() { + if(DEBUG_MODE){ + return new StructureDefinition<>(new HashMap<>(elements), new HashMap<>(shapes), compileMap()); + }else { + return compileMap()::get; + } + } + + @SuppressWarnings("unchecked") + private Map<String, IStructureElementProvider<T>[]> compileMap() { + List<Integer> mising = new ArrayList<>(); + shapes.values().stream().map(CharSequence::chars).forEach(intStream -> intStream.forEach(c -> { + IStructureElementProvider<T> iStructureElement = elements.get((char) c); + if (iStructureElement == null) { + mising.add(c); + } + })); + if (mising.isEmpty()) { + Map<String, IStructureElementProvider<T>[]> map = new HashMap<>(); + shapes.forEach((key, value) -> { + IStructureElementProvider<T>[] compiled = new IStructureElementProvider[value.length()]; + for (char i = 0; i < compiled.length; i++) { + compiled[i] = this.elements.get(i); + } + map.put(key, compiled); + }); + return map; + } else { + throw new RuntimeException("Missing Structure Element bindings for (chars as integers): " + + Arrays.toString(mising.toArray())); + } + } + } + + public Map<Character, IStructureElementProvider<T>> getElements(){ + return elements; + } + + public Map<String, String> getShapes() { + return shapes; + } + + public Map<String, IStructureElementProvider<T>[]> getCompiled() { + return compiled; + } + + @Override + public IStructureElementProvider<T>[] getElementsFor(String name) { + return compiled.get(name); + } +}
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java new file mode 100644 index 0000000000..69f5a6e43c --- /dev/null +++ b/src/main/java/com/github/technus/tectech/mechanics/structure/StructureUtility.java @@ -0,0 +1,473 @@ +package com.github.technus.tectech.mechanics.structure; + +import com.github.technus.tectech.TecTech; +import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; +import com.github.technus.tectech.util.Vec3Impl; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.init.Blocks; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import java.util.*; + +public class StructureUtility { + private static final String NICE_CHARS ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_=|[]{};:'<>,./?"; + @SuppressWarnings("rawtypes") + private static final Map<Vec3Impl,IStructureNavigate> STEP = new HashMap<>(); + @SuppressWarnings("rawtypes") + private static final IStructureElement AIR= (t, world, x, y, z) -> world.getBlock(x, y, z).getMaterial() == Material.air; + @SuppressWarnings("rawtypes") + private static final IStructureElement NOT_AIR= (t, world, x, y, z) -> world.getBlock(x, y, z).getMaterial() != Material.air; + + private StructureUtility(){ + + } + + @SuppressWarnings("unchecked") + public static <T> IStructureElement<T> isAir(){ + return AIR; + } + + @SuppressWarnings("unchecked") + public static <T> IStructureElement<T> notAir(){ + return NOT_AIR; + } + + /** + * Does not allow Block duplicates (with different meta) + */ + public static <T> IStructureElement<T> ofBlocksFlat(Map<Block, Integer> blocsMap,Block hintBlock,int hintMeta){ + if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + return blocsMap.getOrDefault(world.getBlock(x, y, z), -1) == world.getBlockMetadata(x, y, z); + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z) { + world.setBlock(x,y,z,hintBlock,hintMeta,2); + return true; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z) { + TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta); + return true; + } + }; + } + + /** + * Allows block duplicates (with different meta) + */ + public static <T> IStructureElement<T> ofBlocks(Map<Block, Set<Integer>> blocsMap,Block hintBlock,int hintMeta){ + if(blocsMap==null || blocsMap.isEmpty() || hintBlock==null){ + throw new IllegalArgumentException(); + } + for (Set<Integer> value : blocsMap.values()) { + if(value.isEmpty()){ + throw new IllegalArgumentException(); + } + } + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + return blocsMap.getOrDefault(world.getBlock(x, y, z), Collections.emptySet()).contains(world.getBlockMetadata(x, y, z)); + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z) { + world.setBlock(x,y,z,hintBlock,hintMeta,2); + return true; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z) { + TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta); + return true; + } + }; + } + + public static <T> IStructureElement<T> ofBlock(Block block, int meta,Block hintBlock,int hintMeta){ + if(block==null || hintBlock==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + return block == world.getBlock(x, y, z) && meta == world.getBlockMetadata(x, y, z); + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z) { + world.setBlock(x,y,z,hintBlock,hintMeta,2); + return true; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z) { + TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta); + return true; + } + }; + } + + public static <T> IStructureElement<T> ofBlock(Block block, int meta){ + return ofBlock(block, meta,block,meta); + } + + public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder iBlockAdder,Block hintBlock,int hintMeta){ + if(iBlockAdder==null ||hintBlock==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + return iBlockAdder.apply(world.getBlock(x, y, z), world.getBlockMetadata(x, y, z)); + } + + @Override + public boolean placeBlock(T t, World world, int x, int y, int z) { + world.setBlock(x,y,z,hintBlock,hintMeta,2); + return true; + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z) { + TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta); + return true; + } + }; + } + + public static <T> IStructureElement<T> ofTileAdder(ITileAdder iTileAdder,Block hintBlock,int hintMeta){ + if(iTileAdder==null ||hintBlock==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + return tileEntity instanceof IGregTechTileEntity && iTileAdder.apply(tileEntity); + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z) { + TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta); + return true; + } + }; + } + + public static <T> IStructureElement<T> ofHatchAdder(IHatchAdder iHatchAdder, Short textureIndex,Block hintBlock,int hintMeta){ + if(iHatchAdder==null ||hintBlock==null){ + throw new IllegalArgumentException(); + } + return new IStructureElement<T>() { + @Override + public boolean check(T t, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + return tileEntity instanceof IGregTechTileEntity && iHatchAdder.apply((IGregTechTileEntity) tileEntity, textureIndex); + } + + @Override + public boolean spawnHint(T t, World world, int x, int y, int z) { + TecTech.proxy.hint_particle(world,x,y,z,hintBlock,hintMeta); + return true; + } + }; + } + + @SuppressWarnings("unchecked") + public static <T> IStructureNavigate<T> step(Vec3Impl step){ + if(step==null || step.get0()<0 || step.get1()<0 || step.get2()<0){ + throw new IllegalArgumentException(); + } + return STEP.computeIfAbsent(step, vec3 -> { + if(vec3.get2()>0){ + return stepC(vec3.get0(), vec3.get1(), vec3.get2()); + }else if(vec3.get1()>0){ + return stepB(vec3.get0(), vec3.get1(), vec3.get2()); + }else { + return stepA(vec3.get0(), vec3.get1(), vec3.get2()); + } + }); + } + + public static <T> IStructureNavigate<T> step(int a,int b, int c){ + return step(new Vec3Impl(a,b,c)); + } + + private static <T> IStructureNavigate<T> stepA(int a,int b, int c){ + return new IStructureNavigate<T>() { + @Override + public int getStepA() { + return a; + } + + @Override + public int getStepB() { + return b; + } + + @Override + public int getStepC() { + return c; + } + }; + } + + private static <T> IStructureNavigate<T> stepB(int a,int b, int c){ + return new IStructureNavigate<T>() { + @Override + public int getStepA() { + return a; + } + + @Override + public int getStepB() { + return b; + } + + @Override + public int getStepC() { + return c; + } + + @Override + public boolean resetA() { + return true; + } + }; + } + + private static <T> IStructureNavigate<T> stepC(int a,int b, int c){ + return new IStructureNavigate<T>() { + @Override + public int getStepA() { + return a; + } + + @Override + public int getStepB() { + return b; + } + + @Override + public int getStepC() { + return c; + } + + @Override + public boolean resetA() { + return true; + } + + @Override + public boolean resetB() { + return true; + } + }; + } + + public static <T> IStructureFallback<T> ofElementChain(IStructureElement<T>... elementChain){ + if(elementChain==null || elementChain.length==0){ + throw new IllegalArgumentException(); + } + for (IStructureElementProvider<T> iStructureElement : elementChain) { + if(iStructureElement==null){ + throw new IllegalArgumentException(); + } + } + return () -> elementChain; + } + + public static <T> IStructureFallbackProvider<T> ofProviderChain(IStructureElementProvider<T>... elementChain){ + if(elementChain==null || elementChain.length==0){ + throw new IllegalArgumentException(); + } + for (IStructureElementProvider<T> iStructureElement : elementChain) { + if(iStructureElement==null){ + throw new IllegalArgumentException(); + } + } + return () -> elementChain; + } + + /** + * Use only to get pseudo code... + * @param world + * @return + */ + public static String getPseudoJavaCode(World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC, + int sizeA,int sizeB, int sizeC) { + Map<Block, Set<Integer>> blocks = new TreeMap<>(Comparator.comparing(Block::getUnlocalizedName)); + Set<Class<? extends TileEntity>> tiles = new TreeSet<>(Comparator.comparing(Class::getCanonicalName)); + Set<Class<? extends IMetaTileEntity>> gtTiles = new TreeSet<>(Comparator.comparing(Class::getCanonicalName)); + iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ, + basePositionA, basePositionB, basePositionC, + sizeA, sizeB, sizeC, ((w, x, y, z) -> { + TileEntity tileEntity = w.getTileEntity(x, y, z); + if (tileEntity == null) { + Block block = w.getBlock(x, y, z); + if (block != null && block != Blocks.air) { + blocks.compute(block, (b, set) -> { + if (set == null) { + set = new TreeSet<>(); + } + set.add(world.getBlockMetadata(x, y, z)); + return set; + }); + } + } else { + if (tileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); + if (meta != null) { + gtTiles.add(meta.getClass()); + } else { + tiles.add(tileEntity.getClass()); + } + } else { + tiles.add(tileEntity.getClass()); + } + } + })); + Map<String, Character> map = new HashMap<>(); + StringBuilder builder = new StringBuilder(); + { + int i = 0; + char c; + builder.append("\n\nStructure:\n") + .append("\nBlocks:\n"); + for (Map.Entry<Block, Set<Integer>> entry : blocks.entrySet()) { + Block block = entry.getKey(); + Set<Integer> set = entry.getValue(); + for (Integer meta : set) { + c = NICE_CHARS.charAt(i++); + if(i>NICE_CHARS.length()){ + return "Too complicated for nice chars"; + } + map.put(block.getUnlocalizedName() + '\0' + meta, c); + builder.append(c).append(" -> ofBlock...(") + .append(block.getUnlocalizedName()).append(", ").append(meta).append(", ...);\n"); + } + } + builder.append("\nTiles:\n"); + for (Class<? extends TileEntity> tile : tiles) { + c = NICE_CHARS.charAt(i++); + if(i>NICE_CHARS.length()){ + return "Too complicated for nice chars"; + } + map.put(tile.getCanonicalName(), c); + builder.append(c).append(" -> ofTileAdder(") + .append(tile.getCanonicalName()).append(", ...);\n"); + } + builder.append("\nMeta:\n"); + for (Class<? extends IMetaTileEntity> gtTile : gtTiles) { + c = NICE_CHARS.charAt(i++); + if(i>NICE_CHARS.length()){ + return "Too complicated for nice chars"; + } + map.put(gtTile.getCanonicalName(), c); + builder.append(c).append(" -> ofHatchAdder(") + .append(gtTile.getCanonicalName()).append(", textureId, ...);\n"); + } + } + builder.append("\nOffsets:\n") + .append(basePositionA).append(' ').append(basePositionB).append(' ').append(basePositionC).append('\n'); + builder.append("\nScan:\n") + .append("new String[][]{{\n") + .append(" \""); + + iterate(world, extendedFacing, basePositionX, basePositionY, basePositionZ, + basePositionA, basePositionB, basePositionC, + sizeA, sizeB, sizeC, ((w, x, y, z) -> { + TileEntity tileEntity = w.getTileEntity(x, y, z); + if (tileEntity == null) { + Block block = w.getBlock(x, y, z); + if (block != null && block != Blocks.air) { + builder.append(map.get(block.getUnlocalizedName() + '\0' + world.getBlockMetadata(x, y, z))); + }else { + builder.append(' '); + } + } else { + if (tileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) tileEntity).getMetaTileEntity(); + if (meta != null) { + builder.append(map.get(meta.getClass().getCanonicalName())); + } else { + builder.append(map.get(tileEntity.getClass().getCanonicalName())); + } + } else { + builder.append(map.get(tileEntity.getClass().getCanonicalName())); + } + } + }), + () -> builder.append("\",\n").append(" \""), + () -> { + builder.setLength(builder.length()-7); + builder.append("\n").append("},{\n").append(" \""); + }); + builder.setLength(builder.length()-8); + builder.append("};\n\n"); + return(builder.toString().replaceAll("\"\"","E")); + } + + public static void iterate(World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC, + int sizeA,int sizeB, int sizeC, + IBlockPosConsumer iBlockPosConsumer){ + sizeA-=basePositionA; + sizeB-=basePositionB; + sizeC-=basePositionC; + + int[] abc = new int[3]; + int[] xyz = new int[3]; + + for (abc[2]=-basePositionC ; abc[2] < sizeC; abc[2]++) { + for (abc[1]=-basePositionB; abc[1] < sizeB; abc[1]++) { + for (abc[0]=-basePositionA ; abc[0] < sizeA; abc[0]++) { + extendedFacing.getWorldOffset(abc, xyz); + iBlockPosConsumer.consume(world, xyz[0]+basePositionX,xyz[1]+basePositionY,xyz[2]+basePositionZ); + } + + } + } + } + + public static void iterate(World world, ExtendedFacing extendedFacing, + int basePositionX, int basePositionY, int basePositionZ, + int basePositionA, int basePositionB, int basePositionC, + int sizeA, int sizeB, int sizeC, + IBlockPosConsumer iBlockPosConsumer, + Runnable nextB, + Runnable nextC){ + sizeA-=basePositionA; + sizeB-=basePositionB; + sizeC-=basePositionC; + + int[] abc = new int[3]; + int[] xyz = new int[3]; + + for (abc[2]=-basePositionC ; abc[2] < sizeC; abc[2]++) { + for (abc[1]=-basePositionB; abc[1] < sizeB; abc[1]++) { + for (abc[0]=-basePositionA ; abc[0] < sizeA; abc[0]++) { + extendedFacing.getWorldOffset(abc, xyz); + iBlockPosConsumer.consume(world, xyz[0]+basePositionX,xyz[1]+basePositionY,xyz[2]+basePositionZ); + } + nextB.run(); + } + nextC.run(); + } + } +} diff --git a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java index 7b7d1983fa..4160ae2aba 100644 --- a/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java +++ b/src/main/java/com/github/technus/tectech/thing/item/ConstructableTriggerItem.java @@ -1,15 +1,14 @@ package com.github.technus.tectech.thing.item; +import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.alignment.IAlignment; import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; +import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.mechanics.constructable.IMultiblockInfoContainer; import com.github.technus.tectech.util.CommonValues; -import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.constructable.IConstructable; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.Item; @@ -82,7 +81,7 @@ public final class ConstructableTriggerItem extends Item { IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); if (metaTE instanceof IConstructable) { ((IConstructable) metaTE).construct(aStack, true); - TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack.stackSize)); + TecTech.proxy.printInchat(((IConstructable) metaTE).getStructureDescription(aStack)); return false; } else if(MULTIBLOCK_MAP.containsKey(metaTE.getClass().getCanonicalName())){ IMultiblockInfoContainer iMultiblockInfoContainer = MULTIBLOCK_MAP.get(metaTE.getClass().getCanonicalName()); @@ -93,12 +92,12 @@ public final class ConstructableTriggerItem extends Item { iMultiblockInfoContainer.construct(aStack, true, tTileEntity, ExtendedFacing.of(ForgeDirection.getOrientation(((IGregTechTileEntity) tTileEntity).getFrontFacing()))); } - TecTech.proxy.printInchat(MULTIBLOCK_MAP.get(metaTE.getClass().getCanonicalName()).getDescription(aStack.stackSize)); + TecTech.proxy.printInchat(MULTIBLOCK_MAP.get(metaTE.getClass().getCanonicalName()).getDescription(aStack)); return false; } } else if(tTileEntity instanceof IConstructable){ ((IConstructable) tTileEntity).construct(aStack,true); - TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack.stackSize)); + TecTech.proxy.printInchat(((IConstructable) tTileEntity).getStructureDescription(aStack)); return false; } else if(MULTIBLOCK_MAP.containsKey(tTileEntity.getClass().getCanonicalName())){ IMultiblockInfoContainer iMultiblockInfoContainer = MULTIBLOCK_MAP.get(tTileEntity.getClass().getCanonicalName()); @@ -109,7 +108,7 @@ public final class ConstructableTriggerItem extends Item { iMultiblockInfoContainer.construct(aStack, true, tTileEntity, ExtendedFacing.of(ForgeDirection.getOrientation(aSide))); } - TecTech.proxy.printInchat(MULTIBLOCK_MAP.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack.stackSize)); + TecTech.proxy.printInchat(MULTIBLOCK_MAP.get(tTileEntity.getClass().getCanonicalName()).getDescription(aStack)); return false; } //} else { diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java index 4333d4c8c9..4151dbfec0 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_annihilation.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -108,7 +108,7 @@ public class GT_MetaTileEntity_EM_annihilation extends GT_MetaTileEntity_Multibl } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 c5aaa1d66f..d90f4af8d2 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 @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -306,7 +306,7 @@ public class GT_MetaTileEntity_EM_bhg extends GT_MetaTileEntity_MultiblockBase_E } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 fe676910ee..490ca2084b 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 @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.compatibility.thaumcraft.elementalMatter.definitions.dComplexAspectDefinition; @@ -689,7 +690,7 @@ public class GT_MetaTileEntity_EM_collider extends GT_MetaTileEntity_MultiblockB } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 433b8b4950..e70cc10926 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 @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.util.Util; @@ -350,7 +351,7 @@ public class GT_MetaTileEntity_EM_computer extends GT_MetaTileEntity_MultiblockB } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java index 7a71f36d3b..a9e5b2f8a1 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_crafting.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -110,7 +110,7 @@ public class GT_MetaTileEntity_EM_crafting extends GT_MetaTileEntity_MultiblockB } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java index 647bbf4a3b..d5c9162d1d 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_dataBank.java @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.mechanics.dataTransport.InventoryDataPacket; @@ -10,7 +10,7 @@ import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_H import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -175,7 +175,7 @@ public class GT_MetaTileEntity_EM_dataBank extends GT_MetaTileEntity_MultiblockB } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 be28a3d0c8..3b17dfa9b9 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 @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; @@ -248,7 +249,7 @@ public class GT_MetaTileEntity_EM_decay extends GT_MetaTileEntity_MultiblockBase } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 fed03d1845..5dfa38294b 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 @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; import com.github.technus.tectech.mechanics.elementalMatter.core.stacks.cElementalInstanceStack; @@ -11,7 +11,7 @@ import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -153,7 +153,7 @@ public class GT_MetaTileEntity_EM_dequantizer extends GT_MetaTileEntity_Multiblo } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 aed3025d4f..1fff071e9c 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 @@ -1,7 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; import cofh.api.energy.IEnergyContainerItem; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; @@ -9,7 +9,7 @@ import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -187,7 +187,7 @@ public class GT_MetaTileEntity_EM_infuser extends GT_MetaTileEntity_MultiblockBa } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 8a76ee6ff1..199bb8ee6f 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 @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_InputElemental; @@ -174,7 +175,7 @@ public class GT_MetaTileEntity_EM_junction extends GT_MetaTileEntity_MultiblockB } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 6315a2f295..ab86c0494f 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 @@ -1,6 +1,6 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.TecTech; @@ -14,7 +14,7 @@ import com.github.technus.tectech.mechanics.elementalMatter.core.transformations import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.GregTech_API; @@ -202,7 +202,7 @@ public class GT_MetaTileEntity_EM_quantizer extends GT_MetaTileEntity_Multiblock } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 2a739cb6c7..c6f9c810a8 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 @@ -1,13 +1,13 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.recipe.TT_recipe; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_EnergyMulti; import com.github.technus.tectech.thing.metaTileEntity.hatch.GT_MetaTileEntity_Hatch_Holder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.enums.ItemList; @@ -557,7 +557,7 @@ public class GT_MetaTileEntity_EM_research extends GT_MetaTileEntity_MultiblockB } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } } 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 48479b9d71..896d0f41bc 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_scanner.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.mechanics.elementalMatter.core.cElementalInstanceStackMap; @@ -518,7 +519,7 @@ public class GT_MetaTileEntity_EM_scanner extends GT_MetaTileEntity_MultiblockBa } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java index ece01f7489..140383caac 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_stabilizer.java @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import net.minecraft.block.Block; @@ -74,7 +74,7 @@ public class GT_MetaTileEntity_EM_stabilizer extends GT_MetaTileEntity_Multibloc } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 39f9441cb7..7398889c89 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 @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.mechanics.dataTransport.QuantumDataPacket; @@ -221,7 +222,7 @@ public class GT_MetaTileEntity_EM_switch extends GT_MetaTileEntity_MultiblockBas } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 c2e759e96c..4e2f916f2f 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_EM_transformer.java @@ -1,26 +1,27 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.mechanics.constructable.IConstructable; +import com.github.technus.tectech.mechanics.structure.IStructureDefinition; +import com.github.technus.tectech.mechanics.structure.StructureDefinition; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; +import com.github.technus.tectech.util.CommonValues; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import net.minecraft.block.Block; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.ResourceLocation; +import static com.github.technus.tectech.mechanics.structure.StructureUtility.ofBlock; +import static com.github.technus.tectech.mechanics.structure.StructureUtility.ofHatchAdder; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.textureOffset; import static com.github.technus.tectech.thing.casing.GT_Block_CasingsTT.texturePage; import static com.github.technus.tectech.thing.casing.TT_Container_Casings.sBlockCasingsTT; @@ -32,21 +33,25 @@ import static net.minecraft.util.StatCollector.translateToLocal; */ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_MultiblockBase_EM implements IConstructable { //region structure - private static final String[][] shape = new String[][]{ - {" ", " . ", " ",}, - {" ", " 0 ", " ",}, - {" ", " ", " ",}, - }; - private static final Block[] blockType = new Block[]{sBlockCasings1}; - private static final byte[] blockMeta = new byte[]{15}; - private final IHatchAdder[] addingMethods = new IHatchAdder[]{this::addEnergyIOToMachineList}; - private static final short[] casingTextures = new short[]{textureOffset}; - private static final Block[] blockTypeFallback = new Block[]{sBlockCasingsTT}; - private static final byte[] blockMetaFallback = new byte[]{0}; private static final String[] description = new String[]{ EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", translateToLocal("gt.blockmachines.multimachine.em.transformer.hint"),//1 - Energy IO Hatches or High Power Casing }; + private static final IStructureDefinition<GT_MetaTileEntity_EM_transformer> STRUCTURE_DEFINITION = + StructureDefinition.<GT_MetaTileEntity_EM_transformer>builder() + .addShape("main",new String[][]{ + {"111", "1.1", "111",}, + {"111", "101", "111",}, + {"111", "111", "111",}, + }) + .addElement('0', ofBlock(sBlockCasings1,15)) + .addElement('1', trafo->ofHatchAdder(trafo::addEnergyIOToMachineList,textureOffset,sBlockCasingsTT,0)) + .build(); + + @Override + public IStructureDefinition<GT_MetaTileEntity_EM_transformer> getStructure_EM() { + return STRUCTURE_DEFINITION; + } //endregion public GT_MetaTileEntity_EM_transformer(int aID, String aName, String aNameRegional) { @@ -78,7 +83,7 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo @Override public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { - return structureCheck_EM(shape, blockType, blockMeta, addingMethods, casingTextures, blockTypeFallback, blockMetaFallback, 1, 1, 0); + return structureCheck_EM("main", 1, 1, 0); } @Override @@ -150,11 +155,11 @@ public class GT_MetaTileEntity_EM_transformer extends GT_MetaTileEntity_Multiblo @Override public void construct(ItemStack stackSize, boolean hintsOnly) { - Structure.builder(shape, blockType, blockMeta, 1, 1, 0, getBaseMetaTileEntity(), getExtendedFacing(), hintsOnly); + //Structure.builder(shape, blockType, blockMeta, 1, 1, 0, getBaseMetaTileEntity(), getExtendedFacing(), hintsOnly); } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 2b2ebdd1a4..f909d000c7 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 @@ -1,11 +1,11 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.thing.block.QuantumGlassBlock; import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -109,7 +109,7 @@ public class GT_MetaTileEntity_EM_wormhole extends GT_MetaTileEntity_MultiblockB } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java index 9c40d6ebc9..ba926f1ace 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_microwave.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.Reference; import com.github.technus.tectech.mechanics.constructable.IConstructable; @@ -250,7 +251,7 @@ public class GT_MetaTileEntity_TM_microwave extends GT_MetaTileEntity_Multiblock } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_proccessingStack.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_proccessingStack.java index 678f211744..47f36014ac 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_proccessingStack.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_proccessingStack.java @@ -5,7 +5,7 @@ import com.github.technus.tectech.mechanics.constructable.IConstructable; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_Container_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_GUIContainer_MultiMachineEM; import com.github.technus.tectech.thing.metaTileEntity.multi.base.GT_MetaTileEntity_MultiblockBase_EM; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; import com.github.technus.tectech.thing.metaTileEntity.multi.base.render.TT_RenderedExtendedFacingTexture; import gregtech.api.enums.Textures; import gregtech.api.interfaces.ITexture; @@ -126,7 +126,7 @@ public class GT_MetaTileEntity_TM_proccessingStack extends GT_MetaTileEntity_Mul } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java index 327b54e561..a4a234f9b4 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/GT_MetaTileEntity_TM_teslaCoil.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.loader.NetworkDispatcher; @@ -827,7 +828,7 @@ public class GT_MetaTileEntity_TM_teslaCoil extends GT_MetaTileEntity_Multiblock } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java index 2f23aae431..7735678f72 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/GT_MetaTileEntity_MultiblockBase_EM.java @@ -6,7 +6,9 @@ import com.github.technus.tectech.mechanics.alignment.*; import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; import com.github.technus.tectech.mechanics.alignment.enumerable.Flip; import com.github.technus.tectech.mechanics.alignment.enumerable.Rotation; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.IStructureDefinition; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.Util; import com.github.technus.tectech.util.Vec3Impl; import com.github.technus.tectech.loader.NetworkDispatcher; @@ -191,6 +193,27 @@ public abstract class GT_MetaTileEntity_MultiblockBase_EM extends GT_MetaTileEnt toolSetDirection(ForgeDirection.getOrientation(getBaseMetaTileEntity().getFrontFacing())); } + /** + * Gets structure + * @return STATIC INSTANCE OF STRUCTURE + */ + public IStructureDefinition<? extends GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM(){ + throw new NoSuchMethodError("Implement it as STATIC INSTANCE"); + } + + @SuppressWarnings("unchecked") + private IStructureDefinition<GT_MetaTileEntity_MultiblockBase_EM> getStructure_EM_Internal(){ + return (IStructureDefinition<GT_MetaTileEntity_MultiblockBase_EM>)getStructure_EM(); + } + + public final boolean structureCheck_EM(String piece,int horizontalOffset, int verticalOffset, int depthOffset) { + IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); + return getStructure_EM_Internal().check(this,piece, baseMetaTileEntity.getWorld(),getExtendedFacing(), + baseMetaTileEntity.getXCoord(),baseMetaTileEntity.getYCoord(),baseMetaTileEntity.getZCoord(), + horizontalOffset,verticalOffset,depthOffset,!mMachine); + } + + @Deprecated public final boolean structureCheck_EM( String[][] structure,//0-9 casing, +- air no air, a-z ignore Block[] blockType,//use numbers 0-9 for casing types diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IHatchAdder.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IHatchAdder.java deleted file mode 100644 index b695472012..0000000000 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/base/IHatchAdder.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.github.technus.tectech.thing.metaTileEntity.multi.base; - - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -public interface IHatchAdder { - Boolean apply(IGregTechTileEntity iGregTechTileEntity, Short aShort); -} diff --git a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java index f6f3ec9a63..722580a221 100644 --- a/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java +++ b/src/main/java/com/github/technus/tectech/thing/metaTileEntity/multi/em_machine/GT_MetaTileEntity_EM_machine.java @@ -1,6 +1,7 @@ package com.github.technus.tectech.thing.metaTileEntity.multi.em_machine; -import com.github.technus.tectech.mechanics.constructable.Structure; +import com.github.technus.tectech.mechanics.structure.IHatchAdder; +import com.github.technus.tectech.mechanics.structure.Structure; import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; import com.github.technus.tectech.util.Util; @@ -354,7 +355,7 @@ public class GT_MetaTileEntity_EM_machine extends GT_MetaTileEntity_MultiblockBa } @Override - public String[] getStructureDescription(int stackSize) { + public String[] getStructureDescription(ItemStack stackSize) { return description; } }
\ No newline at end of file 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 194d357b1c..42f25ddfde 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 @@ -1,11 +1,12 @@ package com.github.technus.tectech.thing.metaTileEntity.single; -import com.github.technus.tectech.mechanics.constructable.Structure; -import com.github.technus.tectech.util.CommonValues; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.util.Util; +import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; +import com.github.technus.tectech.mechanics.structure.StructureUtility; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_Container_DebugStructureWriter; import com.github.technus.tectech.thing.metaTileEntity.single.gui.GT_GUIContainer_DebugStructureWriter; +import com.github.technus.tectech.util.CommonValues; +import com.github.technus.tectech.util.Util; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Textures; @@ -20,6 +21,7 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; import static com.github.technus.tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT; import static net.minecraft.util.StatCollector.translateToLocal; @@ -105,21 +107,22 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti } @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - if (aBaseMetaTileEntity.isAllowedToWork()) { - result = Structure.writer(getBaseMetaTileEntity(), numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], false); - for (String s : result) { - TecTech.LOGGER.info(s); - } - aBaseMetaTileEntity.disableWorking(); - } + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + aBaseMetaTileEntity.disableWorking(); } @Override - public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) { - result = Structure.writer(getBaseMetaTileEntity(), numbers[0], numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], true); - for (String s : result) { - TecTech.LOGGER.info(s); + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + String pseudoJavaCode = StructureUtility.getPseudoJavaCode(aBaseMetaTileEntity.getWorld(), + ExtendedFacing.of(ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing())), + aBaseMetaTileEntity.getXCoord(), aBaseMetaTileEntity.getYCoord(), aBaseMetaTileEntity.getZCoord(), + numbers[0], numbers[1], numbers[2], + numbers[3], numbers[4], numbers[5]); + TecTech.LOGGER.info(pseudoJavaCode); + result = pseudoJavaCode.split("\\n"); + aBaseMetaTileEntity.disableWorking(); } } @@ -129,8 +132,6 @@ public class GT_MetaTileEntity_DebugStructureWriter extends GT_MetaTileEntity_Ti return true; } aBaseMetaTileEntity.openGUI(aPlayer); - //if (TecTechConfig.DEBUG_MODE && aPlayer.getHeldItem() != null) - // TecTech.LOGGER.info("UnlocalizedName: " + getUniqueIdentifier(aPlayer.getHeldItem())); return true; } diff --git a/src/main/java/com/github/technus/tectech/util/Util.java b/src/main/java/com/github/technus/tectech/util/Util.java index b81506d27c..1843770e3a 100644 --- a/src/main/java/com/github/technus/tectech/util/Util.java +++ b/src/main/java/com/github/technus/tectech/util/Util.java @@ -1,22 +1,14 @@ package com.github.technus.tectech.util; import com.github.technus.tectech.TecTech; -import com.github.technus.tectech.mechanics.alignment.enumerable.ExtendedFacing; -import com.github.technus.tectech.thing.casing.TT_Container_Casings; -import com.github.technus.tectech.thing.metaTileEntity.multi.base.IHatchAdder; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.ObfuscationReflectionHelper; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.api.GregTech_API; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_TieredMachineBlock; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.inventory.Container; import net.minecraft.inventory.ICrafting; @@ -25,14 +17,12 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.storage.IPlayerFileData; import net.minecraft.world.storage.SaveHandler; -import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import org.apache.commons.lang3.StringUtils; @@ -42,12 +32,6 @@ import java.io.FileOutputStream; import java.lang.reflect.Field; import java.nio.charset.StandardCharsets; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static com.github.technus.tectech.loader.TecTechConfig.DEBUG_MODE; -import static gregtech.api.enums.GT_Values.E; -import static java.nio.charset.Charset.forName; /** * Created by Tec on 21.03.2017. diff --git a/src/main/java/com/github/technus/tectech/util/Vec3Impl.java b/src/main/java/com/github/technus/tectech/util/Vec3Impl.java index 84e6497560..9ba96d741a 100644 --- a/src/main/java/com/github/technus/tectech/util/Vec3Impl.java +++ b/src/main/java/com/github/technus/tectech/util/Vec3Impl.java @@ -20,20 +20,6 @@ public class Vec3Impl implements Comparable<Vec3Impl> { this(baseMetaTileEntity.getXCoord(),baseMetaTileEntity.getYCoord(),baseMetaTileEntity.getZCoord()); } - public boolean equals(Object o) { - if (this == o) { - return true; - } else if (o instanceof Vec3Impl) { - Vec3Impl vec3i = (Vec3Impl)o; - return val0 == vec3i.val0 && val1 == vec3i.val1 && val2 == vec3i.val2; - } - return false; - } - - public int hashCode() { - return (val1 + val2 * 31) * 31 + val0; - } - public int compareTo(Vec3Impl o) { return val1 == o.val1 ? val2 == o.val2 ? val0 - o.val0 : val2 - o.val2 : val1 - o.val1; } @@ -143,4 +129,18 @@ public class Vec3Impl implements Comparable<Vec3Impl> { public Vec3Impl abs() { return new Vec3Impl(Math.abs(val0),Math.abs(val1),Math.abs(val2)); } + + public boolean equals(Object o) { + if (this == o) { + return true; + } else if (o instanceof Vec3Impl) { + Vec3Impl vec3i = (Vec3Impl)o; + return val0 == vec3i.val0 && val1 == vec3i.val1 && val2 == vec3i.val2; + } + return false; + } + + public int hashCode() { + return (val1 + val2 * 31) * 31 + val0; + } }
\ No newline at end of file |