예제 #1
0
 public static void init() {
   Utils.LOG_INFO("Registering Tile Entities.");
   // GameRegistry.registerTileEntity(TileEntityReverter.class, "TE_blockGriefSaver");
   // GameRegistry.registerTileEntity(TileEntityReverter.class, "Tower Reverter");
   // GameRegistry.registerTileEntity(TileEntityNHG.class, "NuclearFueledHeliumGenerator");
   // GameRegistry.registerTileEntity(TileEntityCharger.class, "TE_Charger");
   // GameRegistry.registerTileEntity(TileEntityHeliumGenerator.class, "Helium");
   GameRegistry.registerTileEntity(TileEntityWorkbench.class, "TileWorkbench");
   GameRegistry.registerTileEntity(TileEntityWorkbenchAdvanced.class, "TileWorkbenchAdvanced");
 }
  @Override
  public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
    int controllerX = aBaseMetaTileEntity.getXCoord();
    int controllerY = aBaseMetaTileEntity.getYCoord();
    int controllerZ = aBaseMetaTileEntity.getZCoord();

    byte tSide = getBaseMetaTileEntity().getBackFacing();
    if ((getBaseMetaTileEntity()
            .getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 1))
        && (getBaseMetaTileEntity()
                .getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 2)
            && (getBaseMetaTileEntity()
                .getAirAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 3)))) {
      int tAirCount = 0;
      for (byte i = -1; i < 2; i = (byte) (i + 1)) {
        for (byte j = -1; j < 2; j = (byte) (j + 1)) {
          for (byte k = -1; k < 2; k = (byte) (k + 1)) {
            if (getBaseMetaTileEntity().getAirOffset(i, j, k)) {
              Utils.LOG_INFO(
                  "Found Air at: "
                      + (controllerX + i)
                      + " "
                      + (controllerY + k)
                      + " "
                      + (controllerZ + k));
              // if (aBaseMetaTileEntity.getWorld().isRemote){
              // asdasd.renderStandardBlock(ModBlocks.MatterFabricatorEffectBlock, (controllerX+i),
              // (controllerY+k), (controllerZ+k));
              // UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k),
              // Color.YELLOW_GREEN);
              // }
              tAirCount++;
            }
          }
        }
      }
      if (tAirCount != 10) {
        Utils.LOG_INFO("False. Air != 10. Air == " + tAirCount);
        // return false;
      }
      for (byte i = 2; i < 6; i = (byte) (i + 1)) {
        // UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY), (controllerZ),
        // Color.LIME_GREEN);
        IGregTechTileEntity tTileEntity;
        if ((null
                != (tTileEntity =
                    getBaseMetaTileEntity().getIGregTechTileEntityAtSideAndDistance(i, 2)))
            && (tTileEntity.getFrontFacing() == getBaseMetaTileEntity().getFrontFacing())
            && (tTileEntity.getMetaTileEntity() != null)
            && ((tTileEntity.getMetaTileEntity()
                instanceof GregtechMetaTileEntity_IndustrialSinter))) {
          // Utils.LOG_INFO("False 1");
          return false;
        }
      }
      int tX = getBaseMetaTileEntity().getXCoord();
      int tY = getBaseMetaTileEntity().getYCoord();
      int tZ = getBaseMetaTileEntity().getZCoord();
      for (byte i = -1; i < 2; i = (byte) (i + 1)) {
        for (byte j = -1; j < 2; j = (byte) (j + 1)) {
          if ((i != 0) || (j != 0)) {
            for (byte k = 0; k < 5; k = (byte) (k + 1)) {
              // UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k), (controllerZ+k),
              // Color.ORANGE);
              if (((i == 0) || (j == 0)) && ((k == 1) || (k == 2) || (k == 3))) {
                // UtilsRendering.drawBlockInWorld((controllerX+i), (controllerY+k),
                // (controllerZ+k), Color.TOMATO);
                if (getBaseMetaTileEntity()
                            .getBlock(
                                tX + (tSide == 5 ? k : tSide == 4 ? -k : i),
                                tY + j,
                                tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))
                        == getCasingBlock()
                    && getBaseMetaTileEntity()
                            .getMetaID(
                                tX + (tSide == 5 ? k : tSide == 4 ? -k : i),
                                tY + j,
                                tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))
                        == getCasingMeta()) {
                } else if (!addToMachineList(
                        getBaseMetaTileEntity()
                            .getIGregTechTileEntity(
                                tX + (tSide == 5 ? k : tSide == 4 ? -k : i),
                                tY + j,
                                tZ + (tSide == 2 ? -k : tSide == 3 ? k : i)))
                    && (!addEnergyInputToMachineList(
                        getBaseMetaTileEntity()
                            .getIGregTechTileEntity(
                                tX + (tSide == 5 ? k : tSide == 4 ? -k : i),
                                tY + j,
                                tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))))) {
                  Utils.LOG_INFO("False 2");
                  return false;
                }
              } else if (getBaseMetaTileEntity()
                          .getBlock(
                              tX + (tSide == 5 ? k : tSide == 4 ? -k : i),
                              tY + j,
                              tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))
                      == getCasingBlock()
                  && getBaseMetaTileEntity()
                          .getMetaID(
                              tX + (tSide == 5 ? k : tSide == 4 ? -k : i),
                              tY + j,
                              tZ + (tSide == 2 ? -k : tSide == 3 ? k : i))
                      == getCasingMeta()) {
              } else {
                Utils.LOG_INFO("False 3");
                return false;
              }
            }
          }
        }
      }
      if (this.mOutputHatches.size() != 0 || this.mInputHatches.size() != 0) {
        Utils.LOG_INFO("Use Busses, Not Hatches for Input/Output.");
        return false;
      }
      if (this.mInputBusses.size() != 2 || this.mOutputBusses.size() != 2) {
        Utils.LOG_INFO("Incorrect amount of Input & Output busses.");
        return false;
      }
      this.mMaintenanceHatches.clear();
      IGregTechTileEntity tTileEntity =
          getBaseMetaTileEntity()
              .getIGregTechTileEntityAtSideAndDistance(getBaseMetaTileEntity().getBackFacing(), 4);
      if ((tTileEntity != null) && (tTileEntity.getMetaTileEntity() != null)) {
        if ((tTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_Hatch_Maintenance)) {
          this.mMaintenanceHatches.add(
              (GT_MetaTileEntity_Hatch_Maintenance) tTileEntity.getMetaTileEntity());
          ((GT_MetaTileEntity_Hatch) tTileEntity.getMetaTileEntity()).mMachineBlock =
              getCasingTextureIndex();
        } else {
          Utils.LOG_INFO("Maintenance hatch must be in the middle block on the back.");
          return false;
        }
      }
      if (this.mMaintenanceHatches.size() != 1 || this.mEnergyHatches.size() != 1) {
        Utils.LOG_INFO("Incorrect amount of Maintenance or Energy hatches.");
        return false;
      }
    } else {
      Utils.LOG_INFO("False 5");
      return false;
    }
    Utils.LOG_INFO("True");
    return true;
  }