Exemplo n.º 1
0
 @Override
 public int hashCode() {
   int hash = 7;
   hash = 41 * hash + stack.getItem().hashCode();
   hash = 41 * hash + stack.getItemDamage();
   hash = 41 * hash + stack.getCount();
   hash = 41 * hash + (stack.getTagCompound() == null ? 0 : stack.getTagCompound().hashCode());
   hash = 41 * hash + (this.wildcardSize ? 1 : 0);
   return hash;
 }
Exemplo n.º 2
0
  @Override
  public IData getTag() {
    if (tag == null) {
      if (stack.getTagCompound() == null) {
        return DataMap.EMPTY;
      }

      tag = NBTConverter.from(stack.getTagCompound(), true);
    }
    return tag;
  }
Exemplo n.º 3
0
 @Override
 public boolean matches(IItemStack item) {
   ItemStack internal = getItemStack(item);
   return internal != null
       && stack != null
       && internal.getItem() == stack.getItem()
       && (wildcardSize || internal.getCount() >= stack.getCount())
       && (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE
           || stack.getItemDamage() == internal.getItemDamage()
           || (!stack.getHasSubtypes() && !stack.getItem().isDamageable()));
 }
Exemplo n.º 4
0
 @Override
 public ILiquidStack getLiquid() {
   if (stack.getItem() instanceof ItemFluidContainer) {
     return new MCLiquidStack(
         stack
             .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null)
             .getTankProperties()[0]
             .getContents());
   }
   //		FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
   return null;
 }
Exemplo n.º 5
0
  @Override
  public IItemStack updateTag(IData tagUpdate) {
    if (tag == null) {
      if (stack.getTagCompound() == null) {
        return withTag(tagUpdate);
      }

      tag = NBTConverter.from(stack.getTagCompound(), true);
    }

    IData updated = tag.update(tagUpdate);
    return withTag(updated);
  }
Exemplo n.º 6
0
  public MCItemStack(ItemStack itemStack) {
    //		if(itemStack.isEmpty())
    //			throw new IllegalArgumentException("stack cannot be null");

    stack = itemStack.copy();
    items = Collections.singletonList(this);
  }
Exemplo n.º 7
0
 @Override
 public IBlock asBlock() {
   ResourceLocation name =
       Block.REGISTRY.getNameForObject(Block.getBlockFromItem(stack.getItem()));
   if (Block.REGISTRY.containsKey(name)) {
     return new MCItemBlock(stack);
   } else {
     throw new ClassCastException("This item is not a block");
   }
 }
Exemplo n.º 8
0
  @Override
  public IItemStack removeTag(String tag) {
    ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), stack.getItemDamage());

    if (tag == null) {
      result.setTagCompound(null);
    } else {
      result.getTagCompound().removeTag(tag);
    }
    IData dataTag = NBTConverter.from(result.getTagCompound(), false);
    return new MCItemStack(result, dataTag);
  }
Exemplo n.º 9
0
 @Override
 public IItemStack withTag(IData tag) {
   ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), stack.getItemDamage());
   if (tag == null) {
     result.setTagCompound(null);
   } else {
     result.setTagCompound((NBTTagCompound) NBTConverter.from(tag));
   }
   return new MCItemStack(result, tag);
 }
Exemplo n.º 10
0
 @Override
 public IItemStack withDamage(int damage) {
   if (stack.getItem().getHasSubtypes()) {
     MineTweakerAPI.logWarning("subitems don't have damaged states");
     return this;
   } else {
     ItemStack result = new ItemStack(stack.getItem(), stack.getCount(), damage);
     result.setTagCompound(stack.getTagCompound());
     return new MCItemStack(result, tag);
   }
 }
Exemplo n.º 11
0
 @Override
 public IIngredient anyDamage() {
   if (stack.getItem().getHasSubtypes()) {
     MineTweakerAPI.logWarning("subitems don't have damaged states");
     return this;
   } else {
     ItemStack result =
         new ItemStack(stack.getItem(), stack.getCount(), OreDictionary.WILDCARD_VALUE);
     result.setTagCompound(stack.getTagCompound());
     return new MCItemStack(result, tag);
   }
 }
Exemplo n.º 12
0
  @Override
  public List<IOreDictEntry> getOres() {
    List<IOreDictEntry> result = new ArrayList<>();

    for (String key : OreDictionary.getOreNames()) {
      for (ItemStack is : OreDictionary.getOres(key)) {
        if (is.getItem() == stack.getItem()
            && (is.getItemDamage() == OreDictionary.WILDCARD_VALUE
                || is.getItemDamage() == stack.getItemDamage())) {
          result.add(MineTweakerAPI.oreDict.get(key));
          break;
        }
      }
    }

    return result;
  }
Exemplo n.º 13
0
  @Override
  public String toString() {
    StringBuilder result = new StringBuilder();
    result.append('<');
    result.append(Item.REGISTRY.getNameForObject(stack.getItem()));

    if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
      result.append(":*");
    } else if (stack.getItemDamage() > 0) {
      result.append(':').append(stack.getItemDamage());
    }
    result.append('>');

    if (stack.getTagCompound() != null) {
      result.append(".withTag(");
      result.append(NBTConverter.from(stack.getTagCompound(), wildcardSize).toString());
      result.append(")");
    }

    return result.toString();
  }
Exemplo n.º 14
0
 @Override
 public int getMaxDamage() {
   return stack.getMaxDamage();
 }
Exemplo n.º 15
0
 @Override
 public boolean matchesExact(IItemStack item) {
   ItemStack internal = getItemStack(item);
   if (internal.getTagCompound() != null && stack.getTagCompound() == null) {
     return false;
   }
   if (internal.getTagCompound() == null && stack.getTagCompound() != null) {
     return false;
   }
   if (internal.getTagCompound() == null && stack.getTagCompound() == null) {
     return stack.getItem() == internal.getItem()
         && (internal.getMetadata() == 32767 || stack.getMetadata() == internal.getMetadata());
   }
   if (internal.getTagCompound().getKeySet().equals(stack.getTagCompound().getKeySet())) {
     for (String s : internal.getTagCompound().getKeySet()) {
       if (!internal.getTagCompound().getTag(s).equals(stack.getTagCompound().getTag(s))) {
         return false;
       }
     }
   }
   return stack.getItem() == internal.getItem()
       && (internal.getMetadata() == 32767 || stack.getMetadata() == internal.getMetadata());
 }
Exemplo n.º 16
0
 @Override
 public IItemStack anyAmount() {
   ItemStack result = new ItemStack(stack.getItem(), 1, stack.getItemDamage());
   result.setTagCompound(stack.getTagCompound());
   return new MCItemStack(result, tag, true);
 }
Exemplo n.º 17
0
 @Override
 public int getDamage() {
   return stack.getItemDamage();
 }
Exemplo n.º 18
0
 @Override
 public String getDisplayName() {
   return stack.getDisplayName();
 }
Exemplo n.º 19
0
 @Override
 public IItemDefinition getDefinition() {
   return new MCItemDefinition(
       Item.REGISTRY.getNameForObject(stack.getItem()).toString(), stack.getItem());
 }
Exemplo n.º 20
0
 @Override
 public IItemStack withAmount(int amount) {
   ItemStack result = new ItemStack(stack.getItem(), amount, stack.getItemDamage());
   result.setTagCompound(stack.getTagCompound());
   return new MCItemStack(result, tag);
 }
Exemplo n.º 21
0
 @Override
 public String getName() {
   return stack.getUnlocalizedName();
 }
Exemplo n.º 22
0
 @Override
 public int getAmount() {
   return stack.getCount();
 }
Exemplo n.º 23
0
 @Override
 public int getMaxStackSize() {
   return stack.getMaxStackSize();
 }
Exemplo n.º 24
0
 @Override
 public float getBlockHardness() {
   return ReflectionHelper.getPrivateValue(
       Block.class, Block.getBlockFromItem(stack.getItem()), "blockHardness");
 }