コード例 #1
0
  public boolean generate(World worldIn, Random rand, BlockPos position) {
    if (worldIn.isAirBlock(position)
        && worldIn.getBlockState(position.down()).getBlock() == this.baseBlockRequired) {
      int i = rand.nextInt(32) + 6;
      int j = rand.nextInt(4) + 1;
      BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

      for (int k = position.getX() - j; k <= position.getX() + j; ++k) {
        for (int l = position.getZ() - j; l <= position.getZ() + j; ++l) {
          int i1 = k - position.getX();
          int j1 = l - position.getZ();

          if (i1 * i1 + j1 * j1 <= j * j + 1
              && worldIn
                      .getBlockState(blockpos$mutableblockpos.set(k, position.getY() - 1, l))
                      .getBlock()
                  != this.baseBlockRequired) {
            return false;
          }
        }
      }

      for (int l1 = position.getY(); l1 < position.getY() + i && l1 < 256; ++l1) {
        for (int i2 = position.getX() - j; i2 <= position.getX() + j; ++i2) {
          for (int j2 = position.getZ() - j; j2 <= position.getZ() + j; ++j2) {
            int k2 = i2 - position.getX();
            int k1 = j2 - position.getZ();

            if (k2 * k2 + k1 * k1 <= j * j + 1) {
              worldIn.setBlockState(new BlockPos(i2, l1, j2), Blocks.obsidian.getDefaultState(), 2);
            }
          }
        }
      }

      Entity entity = new EntityEnderCrystal(worldIn);
      entity.setLocationAndAngles(
          (double) ((float) position.getX() + 0.5F),
          (double) (position.getY() + i),
          (double) ((float) position.getZ() + 0.5F),
          rand.nextFloat() * 360.0F,
          0.0F);
      worldIn.spawnEntityInWorld(entity);
      worldIn.setBlockState(position.up(i), Blocks.bedrock.getDefaultState(), 2);
      return true;
    } else {
      return false;
    }
  }
コード例 #2
0
  private int func_176186_b(Entity entityIn, int x, int y, int z) {
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int i = x; i < x + this.entitySizeX; ++i) {
      for (int j = y; j < y + this.entitySizeY; ++j) {
        for (int k = z; k < z + this.entitySizeZ; ++k) {
          Block block =
              this.blockaccess.getBlockState(blockpos$mutableblockpos.set(i, j, k)).getBlock();

          if (block.getMaterial() != Material.water) {
            return 0;
          }
        }
      }
    }

    return -1;
  }
コード例 #3
0
ファイル: CommandCompare.java プロジェクト: leijurv/MineBot
  /** Callback when the command is invoked */
  public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if (args.length < 9) {
      throw new WrongUsageException("commands.compare.usage", new Object[0]);
    } else {
      sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, 0);
      BlockPos blockpos = parseBlockPos(sender, args, 0, false);
      BlockPos blockpos1 = parseBlockPos(sender, args, 3, false);
      BlockPos blockpos2 = parseBlockPos(sender, args, 6, false);
      StructureBoundingBox structureboundingbox = new StructureBoundingBox(blockpos, blockpos1);
      StructureBoundingBox structureboundingbox1 =
          new StructureBoundingBox(blockpos2, blockpos2.add(structureboundingbox.func_175896_b()));
      int i =
          structureboundingbox.getXSize()
              * structureboundingbox.getYSize()
              * structureboundingbox.getZSize();

      if (i > 524288) {
        throw new CommandException(
            "commands.compare.tooManyBlocks",
            new Object[] {Integer.valueOf(i), Integer.valueOf(524288)});
      } else if (structureboundingbox.minY >= 0
          && structureboundingbox.maxY < 256
          && structureboundingbox1.minY >= 0
          && structureboundingbox1.maxY < 256) {
        World world = sender.getEntityWorld();

        if (world.isAreaLoaded(structureboundingbox) && world.isAreaLoaded(structureboundingbox1)) {
          boolean flag = false;

          if (args.length > 9 && args[9].equals("masked")) {
            flag = true;
          }

          i = 0;
          BlockPos blockpos3 =
              new BlockPos(
                  structureboundingbox1.minX - structureboundingbox.minX,
                  structureboundingbox1.minY - structureboundingbox.minY,
                  structureboundingbox1.minZ - structureboundingbox.minZ);
          BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
          BlockPos.MutableBlockPos blockpos$mutableblockpos1 = new BlockPos.MutableBlockPos();

          for (int j = structureboundingbox.minZ; j <= structureboundingbox.maxZ; ++j) {
            for (int k = structureboundingbox.minY; k <= structureboundingbox.maxY; ++k) {
              for (int l = structureboundingbox.minX; l <= structureboundingbox.maxX; ++l) {
                blockpos$mutableblockpos.func_181079_c(l, k, j);
                blockpos$mutableblockpos1.func_181079_c(
                    l + blockpos3.getX(), k + blockpos3.getY(), j + blockpos3.getZ());
                boolean flag1 = false;
                IBlockState iblockstate = world.getBlockState(blockpos$mutableblockpos);

                if (!flag || iblockstate.getBlock() != Blocks.air) {
                  if (iblockstate == world.getBlockState(blockpos$mutableblockpos1)) {
                    TileEntity tileentity = world.getTileEntity(blockpos$mutableblockpos);
                    TileEntity tileentity1 = world.getTileEntity(blockpos$mutableblockpos1);

                    if (tileentity != null && tileentity1 != null) {
                      NBTTagCompound nbttagcompound = new NBTTagCompound();
                      tileentity.writeToNBT(nbttagcompound);
                      nbttagcompound.removeTag("x");
                      nbttagcompound.removeTag("y");
                      nbttagcompound.removeTag("z");
                      NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                      tileentity1.writeToNBT(nbttagcompound1);
                      nbttagcompound1.removeTag("x");
                      nbttagcompound1.removeTag("y");
                      nbttagcompound1.removeTag("z");

                      if (!nbttagcompound.equals(nbttagcompound1)) {
                        flag1 = true;
                      }
                    } else if (tileentity != null) {
                      flag1 = true;
                    }
                  } else {
                    flag1 = true;
                  }

                  ++i;

                  if (flag1) {
                    throw new CommandException("commands.compare.failed", new Object[0]);
                  }
                }
              }
            }
          }

          sender.setCommandStat(CommandResultStats.Type.AFFECTED_BLOCKS, i);
          notifyOperators(
              sender, this, "commands.compare.success", new Object[] {Integer.valueOf(i)});
        } else {
          throw new CommandException("commands.compare.outOfWorld", new Object[0]);
        }
      } else {
        throw new CommandException("commands.compare.outOfWorld", new Object[0]);
      }
    }
  }