ItemRef( final ItemStack stack ) { this.ref = stack.getItem(); if( stack.getItem().isDamageable() ) { this.damage = 0; // IGNORED } else { this.damage = stack.getItemDamage(); // might be important... } this.hash = this.ref.hashCode() ^ this.damage; }
public TileItemGen() { if( POSSIBLE_ITEMS.isEmpty() ) { for( final Object obj : Item.REGISTRY ) { final Item mi = (Item) obj; if( mi != null && mi != Items.AIR ) { if( mi.isDamageable() ) { for( int dmg = 0; dmg < mi.getMaxDamage(); dmg++ ) { POSSIBLE_ITEMS.add( new ItemStack( mi, 1, dmg ) ); } } else { final NonNullList<ItemStack> list = NonNullList.create(); mi.getSubItems( mi.getCreativeTab(), list ); POSSIBLE_ITEMS.addAll( list ); } } } } }
IAEItemStack getAmountCrafted( IAEItemStack what2 ) { for( final IAEItemStack is : this.details.getCondensedOutputs() ) { if( is.equals( what2 ) ) { what2 = what2.copy(); what2.setStackSize( is.getStackSize() ); return what2; } } // more fuzzy! for( final IAEItemStack is : this.details.getCondensedOutputs() ) { if( is.getItem() == what2.getItem() && ( is.getItem().isDamageable() || is.getItemDamage() == what2.getItemDamage() ) ) { what2 = is.copy(); what2.setStackSize( is.getStackSize() ); return what2; } } throw new IllegalStateException( "Crafting Tree construction failed." ); }
if( a.getItem() == b.getItem() && a.getItem().isDamageable() )
private boolean fuzzyItemStackComparison( ItemStack a, ItemStack b, FuzzyMode mode ) { if( a.getItem() == b.getItem() ) { if( a.getItem().isDamageable() ) { if( mode == FuzzyMode.IGNORE_ALL ) { return true; } else if( mode == FuzzyMode.PERCENT_99 ) { return ( a.getItemDamage() > 1 ) == ( b.getItemDamage() > 1 ); } else { final float percentDamageOfA = (float) a.getItemDamage() / (float) a.getMaxDamage(); final float percentDamageOfB = (float) b.getItemDamage() / (float) b.getMaxDamage(); return ( percentDamageOfA > mode.breakPoint ) == ( percentDamageOfB > mode.breakPoint ); } } return a.getMetadata() == b.getMetadata(); } return false; }
@Override public boolean apply(@Nullable Item item) { return NullHelper.notnullM(item, "EnumEnchantmentType.canEnchantItem(null)").isDamageable() && !(item instanceof ItemArmor) && !(item instanceof ItemSword) && !(item instanceof ItemBow) && !(item instanceof ItemFishingRod); }
@Override public boolean apply(@Nullable Item item) { return NullHelper.notnullM(item, "EnumEnchantmentType.canEnchantItem(null)").isDamageable() && !(item instanceof ItemArmor) && !(item instanceof ItemFishingRod); }
if( newDef.getItem().isDamageable() )
if( newDef.getItem().isDamageable() )
public static boolean canDamage(@Nonnull ItemStack stack) { return stack.isItemStackDamageable() && stack.getItem().isDamageable(); }
protected @Nonnull ItemStack mkItemStack(@Nonnull ItemStack target, @Nonnull Block targetBlock) { Item itemFromBlock = Item.getItemFromBlock(targetBlock); if (itemFromBlock.isDamageable() || itemFromBlock.getHasSubtypes()) { return new ItemStack(targetBlock, 1, target.getItemDamage()); } else { return new ItemStack(targetBlock, 1, 0); } }
if( target.isDamageable() && target.isRepairable() )
private @Nonnull static LootEntry createLootEntry(@Nonnull Item item, int meta, int minStackSize, int maxStackSize, float chance) { LootCondition[] chanceCond = new LootCondition[] { new RandomChance(chance) }; final ResourceLocation registryName = NullHelper.notnull(item.getRegistryName(), "found unregistered item"); if (item.isDamageable()) { return new LootEntryItem(item, 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setDamage(item, meta), setEnergy() }, chanceCond, registryName.toString() + ":" + meta); } else { return new LootEntryItem(item, 1, 1, new LootFunction[] { setCount(minStackSize, maxStackSize), setMetadata(meta) }, chanceCond, registryName.toString() + ":" + meta); } }
public boolean isBlacklisted(World world, EntityPlayer player, ItemStack stack) { if (stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock)stack.getItem()).getBlock(); if (block.hasTileEntity(block.getStateForPlacement(world, BlockPos.ORIGIN, EnumFacing.DOWN, 0F, 0F, 0F, stack.getItemDamage(), player, stack))) return true; } return registry.getValueOf(stack) == null && (stack.getItem().isDamageable() || blacklist.contains(stack)); }
public boolean CanExtract(ItemStack item) { for (int i = 0; i < _filterInventory.getSizeInventory(); i++) { ItemStack stack = _filterInventory.getStackInSlot(i); if ((stack != null) && (stack.getItem() == item.getItem())) { if (item.getItem().isDamageable()) { return areItemsIncluded(); } if (stack.getItemDamage() == item.getItemDamage()) { return areItemsIncluded(); } } } return !areItemsIncluded(); }
@Override public NonNullList<ItemStack> getRemainingItems(final InventoryCrafting inventoryCrafting) { final NonNullList<ItemStack> remainingItems = NonNullList.withSize(inventoryCrafting.getSizeInventory(), ItemStack.EMPTY); for(int i = 0; i < remainingItems.size(); ++i) { final ItemStack itemstack = inventoryCrafting.getStackInSlot(i); if(!itemstack.isEmpty() && itemstack.getItem().isDamageable()) { remainingItems.set(i, damageTool(itemstack.copy())); } else { remainingItems.set(i, ForgeHooks.getContainerItem(itemstack)); } } return remainingItems; }
return stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == stack2.getItemDamage() || stack1.getItem().isDamageable() || stack1.getItemDamage() == OreDictionary.WILDCARD_VALUE);
@Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); if (!state.getValue(LIT) && isFireStarter(stack)) { if (world.isRemote) { return true; } world.setBlockState(pos, state.withProperty(LIT, true)); if (stack.getItem().isDamageable()) { stack.damageItem(1, player); } world.playSound(null, pos, SoundEvents.BLOCK_FIRE_AMBIENT, SoundCategory.PLAYERS, 1, 1); return true; } else if (state.getValue(LIT) && stack.getItem() == Items.WATER_BUCKET) { if (world.isRemote) { return true; } world.setBlockState(pos, state.withProperty(LIT, false)); if (!player.capabilities.isCreativeMode) { player.setHeldItem(hand, new ItemStack(Items.BUCKET)); } world.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.PLAYERS, 0.5f, 1); } return super.onBlockActivated(world, pos, state, player, hand, facing, hitX, hitY, hitZ); }
ItemStack took = network.extractItem(possibility, 1, IComparer.COMPARE_NBT | (possibility.getItem().isDamageable() ? 0 : IComparer.COMPARE_DAMAGE), Action.PERFORM); for (ItemStack possibility : possibilities) { for (int j = 0; j < player.inventory.getSizeInventory(); ++j) { if (API.instance().getComparer().isEqual(possibility, player.inventory.getStackInSlot(j), IComparer.COMPARE_NBT | (possibility.getItem().isDamageable() ? 0 : IComparer.COMPARE_DAMAGE))) { grid.getCraftingMatrix().setInventorySlotContents(i, ItemHandlerHelper.copyStackWithSize(player.inventory.getStackInSlot(j), 1));
if (target.isDamageable() && target.isRepairable()) { boolean isBad = false; for (int x = 0; x < ic.getSizeInventory(); x++) {