/**
   * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
   */
  public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) {
    int var5 = 0;

    if (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID) {
      ++var5;
    }

    if (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID) {
      ++var5;
    }

    if (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID) {
      ++var5;
    }

    if (par1World.getBlockId(par2, par3, par4 + 1) == this.blockID) {
      ++var5;
    }

    return var5 > 1
        ? false
        : (this.isThereANeighborChest(par1World, par2 - 1, par3, par4)
            ? false
            : (this.isThereANeighborChest(par1World, par2 + 1, par3, par4)
                ? false
                : (this.isThereANeighborChest(par1World, par2, par3, par4 - 1)
                    ? false
                    : !this.isThereANeighborChest(par1World, par2, par3, par4 + 1))));
  }
  /**
   * Returns if the vine can stay in the world. It also changes the metadata according to
   * neighboring blocks.
   */
  private boolean canVineStay(World par1World, int par2, int par3, int par4) {
    int var5 = par1World.getBlockMetadata(par2, par3, par4);
    int var6 = var5;

    if (var5 > 0) {
      for (int var7 = 0; var7 <= 3; ++var7) {
        int var8 = 1 << var7;

        if ((var5 & var8) != 0
            && !this.canBePlacedOn(
                par1World.getBlockId(
                    par2 + Direction.offsetX[var7], par3, par4 + Direction.offsetZ[var7]))
            && (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID
                || (par1World.getBlockMetadata(par2, par3 + 1, par4) & var8) == 0)) {
          var6 &= ~var8;
        }
      }
    }

    if (var6 == 0 && !this.canBePlacedOn(par1World.getBlockId(par2, par3 + 1, par4))) {
      return false;
    } else {
      if (var6 != var5) {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, var6);
      }

      return true;
    }
  }
  private void tryToCatchBlockOnFire(
      World par1World, int par2, int par3, int par4, int par5, Random par6Random, int par7) {
    if (oldFire) {
      tryToCatchBlockOnFire_old(par1World, par2, par3, par4, par5, par6Random);
      return;
    }
    int i = abilityToCatchFire[par1World.getBlockId(par2, par3, par4)];

    if (par6Random.nextInt(par5) < i) {
      boolean flag = par1World.getBlockId(par2, par3, par4) == Block.tnt.blockID;

      if (par6Random.nextInt(par7 + 10) < 5 && !par1World.canLightningStrikeAt(par2, par3, par4)) {
        int j = par7 + par6Random.nextInt(5) / 4;

        if (j > 15) {
          j = 15;
        }

        par1World.setBlock(par2, par3, par4, blockID, j, 3);
      } else {
        par1World.setBlockToAir(par2, par3, par4);
      }

      if (flag) {
        Block.tnt.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
      }
    }
  }
Exemple #4
0
  /**
   * Takes in the distance the entity has fallen this tick and whether its on the ground to update
   * the fall distance and deal fall damage if landing on the ground. Args: distanceFallenThisTick,
   * onGround
   */
  protected void updateFallState(double par1, boolean par3) {
    if (par3) {
      if (fallDistance > 0.0F) {
        if (this instanceof EntityLiving) {
          int i = MathHelper.floor_double(posX);
          int j = MathHelper.floor_double(posY - 0.2D - (double) yOffset);
          int k = MathHelper.floor_double(posZ);
          int l = worldObj.getBlockId(i, j, k);

          if (l == 0 && worldObj.getBlockId(i, j - 1, k) == Block.fence.blockID) {
            l = worldObj.getBlockId(i, j - 1, k);
          }

          if (l > 0) {
            Block.blocksList[l].onFallenUpon(worldObj, i, j, k, this, fallDistance);
          }
        }

        fall(fallDistance);
        fallDistance = 0.0F;
      }
    } else if (par1 < 0.0D) {
      fallDistance -= par1;
    }
  }
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (world.isRemote) {
     return;
   }
   if (world.getBlockLightValue(i, j + 1, k) < 4
       && Block.lightOpacity[world.getBlockId(i, j + 1, k)] > 2) {
     world.setBlockWithNotify(i, j, k, Block.dirt.blockID);
   } else if (world.getBlockLightValue(i, j + 1, k) >= 9) {
     for (int l = 0; l < 4; l++) {
       int i1 = (i + random.nextInt(3)) - 1;
       int j1 = (j + random.nextInt(5)) - 3;
       int k1 = (k + random.nextInt(3)) - 1;
       int l1 = world.getBlockId(i1, j1 + 1, k1);
       if (world.getBlockId(i1, j1, k1) == Block.dirt.blockID
           && world.getBlockLightValue(i1, j1 + 1, k1) >= 4
           && Block.lightOpacity[l1] <= 2) {
         if (blockID == ZooDirts.savannah.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.savannah.blockID);
         }
         if (blockID == ZooDirts.tropical.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.tropical.blockID);
         }
         if (blockID == ZooDirts.coniferous.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.coniferous.blockID);
         }
         if (blockID == ZooDirts.deciduous.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.deciduous.blockID);
         }
       }
     }
   }
 }
 public boolean onItemUse(
     ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
   int i1 = world.getBlockId(i, j, k);
   if (i1 == Block.snow.blockID) {
     l = 0;
   } else if (i1 != Block.vine.blockID) {
     if (l == 0) {
       j--;
     }
     if (l == 1) {
       j++;
     }
     if (l == 2) {
       k--;
     }
     if (l == 3) {
       k++;
     }
     if (l == 4) {
       i--;
     }
     if (l == 5) {
       i++;
     }
   }
   if (itemstack.stackSize == 0) {
     return false;
   }
   if (!entityplayer.canPlayerEdit(i, j, k)) {
     return false;
   }
   if (j == world.worldYMax - 1 && Block.blocksList[blockID].blockMaterial.isSolid()) {
     return false;
   }
   if (world.canBlockBePlacedAt(blockID, i, j, k, false, l)) {
     Block block = Block.blocksList[blockID];
     if (world.setBlockAndMetadataWithNotify(
         i, j, k, blockID, getMetadata(itemstack.getItemDamage()))) {
       if (world.getBlockId(i, j, k) == blockID) {
         Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
         Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer);
       }
       world.playSoundEffect(
           (float) i + 0.5F,
           (float) j + 0.5F,
           (float) k + 0.5F,
           block.stepSound.stepSoundDir(),
           (block.stepSound.getVolume() + 1.0F) / 2.0F,
           block.stepSound.getPitch() * 0.8F);
       itemstack.stackSize--;
     }
     return true;
   } else {
     return false;
   }
 }
 /** Checks the neighbor blocks to see if there is a chest there. Args: world, x, y, z */
 private boolean isThereANeighborChest(World par1World, int par2, int par3, int par4) {
   return par1World.getBlockId(par2, par3, par4) != this.blockID
       ? false
       : (par1World.getBlockId(par2 - 1, par3, par4) == this.blockID
           ? true
           : (par1World.getBlockId(par2 + 1, par3, par4) == this.blockID
               ? true
               : (par1World.getBlockId(par2, par3, par4 - 1) == this.blockID
                   ? true
                   : par1World.getBlockId(par2, par3, par4 + 1) == this.blockID)));
 }
  public ItemStack fillCustomBucket(World w, int i, int j, int k) {
    if (w.getBlockId(i, j, k) == Zoo.saltwaterStill.blockID
        || w.getBlockId(i, j, k) == Zoo.saltwaterMoving.blockID) {
      w.setBlockWithNotify(i, j, k, 0);

      EntityPlayer player = ModLoader.getMinecraftInstance().thePlayer;
      if (!player.capabilities.isCreativeMode) {
        return new ItemStack(this);
      }
    }

    return null;
  }
 private void tryToCatchBlockOnFire_old(World world, int i, int j, int k, int l, Random random) {
   int i1 = abilityToCatchFire[world.getBlockId(i, j, k)];
   if (random.nextInt(l) < i1) {
     boolean flag = world.getBlockId(i, j, k) == Block.tnt.blockID;
     if (random.nextInt(2) == 0 && !world.canLightningStrikeAt(i, j, k)) {
       world.setBlock(i, j, k, blockID);
     } else {
       world.setBlockToAir(i, j, k);
     }
     if (flag) {
       Block.tnt.onBlockDestroyedByPlayer(world, i, j, k, 0);
     }
   }
 }
Exemple #10
0
  public static void placeDoorBlock(
      World par0World, int par1, int par2, int par3, int par4, Block par5Block) {
    byte byte0 = 0;
    byte byte1 = 0;

    if (par4 == 0) {
      byte1 = 1;
    }

    if (par4 == 1) {
      byte0 = -1;
    }

    if (par4 == 2) {
      byte1 = -1;
    }

    if (par4 == 3) {
      byte0 = 1;
    }

    int i =
        (par0World.isBlockNormalCube(par1 - byte0, par2, par3 - byte1) ? 1 : 0)
            + (par0World.isBlockNormalCube(par1 - byte0, par2 + 1, par3 - byte1) ? 1 : 0);
    int j =
        (par0World.isBlockNormalCube(par1 + byte0, par2, par3 + byte1) ? 1 : 0)
            + (par0World.isBlockNormalCube(par1 + byte0, par2 + 1, par3 + byte1) ? 1 : 0);
    boolean flag =
        par0World.getBlockId(par1 - byte0, par2, par3 - byte1) == par5Block.blockID
            || par0World.getBlockId(par1 - byte0, par2 + 1, par3 - byte1) == par5Block.blockID;
    boolean flag1 =
        par0World.getBlockId(par1 + byte0, par2, par3 + byte1) == par5Block.blockID
            || par0World.getBlockId(par1 + byte0, par2 + 1, par3 + byte1) == par5Block.blockID;
    boolean flag2 = false;

    if (flag && !flag1) {
      flag2 = true;
    } else if (j > i) {
      flag2 = true;
    }

    par0World.editingBlocks = true;
    par0World.setBlockAndMetadataWithNotify(par1, par2, par3, par5Block.blockID, par4);
    par0World.setBlockAndMetadataWithNotify(
        par1, par2 + 1, par3, par5Block.blockID, 8 | (flag2 ? 1 : 0));
    par0World.editingBlocks = false;
    par0World.notifyBlocksOfNeighborChange(par1, par2, par3, par5Block.blockID);
    par0World.notifyBlocksOfNeighborChange(par1, par2 + 1, par3, par5Block.blockID);
  }
  /**
   * Grows vines downward from the given block for a given length. Args: World, x, starty, z,
   * vine-length
   */
  private void growVines(World par1World, int par2, int par3, int par4, int par5) {
    setBlockAndMetadata(par1World, par2, par3, par4, Block.vine.blockID, par5);

    for (int i = 4; par1World.getBlockId(par2, --par3, par4) == 0 && i > 0; i--) {
      setBlockAndMetadata(par1World, par2, par3, par4, Block.vine.blockID, par5);
    }
  }
 @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);
 }
 public boolean isWater(World world, int i, int j, int k) {
   if (world.getBlockId(i, j, k) == mod_NWater.nwater.blockID) {
     return true;
   }
   if (world.getBlockId(i, j, k) == mod_NWater.nwater_still.blockID) {
     return true;
   }
   if (world.getBlockId(i, j, k) == mod_NWater.nlava.blockID) {
     return true;
   }
   if (world.getBlockId(i, j, k) == mod_NWater.nlava_still.blockID) {
     return true;
   }
   return (world.getBlockId(i, j, k) == mod_NWater.grate.blockID)
       & (world.getBlockMetadata(i, j, k) != 10);
 }
  @Override
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    for (int i = 0;
        ((i = par1World.getBlockId(par3, par4, par5)) == 0 || i == Block.leaves.blockID)
            && par4 > 0;
        par4--) {}

    for (int j = 0; j < 128; j++) {
      int k = (par3 + par2Random.nextInt(8)) - par2Random.nextInt(8);
      int l = (par4 + par2Random.nextInt(4)) - par2Random.nextInt(4);
      int i1 = (par5 + par2Random.nextInt(8)) - par2Random.nextInt(8);

      boolean old =
          ODNBXlite.MapFeatures < ODNBXlite.FEATURES_13
              || ODNBXlite.Generator < ODNBXlite.GEN_NEWBIOMES;
      boolean oldc =
          ((BlockFlower) Block.blocksList[tallGrassID]).canBlockStay(par1World, k, l, i1);
      boolean newc = Block.blocksList[tallGrassID].canBlockStay(par1World, k, l, i1);
      if (par1World.isAirBlock(k, l, i1) && ((oldc && old) || (!old && newc))) {
        par1World.setBlock(k, l, i1, tallGrassID, tallGrassMetadata, 0);
      }
    }

    return true;
  }
  /**
   * Activate the clicked on block, otherwise use the held item. Args: player, world, itemStack, x,
   * y, z, side, xOffset, yOffset, zOffset
   */
  public boolean activateBlockOrUseItem(
      EntityPlayer par1EntityPlayer,
      World par2World,
      ItemStack par3ItemStack,
      int par4,
      int par5,
      int par6,
      int par7,
      float par8,
      float par9,
      float par10) {
    int var11 = par2World.getBlockId(par4, par5, par6);

    if (var11 > 0
        && Block.blocksList[var11].onBlockActivated(
            par2World, par4, par5, par6, par1EntityPlayer, par7, par8, par9, par10)) {
      return true;
    } else if (par3ItemStack == null) {
      return false;
    } else if (this.isCreative()) {
      int var12 = par3ItemStack.getItemDamage();
      int var13 = par3ItemStack.stackSize;
      boolean var14 =
          par3ItemStack.func_77943_a(
              par1EntityPlayer, par2World, par4, par5, par6, par7, par8, par9, par10);
      par3ItemStack.setItemDamage(var12);
      par3ItemStack.stackSize = var13;
      return var14;
    } else {
      return par3ItemStack.func_77943_a(
          par1EntityPlayer, par2World, par4, par5, par6, par7, par8, par9, par10);
    }
  }
  private void func_48198_a(World par1World, int par2, int par3, int par4, int par5) {
    par1World.setBlockAndMetadataWithNotify(par2, par3, par4, Block.vine.blockID, par5);

    for (int i = 4; par1World.getBlockId(par2, --par3, par4) == 0 && i > 0; i--) {
      par1World.setBlockAndMetadataWithNotify(par2, par3, par4, Block.vine.blockID, par5);
    }
  }
  public boolean onItemUse(
      ItemStack par1ItemStack,
      EntityPlayer par2EntityPlayer,
      World par3World,
      int par4,
      int par5,
      int par6,
      int par7) {
    if (par3World.isRemote) {
      return true;
    } else {
      int var8 = par3World.getBlockId(par4, par5, par6);
      par4 += Facing.offsetsXForSide[par7];
      par5 += Facing.offsetsYForSide[par7];
      par6 += Facing.offsetsZForSide[par7];
      double var9 = 0.0D;
      if (par7 == 1 && var8 == Block.fence.blockID || var8 == Block.netherFence.blockID) {
        var9 = 0.5D;
      }

      if (func_48440_a(
              par3World,
              par1ItemStack.getItemDamage(),
              (double) par4 + 0.5D,
              (double) par5 + var9,
              (double) par6 + 0.5D)
          && !par2EntityPlayer.capabilities.isCreativeMode) {
        --par1ItemStack.stackSize;
      }

      return true;
    }
  }
Exemple #18
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(par1World));
    }
  }
 public boolean onBlockStartBreak(
     ItemStack itemstack, int x, int y, int z, EntityPlayer entityplayer) {
   World world = entityplayer.worldObj;
   if (world.isRemote) {
     return false;
   }
   int bID = world.getBlockId(x, y, z);
   int md = world.getBlockMetadata(x, y, z);
   boolean flag = true;
   boolean flag1 = true;
   if (headType == handleType) {
     flag = powers(itemstack, bID, x, y, z, world, entityplayer, md, headType);
   } else {
     if (random.nextInt(100) + 1 <= 80) {
       flag = powers(itemstack, bID, x, y, z, world, entityplayer, md, headType);
     }
     if (random.nextInt(100) + 1 <= 20) {
       flag1 = powers(itemstack, bID, x, y, z, world, entityplayer, md, handleType);
     }
   }
   if (!ForgeHooks.canHarvestBlock(Block.blocksList[bID], entityplayer, md)) {
     flag = false;
   }
   if (!flag || !flag1) {
     world.playAuxSFX(2001, x, y, z, bID + (md << 12));
     world.setBlockWithNotify(x, y, z, 0);
     onBlockDestroyed(itemstack, bID, x, y, z, entityplayer);
     return true;
   } else {
     return false;
   }
 }
  /** Handles a players right click */
  public boolean onPlayerRightClick(
      EntityPlayer par1EntityPlayer,
      World par2World,
      ItemStack par3ItemStack,
      int par4,
      int par5,
      int par6,
      int par7) {
    syncCurrentPlayItem();
    netClientHandler.addToSendQueue(
        new Packet15Place(par4, par5, par6, par7, par1EntityPlayer.inventory.getCurrentItem()));
    int i = par2World.getBlockId(par4, par5, par6);

    if (i > 0
        && Block.blocksList[i].blockActivated(par2World, par4, par5, par6, par1EntityPlayer)) {
      return true;
    }

    if (par3ItemStack == null) {
      return false;
    }

    if (creativeMode) {
      int j = par3ItemStack.getItemDamage();
      int k = par3ItemStack.stackSize;
      boolean flag = par3ItemStack.useItem(par1EntityPlayer, par2World, par4, par5, par6, par7);
      par3ItemStack.setItemDamage(j);
      par3ItemStack.stackSize = k;
      return flag;
    } else {
      return par3ItemStack.useItem(par1EntityPlayer, par2World, par4, par5, par6, par7);
    }
  }
Exemple #21
0
  /**
   * checks to see if you can place this block can be placed on that side of a block: BlockLever
   * overrides
   */
  public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5) {
    if (par5 == 0) {
      return false;
    }

    if (par5 == 1) {
      return false;
    }

    if (par5 == 2) {
      par4++;
    }

    if (par5 == 3) {
      par4--;
    }

    if (par5 == 4) {
      par2++;
    }

    if (par5 == 5) {
      par2--;
    }

    return isValidSupportBlock(par1World.getBlockId(par2, par3, par4));
  }
Exemple #22
0
  public int intercept(EntityPlayer p, World world1, Loc loc, int i) {
    if (i == Block.bed.blockID) {
      return AetherBlocks.Bed.blockID;
    }
    if (i == Block.waterMoving.blockID || i == Block.waterStill.blockID) {
      if (world1.getBlockId(loc.x(), loc.y() - 1, loc.z()) == Block.glowStone.blockID
          && ((BlockAetherPortal) AetherBlocks.Portal)
              .tryToCreatePortal(world1, loc.x(), loc.y(), loc.z())) {
        return AetherBlocks.Portal.blockID;
      }
      if (p.dimension != -1) {
        return i;
      }
    }
    Random random = new Random();
    for (int j = 0; j < 10; j++) {
      world1.spawnParticle(
          "smoke",
          loc.x + 0.5D + random.nextGaussian() * 0.10000000000000001D,
          loc.y + 0.5D + random.nextGaussian() * 0.10000000000000001D,
          loc.z + 0.5D + random.nextGaussian() * 0.01D,
          random.nextGaussian() * 0.01D,
          random.nextGaussian() * 0.01D,
          random.nextGaussian() * 0.10000000000000001D);
    }

    if (i == Block.lavaMoving.blockID || i == Block.lavaStill.blockID) {
      return AetherBlocks.Aerogel.blockID;
    }
    if (p.dimension < 0 && (i == Block.waterMoving.blockID || i == Block.waterStill.blockID)) {
      return Block.cobblestone.blockID;
    } else {
      return 0;
    }
  }
Exemple #23
0
  /** Returns true if the specified rail is passing power to its neighbor */
  private boolean isRailPassingPower(
      World par1World, int par2, int par3, int par4, boolean par5, int par6, int par7) {
    int var8 = par1World.getBlockId(par2, par3, par4);

    if (var8 == Block.railPowered.blockID) {
      int var9 = par1World.getBlockMetadata(par2, par3, par4);
      int var10 = var9 & 7;

      if (par7 == 1 && (var10 == 0 || var10 == 4 || var10 == 5)) {
        return false;
      }

      if (par7 == 0 && (var10 == 1 || var10 == 2 || var10 == 3)) {
        return false;
      }

      if ((var9 & 8) != 0) {
        if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
          return true;
        }

        return this.isNeighborRailPowered(par1World, par2, par3, par4, var9, par5, par6 + 1);
      }
    }

    return false;
  }
Exemple #24
0
  /**
   * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they
   * intersect the mask.) Parameters: World, X, Y, Z, mask, list, colliding entity
   */
  public void addCollisionBoxesToList(
      World par1World,
      int par2,
      int par3,
      int par4,
      AxisAlignedBB par5AxisAlignedBB,
      List par6List,
      Entity par7Entity) {
    boolean var8 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 - 1));
    boolean var9 = this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2, par3, par4 + 1));
    boolean var10 =
        this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 - 1, par3, par4));
    boolean var11 =
        this.canThisPaneConnectToThisBlockID(par1World.getBlockId(par2 + 1, par3, par4));

    if ((!var10 || !var11) && (var10 || var11 || var8 || var9)) {
      if (var10 && !var11) {
        this.setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
        super.addCollisionBoxesToList(
            par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
      } else if (!var10 && var11) {
        this.setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
        super.addCollisionBoxesToList(
            par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
      }
    } else {
      this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
      super.addCollisionBoxesToList(
          par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
    }

    if ((!var8 || !var9) && (var10 || var11 || var8 || var9)) {
      if (var8 && !var9) {
        this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
        super.addCollisionBoxesToList(
            par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
      } else if (!var8 && var9) {
        this.setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
        super.addCollisionBoxesToList(
            par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
      }
    } else {
      this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
      super.addCollisionBoxesToList(
          par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
    }
  }
Exemple #25
0
 /**
  * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with
  * plants.
  */
 public boolean canBlockStay(World par1World, int par2, int par3, int par4) {
   int var5 = getDirection(par1World.getBlockMetadata(par2, par3, par4));
   par2 += Direction.offsetX[var5];
   par4 += Direction.offsetZ[var5];
   int var6 = par1World.getBlockId(par2, par3, par4);
   return var6 == Block.wood.blockID
       && BlockLog.limitToValidMetadata(par1World.getBlockMetadata(par2, par3, par4)) == 3;
 }
 @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);
       }
     }
   }
 }
 public boolean canBlockStay(World world, int i, int j, int k) {
   if (j < 0 || j >= 128) {
     return false;
   } else {
     return (world.getFullBlockLightValue(i, j, k) >= 8 || world.canBlockSeeTheSky(i, j, k))
         && canThisPlantGrowOnThisBlockID(world.getBlockId(i, j - 1, k));
   }
 }
Exemple #28
0
 /**
  * Returns the current strength at the specified block if it is greater than the passed value, or
  * the passed value otherwise. Signature: (world, x, y, z, strength)
  */
 private int getMaxCurrentStrength(World par1World, int par2, int par3, int par4, int par5) {
   if (par1World.getBlockId(par2, par3, par4) != this.blockID) {
     return par5;
   } else {
     int var6 = par1World.getBlockMetadata(par2, par3, par4);
     return var6 > par5 ? var6 : par5;
   }
 }
 public int getChanceToEncourageFire(World world, int i, int j, int k, int l) {
   int i1 = chanceToEncourageFire[world.getBlockId(i, j, k)];
   if (i1 > l) {
     return i1;
   } else {
     return l;
   }
 }
  public static int getBlockIdAtEntityViewpoint(
      World par0World, EntityLiving par1EntityLiving, float par2) {
    Vec3D var3 = projectViewFromEntity(par1EntityLiving, (double) par2);
    ChunkPosition var4 = new ChunkPosition(var3);
    int var5 = par0World.getBlockId(var4.x, var4.y, var4.z);
    if (var5 != 0 && Block.blocksList[var5].blockMaterial.isLiquid()) {
      float var6 =
          BlockFluid.getFluidHeightPercent(par0World.getBlockMetadata(var4.x, var4.y, var4.z))
              - 0.11111111F;
      float var7 = (float) (var4.y + 1) - var6;
      if (var3.yCoord >= (double) var7) {
        var5 = par0World.getBlockId(var4.x, var4.y + 1, var4.z);
      }
    }

    return var5;
  }