Exemplo n.º 1
0
 @Override
 public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
   if (world.getBlockId(i, j - 1, k) == this.blockID || world.isBlockOpaqueCube(i, j - 1, k)) {
     return AxisAlignedBB.getBoundingBox(i + 0.3, j, k + 0.3, i + 0.7, j + 1, k + 0.7);
   }
   return AxisAlignedBB.getBoundingBox(i, j + 0.4, k, i + 1, j + 0.6, k + 1);
 }
Exemplo n.º 2
0
  @Override
  public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
    int dir = world.getBlockMetadata(i, j, k);

    if (dir == 0) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.85F, i + 1F, j + 1F, k + 1F);
    } else if (dir == 1) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.0F, i + 0.15F, j + 1F, k + 1F);
    } else if (dir == 2) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.00F, i + 1F, j + 1F, k + 0.15F);
    } else if (dir == 3) {
      return AxisAlignedBB.getBoundingBox(i + 0.85F, j + 0F, k + 0.0F, i + 1F, j + 1F, k + 1F);
    }

    return AxisAlignedBB.getBoundingBox(i, j, k, i + 1, j + 1, k + 1);
  }
Exemplo n.º 3
0
 @Override
 public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int i, int j, int k) {
   return AxisAlignedBB.getBoundingBox(i, j, k, i + 1, j + 0.825, k + 1);
 }
  @ForgeSubscribe
  public void DrawBlockHighlightEvent(DrawBlockHighlightEvent evt) {
    World world = evt.player.worldObj;
    double var8 =
        evt.player.lastTickPosX
            + (evt.player.posX - evt.player.lastTickPosX) * (double) evt.partialTicks;
    double var10 =
        evt.player.lastTickPosY
            + (evt.player.posY - evt.player.lastTickPosY) * (double) evt.partialTicks;
    double var12 =
        evt.player.lastTickPosZ
            + (evt.player.posZ - evt.player.lastTickPosZ) * (double) evt.partialTicks;

    boolean isMetalHoe = false;

    if (evt.currentItem != null
        && evt.currentItem.getItem().shiftedIndex != TFCItems.IgInHoe.shiftedIndex
        && evt.currentItem.getItem().shiftedIndex != TFCItems.IgExHoe.shiftedIndex
        && evt.currentItem.getItem().shiftedIndex != TFCItems.SedHoe.shiftedIndex
        && evt.currentItem.getItem().shiftedIndex != TFCItems.MMHoe.shiftedIndex) {
      isMetalHoe = true;
    }

    if (evt.currentItem != null
        && evt.currentItem.getItem() instanceof ItemCustomHoe
        && isMetalHoe
        && PlayerManagerTFC.getInstance().getClientPlayer().hoeMode == 1) {
      int id = world.getBlockId(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
      int crop = 0;
      if (id == Block.crops.blockID
          && (world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil.blockID
              || world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil2.blockID)) {
        id = TFCBlocks.tilledSoil.blockID;
        crop = 1;
      }

      if (id == TFCBlocks.tilledSoil.blockID || id == TFCBlocks.tilledSoil2.blockID) {
        TileEntityFarmland te =
            (TileEntityFarmland)
                world.getBlockTileEntity(
                    evt.target.blockX, evt.target.blockY - crop, evt.target.blockZ);
        te.requestNutrientData();

        float timeMultiplier = (float) TFC_Time.daysInYear / 360f;
        int soilMax = (int) (25000 * timeMultiplier);

        // Setup GL for the depthbox
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4ub(
            TFC_Settings.cropNutrientAColor[0],
            TFC_Settings.cropNutrientAColor[1],
            TFC_Settings.cropNutrientAColor[2],
            TFC_Settings.cropNutrientAColor[3]);
        GL11.glDisable(GL11.GL_CULL_FACE);
        // GL11.glLineWidth(6.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);

        double offset = 0;
        double nutrient = 1.02 + ((double) te.nutrients[0] / (double) soilMax) * 0.5;

        drawBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        offset = 0.3333;
        nutrient = 1.02 + ((double) te.nutrients[1] / (double) soilMax) * 0.5;
        GL11.glColor4ub(
            TFC_Settings.cropNutrientBColor[0],
            TFC_Settings.cropNutrientBColor[1],
            TFC_Settings.cropNutrientBColor[2],
            TFC_Settings.cropNutrientBColor[3]);
        drawBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        offset = 0.6666;
        nutrient = 1.02 + ((double) te.nutrients[2] / (double) soilMax) * 0.5;
        GL11.glColor4ub(
            TFC_Settings.cropNutrientCColor[0],
            TFC_Settings.cropNutrientCColor[1],
            TFC_Settings.cropNutrientCColor[2],
            TFC_Settings.cropNutrientCColor[3]);
        drawBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        GL11.glEnable(GL11.GL_CULL_FACE);

        /** Draw the outliens around the boxes */
        GL11.glColor4f(0.1F, 0.1F, 0.1F, 1.0F);
        GL11.glLineWidth(3.0F);
        GL11.glDepthMask(false);

        offset = 0;
        nutrient = 1.02 + ((double) te.nutrients[0] / (double) soilMax) * 0.5;
        drawOutlinedBoundingBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        offset = 0.3333;
        nutrient = 1.02 + ((double) te.nutrients[1] / (double) soilMax) * 0.5;
        drawOutlinedBoundingBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        offset = 0.6666;
        nutrient = 1.02 + ((double) te.nutrients[2] / (double) soilMax) * 0.5;
        drawOutlinedBoundingBox(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX + offset,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + offset + 0.3333,
                    evt.target.blockY + nutrient - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));
      }
    } else if (evt.currentItem != null
        && evt.currentItem.getItem() instanceof ItemCustomHoe
        && PlayerManagerTFC.getInstance().getClientPlayer().hoeMode == 2) {
      int id = world.getBlockId(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
      int crop = 0;
      if (id == Block.crops.blockID
          && (world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil.blockID
              || world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil2.blockID)) {
        id = TFCBlocks.tilledSoil.blockID;
        crop = 1;
      }

      if (id == TFCBlocks.tilledSoil.blockID || id == TFCBlocks.tilledSoil2.blockID) {
        boolean water =
            TFC.Blocks.BlockFarmland.isWaterNearby(
                world, evt.target.blockX, evt.target.blockY - crop, evt.target.blockZ);

        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        if (water) GL11.glColor4ub((byte) 14, (byte) 23, (byte) 212, (byte) 200);
        else GL11.glColor4ub((byte) 0, (byte) 0, (byte) 0, (byte) 200);
        GL11.glDisable(GL11.GL_CULL_FACE);
        // GL11.glLineWidth(6.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);

        drawFace(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX,
                    evt.target.blockY + 1.01 - crop,
                    evt.target.blockZ,
                    evt.target.blockX + 1,
                    evt.target.blockY + 1.02 - crop,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        GL11.glEnable(GL11.GL_CULL_FACE);
      }
    } else if (evt.currentItem != null
        && evt.currentItem.getItem() instanceof ItemCustomHoe
        && PlayerManagerTFC.getInstance().getClientPlayer().hoeMode == 3) {
      int id = world.getBlockId(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
      if (id == Block.crops.blockID
          && (world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil.blockID
              || world.getBlockId(evt.target.blockX, evt.target.blockY - 1, evt.target.blockZ)
                  == TFCBlocks.tilledSoil2.blockID)) {
        TileEntityCrop te =
            (TileEntityCrop)
                world.getBlockTileEntity(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
        CropIndex index = CropManager.getInstance().getCropFromId(te.cropId);
        boolean fullyGrown = te.growth >= index.numGrowthStages;

        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        if (fullyGrown) GL11.glColor4ub((byte) 64, (byte) 200, (byte) 37, (byte) 200);
        else GL11.glColor4ub((byte) 200, (byte) 37, (byte) 37, (byte) 200);
        GL11.glDisable(GL11.GL_CULL_FACE);
        // GL11.glLineWidth(6.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);

        drawFace(
            AxisAlignedBB.getAABBPool()
                .addOrModifyAABBInPool(
                    evt.target.blockX,
                    evt.target.blockY + 0.01,
                    evt.target.blockZ,
                    evt.target.blockX + 1,
                    evt.target.blockY + 0.02,
                    evt.target.blockZ + 1)
                .expand(0.002F, 0.002F, 0.002F)
                .getOffsetBoundingBox(-var8, -var10, -var12));

        GL11.glEnable(GL11.GL_CULL_FACE);
      }
    }
  }