Пример #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);
 }
Пример #2
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityplayer,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    super.onBlockActivated(world, x, y, z, entityplayer, side, hitX, hitY, hitZ);
    TileEntityQuern te = (TileEntityQuern) world.getBlockTileEntity(x, y, z);
    if (!world.isRemote) {
      if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.storage[2] != null) {
        te.shouldRotate = true;
        world.playSoundEffect(x, y, z, TFC_Sounds.STONEDRAG, 1, 1);
      } else if ((!te.shouldRotate && (hitX < 0.65 || hitZ < 0.65)) || te.storage[2] == null) {
        entityplayer.openGui(TerraFirmaCraft.instance, 33, world, x, y, z);
      }
    } else if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.hasQuern) {
      te.shouldRotate = true;
    }

    return true;
  }
Пример #3
0
  public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
    int dir = world.getBlockMetadata(i, j, k);

    if (dir == 0) {
      if (!world.isBlockOpaqueCube(i, j, k + 1)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 1) {
      if (!world.isBlockOpaqueCube(i - 1, j, k)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 2) {
      if (!world.isBlockOpaqueCube(i, j, k - 1)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 3) {
      if (!world.isBlockOpaqueCube(i + 1, j, k)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    }
  }
  @Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure the player has the correct tool out
    boolean isAxeorSaw = false;
    boolean isHammer = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (!world.isRemote) {
      if (equip != null) {
        for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Axes[cnt]) {
            isAxeorSaw = true;
            if (cnt < 4) isStone = true;
          }
        }
        //				for(int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++)
        //				{
        //					if(equip.getItem() == Recipes.Saws[cnt])
        //					{
        //						isAxeorSaw = true;
        //					}
        //				}
        for (int cnt = 0; cnt < Recipes.Hammers.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Hammers[cnt]) {
            isHammer = true;
          }
        }
      }
      if (isAxeorSaw) {
        damage = -1;
        ProcessTree(world, i, j, k, l, equip);

        if (damage + equip.getItemDamage() > equip.getMaxDamage()) {
          int ind = entityplayer.inventory.currentItem;
          entityplayer.inventory.setInventorySlotContents(ind, null);
          world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
        } else {
          equip.damageItem(damage, entityplayer);
        }
      } else if (isHammer) {
        EntityItem item =
            new EntityItem(
                world,
                i + 0.5,
                j + 0.5,
                k + 0.5,
                new ItemStack(Item.stick, 1 + world.rand.nextInt(3)));
        world.spawnEntityInWorld(item);
      } else {
        world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
      }
    }
  }
Пример #5
0
  /**
   * Returns a boolean array indicating which flow directions are optimal based on each direction's
   * calculated flow cost. Each array index corresponds to one of the four cardinal directions. A
   * value of true indicates the direction is optimal.
   */
  private boolean[] getOptimalFlowDirections(World par1World, int par2, int par3, int par4) {
    int var5;
    int var6;

    for (var5 = 0; var5 < 4; ++var5) {
      this.flowCost[var5] = 1000;
      var6 = par2;
      int var8 = par4;

      if (var5 == 0) {
        var6 = par2 - 1;
      }

      if (var5 == 1) {
        ++var6;
      }

      if (var5 == 2) {
        var8 = par4 - 1;
      }

      if (var5 == 3) {
        ++var8;
      }

      if (!this.blockBlocksFlow(par1World, var6, par3, var8)
          && (par1World.getBlockId(var6, par3, var8) != this.blockID
              || par1World.getBlockMetadata(var6, par3, var8) != 0)) {
        if (!this.blockBlocksFlow(par1World, var6, par3 - 1, var8)) {
          this.flowCost[var5] = 0;
        } else {
          this.flowCost[var5] = this.calculateFlowCost(par1World, var6, par3, var8, 1, var5);
        }
      }
    }

    var5 = this.flowCost[0];

    for (var6 = 1; var6 < 4; ++var6) {
      if (this.flowCost[var6] < var5) {
        var5 = this.flowCost[var6];
      }
    }

    for (var6 = 0; var6 < 4; ++var6) {
      this.isOptimalFlowDirection[var6] = this.flowCost[var6] == var5;
    }

    return this.isOptimalFlowDirection;
  }
Пример #6
0
 @Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   boolean check = false;
   for (int h = -1; h <= 1; h++) {
     for (int g = -1; g <= 1; g++) {
       for (int f = -1; f <= 1; f++) {
         if (world.getBlockId(i + h, j + g, k + f) == blockID
             && world.getBlockMetadata(i + h, j + g, k + f) == world.getBlockMetadata(i, j, k)) {
           check = true;
         }
       }
     }
   }
   if (!check) {
     world.setBlock(i, j, k, 0);
   }
 }
Пример #7
0
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    super.onBlockAdded(par1World, par2, par3, par4);

    //        if (par1World.getBlockId(par2, par3, par4) == this.blockID)
    //        {
    par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
    //        }
  }
 @Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   boolean check = false;
   for (int h = -2; h <= 2; h++) {
     for (int g = -2; g <= 2; g++) {
       for (int f = -2; f <= 2; f++) {
         if (world.getBlockId(i + h, j + g, k + f) == blockID
             && world.getBlockMetadata(i + h, j + g, k + f) == world.getBlockMetadata(i, j, k)) {
           check = true;
         }
       }
     }
   }
   if (!check) {
     world.setBlock(i, j, k, 0);
     dropBlockAsItem_do(world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
   }
 }
  private void ProcessTree(World world, int i, int j, int k, int l, ItemStack stack) {
    int x = i;
    int y = 0;
    int z = k;
    boolean checkArray[][][] = new boolean[11][50][11];

    boolean reachedTop = false;
    while (!reachedTop) {
      if (l != 9 && l != 15 && world.getBlockId(x, j + y + 1, z) == 0) {
        reachedTop = true;
      } else if ((l == 9 || l == 15)
          && world.getBlockId(x, j + y + 1, z) == 0
          && world.getBlockId(x + 1, j + y + 1, z) != blockID
          && world.getBlockId(x - 1, j + y + 1, z) != blockID
          && world.getBlockId(x, j + y + 1, z + 1) != blockID
          && world.getBlockId(x, j + y + 1, z - 1) != blockID
          && world.getBlockId(x - 1, j + y + 1, z - 1) != blockID
          && world.getBlockId(x - 1, j + y + 1, z + 1) != blockID
          && world.getBlockId(x + 1, j + y + 1, z + 1) != blockID
          && world.getBlockId(x + 1, j + y + 1, z - 1) != blockID) {
        reachedTop = true;
      }

      scanLogs(world, i, j + y, k, l, checkArray, 6, y, 6, stack);

      y++;
    }
  }
Пример #10
0
  private void scanLogs(
      World world, int i, int j, int k, int l, boolean[][][] checkArray, int x, int y, int z) {
    if (y >= 0) {
      checkArray[x][y][z] = true;
      int offsetX = 0;
      int offsetY = 0;
      int offsetZ = 0;

      for (offsetY = 0; offsetY <= 1; offsetY++) {
        for (offsetX = -1; offsetX <= 1; offsetX++) {
          for (offsetZ = -1; offsetZ <= 1; offsetZ++) {
            if (x + offsetX < 11
                && x + offsetX >= 0
                && z + offsetZ < 11
                && z + offsetZ >= 0
                && y + offsetY < 50
                && y + offsetY >= 0) {
              if (checkOut(world, i + offsetX, j + offsetY, k + offsetZ, l)
                  && !checkArray[x + offsetX][y + offsetY][z + offsetZ]) {
                scanLogs(
                    world,
                    i + offsetX,
                    j + offsetY,
                    k + offsetZ,
                    l,
                    checkArray,
                    x + offsetX,
                    y + offsetY,
                    z + offsetZ);
              }
            }
          }
        }
      }

      world.setBlockWithNotify(i, j, k, 0);
      world.markBlockForUpdate(i, j, k);
    }
  }
Пример #11
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World world, int x, int y, int z, Random random) {
    // Initialize variables
    int volume = 0;
    int remainder = 0;
    int direction = 0;
    boolean[] optimal = new boolean[4];

    int meta = world.getBlockMetadata(x, y, z);

    // Try to move down
    if (moveToBlock(world, x, y, z, x, y - 1, z)) {
      return;
    }

    // Get optimal flow direction
    optimal = getOptimalFlowDirections(world, x, y, z);

    // Move
    if (optimal[0]) {
      if (!moveToBlock(world, x, y, z, x - 1, y, z))
        if (!moveToBlock(world, x, y, z, x, y, z + 1))
          if (!moveToBlock(world, x, y, z, x, y, z - 1))
            if (!moveToBlock(world, x, y, z, x + 1, y, z)) ;
    } else if (optimal[1]) {
      if (!moveToBlock(world, x, y, z, x + 1, y, z))
        if (!moveToBlock(world, x, y, z, x, y, z + 1))
          if (!moveToBlock(world, x, y, z, x, y, z - 1))
            if (!moveToBlock(world, x, y, z, x - 1, y, z)) ;
    } else if (optimal[2]) {
      if (!moveToBlock(world, x, y, z, x, y, z - 1))
        if (!moveToBlock(world, x, y, z, x - 1, y, z))
          if (!moveToBlock(world, x, y, z, x + 1, y, z))
            if (!moveToBlock(world, x, y, z, x, y, z + 1)) ;
    } else if (optimal[3]) {
      if (!moveToBlock(world, x, y, z, x, y, z + 1))
        if (!moveToBlock(world, x, y, z, x - 1, y, z))
          if (!moveToBlock(world, x, y, z, x + 1, y, z))
            if (!moveToBlock(world, x, y, z, x, y, z - 1)) ;
    }

    //		if (meta == world.getBlockMetadata(x, y, z) && meta > 5)
    //		{
    //		    if(random.nextInt(100) < 10)
    //		    {
    //		        if(meta > 1)
    //		            world.setBlockMetadata(x, y, z, meta-1);
    //		        else
    //		            world.setBlock(x, y, z, 0);
    //		    }
    //		}
  }
Пример #12
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);
  }
Пример #13
0
  /**
   * calculateFlowCost(World world, int x, int y, int z, int accumulatedCost, int
   * previousDirectionOfFlow) - Used to determine the path of least resistance, this method returns
   * the lowest possible flow cost for the direction of flow indicated. Each necessary horizontal
   * flow adds to the flow cost.
   */
  private int calculateFlowCost(World par1World, int par2, int par3, int par4, int par5, int par6) {
    int var7 = 1000;

    for (int var8 = 0; var8 < 4; ++var8) {
      if ((var8 != 0 || par6 != 1)
          && (var8 != 1 || par6 != 0)
          && (var8 != 2 || par6 != 3)
          && (var8 != 3 || par6 != 2)) {
        int var9 = par2;
        int var11 = par4;

        if (var8 == 0) {
          var9 = par2 - 1;
        }

        if (var8 == 1) {
          ++var9;
        }

        if (var8 == 2) {
          var11 = par4 - 1;
        }

        if (var8 == 3) {
          ++var11;
        }

        if (!this.blockBlocksFlow(par1World, var9, par3, var11)
            && ((par1World.getBlockMaterial(var9, par3, var11) != this.blockMaterial /*||
                		par1World.getBlockId(var9, par3, var11) == this.blockID) || par1World.getBlockMetadata(var9, par3, var11) != 0*/))) {
          if (!this.blockBlocksFlow(par1World, var9, par3 - 1, var11)) {
            return par5;
          }

          if (par5 < 4) {
            int var12 = this.calculateFlowCost(par1World, var9, par3, var11, par5 + 1, var8);

            if (var12 < var7) {
              var7 = var12;
            }
          }
        }
      }
    }

    return var7;
  }
Пример #14
0
  /** Returns true if block at coords blocks fluids */
  private boolean blockBlocksFlow(World par1World, int par2, int par3, int par4) {
    int var5 = par1World.getBlockId(par2, par3, par4);

    if (var5 != Block.doorWood.blockID
        && var5 != Block.doorSteel.blockID
        && var5 != Block.signPost.blockID
        && var5 != Block.ladder.blockID
        && var5 != Block.reed.blockID) {
      if (var5 == 0) {
        return false;
      } else {
        Material var6 = Block.blocksList[var5].blockMaterial;
        return var6 == Material.portal ? true : var6.blocksMovement();
      }
    } else {
      return true;
    }
  }
Пример #15
0
 @Override
 public void updateTick(World world, int i, int j, int k, Random rand) {
   if (!world.isRemote) {
     if (!world.isBlockOpaqueCube(i, j - 1, k)) {
       if (world.getBlockId(i + 1, j, k) != blockID
           && world.getBlockId(i - 1, j, k) != blockID
           && world.getBlockId(i, j, k + 1) != blockID
           && world.getBlockId(i, j, k - 1) != blockID
           && world.getBlockId(i + 1, j, k + 1) != blockID
           && world.getBlockId(i + 1, j, k - 1) != blockID
           && world.getBlockId(i - 1, j, k + 1) != blockID
           && world.getBlockId(i - 1, j, k - 1) != blockID) {
         world.setBlock(i, j, k, 0);
       }
     }
   }
 }
Пример #16
0
  public void SurroundWithLeaves(World world, int i, int j, int k) {
    for (int y = 0; y <= 1; y++) {
      for (int x = 1; x >= -1; x--) {
        for (int z = 1; z >= -1; z--) {
          if (world.getBlockId(i + x, j + y, k + z) == 0
              && (world.getBlockId(i + x, j + y + 1, k + z) == 0
                  || world.getBlockId(i + x, j + y + 2, k + z) == 0)) {
            int meta = world.getBlockMetadata(i, j, k);
            int id =
                meta < 8 ? TFCBlocks.fruitTreeLeaves.blockID : TFCBlocks.fruitTreeLeaves2.blockID;

            if (world.getBlockId(i, j, k) != TFCBlocks.fruitTreeWood.blockID) id = 0;

            world.setBlockAndMetadata(i + x, j + y, k + z, id, world.getBlockMetadata(i, j, k));
          }
        }
      }
    }
  }
Пример #17
0
  private boolean moveToBlock(World world, int x, int y, int z, int x2, int y2, int z2) {
    int blockID2 = world.getBlockId(x2, y2, z2);
    int originMeta = world.getBlockMetadata(x, y, z);
    int destMeta = world.getBlockMetadata(x2, y2, z2);
    if (blockID2 == this.blockID) {
      if (destMeta > originMeta || y > y2) {
        if (originMeta < 7 && destMeta > 0) {
          world.setBlockMetadata(x, y, z, originMeta + 1);
          world.markBlockForUpdate(x, y, z);
          world.setBlockMetadata(x2, y2, z2, destMeta - 1);
          world.markBlockForUpdate(x2, y2, z2);
          return true;
        } else if (destMeta > 0) {
          world.setBlockWithNotify(x, y, z, 0);
          world.markBlockForUpdate(x, y, z);
          world.setBlockMetadata(x2, y2, z2, destMeta - 1);
          world.markBlockForUpdate(x2, y2, z2);
          return true;
        } else {
          return false;
        }
      } else {
        return false;
      }
    } else if (liquidCanDisplaceBlock(world, x2, y2, z2)) {
      if (blockID2 > 0) {
        if (this.blockMaterial == Material.lava) {
          this.triggerLavaMixEffects(world, x2, y2, z2);
        } else if (blockID2 == Block.waterMoving.blockID || blockID2 == Block.waterStill.blockID) {
          if (originMeta < 7) {
            world.setBlockMetadataWithNotify(x, y, z, originMeta + 1);
            world.markBlockForUpdate(x, y, z);
            return true;
          } else {
            world.setBlockWithNotify(x, y, z, 0);
            world.markBlockForUpdate(x, y, z);
            return true;
          }
        } else {
          Block.blocksList[blockID2].dropBlockAsItem(
              world, x2, y2, z2, world.getBlockMetadata(x2, y2, z2), 0);
        }
      }

      if (y2 < y) {
        world.setBlockWithNotify(x, y, z, 0);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, originMeta);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      }
      if (originMeta < 7) {
        world.setBlockMetadataWithNotify(x, y, z, originMeta + 1);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, 7);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      } else if (world.getBlockId(x - 1, y, z) != this.blockID
          && world.getBlockId(x + 1, y, z) != this.blockID
          && world.getBlockId(x, y + 1, z) != this.blockID
          && world.getBlockId(x, y, z - 1) != this.blockID
          && world.getBlockId(x, y, z + 1) != this.blockID) {
        world.setBlockWithNotify(x, y, z, 0);
        return true;
      } else {
        world.setBlockWithNotify(x, y, z, 0);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, 7);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      }
    } else {
      return false;
    }
  }
  @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);
      }
    }
  }
Пример #19
0
 public boolean onBlockActivated(
     World world,
     int i,
     int j,
     int k,
     EntityPlayer entityplayer,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   if (!world.isRemote) {
     TileEntityToolRack te = (TileEntityToolRack) world.getBlockTileEntity(i, j, k);
     int dir = world.getBlockMetadata(i, j, k);
     if (te != null) {
       if (dir == 0) {
         if (hitX < 0.5 && hitY > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 0, 0);
         } else if (hitX > 0.5 && hitY > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 1, 0);
         } else if (hitX < 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 2, 0);
         } else if (hitX > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 3, 0);
         }
       } else if (dir == 1) {
         if (hitZ < 0.5 && hitY > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 0, 1);
         } else if (hitZ > 0.5 && hitY > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 1, 1);
         } else if (hitZ < 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 2, 1);
         } else if (hitZ > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 3, 1);
         }
       } else if (dir == 2) {
         if (hitX < 0.5 && hitY > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 0, 2);
         } else if (hitX > 0.5 && hitY > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 1, 2);
         } else if (hitX < 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 2, 2);
         } else if (hitX > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 3, 2);
         }
       } else if (dir == 3) {
         if (hitZ < 0.5 && hitY > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 0, 3);
         } else if (hitZ > 0.5 && hitY > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 1, 3);
         } else if (hitZ < 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 2, 3);
         } else if (hitZ > 0.5) {
           handleArea(world, i, j, k, entityplayer, te, 3, 3);
         }
       }
       te.broadcastPacketInRange(te.createUpdatePacket());
       return true;
     }
   }
   return false;
 }
Пример #20
0
  @Override
  public void updateTick(World world, int i, int j, int k, Random rand) {
    FloraManager manager = FloraManager.getInstance();
    FloraIndex fi = manager.findMatchingIndex(this.getType(world.getBlockMetadata(i, j, k)));

    float temp = TFC_Climate.getHeightAdjustedTemp(i, j, k);

    if (!world.isRemote
        && world.getBlockTileEntity(i, j, k) != null
        && TFC_Time.currentMonth < 6
        && fi != null
        && temp >= fi.minTemp
        && temp < fi.maxTemp) {
      TileEntityFruitTreeWood te = (TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k);
      int t = 1;
      if (TFC_Time.currentMonth < 3) t = 2;

      int leafGrowthRate = 20;
      int trunkGrowTime = 30;
      int branchGrowTime = 20;

      // grow upward
      if (te.birthTimeWood + trunkGrowTime < TFC_Time.totalDays()
          && te.height < 3
          && te.isTrunk
          && rand.nextInt(16 / t) == 0
          && (world.getBlockId(i, j + 1, k) == 0
              || world.getBlockId(i, j + 1, k) == TFCBlocks.fruitTreeLeaves.blockID)) {
        world.setBlockAndMetadata(i, j + 1, k, this.blockID, world.getBlockMetadata(i, j, k));
        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setTrunk(true);
        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setHeight(te.height + 1);
        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j + 1, k)).setBirth();

        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k)).setBirthWood(trunkGrowTime);
      } else if (te.birthTimeWood + branchGrowTime < TFC_Time.totalDays()
          && te.height == 2
          && te.isTrunk
          && rand.nextInt(16 / t) == 0
          && world.getBlockId(i, j + 1, k) != blockID) {
        int r = rand.nextInt(4);
        if (r == 0 && world.getBlockId(i + 1, j, k) == 0
            || world.getBlockId(i + 1, j, k) == TFCBlocks.fruitTreeLeaves.blockID) {
          world.setBlockAndMetadata(i + 1, j, k, this.blockID, world.getBlockMetadata(i, j, k));
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setTrunk(false);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setHeight(te.height);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i + 1, j, k)).setBirth();
        } else if (r == 1 && world.getBlockId(i, j, k - 1) == 0
            || world.getBlockId(i, j, k - 1) == TFCBlocks.fruitTreeLeaves.blockID) {
          world.setBlockAndMetadata(i, j, k - 1, this.blockID, world.getBlockMetadata(i, j, k));
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setTrunk(false);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setHeight(te.height);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k - 1)).setBirth();
        } else if (r == 2 && world.getBlockId(i - 1, j, k) == 0
            || world.getBlockId(i - 1, j, k) == TFCBlocks.fruitTreeLeaves.blockID) {
          world.setBlockAndMetadata(i - 1, j, k, this.blockID, world.getBlockMetadata(i, j, k));
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setTrunk(false);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setHeight(te.height);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i - 1, j, k)).setBirth();
        } else if (r == 3 && world.getBlockId(i, j, k + 1) == 0
            || world.getBlockId(i, j, k + 1) == TFCBlocks.fruitTreeLeaves.blockID) {
          world.setBlockAndMetadata(i, j, k + 1, this.blockID, world.getBlockMetadata(i, j, k));
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setTrunk(false);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setHeight(te.height);
          ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k + 1)).setBirth();
        }

        ((TileEntityFruitTreeWood) world.getBlockTileEntity(i, j, k)).setBirthWood(branchGrowTime);
      } else if (te.birthTimeWood + 1 < TFC_Time.totalDays()
          && rand.nextInt(leafGrowthRate) == 0
          && world.getBlockId(i, j + 2, k) != blockID) {
        if (world.getBlockId(i, j + 1, k) == 0
            && world.getBlockId(i, j + 2, k) == 0
            && BlockFruitLeaves.canStay(
                world, i, j + 1, k, TFCBlocks.fruitTreeLeaves.blockID)) // above
        {
          world.setBlockAndMetadata(
              i, j + 1, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i, j + 1, k);
        } else if (world.getBlockId(i + 1, j, k) == 0
            && world.getBlockId(i + 1, j + 1, k) == 0
            && BlockFruitLeaves.canStay(
                world, i + 1, j, k, TFCBlocks.fruitTreeLeaves.blockID)) // +x
        {
          world.setBlockAndMetadata(
              i + 1, j, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i + 1, j, k);
        } else if (world.getBlockId(i - 1, j, k) == 0
            && world.getBlockId(i - 1, j + 1, k) == 0
            && BlockFruitLeaves.canStay(
                world, i - 1, j, k, TFCBlocks.fruitTreeLeaves.blockID)) // -x
        {
          world.setBlockAndMetadata(
              i - 1, j, k, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i - 1, j, k);
        } else if (world.getBlockId(i, j, k + 1) == 0
            && world.getBlockId(i, j + 1, k + 1) == 0
            && BlockFruitLeaves.canStay(
                world, i, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // +z
        {
          world.setBlockAndMetadata(
              i, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i, j, k + 1);
        } else if (world.getBlockId(i, j, k - 1) == 0
            && world.getBlockId(i, j + 1, k - 1) == 0
            && BlockFruitLeaves.canStay(
                world, i, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // -z
        {
          world.setBlockAndMetadata(
              i, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i, j, k - 1);
        } else if (world.getBlockId(i + 1, j, k - 1) == 0
            && world.getBlockId(i + 1, j + 1, k - 1) == 0
            && BlockFruitLeaves.canStay(
                world, i + 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // +x/-z
        {
          world.setBlockAndMetadata(
              i + 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i + 1, j, k - 1);
        } else if (world.getBlockId(i + 1, j, k + 1) == 0
            && world.getBlockId(i + 1, j + 1, k + 1) == 0
            && BlockFruitLeaves.canStay(
                world, i + 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // +x/+z
        {
          world.setBlockAndMetadata(
              i + 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i + 1, j, k + 1);
        } else if (world.getBlockId(i - 1, j, k - 1) == 0
            && world.getBlockId(i - 1, j + 1, k - 1) == 0
            && BlockFruitLeaves.canStay(
                world, i - 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID)) // -x/-z
        {
          world.setBlockAndMetadata(
              i - 1, j, k - 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i - 1, j, k - 1);
        } else if (world.getBlockId(i - 1, j, k + 1) == 0
            && world.getBlockId(i - 1, j + 1, k + 1) == 0
            && BlockFruitLeaves.canStay(
                world, i - 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID)) // -x/+z
        {
          world.setBlockAndMetadata(
              i - 1, j, k + 1, TFCBlocks.fruitTreeLeaves.blockID, world.getBlockMetadata(i, j, k));
          world.markBlockForUpdate(i - 1, j, k + 1);
        }
      }
    }
  }
Пример #21
0
 private boolean checkOut(World world, int i, int j, int k, int l) {
   if (world.getBlockId(i, j, k) == blockID && world.getBlockMetadata(i, j, k) == l) {
     return true;
   }
   return false;
 }
Пример #22
0
  private void scanLogs(
      World world,
      int i,
      int j,
      int k,
      int l,
      boolean[][][] checkArray,
      int x,
      int y,
      int z,
      ItemStack stack) {
    if (y >= 0) {
      checkArray[x][y][z] = true;
      int offsetX = 0;
      int offsetY = 0;
      int offsetZ = 0;

      for (offsetY = 0; offsetY <= 1; offsetY++) {
        for (offsetX = -2; offsetX <= 2; offsetX++) {
          for (offsetZ = -2; offsetZ <= 2; offsetZ++) {
            if (x + offsetX < 11
                && x + offsetX >= 0
                && z + offsetZ < 11
                && z + offsetZ >= 0
                && y + offsetY < 50
                && y + offsetY >= 0) {
              if (checkOut(world, i + offsetX, j + offsetY, k + offsetZ, l)
                  && !checkArray[x + offsetX][y + offsetY][z + offsetZ]) {
                scanLogs(
                    world,
                    i + offsetX,
                    j + offsetY,
                    k + offsetZ,
                    l,
                    checkArray,
                    x + offsetX,
                    y + offsetY,
                    z + offsetZ,
                    stack);
              }
            }
          }
        }
      }

      damage++;
      if (stack != null) {
        if (damage + stack.getItemDamage() <= stack.getMaxDamage()) {
          world.setBlock(i, j, k, 0);
          world.markBlockForUpdate(i, j, k);
          if ((isStone && world.rand.nextInt(10) != 0) || !isStone)
            dropBlockAsItem_do(
                world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
        }
      } else {
        world.setBlock(i, j, k, 0);
        world.markBlockForUpdate(i, j, k);
        dropBlockAsItem_do(
            world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
      }
    }
  }
Пример #23
0
  @Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure teh palyer has the correct tool out
    boolean isAxeorSaw = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (equip != null) {
      for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
        if (equip.getItem() == Recipes.Axes[cnt]) {
          isAxeorSaw = true;
        }
      }
      for (int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++) {
        if (equip.getItem() == Recipes.Saws[cnt]) {
          isAxeorSaw = true;
        }
      }
    }
    if (isAxeorSaw) {
      int x = i;
      int y = 0;
      int z = k;
      int count = 0;

      if (world.getBlockId(i, j + 1, k) == blockID || world.getBlockId(i, j - 1, k) == blockID) {
        // super.harvestBlock(world, entityplayer, i, j, k, l);
        boolean checkArray[][][] = new boolean[11][50][11];

        if (TFC_Core.isGrass(world.getBlockId(i, j + y - 1, k))
            || TFC_Core.isDirt(world.getBlockId(i, j + y - 1, k))) {
          boolean reachedTop = false;
          while (!reachedTop) {
            if (l != 9 && l != 15 && world.getBlockId(x, j + y + 1, z) == 0) {
              reachedTop = true;
            } else if ((l == 9 || l == 15)
                && world.getBlockId(x, j + y + 1, z) == 0
                && world.getBlockId(x + 1, j + y + 1, z) != blockID
                && world.getBlockId(x - 1, j + y + 1, z) != blockID
                && world.getBlockId(x, j + y + 1, z + 1) != blockID
                && world.getBlockId(x, j + y + 1, z - 1) != blockID
                && world.getBlockId(x - 1, j + y + 1, z - 1) != blockID
                && world.getBlockId(x - 1, j + y + 1, z + 1) != blockID
                && world.getBlockId(x + 1, j + y + 1, z + 1) != blockID
                && world.getBlockId(x + 1, j + y + 1, z - 1) != blockID) {
              reachedTop = true;
            }

            scanLogs(world, i, j + y, k, l, checkArray, 6, y, 6);

            y++;
          }
        }
      } else if (world.getBlockId(i + 1, j, k) == blockID
          || world.getBlockId(i - 1, j, k) == blockID
          || world.getBlockId(i, j, k + 1) == blockID
          || world.getBlockId(i, j, k - 1) == blockID) {
        Random R = new Random();
        if (R.nextInt(100) > 50 && isAxeorSaw) {
          dropBlockAsItem_do(world, i, j, k, new ItemStack(TFCItems.FruitTreeSapling1, 1, l));
        }
      }
    } else {
      world.setBlockAndMetadata(i, j, k, blockID, l);
    }
  }
Пример #24
0
 @Override
 public void onBlockDestroyedByExplosion(World world, int i, int j, int k, Explosion ex) {
   ProcessTree(world, i, j, k, world.getBlockMetadata(i, j, k), null);
 }
Пример #25
0
 /**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor blockID
  */
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   if (par1World.getBlockId(par2, par3, par4) == this.blockID) {
     par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
   }
 }
Пример #26
0
 /** Returns true if the block at the coordinates can be displaced by the liquid. */
 private boolean liquidCanDisplaceBlock(World par1World, int par2, int par3, int par4) {
   Material material = par1World.getBlockMaterial(par2, par3, par4);
   return material == this.blockMaterial
       ? true
       : (material == Material.lava ? false : !this.blockBlocksFlow(par1World, par2, par3, par4));
 }