private void addStack(ItemStack stack) { if(stack.isEmpty()) return; for(ItemStack oStack : materials) if(oStack.isItemEqual(stack) && ItemStack.areItemStackTagsEqual(oStack, stack)) { oStack.grow(stack.getCount()); return; } materials.add(stack); }
@Override public boolean useItem(BlockVector3 position, BaseItem item, Direction face) { Item nativeItem = Item.getByNameOrId(item.getType().getId()); ItemStack stack = null; if (item.getNbtData() == null) { stack = new ItemStack(nativeItem, 1, 0); } else { stack = new ItemStack(nativeItem, 1, 0, NBTConverter.toNative(item.getNbtData())); } World world = getWorld(); EnumActionResult used = stack.onItemUse(new WorldEditFakePlayer((WorldServer) world), world, ForgeAdapter.toBlockPos(position), EnumHand.MAIN_HAND, ForgeAdapter.adapt(face), 0, 0, 0); return used != EnumActionResult.FAIL; }
@Override public ItemStack getItemStack( final PartItemStack type ) { if( type == PartItemStack.NETWORK ) { final ItemStack copy = this.is.copy(); copy.setTagCompound( null ); return copy; } return this.is; }
@Override public ItemStack getContainerItem( final ItemStack itemStack ) { ItemStack copy = itemStack.copy(); copy.setItemDamage( itemStack.getItemDamage() + 1 ); return copy; }
private static String getMagnetKey(ItemStack stack) { if(stack.isEmpty()) return ""; return "i_" + stack.getItem().getTranslationKey() + "@" + stack.getItemDamage(); }
public static String stackToString(ItemStack stack, boolean forceIgnore) { if(stack.isEmpty()) return "NULL"; if(stack.hasTagCompound() && stack.getItem() instanceof IRecipeKeyProvider) return ((IRecipeKeyProvider) stack.getItem()).getKey(stack); return stack.getTranslationKey() + (forceIgnore || ignoreMeta(stack) ? "" : "~" + stack.getItemDamage()); }
@Override public void giveItem(BaseItemStack itemStack) { this.player.inventory.addItemStackToInventory( new ItemStack(Item.getByNameOrId(itemStack.getType().getId()), itemStack.getAmount(), 0)); }
public Bounds( final ItemStack stack, final FuzzyMode fuzzy, final boolean ignoreMeta ) { Preconditions.checkState( !stack.isEmpty(), "ItemStack#isEmpty() has to be false" ); Preconditions.checkState( stack.getCount() == 1, "ItemStack#getCount() has to be 1" ); final NBTTagCompound tag = stack.hasTagCompound() ? stack.getTagCompound() : null; this.lower = this.makeLowerBound( stack, tag, fuzzy, ignoreMeta ); this.upper = this.makeUpperBound( stack, tag, fuzzy, ignoreMeta ); }
public void populateDropStackNBTs(List<ItemStack> drops) { if(isPassiveFlower() && ticksExisted > 0 && BotaniaAPI.internalHandler.getPassiveFlowerDecay() > 0) { ItemStack drop = drops.get(0); if(!drop.isEmpty()) { if(!drop.hasTagCompound()) drop.setTagCompound(new NBTTagCompound()); NBTTagCompound cmp = drop.getTagCompound(); cmp.setInteger(TAG_PASSIVE_DECAY_TICKS, passiveDecayTicks); } } }
public static boolean isItemBlacklistedFromMagnet(ItemStack stack, int recursion) { if(recursion > 5) return false; if(stack.getItemDamage() != Short.MAX_VALUE) { ItemStack copy = new ItemStack(stack.getItem(), 0, Short.MAX_VALUE); boolean general = isItemBlacklistedFromMagnet(copy, recursion + 1); if(general) return true; } String key = getMagnetKey(stack); return magnetBlacklist.contains(key); }
@Override public int hashCode() { return Objects.hash( this.itemId, this.itemDamage, this.itemStack.hasTagCompound() ? this.itemStack.getTagCompound() : 0 ); }
@SubscribeEvent public static void onDrops(LivingDropsEvent event) { if(event.getEntityLiving() instanceof EntityBlaze && event.getEntityLiving().getEntityData().getBoolean(TAG_FEL_SPAWNED)) if(event.getDrops().isEmpty()) event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(Items.BLAZE_POWDER, 6))); else for(EntityItem item : event.getDrops()) { ItemStack stack = item.getItem(); if(stack.getItem() == Items.BLAZE_ROD) item.setItem(new ItemStack(Items.BLAZE_POWDER, stack.getCount() * 10)); } }
@Override public void onEquipped(ItemStack stack, EntityLivingBase player) { super.onEquipped(stack, player); if(stack.getItemDamage() != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName(), SUPER_AWESOME_HASH)) { stack.setItemDamage(WING_TYPES); stack.getTagCompound().removeTag("display"); } }
@Override public void getDrops(NonNullList<ItemStack> stacks, IBlockAccess world, BlockPos pos, @Nonnull IBlockState state, int fortune) { TileEntity tile = world.getTileEntity(pos); if(tile != null && tile instanceof TileCacophonium) { stacks.add(new ItemStack(Blocks.NOTEBLOCK)); ItemStack thingy = ((TileCacophonium) tile).stack; if(!thingy.isEmpty()) stacks.add(thingy.copy()); } }
@Nonnull @Override public String getItemStackDisplayName(@Nonnull ItemStack par1ItemStack) { Block block = getBlock(par1ItemStack); int meta = getBlockMeta(par1ItemStack); ItemStack stack = new ItemStack(block, 1, meta); return super.getItemStackDisplayName(par1ItemStack) + (stack.isEmpty() ? "" : " (" + TextFormatting.GREEN + stack.getDisplayName() + TextFormatting.RESET + ")"); }