Пример #1
0
  /** Attempts to place the liquid contained inside the bucket. */
  public boolean tryPlaceContainedLiquid(
      World par1World, double par2, double par4, double par6, int par8, int par9, int par10) {
    if (this.isFull <= 0) {
      return false;
    } else if (!par1World.isAirBlock(par8, par9, par10)
        && par1World.getBlockMaterial(par8, par9, par10).isSolid()) {
      return false;
    } else {
      if (par1World.provider.isHellWorld && this.isFull == Block.waterMoving.blockID) {
        par1World.playSoundEffect(
            par2 + 0.5D,
            par4 + 0.5D,
            par6 + 0.5D,
            "random.fizz",
            0.5F,
            2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);

        for (int var11 = 0; var11 < 8; ++var11) {
          par1World.spawnParticle(
              "largesmoke",
              (double) par8 + Math.random(),
              (double) par9 + Math.random(),
              (double) par10 + Math.random(),
              0.0D,
              0.0D,
              0.0D);
        }
      } else {
        par1World.setBlock(par8, par9, par10, this.isFull, 0, 3);
      }

      return true;
    }
  }
  @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;
  }
Пример #3
0
 public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) {
   MovingObjectPosition movingobjectposition = func_40402_a(world, entityplayer, true);
   if (movingobjectposition == null) {
     return itemstack;
   }
   if (movingobjectposition.typeOfHit == EnumMovingObjectType.TILE) {
     int i = movingobjectposition.blockX;
     int j = movingobjectposition.blockY;
     int k = movingobjectposition.blockZ;
     if (!world.canMineBlock(entityplayer, i, j, k)) {
       return itemstack;
     }
     if (!entityplayer.func_35190_e(i, j, k)) {
       return itemstack;
     }
     if (world.getBlockMaterial(i, j, k) == Material.water
         && world.getBlockMetadata(i, j, k) == 0
         && world.isAirBlock(i, j + 1, k)) {
       world.setBlockWithNotify(i, j + 1, k, Block.waterlily.blockID);
       if (!entityplayer.capabilities.depleteBuckets) {
         itemstack.stackSize--;
       }
     }
   }
   return itemstack;
 }
Пример #4
0
 @Override
 public void onNeighborBlockChange(
     World world, BlockPos pos, IBlockState state, Block neighborBlock) {
   if (world.isAirBlock(pos.up())) {
     this.dropBlockAsItem(world, pos, state, 0);
     world.setBlockToAir(pos);
   }
 }
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (random.nextInt(100) == 0) {
     int l = (i + random.nextInt(3)) - 1;
     int i1 = (j + random.nextInt(2)) - random.nextInt(2);
     int j1 = (k + random.nextInt(3)) - 1;
     if (world.isAirBlock(l, i1, j1) && canBlockStay(world, l, i1, j1)) {
       world.setBlockWithNotify(l, i1, j1, blockID);
     }
   }
 }
Пример #6
0
 public boolean onItemUse(
     ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
   if (l != 1) {
     return false;
   }
   j++;
   BlockBed blockbed = (BlockBed) Block.bed;
   int i1 = MathHelper.floor_double((double) ((entityplayer.rotationYaw * 4F) / 360F) + 0.5D) & 3;
   byte byte0 = 0;
   byte byte1 = 0;
   if (i1 == 0) {
     byte1 = 1;
   }
   if (i1 == 1) {
     byte0 = -1;
   }
   if (i1 == 2) {
     byte1 = -1;
   }
   if (i1 == 3) {
     byte0 = 1;
   }
   if (!entityplayer.func_35190_e(i, j, k)
       || !entityplayer.func_35190_e(i + byte0, j, k + byte1)) {
     return false;
   }
   if (world.isAirBlock(i, j, k)
       && world.isAirBlock(i + byte0, j, k + byte1)
       && world.isBlockNormalCube(i, j - 1, k)
       && world.isBlockNormalCube(i + byte0, j - 1, k + byte1)) {
     world.setBlockAndMetadataWithNotify(i, j, k, blockbed.blockID, i1);
     world.setBlockAndMetadataWithNotify(i + byte0, j, k + byte1, blockbed.blockID, i1 + 8);
     itemstack.stackSize--;
     return true;
   } else {
     return false;
   }
 }
Пример #7
0
 public boolean onItemUse(
     ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
   if (l != 1) {
     return false;
   }
   int i1 = world.getBlockId(i, j, k);
   if (i1 == Block.tilledField.blockID && world.isAirBlock(i, j + 1, k)) {
     world.setBlockWithNotify(i, j + 1, k, field_271_a);
     itemstack.stackSize--;
     return true;
   } else {
     return false;
   }
 }
 private int getChanceOfNeighborsEncouragingFire(World world, int i, int j, int k) {
   int l = 0;
   if (!world.isAirBlock(i, j, k)) {
     return 0;
   } else {
     l = getChanceToEncourageFire(world, i + 1, j, k, l);
     l = getChanceToEncourageFire(world, i - 1, j, k, l);
     l = getChanceToEncourageFire(world, i, j - 1, k, l);
     l = getChanceToEncourageFire(world, i, j + 1, k, l);
     l = getChanceToEncourageFire(world, i, j, k - 1, l);
     l = getChanceToEncourageFire(world, i, j, k + 1, l);
     return l;
   }
 }
Пример #9
0
  /** Gets the highest chance of a neighbor block encouraging this block to catch fire */
  private int getChanceOfNeighborsEncouragingFire(World par1World, int par2, int par3, int par4) {
    int i = 0;

    if (!par1World.isAirBlock(par2, par3, par4)) {
      return 0;
    } else {
      i = getChanceToEncourageFire(par1World, par2 + 1, par3, par4, i);
      i = getChanceToEncourageFire(par1World, par2 - 1, par3, par4, i);
      i = getChanceToEncourageFire(par1World, par2, par3 - 1, par4, i);
      i = getChanceToEncourageFire(par1World, par2, par3 + 1, par4, i);
      i = getChanceToEncourageFire(par1World, par2, par3, par4 - 1, i);
      i = getChanceToEncourageFire(par1World, par2, par3, par4 + 1, i);
      return i;
    }
  }
Пример #10
0
 public boolean onItemUse(
     ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
   if (l != 1) {
     return false;
   }
   if (!entityplayer.canPlayerEdit(i, j, k) || !entityplayer.canPlayerEdit(i, j + 1, k)) {
     return false;
   }
   int i1 = world.getBlockId(i, j, k);
   if (i1 == field_40438_b && world.isAirBlock(i, j + 1, k)) {
     world.setBlockWithNotify(i, j + 1, k, blockType);
     itemstack.stackSize--;
     return true;
   } else {
     return false;
   }
 }
Пример #11
0
  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);

      if (par1World.isAirBlock(k, l, i1)
          && ((Block) Block.blocksList[pileID]).canBlockStay(par1World, k, l, i1)) {
        par1World.setBlockAndMetadata(k, l, i1, pileID, pileMetadata);
      }
    }

    return true;
  }
Пример #12
0
  @Override
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    if (!par1World.isAirBlock(par3, par4, par5)
        || par1World.getBlockId(par3, par4 - 1, par5) != this.replaceID) {
      return false;
    }

    int i = par2Random.nextInt(32) + 6;
    int j = par2Random.nextInt(4) + 1;

    for (int k = par3 - j; k <= par3 + j; k++) {
      for (int i1 = par5 - j; i1 <= par5 + j; i1++) {
        int k1 = k - par3;
        int i2 = i1 - par5;

        if (k1 * k1 + i2 * i2 <= j * j + 1
            && par1World.getBlockId(k, par4 - 1, i1) != this.replaceID) {
          return false;
        }
      }
    }

    for (int l = par4; l < par4 + i && l < 128; l++) {
      for (int j1 = par3 - j; j1 <= par3 + j; j1++) {
        for (int l1 = par5 - j; l1 <= par5 + j; l1++) {
          int j2 = j1 - par3;
          int k2 = l1 - par5;

          if (j2 * j2 + k2 * k2 <= j * j + 1) {
            par1World.setBlockWithNotify(j1, l, l1, Block.obsidian.blockID);
          }
        }
      }
    }

    EntityEnderCrystal entityendercrystal = new EntityEnderCrystal(par1World);
    entityendercrystal.setLocationAndAngles(
        par3 + 0.5F, par4 + i, par5 + 0.5F, par2Random.nextFloat() * 360F, 0.0F);
    par1World.spawnEntityInWorld(entityendercrystal);
    par1World.setBlockWithNotify(par3, par4 + i, par5, Block.bedrock.blockID);
    return true;
  }
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    for (int var6 = 0; var6 < 10; ++var6) {
      int var7 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8);
      int var8 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
      int var9 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8);

      if (par1World.isAirBlock(var7, var8, var9)) {
        int var10 = 1 + par2Random.nextInt(par2Random.nextInt(3) + 1);

        for (int var11 = 0; var11 < var10; ++var11) {
          if (Block.cactus.canBlockStay(par1World, var7, var8 + var11, var9)) {
            par1World.setBlockAndMetadataWithNotify(
                var7, var8 + var11, var9, Block.cactus.blockID, 0, 2);
          }
        }
      }
    }

    return true;
  }
Пример #14
0
  private static void expandPortal(
      World world,
      int i,
      int j,
      int k,
      Collection<ChunkCoordinates> set,
      Stack<ChunkCoordinates> created) {
    if (!world.isAirBlock(i, j, k)) {
      return;
    }

    int score =
        isValidLinkPortalBlock(world.getBlock(i + 1, j, k))
            + isValidLinkPortalBlock(world.getBlock(i - 1, j, k))
            + isValidLinkPortalBlock(world.getBlock(i, j + 1, k))
            + isValidLinkPortalBlock(world.getBlock(i, j - 1, k))
            + isValidLinkPortalBlock(world.getBlock(i, j, k + 1))
            + isValidLinkPortalBlock(world.getBlock(i, j, k - 1));
    if (score > 1) {
      world.setBlock(i, j, k, NailedBlocks.portal, 0, 0);
      created.push(new ChunkCoordinates(i, j, k));
      addSurrounding(set, i, j, k);
    }
  }
Пример #15
0
  public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
    float var4 = 1.0F;
    double var5 = player.prevPosX + (player.posX - player.prevPosX) * (double) var4;
    double var7 =
        player.prevPosY
            + (player.posY - player.prevPosY) * (double) var4
            + 1.62D
            - (double) player.yOffset;
    double var9 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) var4;
    boolean var11 = this.isFull == 0;
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, var11);

    if (mop == null) {
      return itemstack;
    }
    if (mop.typeOfHit == EnumMovingObjectType.TILE) {
      int x = mop.blockX;
      int y = mop.blockY;
      int z = mop.blockZ;
      if (!world.canMineBlock(player, x, y, z)) {
        return itemstack;
      }
      if (isFull == 0) {
        int bID = world.getBlockId(x, y, z);
        if ((bID == Block.waterMoving.blockID || bID == Block.waterStill.blockID)
            && world.getBlockMetadata(x, y, z) == 0) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketWater);
        }
        if ((bID == Block.lavaMoving.blockID || bID == Block.lavaStill.blockID)
            && world.getBlockMetadata(x, y, z) == 0) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketLava);
        }
        if (bID == Block.sand.blockID) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketSand);
        }
        if (bID == Block.gravel.blockID) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketGravel);
        }
      } else {
        if (isFull < 0) {
          return new ItemStack(mod_InfiTools.goldBucketEmpty);
        }
        if (mop.sideHit == 0) {
          y--;
        }
        if (mop.sideHit == 1) {
          y++;
        }
        if (mop.sideHit == 2) {
          z--;
        }
        if (mop.sideHit == 3) {
          z++;
        }
        if (mop.sideHit == 4) {
          x--;
        }
        if (mop.sideHit == 5) {
          x++;
        }
        if (world.isAirBlock(x, y, z) || !world.getBlockMaterial(x, y, z).isSolid()) {
          if (world.worldProvider.isHellWorld && isFull == Block.waterMoving.blockID) {
            world.playSoundEffect(
                x + 0.5D,
                y + 0.5D,
                z + 0.5D,
                "random.fizz",
                0.5F,
                2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
            for (int l = 0; l < 8; l++) {
              world.spawnParticle(
                  "largesmoke",
                  (double) x + Math.random(),
                  (double) y + Math.random(),
                  (double) z + Math.random(),
                  0.0D,
                  0.0D,
                  0.0D);
            }
          } else {
            world.setBlockAndMetadataWithNotify(x, y, z, isFull, 0);
          }
          return new ItemStack(mod_InfiTools.goldBucketEmpty);
        }
      }
    } else if (isFull == 0 && (mop.entityHit instanceof EntityCow)) {
      return new ItemStack(mod_InfiTools.goldBucketMilk);
    }
    return itemstack;
  }
Пример #16
0
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    int i = par2Random.nextInt(3) + field_48202_a;
    boolean flag = true;

    if (par4 < 1 || par4 + i + 1 > 256) {
      return false;
    }

    for (int j = par4; j <= par4 + 1 + i; j++) {
      byte byte0 = 1;

      if (j == par4) {
        byte0 = 0;
      }

      if (j >= (par4 + 1 + i) - 2) {
        byte0 = 2;
      }

      for (int l = par3 - byte0; l <= par3 + byte0 && flag; l++) {
        for (int j1 = par5 - byte0; j1 <= par5 + byte0 && flag; j1++) {
          if (j >= 0 && j < 256) {
            int j2 = par1World.getBlockId(l, j, j1);

            if (j2 != 0
                && j2 != mod_ExtraBiomesXL.leavesRed.blockID
                && j2 != Block.grass.blockID
                && j2 != Block.dirt.blockID
                && j2 != Block.wood.blockID) {
              flag = false;
            }
          } else {
            flag = false;
          }
        }
      }
    }

    if (!flag) {
      return false;
    }

    int k = par1World.getBlockId(par3, par4 - 1, par5);

    if (k != Block.grass.blockID && k != Block.dirt.blockID || par4 >= 256 - i - 1) {
      return false;
    }

    par1World.setBlock(par3, par4 - 1, par5, Block.dirt.blockID);
    byte byte1 = 3;
    int i1 = 0;

    for (int k1 = (par4 - byte1) + i; k1 <= par4 + i; k1++) {
      int k2 = k1 - (par4 + i);
      int j3 = (i1 + 1) - k2 / 2;

      for (int l3 = par3 - j3; l3 <= par3 + j3; l3++) {
        int j4 = l3 - par3;

        for (int l4 = par5 - j3; l4 <= par5 + j3; l4++) {
          int i5 = l4 - par5;

          if ((Math.abs(j4) != j3 || Math.abs(i5) != j3 || par2Random.nextInt(2) != 0 && k2 != 0)
              && !Block.opaqueCubeLookup[par1World.getBlockId(l3, k1, l4)]) {
            setBlockAndMetadata(
                par1World, l3, k1, l4, mod_ExtraBiomesXL.leavesRed.blockID, field_48199_d);
          }
        }
      }
    }

    for (int l1 = 0; l1 < i; l1++) {
      int l2 = par1World.getBlockId(par3, par4 + l1, par5);

      if (l2 != 0 && l2 != mod_ExtraBiomesXL.leavesRed.blockID) {
        continue;
      }

      setBlockAndMetadata(par1World, par3, par4 + l1, par5, Block.wood.blockID, field_48201_c);

      if (!field_48200_b || l1 <= 0) {
        continue;
      }

      if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 - 1, par4 + l1, par5)) {
        setBlockAndMetadata(par1World, par3 - 1, par4 + l1, par5, Block.vine.blockID, 8);
      }

      if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 1, par4 + l1, par5)) {
        setBlockAndMetadata(par1World, par3 + 1, par4 + l1, par5, Block.vine.blockID, 2);
      }

      if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + l1, par5 - 1)) {
        setBlockAndMetadata(par1World, par3, par4 + l1, par5 - 1, Block.vine.blockID, 1);
      }

      if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + l1, par5 + 1)) {
        setBlockAndMetadata(par1World, par3, par4 + l1, par5 + 1, Block.vine.blockID, 4);
      }
    }

    if (field_48200_b) {
      for (int i2 = (par4 - 3) + i; i2 <= par4 + i; i2++) {
        int i3 = i2 - (par4 + i);
        int k3 = 2 - i3 / 2;

        for (int i4 = par3 - k3; i4 <= par3 + k3; i4++) {
          for (int k4 = par5 - k3; k4 <= par5 + k3; k4++) {
            if (par1World.getBlockId(i4, i2, k4) != mod_ExtraBiomesXL.leavesRed.blockID) {
              continue;
            }

            if (par2Random.nextInt(4) == 0 && par1World.getBlockId(i4 - 1, i2, k4) == 0) {
              func_48198_a(par1World, i4 - 1, i2, k4, 8);
            }

            if (par2Random.nextInt(4) == 0 && par1World.getBlockId(i4 + 1, i2, k4) == 0) {
              func_48198_a(par1World, i4 + 1, i2, k4, 2);
            }

            if (par2Random.nextInt(4) == 0 && par1World.getBlockId(i4, i2, k4 - 1) == 0) {
              func_48198_a(par1World, i4, i2, k4 - 1, 1);
            }

            if (par2Random.nextInt(4) == 0 && par1World.getBlockId(i4, i2, k4 + 1) == 0) {
              func_48198_a(par1World, i4, i2, k4 + 1, 4);
            }
          }
        }
      }
    }

    return true;
  }
Пример #17
0
  public boolean generate(World world, Random random, int i, int j, int k) {
    i -= 8;
    for (k -= 8; j > 0 && world.isAirBlock(i, j, k); j--) {}
    j -= 4;
    boolean aflag[] = new boolean[2048];
    int l = random.nextInt(4) + 4;
    for (int i1 = 0; i1 < l; i1++) {
      double d = random.nextDouble() * 6D + 3D;
      double d1 = random.nextDouble() * 4D + 2D;
      double d2 = random.nextDouble() * 6D + 3D;
      double d3 = random.nextDouble() * (16D - d - 2D) + 1.0D + d / 2D;
      double d4 = random.nextDouble() * (8D - d1 - 4D) + 2D + d1 / 2D;
      double d5 = random.nextDouble() * (16D - d2 - 2D) + 1.0D + d2 / 2D;
      for (int j4 = 1; j4 < 15; j4++) {
        for (int k4 = 1; k4 < 15; k4++) {
          for (int l4 = 1; l4 < 7; l4++) {
            double d6 = ((double) j4 - d3) / (d / 2D);
            double d7 = ((double) l4 - d4) / (d1 / 2D);
            double d8 = ((double) k4 - d5) / (d2 / 2D);
            double d9 = d6 * d6 + d7 * d7 + d8 * d8;
            if (d9 < 1.0D) {
              aflag[(j4 * 16 + k4) * 8 + l4] = true;
            }
          }
        }
      }
    }

    for (int j1 = 0; j1 < 16; j1++) {
      for (int j2 = 0; j2 < 16; j2++) {
        for (int j3 = 0; j3 < 8; j3++) {
          boolean flag =
              !aflag[(j1 * 16 + j2) * 8 + j3]
                  && (j1 < 15 && aflag[((j1 + 1) * 16 + j2) * 8 + j3]
                      || j1 > 0 && aflag[((j1 - 1) * 16 + j2) * 8 + j3]
                      || j2 < 15 && aflag[(j1 * 16 + (j2 + 1)) * 8 + j3]
                      || j2 > 0 && aflag[(j1 * 16 + (j2 - 1)) * 8 + j3]
                      || j3 < 7 && aflag[(j1 * 16 + j2) * 8 + (j3 + 1)]
                      || j3 > 0 && aflag[(j1 * 16 + j2) * 8 + (j3 - 1)]);
          if (!flag) {
            continue;
          }
          Material material = world.getBlockMaterial(i + j1, j + j3, k + j2);
          if (j3 >= 4 && material.getIsLiquid()) {
            return false;
          }
          if (j3 < 4
              && !material.isSolid()
              && world.getBlockId(i + j1, j + j3, k + j2) != field_15005_a) {
            return false;
          }
        }
      }
    }

    for (int k1 = 0; k1 < 16; k1++) {
      for (int k2 = 0; k2 < 16; k2++) {
        for (int k3 = 0; k3 < 8; k3++) {
          if (aflag[(k1 * 16 + k2) * 8 + k3]) {
            world.setBlock(i + k1, j + k3, k + k2, k3 < 4 ? field_15005_a : 0);
          }
        }
      }
    }

    for (int l1 = 0; l1 < 16; l1++) {
      for (int l2 = 0; l2 < 16; l2++) {
        for (int l3 = 4; l3 < 8; l3++) {
          if (aflag[(l1 * 16 + l2) * 8 + l3]
              && world.getBlockId(i + l1, (j + l3) - 1, k + l2) == Block.dirt.blockID
              && world.getSavedLightValue(EnumSkyBlock.Sky, i + l1, j + l3, k + l2) > 0) {
            world.setBlock(i + l1, (j + l3) - 1, k + l2, Block.grass.blockID);
          }
        }
      }
    }

    if (Block.blocksList[field_15005_a].blockMaterial == Material.lava) {
      for (int i2 = 0; i2 < 16; i2++) {
        for (int i3 = 0; i3 < 16; i3++) {
          for (int i4 = 0; i4 < 8; i4++) {
            boolean flag1 =
                !aflag[(i2 * 16 + i3) * 8 + i4]
                    && (i2 < 15 && aflag[((i2 + 1) * 16 + i3) * 8 + i4]
                        || i2 > 0 && aflag[((i2 - 1) * 16 + i3) * 8 + i4]
                        || i3 < 15 && aflag[(i2 * 16 + (i3 + 1)) * 8 + i4]
                        || i3 > 0 && aflag[(i2 * 16 + (i3 - 1)) * 8 + i4]
                        || i4 < 7 && aflag[(i2 * 16 + i3) * 8 + (i4 + 1)]
                        || i4 > 0 && aflag[(i2 * 16 + i3) * 8 + (i4 - 1)]);
            if (flag1
                && (i4 < 4 || random.nextInt(2) != 0)
                && world.getBlockMaterial(i + i2, j + i4, k + i3).isSolid()) {
              world.setBlock(i + i2, j + i4, k + i3, Block.stone.blockID);
            }
          }
        }
      }
    }
    return true;
  }
Пример #18
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    if (!par1World.isRemote && par1World.rand.nextInt(4) == 0) {
      byte var6 = 4;
      int var7 = 5;
      boolean var8 = false;
      int var9;
      int var10;
      int var11;
      label138:
      for (var9 = par2 - var6; var9 <= par2 + var6; ++var9) {
        for (var10 = par4 - var6; var10 <= par4 + var6; ++var10) {
          for (var11 = par3 - 1; var11 <= par3 + 1; ++var11) {
            if (par1World.getBlockId(var9, var11, var10) == this.blockID) {
              --var7;

              if (var7 <= 0) {
                var8 = true;
                break label138;
              }
            }
          }
        }
      }

      var9 = par1World.getBlockMetadata(par2, par3, par4);
      var10 = par1World.rand.nextInt(6);
      var11 = Direction.vineGrowth[var10];
      int var12;
      int var13;

      if (var10 == 1 && par3 < 255 && par1World.isAirBlock(par2, par3 + 1, par4)) {
        if (var8) {
          return;
        }

        var12 = par1World.rand.nextInt(16) & var9;

        if (var12 > 0) {
          for (var13 = 0; var13 <= 3; ++var13) {
            if (!this.canBePlacedOn(
                par1World.getBlockId(
                    par2 + Direction.offsetX[var13], par3 + 1, par4 + Direction.offsetZ[var13]))) {
              var12 &= ~(1 << var13);
            }
          }

          if (var12 > 0) {
            par1World.setBlockAndMetadataWithNotify(par2, par3 + 1, par4, this.blockID, var12);
          }
        }
      } else {
        int var14;

        if (var10 >= 2 && var10 <= 5 && (var9 & 1 << var11) == 0) {
          if (var8) {
            return;
          }

          var12 =
              par1World.getBlockId(
                  par2 + Direction.offsetX[var11], par3, par4 + Direction.offsetZ[var11]);

          if (var12 != 0 && Block.blocksList[var12] != null) {
            if (Block.blocksList[var12].blockMaterial.isOpaque()
                && Block.blocksList[var12].renderAsNormalBlock()) {
              par1World.setBlockMetadataWithNotify(par2, par3, par4, var9 | 1 << var11);
            }
          } else {
            var13 = var11 + 1 & 3;
            var14 = var11 + 3 & 3;

            if ((var9 & 1 << var13) != 0
                && this.canBePlacedOn(
                    par1World.getBlockId(
                        par2 + Direction.offsetX[var11] + Direction.offsetX[var13],
                        par3,
                        par4 + Direction.offsetZ[var11] + Direction.offsetZ[var13]))) {
              par1World.setBlockAndMetadataWithNotify(
                  par2 + Direction.offsetX[var11],
                  par3,
                  par4 + Direction.offsetZ[var11],
                  this.blockID,
                  1 << var13);
            } else if ((var9 & 1 << var14) != 0
                && this.canBePlacedOn(
                    par1World.getBlockId(
                        par2 + Direction.offsetX[var11] + Direction.offsetX[var14],
                        par3,
                        par4 + Direction.offsetZ[var11] + Direction.offsetZ[var14]))) {
              par1World.setBlockAndMetadataWithNotify(
                  par2 + Direction.offsetX[var11],
                  par3,
                  par4 + Direction.offsetZ[var11],
                  this.blockID,
                  1 << var14);
            } else if ((var9 & 1 << var13) != 0
                && par1World.isAirBlock(
                    par2 + Direction.offsetX[var11] + Direction.offsetX[var13],
                    par3,
                    par4 + Direction.offsetZ[var11] + Direction.offsetZ[var13])
                && this.canBePlacedOn(
                    par1World.getBlockId(
                        par2 + Direction.offsetX[var13], par3, par4 + Direction.offsetZ[var13]))) {
              par1World.setBlockAndMetadataWithNotify(
                  par2 + Direction.offsetX[var11] + Direction.offsetX[var13],
                  par3,
                  par4 + Direction.offsetZ[var11] + Direction.offsetZ[var13],
                  this.blockID,
                  1 << (var11 + 2 & 3));
            } else if ((var9 & 1 << var14) != 0
                && par1World.isAirBlock(
                    par2 + Direction.offsetX[var11] + Direction.offsetX[var14],
                    par3,
                    par4 + Direction.offsetZ[var11] + Direction.offsetZ[var14])
                && this.canBePlacedOn(
                    par1World.getBlockId(
                        par2 + Direction.offsetX[var14], par3, par4 + Direction.offsetZ[var14]))) {
              par1World.setBlockAndMetadataWithNotify(
                  par2 + Direction.offsetX[var11] + Direction.offsetX[var14],
                  par3,
                  par4 + Direction.offsetZ[var11] + Direction.offsetZ[var14],
                  this.blockID,
                  1 << (var11 + 2 & 3));
            } else if (this.canBePlacedOn(
                par1World.getBlockId(
                    par2 + Direction.offsetX[var11], par3 + 1, par4 + Direction.offsetZ[var11]))) {
              par1World.setBlockAndMetadataWithNotify(
                  par2 + Direction.offsetX[var11],
                  par3,
                  par4 + Direction.offsetZ[var11],
                  this.blockID,
                  0);
            }
          }
        } else if (par3 > 1) {
          var12 = par1World.getBlockId(par2, par3 - 1, par4);

          if (var12 == 0) {
            var13 = par1World.rand.nextInt(16) & var9;

            if (var13 > 0) {
              par1World.setBlockAndMetadataWithNotify(par2, par3 - 1, par4, this.blockID, var13);
            }
          } else if (var12 == this.blockID) {
            var13 = par1World.rand.nextInt(16) & var9;
            var14 = par1World.getBlockMetadata(par2, par3 - 1, par4);

            if (var14 != (var14 | var13)) {
              par1World.setBlockMetadataWithNotify(par2, par3 - 1, par4, var14 | var13);
            }
          }
        }
      }
    }
  }
Пример #19
0
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    int i = par2Random.nextInt(3) + minTreeHeight;
    boolean flag = true;

    if (par4 < 1 || par4 + i + 1 > 256) {
      return false;
    }

    for (int j = par4; j <= par4 + 1 + i; j++) {
      byte byte0 = 1;

      if (j == par4) {
        byte0 = 0;
      }

      if (j >= (par4 + 1 + i) - 2) {
        byte0 = 2;
      }

      for (int l = par3 - byte0; l <= par3 + byte0 && flag; l++) {
        for (int j1 = par5 - byte0; j1 <= par5 + byte0 && flag; j1++) {
          if (j >= 0 && j < 256) {
            int k2 = par1World.getBlockId(l, j, j1);

            if (k2 != 0
                && k2 != Block.leaves.blockID
                && k2 != Block.grass.blockID
                && k2 != Block.dirt.blockID
                && k2 != Block.wood.blockID) {
              flag = false;
            }
          } else {
            flag = false;
          }
        }
      }
    }

    if (!flag) {
      return false;
    }

    int k = par1World.getBlockId(par3, par4 - 1, par5);

    if (k != Block.grass.blockID && k != Block.dirt.blockID || par4 >= 256 - i - 1) {
      return false;
    }

    setBlock(par1World, par3, par4 - 1, par5, Block.dirt.blockID);
    byte byte1 = 3;
    int i1 = 0;

    for (int k1 = (par4 - byte1) + i; k1 <= par4 + i; k1++) {
      int l2 = k1 - (par4 + i);
      int l3 = (i1 + 1) - l2 / 2;

      for (int k4 = par3 - l3; k4 <= par3 + l3; k4++) {
        int i5 = k4 - par3;

        for (int k5 = par5 - l3; k5 <= par5 + l3; k5++) {
          int l5 = k5 - par5;

          if ((Math.abs(i5) != l3 || Math.abs(l5) != l3 || par2Random.nextInt(2) != 0 && l2 != 0)
              && !Block.opaqueCubeLookup[par1World.getBlockId(k4, k1, k5)]) {
            setBlockAndMetadata(par1World, k4, k1, k5, Block.leaves.blockID, metaLeaves);
          }
        }
      }
    }

    for (int l1 = 0; l1 < i; l1++) {
      int i3 = par1World.getBlockId(par3, par4 + l1, par5);

      if (i3 != 0 && i3 != Block.leaves.blockID) {
        continue;
      }

      setBlockAndMetadata(par1World, par3, par4 + l1, par5, Block.wood.blockID, metaWood);

      if (!vinesGrow || l1 <= 0) {
        continue;
      }

      if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 - 1, par4 + l1, par5)) {
        setBlockAndMetadata(par1World, par3 - 1, par4 + l1, par5, Block.vine.blockID, 8);
      }

      if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3 + 1, par4 + l1, par5)) {
        setBlockAndMetadata(par1World, par3 + 1, par4 + l1, par5, Block.vine.blockID, 2);
      }

      if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + l1, par5 - 1)) {
        setBlockAndMetadata(par1World, par3, par4 + l1, par5 - 1, Block.vine.blockID, 1);
      }

      if (par2Random.nextInt(3) > 0 && par1World.isAirBlock(par3, par4 + l1, par5 + 1)) {
        setBlockAndMetadata(par1World, par3, par4 + l1, par5 + 1, Block.vine.blockID, 4);
      }
    }

    if (vinesGrow) {
      for (int i2 = (par4 - 3) + i; i2 <= par4 + i; i2++) {
        int j3 = i2 - (par4 + i);
        int i4 = 2 - j3 / 2;

        for (int l4 = par3 - i4; l4 <= par3 + i4; l4++) {
          for (int j5 = par5 - i4; j5 <= par5 + i4; j5++) {
            if (par1World.getBlockId(l4, i2, j5) != Block.leaves.blockID) {
              continue;
            }

            if (par2Random.nextInt(4) == 0 && par1World.getBlockId(l4 - 1, i2, j5) == 0) {
              growVines(par1World, l4 - 1, i2, j5, 8);
            }

            if (par2Random.nextInt(4) == 0 && par1World.getBlockId(l4 + 1, i2, j5) == 0) {
              growVines(par1World, l4 + 1, i2, j5, 2);
            }

            if (par2Random.nextInt(4) == 0 && par1World.getBlockId(l4, i2, j5 - 1) == 0) {
              growVines(par1World, l4, i2, j5 - 1, 1);
            }

            if (par2Random.nextInt(4) == 0 && par1World.getBlockId(l4, i2, j5 + 1) == 0) {
              growVines(par1World, l4, i2, j5 + 1, 4);
            }
          }
        }
      }

      if (par2Random.nextInt(5) == 0 && i > 5) {
        for (int j2 = 0; j2 < 2; j2++) {
          for (int k3 = 0; k3 < 4; k3++) {
            if (par2Random.nextInt(4 - j2) == 0) {
              int j4 = par2Random.nextInt(3);
              setBlockAndMetadata(
                  par1World,
                  par3 + Direction.offsetX[Direction.footInvisibleFaceRemap[k3]],
                  ((par4 + i) - 5) + j2,
                  par5 + Direction.offsetZ[Direction.footInvisibleFaceRemap[k3]],
                  Block.cocoa.blockID,
                  j4 << 2 | k3);
            }
          }
        }
      }
    }

    return true;
  }