@Override
 public void onNeighborBlockChange(
     World world, BlockPos pos, IBlockState state, Block neighborBlock) {
   if (!suitableGround(world, pos.down())) {
     world.destroyBlock(pos, true);
   }
 }
  private void setBlocks(World par1World, int x, int y, int z, boolean item, int blockid) {
    if (par1World.blockExists(x, y, z)) {
      if (par1World.getBlockId(x, y, z) != blockid) {
        par1World.destroyBlock(x, y, z, item);
      }

      par1World.setBlock(x, y, z, blockid);
    }
  }
  @Override
  public void processCommand(ICommandSender icommandsender, String[] astring) {

    ArrayList<ChunkCoordinates> ccListsb = new ArrayList<ChunkCoordinates>();
    ArrayList<ChunkCoordinates> ccListdb = new ArrayList<ChunkCoordinates>();
    boolean sameBiome;
    int offset = 1;
    ChunkCoordinates cc = icommandsender.getPlayerCoordinates();
    EntityPlayerMP player = getCommandSenderAsPlayer(icommandsender);

    World w = player.worldObj;
    BiomeGenBase bg = w.getBiomeGenForCoords(cc.posX, cc.posZ);

    sameBiome = true;

    int olddb, newdb;

    newdb = 0;

    while (sameBiome == true) {

      olddb = newdb;

      for (int i = -offset; i <= offset; i++) {
        for (int j = -offset; j <= offset; j++) {
          if (w.getBiomeGenForCoords(cc.posX + i, cc.posZ + j) == bg) {
            ccListsb.add(new ChunkCoordinates(cc.posX + i, 0, cc.posZ + j));
          } else {
            ccListdb.add(new ChunkCoordinates(cc.posX + i, 0, cc.posZ + j));
          }
        }
      }

      newdb = ccListdb.size();

      if ((newdb - olddb >= offset * 8 || offset == 512)) {
        System.out.println("" + ccListsb.size());
        sameBiome = false;
      } else {
        ccListdb.clear();
        ccListsb.clear();
      }

      offset++;
    }

    for (int j = 0; j < ccListsb.size(); j++) {
      for (int i = 0; i < 256; i++) {
        if (w.blockExists(ccListsb.get(j).posX, i, ccListsb.get(j).posZ))
          w.destroyBlock(ccListsb.get(j).posX, i, ccListsb.get(j).posZ, false);
      }
    }

    System.out.println("Done");
  }
 private void breakBlocks(World par1World, int x, int y, int z, boolean item) {
   if (par1World.blockExists(x, y, z)) {
     if (par1World.getBlockId(x, y, z) == SpacecraftBlocks.caravanModulePart.blockID
         || par1World.getBlockId(x, y, z) == GCCoreBlocks.glowstoneTorch.blockID
         || par1World.getBlockId(x, y, z) == Block.furnaceBurning.blockID
         || par1World.getBlockId(x, y, z) == Block.furnaceIdle.blockID
         || par1World.getBlockId(x, y, z) == Block.chest.blockID
         || par1World.getBlockId(x, y, z) == Block.workbench.blockID) {
       par1World.destroyBlock(x, y, z, item);
     }
   }
 }
  private boolean transformUse(
      EntityPlayer player, World world, ItemStack stack, BlockPos targ, int amount) {
    Random r = new Random();
    Block block = world.getBlockState(targ).getBlock();

    if (OreDictionary.itemMatches(new ItemStack(Blocks.log), new ItemStack(block), false)) {
      world.destroyBlock(targ, false);
      world.setBlockState(targ, Parachronology.petrifiedWood.getDefaultState());
      world.markBlockForUpdate(targ);
      stack.stackSize--;
      spread(world, targ, amount);
      return true;
    }
    return false;
  }
Exemple #6
0
  public boolean tryPlaceContainedLiquid(World worldIn, BlockPos pos) {
    if (this.isFull == Blocks.air) {
      return false;
    } else {
      Material material = worldIn.getBlockState(pos).getBlock().getMaterial();
      boolean flag = !material.isSolid();

      if (!worldIn.isAirBlock(pos) && !flag) {
        return false;
      } else {
        if (worldIn.provider.doesWaterVaporize() && this.isFull == Blocks.flowing_water) {
          int i = pos.getX();
          int j = pos.getY();
          int k = pos.getZ();
          worldIn.playSoundEffect(
              (double) ((float) i + 0.5F),
              (double) ((float) j + 0.5F),
              (double) ((float) k + 0.5F),
              "random.fizz",
              0.5F,
              2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);

          for (int l = 0; l < 8; ++l) {
            worldIn.spawnParticle(
                EnumParticleTypes.SMOKE_LARGE,
                (double) i + Math.random(),
                (double) j + Math.random(),
                (double) k + Math.random(),
                0.0D,
                0.0D,
                0.0D,
                new int[0]);
          }
        } else {
          if (!worldIn.isRemote && flag && !material.isLiquid()) {
            worldIn.destroyBlock(pos, true);
          }

          worldIn.setBlockState(pos, this.isFull.getDefaultState(), 3);
        }

        return true;
      }
    }
  }
  @Override
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer player,
      World world,
      BlockPos pos,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    if (this.hasSpawner(stack)) {
      BlockPos posSpawner = pos.offset(side);
      if (world.isAirBlock(posSpawner)) {
        if (!world.isRemote) {
          NBTTagCompound nbtSpawner = this.getSpawnerInfo(stack);
          nbtSpawner.setInteger("x", posSpawner.getX());
          nbtSpawner.setInteger("y", posSpawner.getY());
          nbtSpawner.setInteger("z", posSpawner.getZ());

          world.setBlockState(posSpawner, Blocks.mob_spawner.getDefaultState());
          world.getTileEntity(posSpawner).readFromNBT(nbtSpawner);
          world.markBlockForUpdate(posSpawner);

          if (!player.capabilities.isCreativeMode)
            player.inventory.mainInventory[player.inventory.currentItem] = null;
        } else return true;
      }
    } else {
      TileEntity tile = world.getTileEntity(pos);
      if (tile != null && tile instanceof TileEntityMobSpawner) {
        if (!world.isRemote) {
          NBTTagCompound nbtSpawner = new NBTTagCompound();
          tile.writeToNBT(nbtSpawner);

          this.setSpawnerInfo(stack, nbtSpawner);
          world.destroyBlock(pos, false);
        } else return true;
      }
    }

    return false;
  }
Exemple #8
0
  private boolean tryPlaceContainedLiquid(World world, int x, int y, int z) {
    if (this.isFull <= 0) {
      return false;
    } else {
      Material material = world.getBlockMaterial(x, y, z);
      boolean flag = !material.isSolid();

      if (!world.isAirBlock(x, y, z) && !flag) {
        return false;
      } else {
        if (world.provider.isHellWorld && this.isFull == Block.waterMoving.blockID) {
          world.playSoundEffect(
              (double) ((float) x + 0.5F),
              (double) ((float) y + 0.5F),
              (double) ((float) z + 0.5F),
              "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 {
          if (!world.isRemote && flag && !material.isLiquid()) {
            world.destroyBlock(x, y, z, true);
          }

          world.setBlock(x, y, z, this.isFull, 0, 3);
        }

        return true;
      }
    }
  }
  private void breakBlocksOther(World par1World, int x, int y, int z, boolean item) {
    if (par1World.blockExists(x, y, z)) {

      par1World.destroyBlock(x, y, z, item);
    }
  }
  private int spread(World world, BlockPos from, int times) {

    if (times == 0) return 0;
    if (OreDictionary.itemMatches(
        new ItemStack(Blocks.log),
        new ItemStack(world.getBlockState(from.add(0, -1, 0)).getBlock()),
        false)) {
      world.destroyBlock(from.add(0, -1, 0), false);
      world.setBlockState(from.add(0, -1, 0), Parachronology.petrifiedWood.getDefaultState());
      world.markBlockForUpdate(from);
      times--;
      times = spread(world, from.add(0, -1, 0), times);
    }
    if (times == 0) return 0;
    if (OreDictionary.itemMatches(
        new ItemStack(Blocks.log),
        new ItemStack(world.getBlockState(from.add(0, 1, 0)).getBlock()),
        false)) {
      world.destroyBlock(from.add(0, 1, 0), false);
      world.setBlockState(from.add(0, 1, 0), Parachronology.petrifiedWood.getDefaultState());
      world.markBlockForUpdate(from);
      times--;
      times = spread(world, from.add(0, 1, 0), times);
    }
    if (times == 0) return 0;
    if (OreDictionary.itemMatches(
        new ItemStack(Blocks.log),
        new ItemStack(world.getBlockState(from.add(-1, 0, 0)).getBlock()),
        false)) {
      world.destroyBlock(from.add(-1, 0, 0), false);
      world.setBlockState(from.add(-1, 0, 0), Parachronology.petrifiedWood.getDefaultState());
      world.markBlockForUpdate(from);
      times--;
      times = spread(world, from.add(-1, 0, 0), times);
    }
    if (times == 0) return 0;
    if (OreDictionary.itemMatches(
        new ItemStack(Blocks.log),
        new ItemStack(world.getBlockState(from.add(1, 0, 0)).getBlock()),
        false)) {
      world.destroyBlock(from.add(1, 0, 0), false);
      world.setBlockState(from.add(1, 0, 0), Parachronology.petrifiedWood.getDefaultState());
      world.markBlockForUpdate(from);
      times--;
      times = spread(world, from.add(1, 0, 0), times);
    }
    if (times == 0) return 0;
    if (OreDictionary.itemMatches(
        new ItemStack(Blocks.log),
        new ItemStack(world.getBlockState(from.add(0, 0, -1)).getBlock()),
        false)) {
      world.destroyBlock(from.add(0, 0, -1), false);
      world.setBlockState(from.add(0, 0, -1), Parachronology.petrifiedWood.getDefaultState());
      world.markBlockForUpdate(from);
      times--;
      times = spread(world, from.add(0, 0, -1), times);
    }
    if (times == 0) return 0;
    if (OreDictionary.itemMatches(
        new ItemStack(Blocks.log),
        new ItemStack(world.getBlockState(from.add(0, 0, 1)).getBlock()),
        false)) {
      world.destroyBlock(from.add(0, 0, 1), false);
      world.setBlockState(from.add(0, 0, 1), Parachronology.petrifiedWood.getDefaultState());
      world.markBlockForUpdate(from);
      times--;
      times = spread(world, from.add(0, 0, 1), times);
    }
    return times;
  }