コード例 #1
0
ファイル: Util.java プロジェクト: umamama/MinecraftMods
 public static boolean equalItemAndNBT(ItemStack a, ItemStack b) {
   if (a.isItemEqual(b)) {
     NBTTagCompound tagCompoundA = a.getTagCompound();
     NBTTagCompound tagCompoundB = b.getTagCompound();
     return (tagCompoundA == null && tagCompoundB == null)
         || (tagCompoundA != null && tagCompoundB != null && tagCompoundA.equals(tagCompoundB));
   } else {
     return false;
   }
 }
コード例 #2
0
    @Override
    public boolean equals(Object o) {
      if (this == o) return true;
      if (!(o instanceof BlockData)) return false;

      BlockData data = (BlockData) o;

      return id == data.id
          && meta == data.meta
          && !(te != null ? !te.equals(data.te) : data.te != null);
    }
コード例 #3
0
ファイル: ContainerTFC.java プロジェクト: Miner239/TFCraft
  public static boolean areCompoundsEqual(ItemStack is1, ItemStack is2) {
    ItemStack is3 = is1.copy();
    ItemStack is4 = is2.copy();
    NBTTagCompound is3Tags = is3.getTagCompound();
    NBTTagCompound is4Tags = is4.getTagCompound();

    if (is3Tags == null) return is4Tags == null || is4Tags.hasNoTags();

    if (is4Tags == null) return is3Tags.hasNoTags();

    float temp3 = TFC_ItemHeat.getTemp(is1);
    float temp4 = TFC_ItemHeat.getTemp(is2);
    is3Tags.removeTag("temp");
    is4Tags.removeTag("temp");

    return is3Tags.equals(is4Tags) && Math.abs(temp3 - temp4) < 5;
  }
コード例 #4
0
  public static boolean setTileEntityNBT(
      World worldIn, BlockPos p_179224_1_, ItemStack p_179224_2_) {
    if (p_179224_2_.hasTagCompound() && p_179224_2_.getTagCompound().hasKey("BlockEntityTag", 10)) {
      TileEntity var3 = worldIn.getTileEntity(p_179224_1_);
      if (var3 != null) {
        NBTTagCompound var4 = new NBTTagCompound();
        NBTTagCompound var5 = (NBTTagCompound) var4.copy();
        var3.writeToNBT(var4);
        NBTTagCompound var6 =
            (NBTTagCompound) p_179224_2_.getTagCompound().getTag("BlockEntityTag");
        var4.merge(var6);
        var4.setInteger("x", p_179224_1_.getX());
        var4.setInteger("y", p_179224_1_.getY());
        var4.setInteger("z", p_179224_1_.getZ());
        if (!var4.equals(var5)) {
          var3.readFromNBT(var4);
          var3.markDirty();
          return true;
        }
      }
    }

    return false;
  }
コード例 #5
0
 /**
  * Determines if the two specified tags are equal.
  *
  * @param nbt1 First tag compound to compare
  * @param nbt2 Second tag compound to compare
  * @return true if they are equal; false otherwise
  */
 public static boolean areTagsEqual(final NBTTagCompound nbt1, final NBTTagCompound nbt2) {
   return nbt1 == null && nbt2 != null ? false : nbt1 == null || nbt1.equals(nbt2);
 }
コード例 #6
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]);
      }
    }
  }