Beispiel #1
0
 /**
  * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
  */
 public boolean canPlaceBlockAt(
     World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) {
   return p_149742_3_ >= p_149742_1_.getHeight() - 1
       ? false
       : World.doesBlockHaveSolidTopSurface(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_)
           && super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_, p_149742_4_)
           && super.canPlaceBlockAt(p_149742_1_, p_149742_2_, p_149742_3_ + 1, p_149742_4_);
 }
Beispiel #2
0
  public static boolean canPush(
      Block blockIn, World worldIn, BlockPos pos, EnumFacing direction, boolean allowDestroy) {
    if (blockIn == Blocks.obsidian) {
      return false;
    } else if (!worldIn.getWorldBorder().contains(pos)) {
      return false;
    } else if (pos.getY() >= 0 && (direction != EnumFacing.DOWN || pos.getY() != 0)) {
      if (pos.getY() <= worldIn.getHeight() - 1
          && (direction != EnumFacing.UP || pos.getY() != worldIn.getHeight() - 1)) {
        if (blockIn != Blocks.piston && blockIn != Blocks.sticky_piston) {
          if (blockIn.getBlockHardness(worldIn, pos) == -1.0F) {
            return false;
          }

          if (blockIn.getMobilityFlag() == 2) {
            return false;
          }

          if (blockIn.getMobilityFlag() == 1) {
            if (!allowDestroy) {
              return false;
            }

            return true;
          }
        } else if (((Boolean) worldIn.getBlockState(pos).getValue(EXTENDED)).booleanValue()) {
          return false;
        }

        return !(blockIn instanceof ITileEntityProvider);
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
 @Override
 public boolean generate(World worldIn, Random rand, BlockPos position) {
   int dragonAge = 50 + rand.nextInt(25);
   burnGround(worldIn, rand, position, dragonAge / 5);
   generateStructures(worldIn, rand, position, dragonAge / 5);
   EntityIceDragon dragon = new EntityIceDragon(worldIn);
   dragon.setGender(dragon.getRNG().nextBoolean());
   dragon.growDragon(dragonAge);
   dragon.setHunger(50);
   dragon.setVariant(new Random().nextInt(4));
   dragon.setPositionAndRotation(
       position.getX() + 0.5,
       worldIn.getHeight(position).getY() + 1.5,
       position.getZ() + 0.5,
       rand.nextFloat() * 360,
       0);
   dragon.homeArea = position;
   worldIn.spawnEntityInWorld(dragon);
   return true;
 }
  @Override
  public void onCreate(World world, BlockPos placedPosition) {
    int buildHeight = world.getHeight() - 1;
    for (int y = 0; y < 3; y += 2) {
      if (placedPosition.getY() + y > buildHeight) return;
      for (int x = -1; x <= 1; x++) {
        for (int z = -1; z <= 1; z++) {
          final BlockPos vecToAdd = placedPosition.add(x, y, z);

          if (!vecToAdd.equals(placedPosition)) {
            ((BlockTelepadFake) AsteroidBlocks.fakeTelepad)
                .makeFakeBlock(
                    world,
                    vecToAdd,
                    placedPosition,
                    AsteroidBlocks.fakeTelepad
                        .getDefaultState()
                        .withProperty(BlockTelepadFake.TOP, y == 2));
          }
        }
      }
    }
  }
  public void generateSurface(World world, Random random, int chunkX, int chunkZ) {

    if (AbyssalCraft.generateDarklandsStructures) {
      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new AChouse1().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new AChouse2().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new ACplatform1().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new ACplatform2().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new ACscion1().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }

      for (int k = 0; k < 2; k++) {
        int RandPosX = chunkX + random.nextInt(5);
        int RandPosY = random.nextInt(75);
        int RandPosZ = chunkZ + random.nextInt(5);
        new ACscion2().generate(world, random, new BlockPos(RandPosX, RandPosY, RandPosZ));
      }
    }

    if (AbyssalCraft.generateCoraliumOre) {
      for (int rarity = 0; rarity < 3; rarity++) {
        int veinSize = 2 + random.nextInt(2);
        int x = chunkX + random.nextInt(16);
        int y = random.nextInt(40);
        int z = chunkZ + random.nextInt(16);
        if (BiomeDictionary.isBiomeOfType(
            world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.SWAMP))
          new WorldGenMinable(ACBlocks.coralium_ore.getDefaultState(), veinSize)
              .generate(world, random, new BlockPos(x, y, z));
      }

      for (int rarity = 0; rarity < 6; rarity++) {
        int veinSize = 4 + random.nextInt(2);
        int x = chunkX + random.nextInt(16);
        int y = random.nextInt(40);
        int z = chunkZ + random.nextInt(16);
        if (BiomeDictionary.isBiomeOfType(
                world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.OCEAN)
            && world.getBiomeGenForCoords(new BlockPos(x, 0, z)) != Biomes.DEEP_OCEAN)
          new WorldGenMinable(ACBlocks.coralium_ore.getDefaultState(), veinSize)
              .generate(world, random, new BlockPos(x, y, z));
        if (world.getBiomeGenForCoords(new BlockPos(x, 0, z)) == Biomes.DEEP_OCEAN)
          new WorldGenMinable(ACBlocks.coralium_ore.getDefaultState(), veinSize)
              .generate(world, random, new BlockPos(x, y - 20, z));
      }
    }

    if (AbyssalCraft.generateNitreOre)
      for (int rarity = 0; rarity < 3; rarity++) {
        int veinSize = 4 + random.nextInt(2);
        int x = chunkX + random.nextInt(16);
        int y = random.nextInt(30);
        int z = chunkZ + random.nextInt(16);

        new WorldGenMinable(ACBlocks.nitre_ore.getDefaultState(), veinSize)
            .generate(world, random, new BlockPos(x, y, z));
      }

    if (AbyssalCraft.generateShoggothLairs)
      for (int i = 0; i < 1; i++) {
        int x = chunkX + random.nextInt(16);
        int z = chunkZ + random.nextInt(16);
        if (BiomeDictionary.isBiomeOfType(
                world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.SWAMP)
            || BiomeDictionary.isBiomeOfType(
                    world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.RIVER)
                && !BiomeDictionary.isBiomeOfType(
                    world.getBiomeGenForCoords(new BlockPos(x, 0, z)), Type.OCEAN))
          if (random.nextInt(100) == 0)
            new StructureShoggothPit()
                .generate(world, random, world.getHeight(new BlockPos(x, 0, z)));
      }
  }
  @Override
  public boolean generate(World world, Random random, int xCoord, int yCoord, int zCoord) {
    int treeHeight = random.nextInt(6) + 3;
    boolean flag = true;
    if (yCoord < 1 || yCoord + treeHeight + 1 > world.getHeight()) {
      return false;
    }
    for (int i1 = yCoord; i1 <= yCoord + 1 + treeHeight; i1++) {
      byte byte0 = 1;
      if (i1 == yCoord) {
        byte0 = 0;
      }
      if (i1 >= yCoord + 1 + treeHeight - 2) {
        byte0 = 2;
      }
      for (int i2 = xCoord - byte0; i2 <= xCoord + byte0 && flag; i2++) {
        for (int l2 = zCoord - byte0; l2 <= zCoord + byte0 && flag; l2++) {
          if (i1 >= 0 && i1 < world.getHeight()) {
            int j3 = world.getBlockId(i2, i1, l2);
            if (j3 != 0 && j3 != TFCBlocks.Leaves.blockID && j3 != TFCBlocks.Sapling.blockID) {
              flag = false;
            }
          } else {
            flag = false;
          }
        }
      }
    }

    if (!flag) {
      return false;
    }
    int var3 = world.getBlockId(xCoord, yCoord - 1, zCoord);
    if (!(TFC_Core.isSoil(var3)) || yCoord >= world.getHeight() - treeHeight - 1) {
      return false;
    }
    // DataLayer rockLayer1 =
    // ((TFCWorldChunkManager)world.getWorldChunkManager()).getRockLayerAt(xCoord, zCoord, 0);
    // set the block below the tree to dirt.
    // world.setBlockAndMetadata(xCoord, yCoord - 1, zCoord,
    // TFC_Core.getTypeForGrass(rockLayer1.data2), TFC_Core.getSoilMetaFromStone(rockLayer1.data1,
    // rockLayer1.data2));
    // Now we create the leaves. generates from the bottom up.
    for (int treeHeightOffset = yCoord + 1;
        treeHeightOffset <= yCoord + treeHeight;
        treeHeightOffset++) {
      int treeDiameter = treeHeightOffset - (yCoord + treeHeight);
      int treeRadius = 1 - treeDiameter / 2;

      for (int xPos = xCoord - 1; xPos <= xCoord + 1; xPos++) {
        int l3 = xPos - xCoord;
        for (int zPos = zCoord - 1; zPos <= zCoord + 1; zPos++) {
          int j4 = zPos - zCoord;
          if ((Math.abs(l3) != treeRadius
                  || Math.abs(j4) != treeRadius
                  || random.nextInt(2) != 0 && treeDiameter != 0)
              && world.getBlockId(xPos, treeHeightOffset, zPos) == 0) {
            setBlockAndMetadata(
                world, xPos, treeHeightOffset, zPos, TFCBlocks.Leaves.blockID, treeId);
          }
        }
      }
    }
    // Here we crate the tree trunk
    for (int l1 = 0; l1 < treeHeight; l1++) {
      int k2 = world.getBlockId(xCoord, yCoord + l1, zCoord);
      if (k2 == 0
          || k2 == TFCBlocks.Leaves.blockID
          || Block.blocksList[k2].canBeReplacedByLeaves(world, xCoord, yCoord + l1, zCoord)) {
        setBlockAndMetadata(world, xCoord, yCoord + l1, zCoord, TFCBlocks.Wood.blockID, treeId);
      }
    }

    return true;
  }
  public boolean growTree(World world, Random rand, int x, int y, int z) {
    int treeHeight = rand.nextInt(3) + 5, worldHeight = world.getHeight();
    Block block;

    if (y >= 1 && y + treeHeight + 1 <= worldHeight) {
      int blockId;
      int xOffset;
      int yOffset;
      int zOffset;

      blockId = world.getBlockId(x, y - 1, z);
      block = Block.blocksList[blockId];

      boolean isGrass = blockId == Block.grass.blockID;

      if ((block != null
              && ((isGrass | blockId == Block.dirt.blockID)
                  || block.canSustainPlant(
                      world,
                      x,
                      y - 1,
                      z,
                      ForgeDirection.UP,
                      ((BlockSapling) MineFactoryReloadedCore.rubberSaplingBlock))))
          && y < worldHeight - treeHeight - 1) {
        for (yOffset = y; yOffset <= y + 1 + treeHeight; ++yOffset) {
          byte radius = 1;

          if (yOffset == y) {
            radius = 0;
          }

          if (yOffset >= y + 1 + treeHeight - 2) {
            radius = 2;
          }

          if (yOffset >= 0 & yOffset < worldHeight) {
            for (xOffset = x - radius; xOffset <= x + radius; ++xOffset) {
              for (zOffset = z - radius; zOffset <= z + radius; ++zOffset) {
                blockId = world.getBlockId(xOffset, yOffset, zOffset);

                block = Block.blocksList[blockId];

                if (block != null
                    && !(block.isLeaves(world, xOffset, yOffset, zOffset)
                        || block.isAirBlock(world, xOffset, yOffset, zOffset)
                        || block.canBeReplacedByLeaves(world, xOffset, yOffset, zOffset))) {
                  return false;
                }
              }
            }
          } else {
            return false;
          }
        }

        if (isGrass) {
          this.setBlock(world, x, y - 1, z, Block.dirt.blockID);
        }

        for (yOffset = y - 3 + treeHeight; yOffset <= y + treeHeight; ++yOffset) {
          int var12 = yOffset - (y + treeHeight), center = 1 - var12 / 2;

          for (xOffset = x - center; xOffset <= x + center; ++xOffset) {
            int xPos = xOffset - x, t = xPos >> 31;
            xPos = (xPos + t) ^ t;

            for (zOffset = z - center; zOffset <= z + center; ++zOffset) {
              int zPos = zOffset - z;
              zPos = (zPos + (t = zPos >> 31)) ^ t;

              block = Block.blocksList[world.getBlockId(xOffset, yOffset, zOffset)];

              if (((xPos != center | zPos != center) || rand.nextInt(2) != 0 && var12 != 0)
                  && (block == null
                      || block.isLeaves(world, xOffset, yOffset, zOffset)
                      || block.isAirBlock(world, xOffset, yOffset, zOffset)
                      || block.canBeReplacedByLeaves(world, xOffset, yOffset, zOffset))) {
                this.setBlockAndMetadata(
                    world,
                    xOffset,
                    yOffset,
                    zOffset,
                    MineFactoryReloadedCore.rubberLeavesBlock.blockID,
                    0);
              }
            }
          }
        }

        for (yOffset = 0; yOffset < treeHeight; ++yOffset) {
          xOffset = world.getBlockId(x, y + yOffset, z);

          block = Block.blocksList[xOffset];

          if (block == null
              || block.isAirBlock(world, x, y + yOffset, z)
              || block.isLeaves(world, x, y + yOffset, z)) {
            this.setBlockAndMetadata(
                world, x, y + yOffset, z, MineFactoryReloadedCore.rubberWoodBlock.blockID, 1);
          }
        }

        return true;
      }
    }
    return false;
  }