@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);
      }
    }
  }
Exemplo n.º 2
0
 private int drawArrowScaled(int scale) {
   PlayerInfo pi = PlayerManagerTFC.getInstance().getPlayerInfoFromPlayer(player);
   return (pi.moldTransferTimer == 1000 ? 0 : pi.moldTransferTimer * scale) / 100;
 }
Exemplo n.º 3
0
  @Override
  public boolean onUsed(
      World world,
      EntityPlayer player,
      int x,
      int y,
      int z,
      int blockID,
      int meta,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    byte newMeta = 0;
    if (side == 0) {
      newMeta = (byte) (newMeta | 4);
    }

    int rot = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
    byte flip = (byte) (newMeta & 4);
    byte rotation = 0;

    if (rot == 0) {
      rotation = (byte) (2 | flip);
    } else if (rot == 1) {
      rotation = (byte) (1 | flip);
    } else if (rot == 2) {
      rotation = (byte) (3 | flip);
    } else if (rot == 3) {
      rotation = (byte) (0 | flip);
    }

    int mode = 0;
    PlayerInfo pi = null;

    int hasChisel = -1;
    int hasHammer = -1;

    for (int i = 0; i < 9; i++) {
      if (player.inventory.mainInventory[i] != null
          && player.inventory.mainInventory[i].getItem() instanceof ItemHammer) {
        hasHammer = i;
      }
    }

    if (player.inventory.mainInventory[player.inventory.currentItem] != null
        && player.inventory.mainInventory[player.inventory.currentItem].getItem()
            instanceof ItemChisel) {
      hasChisel = player.inventory.currentItem;
    }

    if (!world.isRemote) {
      pi = PlayerManagerTFC.getInstance().getPlayerInfoFromPlayer(player);

      if (pi != null) {
        mode = pi.ChiselMode;
      }
    } else {
      pi = PlayerManagerTFC.getInstance().getClientPlayer();
    }

    if (pi != null) {
      mode = pi.ChiselMode;
    }

    if (hasChisel >= 0) {
      if (mode == 0) {
        if (side == 0 && world.getBlockId(x, y + 1, z) == blockID) {
          return false;
        }

        CreateSmooth(world, x, y, z, blockID, meta);

        player.inventory.mainInventory[hasChisel].damageItem(1, player);

        return true;
      } else if (mode == 1) {
        if ((side == 0)
            && TFC_Core.isRawStone(blockID)
            && TFC_Core.isRawStone(world.getBlockId(x, y + 1, z))) {
          return false;
        }

        ItemChisel.CreateStairs(world, x, y, z, blockID, meta, rotation);

        player.inventory.mainInventory[hasChisel].damageItem(1, player);

        return true;
      } else if (mode == 2) {
        if ((side == 0)
            && TFC_Core.isRawStone(blockID)
            && TFC_Core.isRawStone(world.getBlockId(x, y + 1, z))) {
          return false;
        }

        ItemChisel.CreateSlab(world, x, y, z, blockID, meta, side);

        player.inventory.mainInventory[hasChisel].damageItem(1, player);

        return true;
      } else if (mode == 3 && pi.lockMatches(x, y, z)) {
        ItemChisel.CreateDetailed(world, x, y, z, blockID, meta, side, hitX, hitY, hitZ);
        if (random.nextInt(4) == 0) {
          player.inventory.mainInventory[hasChisel].damageItem(1, player);
        }
        return true;
      }
    }
    return true;
  }