Guest User

Untitled

a guest
Jan 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2019 bartimaeusnek
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22.  
  23. import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
  24. import net.minecraft.block.Block;
  25. import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
  26. import net.minecraftforge.common.util.ForgeDirection;
  27.  
  28. public class BW_MultiBlockCheck {
  29.  
  30. public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int diameter,int yLevel, int height, Block block, int offset,int aBaseCasingIndex){
  31. return check_layer(aBaseMetaTileEntity,diameter,yLevel,height,block,offset,false,aBaseCasingIndex);
  32. }
  33.  
  34. public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int diameter,int yLevel, int height, Block block, int offset, boolean controllerLayer,int aBaseCasingIndex){
  35. return check_layer(aBaseMetaTileEntity,diameter,yLevel,height,block,offset,controllerLayer,false,aBaseCasingIndex);
  36. }
  37.  
  38. public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int diameter,int yLevel, int height, Block block, int offset, boolean controllerLayer, boolean freeCorners,int aBaseCasingIndex){
  39. return check_layer(aBaseMetaTileEntity,diameter,yLevel,height,block,offset,controllerLayer,freeCorners,false,null,true,aBaseCasingIndex);
  40. }
  41.  
  42. public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int diameter,int yLevel, int height, Block block, int offset, boolean controllerLayer, boolean insideCheck, Block inside,int aBaseCasingIndex){
  43. return check_layer(aBaseMetaTileEntity,diameter,yLevel,height,block,offset,controllerLayer,false,insideCheck,inside,true,aBaseCasingIndex);
  44. }
  45.  
  46. /**
  47. *
  48. * @param aBaseMetaTileEntity the Multiblock controller, usually a parameter
  49. * @param diameter the RADIUS of the layer
  50. * @param yLevel the starting y level of the Layer, referenced to the Multiblock
  51. * @param height the height of the Layers, referenced to the Multiblock
  52. * @param block the block for the walls
  53. * @param offset the offset in most cases should be the same as the diameter
  54. * @param controllerLayer if the layer contains the controller
  55. * @param freeCorners if the corners should be checked
  56. * @param insideCheck if the inside should be empty/filled
  57. * @param inside which block should be inside
  58. * @param allowHatches if hatches are allowed in this Layer
  59. * @param aBaseCasingIndex the Index for the hatches texture
  60. * @return if the layer check was completed
  61. */
  62. public static boolean check_layer(IGregTechTileEntity aBaseMetaTileEntity, int diameter,int yLevel, int height, Block block, int offset, boolean controllerLayer, boolean freeCorners, boolean insideCheck, Block inside, boolean allowHatches, int aBaseCasingIndex){
  63. int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX * offset;
  64. int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ * offset;
  65. for (int x = -diameter; x < diameter; x++) {
  66. for (int y = yLevel; y < height; y++) {
  67. for (int z = -diameter; z < diameter; z++) {
  68. if (freeCorners && (((Math.abs(x) == diameter && Math.abs(z) == diameter))))
  69. continue;
  70. if (controllerLayer && (xDir+x == 0 && zDir+z == 0))
  71. continue;
  72. if (insideCheck && (Math.abs(x) < diameter && Math.abs(z) != diameter))
  73. if (!aBaseMetaTileEntity.getBlockOffset(xDir+x,y,zDir+z).equals(inside))
  74. return false;
  75. if (!aBaseMetaTileEntity.getBlockOffset(xDir+x,y,zDir+z).equals(block))
  76. if (!(allowHatches && (
  77. ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addDynamoToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir+x,y,zDir+z),aBaseCasingIndex) ||
  78. ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addEnergyInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir+x,y,zDir+z),aBaseCasingIndex) ||
  79. ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addMaintenanceToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir+x,y,zDir+z),aBaseCasingIndex) ||
  80. ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addMufflerToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir+x,y,zDir+z),aBaseCasingIndex) ||
  81. ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addInputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir+x,y,zDir+z),aBaseCasingIndex) ||
  82. ((GT_MetaTileEntity_MultiBlockBase) aBaseMetaTileEntity.getMetaTileEntity()).addOutputToMachineList(aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir+x,y,zDir+z),aBaseCasingIndex)
  83. )))
  84. return false;
  85. }
  86. }
  87. }
  88. return true;
  89. }
  90.  
  91. }
Add Comment
Please, Sign In to add comment