Java Code Examples for net.minecraft.item.ItemStack

The following are top voted examples for showing how to use net.minecraft.item.ItemStack. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Proyecto-DASI   File: MinecraftTypeHelper.java   Source Code and License 7 votes vote down vote up
/** Attempt to parse string as a Variation, allowing for block properties having different names to the enum values<br>
 * (eg blue_orchid vs orchidBlue etc.)
 * @param part the string (potentially in the 'wrong' format, eg 'orchidBlue')
 * @param is the ItemStack from which this string came (eg from is.getUnlocalisedName)
 * @return a Variation, if one exists, that matches the part string passed in, or one of the ItemStacks current property values.
 */
public static Variation attemptToGetAsVariant(String part, ItemStack is)
{
    if (is.getItem() instanceof ItemBlock)
    {
        // Unlocalised name doesn't always match the names we use in types.xsd
        // (which are the names displayed by Minecraft when using the F3 debug etc.)
        ItemBlock ib = (ItemBlock)(is.getItem());
        IBlockState bs = ib.block.getStateFromMeta(is.getMetadata());
        for (IProperty prop : (java.util.Set<IProperty>)bs.getProperties().keySet())
        { 
            Comparable<?> comp = bs.getValue(prop);
            Variation var = attemptToGetAsVariant(comp.toString());
            if (var != null)
                return var;
        }
        return null;
    }
    else
        return attemptToGetAsVariant(part);
}
 
Example 2
Project: Mods   File: ItemStatue.java   Source Code and License 6 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer playerIn, World worldIn, BlockPos pos,
		EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
	ItemStack stack = playerIn.getHeldItem(hand);
	if (!worldIn.isRemote && stack.hasTagCompound() && stack.getTagCompound().hasKey("Statue")) {
		EntityStatue statue =new EntityStatue(worldIn);
		statue.readEntityFromNBT(stack.getTagCompound().getCompoundTag("Statue"));
		BlockPos off = pos.offset(facing);
		statue.setPosition(off.getX()+0.5, off.getY(), off.getZ()+0.5);
		statue.rotationYaw = playerIn.rotationYawHead;
		statue.renderYawOffset = playerIn.rotationYawHead;

		statue.ticksLeft = -1;
		worldIn.spawnEntity(statue);
		if (!playerIn.capabilities.isCreativeMode)
			stack.shrink(1);
		return EnumActionResult.SUCCESS;
	}
	return EnumActionResult.SUCCESS;
}
 
Example 3
Project: Backmemed   File: CustomItems.java   Source Code and License 6 votes vote down vote up
public static IBakedModel getCustomItemModel(ItemStack p_getCustomItemModel_0_, IBakedModel p_getCustomItemModel_1_, ResourceLocation p_getCustomItemModel_2_)
{
    if (p_getCustomItemModel_1_.isGui3d())
    {
        return p_getCustomItemModel_1_;
    }
    else if (itemProperties == null)
    {
        return p_getCustomItemModel_1_;
    }
    else
    {
        CustomItemProperties customitemproperties = getCustomItemProperties(p_getCustomItemModel_0_, 1);
        return customitemproperties == null ? p_getCustomItemModel_1_ : customitemproperties.getModel(p_getCustomItemModel_2_);
    }
}
 
Example 4
Project: CustomWorldGen   File: CraftingManager.java   Source Code and License 6 votes vote down vote up
public ItemStack[] getRemainingItems(InventoryCrafting craftMatrix, World worldIn)
{
    for (IRecipe irecipe : this.recipes)
    {
        if (irecipe.matches(craftMatrix, worldIn))
        {
            return irecipe.getRemainingItems(craftMatrix);
        }
    }

    ItemStack[] aitemstack = new ItemStack[craftMatrix.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        aitemstack[i] = craftMatrix.getStackInSlot(i);
    }

    return aitemstack;
}
 
Example 5
Project: Loot-Slash-Conquer   File: ItemLEBauble.java   Source Code and License 6 votes vote down vote up
@Override
public void onEquipped(ItemStack stack, EntityLivingBase entity) 
{
	if (entity.getEntityWorld().isRemote) entity.playSound(SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.1F, 1.3f);
	else
	{
		if (entity instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) entity;
			PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (info != null && info.getPlayerLevel() >= NBTHelper.loadStackNBT(stack).getInteger("Level"))
			{
				EventPlayerTick.updateStats(player, info);
			}
			else player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will not provide any bonuses."));
		}
	}
}
 
Example 6
Project: minecraft-quiverbow   File: Recipe_AA_Plating.java   Source Code and License 6 votes vote down vote up
private ItemStack getAAFromMatrix(InventoryCrafting matrix)
{
	int counter = 0;
	
	while (counter < matrix.getSizeInventory())
	{
		if (matrix.getStackInSlot(counter) != null && matrix.getStackInSlot(counter).getItem() instanceof PackedUpAA)
		{
			return matrix.getStackInSlot(counter);	// Found it
		}
		
		counter += 1;
	}
	
	return null;
}
 
Example 7
Project: minecraft-quiverbow   File: Recipe_AA_Weapon.java   Source Code and License 6 votes vote down vote up
@Override
public ItemStack getCraftingResult(InventoryCrafting matrix)
   {
	ItemStack stack = this.result.copy();
	ItemStack previousAA = this.getAAFromMatrix(matrix);
	
	if (previousAA != null && previousAA.hasTagCompound())	// Copying existing properties
	{
		stack.setTagCompound((NBTTagCompound) previousAA.getTagCompound().copy());
	}
	else	// ...or just applying new ones
	{
		stack.setTagCompound(new NBTTagCompound());
	}
	
	// Apply the new upgrade now
	stack.getTagCompound().setBoolean("hasWeaponUpgrade", true);
	
	if (stack.getTagCompound().getInteger("currentHealth") == 0)	// Just making sure it's not shown with 0 health
	{
		if (stack.getTagCompound().getBoolean("hasArmorUpgrade")) { stack.getTagCompound().setInteger("currentHealth", 40); }
		else { stack.getTagCompound().setInteger("currentHealth", 20); } // Fresh turret, so setting some health
	}
	
       return stack;
   }
 
Example 8
Project: minecraft-quiverbow   File: FlintDuster.java   Source Code and License 6 votes vote down vote up
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)		// Server side
{
	// Ignoring cooldown for firing purposes

	// SFX
	world.playSoundAtEntity(entity, "mob.bat.takeoff", 0.5F, 0.6F);

	// Ready
	FlintDust shot = new FlintDust(world, entity, (float) this.Speed);

	// Properties
	shot.damage = this.Dmg;
	shot.ticksInAirMax = this.MaxBlocks;

	// Go
	world.spawnEntityInWorld(shot);

	this.consumeAmmo(stack, entity, 1);
	this.setCooldown(stack, 4);
}
 
Example 9
Project: minecraft-quiverbow   File: RPG.java   Source Code and License 6 votes vote down vote up
@Override
public void addRecipes()
{
	if (this.Enabled)
	{
		// One Firework Rocket Launcher (empty)
		GameRegistry.addRecipe(new ItemStack(this, 1 , this.getMaxDamage()), "x  ", "yx ", "zyx",
				'x', Blocks.planks,
				'y', Items.iron_ingot,
				'z', Items.flint_and_steel
				);
	}
	else if (Main.noCreative) { this.setCreativeTab(null); }	// Not enabled and not allowed to be in the creative menu

	// Fill the RPG with 1 rocket
	GameRegistry.addRecipe(new ItemStack(this), " ab", "zya", " x ",
			'x', new ItemStack(this, 1 , this.getMaxDamage()),
			'y', Blocks.tnt,
			'z', Blocks.planks,
			'a', Items.paper,
			'b', Items.string
			);
}
 
Example 10
Project: Backmemed   File: WorldClient.java   Source Code and License 6 votes vote down vote up
public void doVoidFogParticles(int posX, int posY, int posZ)
{
    int i = 32;
    Random random = new Random();
    ItemStack itemstack = this.mc.player.getHeldItemMainhand();

    if (itemstack == null || Block.getBlockFromItem(itemstack.getItem()) != Blocks.BARRIER)
    {
        itemstack = this.mc.player.getHeldItemOffhand();
    }

    boolean flag = this.mc.playerController.getCurrentGameType() == GameType.CREATIVE && !itemstack.func_190926_b() && itemstack.getItem() == Item.getItemFromBlock(Blocks.BARRIER);
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();

    for (int j = 0; j < 667; ++j)
    {
        this.showBarrierParticles(posX, posY, posZ, 16, random, flag, blockpos$mutableblockpos);
        this.showBarrierParticles(posX, posY, posZ, 32, random, flag, blockpos$mutableblockpos);
    }
}
 
Example 11
Project: pnc-repressurized   File: TileEntityPressureChamberInterface.java   Source Code and License 6 votes vote down vote up
private void importFromChamber(TileEntityPressureChamberValve core) {
    ItemStackHandler chamberStacks = core.getStacksInChamber();
    for (ItemStack chamberStack : new ItemStackHandlerIterable(chamberStacks)) {
        ItemStack inputStack = inventory.getStackInSlot(0);
        if ((inputStack.isEmpty() || inputStack.isItemEqual(chamberStack)) && filterHandler.doesItemMatchFilter(chamberStack)) {
            int maxAllowedItems = Math.abs(core.getAirHandler(null).getAir()) / PneumaticValues.USAGE_CHAMBER_INTERFACE;
            if (maxAllowedItems > 0) {
                if (!inputStack.isEmpty()) {
                    maxAllowedItems = Math.min(maxAllowedItems, chamberStack.getMaxStackSize() - inputStack.getCount());
                }
                int transferredItems = Math.min(chamberStack.getCount(), maxAllowedItems);
                ItemStack toTransferStack = chamberStack.copy().splitStack(transferredItems);
                ItemStack excess = inventory.insertItem(0, toTransferStack, true);
                if (excess.getCount() < toTransferStack.getCount()) {
                    // we can transfer at least some of the items
                    transferredItems = toTransferStack.getCount() - excess.getCount();
                    core.addAir((core.getAirHandler(null).getAir() > 0 ? -1 : 1) * transferredItems * PneumaticValues.USAGE_CHAMBER_INTERFACE);
                    toTransferStack.setCount(transferredItems);
                    inventory.insertItem(0, toTransferStack, false);
                    chamberStack.shrink(transferredItems);
                }
            }
        }
    }
}
 
Example 12
Project: FoodCraft-Reloaded   File: TileEntitySmeltingDrinkMachine.java   Source Code and License 5 votes vote down vote up
@Override
public void readFromNBT(NBTTagCompound tag) {
    super.readFromNBT(tag);
    CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().readNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, itemStackHandler, null, tag.getTag("Items"));
    progress = tag.getInteger("progress");
    fuel = tag.getInteger("fuel");
    output = new ItemStack(tag.getCompoundTag("output"));
    fluidStack = FluidStack.loadFluidStackFromNBT(tag.getCompoundTag("fluidOutput"));
}
 
Example 13
Project: pnc-repressurized   File: SemiBlockLogistics.java   Source Code and License 5 votes vote down vote up
@Override
public void addDrops(NonNullList<ItemStack> drops) {
    super.addDrops(drops);

    boolean shouldAddTag = false;
    for (int i = 0; i < filters.getSlots(); i++) {
        if (!filters.getStackInSlot(i).isEmpty()) { //Only set a tag when there are requests.
            shouldAddTag = true;
            break;
        }
    }

    for (FluidTank fluidFilter : fluidFilters) {
        if (fluidFilter.getFluidAmount() > 0) {
            shouldAddTag = true;
            break;
        }
    }

    if (invisible) shouldAddTag = true;

    if (shouldAddTag) {
        ItemStack drop = drops.get(0);
        NBTTagCompound tag = new NBTTagCompound();
        writeToNBT(tag);
        drop.setTagCompound(tag);
    }
}
 
Example 14
Project: Loot-Slash-Conquer   File: ItemGenerator.java   Source Code and License 5 votes vote down vote up
/** Creates a melee weapon/armor with randomized stats. */
public static void create(ItemStack stack, NBTTagCompound nbt, World world, ChunkPos pos)
{
	/*
	 * Set rarity
	 * Set level
	 * Generate attributes based on Rarity
	 * 		- Common: 0-1 attributes
	 * 		- Uncommon: 1-2 attributes
	 * 		- Rare: 2-3 attributes
	 * 		- Legendary: 3-4 attributes
	 * 		- Mythic: 4-5 attributes
	 * Generate base damage and base attack speed
	 * Generate name based on attributes + material/type
	 */
	
	if (Rarity.getRarity(nbt) != Rarity.DEFAULT)
	{
		IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
		IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(pos);
		int level = chunkLevel.getChunkLevel();
		
		//Rarity.setRarity(nbt, Rarity.getRandomRarity(nbt, ItemGeneratorHelper.rand)); // sets a random rarity
		ItemGeneratorHelper.setTypes(stack, nbt);
		nbt.setInteger("Level", level); // set level to current player level
		ItemGeneratorHelper.setRandomAttributes(stack, nbt, Rarity.getRarity(nbt));
		ItemGeneratorHelper.setAttributeModifiers(nbt, stack);
		nbt.setInteger("HideFlags", 6); // hides Attribute Modifier and Unbreakable tags
	}
}
 
Example 15
Project: chesttransporter   File: ItemChestTransporter.java   Source Code and License 5 votes vote down vote up
private void damageItem(ItemStack stack, EntityPlayer player)
{
    if (!player.capabilities.isCreativeMode)
    {
        stack.damageItem(1, player);
        if (type.maxDamage == 1)
            stack.damageItem(1, player);
    }
}
 
Example 16
Project: Backmemed   File: Bootstrap.java   Source Code and License 5 votes vote down vote up
protected ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
    Block block = Block.getBlockFromItem(stack.getItem());
    World world = source.getWorld();
    EnumFacing enumfacing = (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING);
    BlockPos blockpos = source.getBlockPos().offset(enumfacing);
    this.field_190911_b = world.func_190527_a(block, blockpos, false, EnumFacing.DOWN, (Entity)null);

    if (this.field_190911_b)
    {
        EnumFacing enumfacing1 = world.isAirBlock(blockpos.down()) ? enumfacing : EnumFacing.UP;
        IBlockState iblockstate = block.getDefaultState().withProperty(BlockShulkerBox.field_190957_a, enumfacing1);
        world.setBlockState(blockpos, iblockstate);
        TileEntity tileentity = world.getTileEntity(blockpos);
        ItemStack itemstack = stack.splitStack(1);

        if (itemstack.hasTagCompound())
        {
            ((TileEntityShulkerBox)tileentity).func_190586_e(itemstack.getTagCompound().getCompoundTag("BlockEntityTag"));
        }

        if (itemstack.hasDisplayName())
        {
            ((TileEntityShulkerBox)tileentity).func_190575_a(itemstack.getDisplayName());
        }

        world.updateComparatorOutputLevel(blockpos, iblockstate.getBlock());
    }

    return stack;
}
 
Example 17
Project: harshencastle   File: HarshenRegistry.java   Source Code and License 5 votes vote down vote up
@Override
public CauldronLiquid registerCauldronLiquid(ItemStack fullItem, ItemStack emptyItem, CauldronLiquid liquid, int fillBy) {
	fillBy = MathHelper.clamp(fillBy, 1, 3);
	liquid.setModID(modID);
	if(emptyItem == null || emptyItem.isEmpty())
		return registerItemLiquid(fullItem, liquid);
	INPUT_FILLBY.put(fullItem, fillBy);
	OUTPUT_FILLBY.put(emptyItem, fillBy);
	INPUT_MAP.put(fullItem, liquid);
	OUTPUT_MAP.put(liquid, emptyItem);
	return liquid;
}
 
Example 18
Project: CustomWorldGen   File: EntitySheep.java   Source Code and License 5 votes vote down vote up
@Override
public java.util.List<ItemStack> onSheared(ItemStack item, net.minecraft.world.IBlockAccess world, BlockPos pos, int fortune)
{
    this.setSheared(true);
    int i = 1 + this.rand.nextInt(3);

    java.util.List<ItemStack> ret = new java.util.ArrayList<ItemStack>();
    for (int j = 0; j < i; ++j)
        ret.add(new ItemStack(Item.getItemFromBlock(Blocks.WOOL), 1, this.getFleeceColor().getMetadata()));

    this.playSound(SoundEvents.ENTITY_SHEEP_SHEAR, 1.0F, 1.0F);
    return ret;
}
 
Example 19
Project: BetterBeginningsReborn   File: KilnRecipeHandler.java   Source Code and License 5 votes vote down vote up
public static void removeRecipe(RecipeElement input, ItemStack output)
{
    ItemStack result = instance().smeltingList.get(input);
    if(instance().smeltingList.containsKey(input) && ItemStack.areItemStacksEqual(result, output)) return;
    {
	instance().experienceList.remove(result);
	instance().smeltingList.remove(input);
    }
}
 
Example 20
Project: ExPetrum   File: ItemRock.java   Source Code and License 5 votes vote down vote up
@Override
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems)
{
	if (tab != this.getCreativeTab())
	{
		return;
	}

	Stream.of(EnumRockClass.values()).forEach(c -> subItems.add(new ItemStack(this, 1, c.ordinal())));
}
 
Example 21
Project: BaseClient   File: EntityPlayer.java   Source Code and License 5 votes vote down vote up
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
    super.writeEntityToNBT(tagCompound);
    tagCompound.setTag("Inventory", this.inventory.writeToNBT(new NBTTagList()));
    tagCompound.setInteger("SelectedItemSlot", this.inventory.currentItem);
    tagCompound.setBoolean("Sleeping", this.sleeping);
    tagCompound.setShort("SleepTimer", (short)this.sleepTimer);
    tagCompound.setFloat("XpP", this.experience);
    tagCompound.setInteger("XpLevel", this.experienceLevel);
    tagCompound.setInteger("XpTotal", this.experienceTotal);
    tagCompound.setInteger("XpSeed", this.xpSeed);
    tagCompound.setInteger("Score", this.getScore());

    if (this.spawnChunk != null)
    {
        tagCompound.setInteger("SpawnX", this.spawnChunk.getX());
        tagCompound.setInteger("SpawnY", this.spawnChunk.getY());
        tagCompound.setInteger("SpawnZ", this.spawnChunk.getZ());
        tagCompound.setBoolean("SpawnForced", this.spawnForced);
    }

    this.foodStats.writeNBT(tagCompound);
    this.capabilities.writeCapabilitiesToNBT(tagCompound);
    tagCompound.setTag("EnderItems", this.theInventoryEnderChest.saveInventoryToNBT());
    ItemStack itemstack = this.inventory.getCurrentItem();

    if (itemstack != null && itemstack.getItem() != null)
    {
        tagCompound.setTag("SelectedItem", itemstack.writeToNBT(new NBTTagCompound()));
    }
}
 
Example 22
Project: SimpleTubes   File: SimpleTubes.java   Source Code and License 5 votes vote down vote up
public void displayAllRelevantItems(NonNullList<ItemStack> list) {
	//Blocks
	list.add(new ItemStack(proxy.blockTube, 1, 0));
	list.add(new ItemStack(proxy.blockDisplacer, 1, 0));
	
	//Items
	for (int i = 0; i < 17; i++)
		list.add(new ItemStack(proxy.itemPaintbrush, 1, i));

	list.add(new ItemStack(proxy.itemUpgrade, 1, 0));
}
 
Example 23
Project: BaseClient   File: InventoryPlayer.java   Source Code and License 5 votes vote down vote up
public boolean canHeldItemHarvest(Block blockIn)
{
    if (blockIn.getMaterial().isToolNotRequired())
    {
        return true;
    }
    else
    {
        ItemStack itemstack = this.getStackInSlot(this.currentItem);
        return itemstack != null ? itemstack.canHarvestBlock(blockIn) : false;
    }
}
 
Example 24
Project: CustomWorldGen   File: EntityMinecartContainer.java   Source Code and License 5 votes vote down vote up
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 */
protected void readEntityFromNBT(NBTTagCompound compound)
{
    super.readEntityFromNBT(compound);
    this.minecartContainerItems = new ItemStack[this.getSizeInventory()];

    if (compound.hasKey("LootTable", 8))
    {
        this.lootTable = new ResourceLocation(compound.getString("LootTable"));
        this.lootTableSeed = compound.getLong("LootTableSeed");
    }
    else
    {
        NBTTagList nbttaglist = compound.getTagList("Items", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i);
            int j = nbttagcompound.getByte("Slot") & 255;

            if (j >= 0 && j < this.minecartContainerItems.length)
            {
                this.minecartContainerItems[j] = ItemStack.loadItemStackFromNBT(nbttagcompound);
            }
        }
    }
}
 
Example 25
Project: Thermionics   File: ItemChunkUnloader.java   Source Code and License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
	tooltip.add(I18n.translateToLocal("item.thermionics.chunkunloader.tip"));
	int loadedState = stack.getItemDamage();
	switch(loadedState) {
	default: //Default to unattuned
		
	case 0: tooltip.add(I18n.translateToLocalFormatted("thermionics.data.chunkunloader.unattuned")); break;
	case 1: tooltip.add(I18n.translateToLocalFormatted("thermionics.data.chunkunloader.unloaded")); break;
	case 2: tooltip.add(I18n.translateToLocalFormatted("thermionics.data.chunkunloader.loaded")); break;
	}
}
 
Example 26
Project: connor41-etfuturum2   File: TippedArrow.java   Source Code and License 5 votes vote down vote up
public static ItemStack setEffect(ItemStack stack, Potion potion, int duration) {
	stack.setTagCompound(new NBTTagCompound());
	NBTTagCompound nbt = new NBTTagCompound();
	stack.getTagCompound().setTag("Potion", nbt);

	PotionEffect effect = new PotionEffect(potion.getId(), potion.isInstant() ? 1 : duration);
	effect.writeCustomPotionEffectToNBT(nbt);

	return stack;
}
 
Example 27
Project: Backmemed   File: TileEntityDispenser.java   Source Code and License 5 votes vote down vote up
public boolean func_191420_l()
{
    for (ItemStack itemstack : this.stacks)
    {
        if (!itemstack.func_190926_b())
        {
            return false;
        }
    }

    return true;
}
 
Example 28
Project: Whoosh   File: ItemTransporter.java   Source Code and License 5 votes vote down vote up
@Override
public boolean decrMode(ItemStack stack) {

    if (!stack.hasTagCompound()) {
        stack.setTagCompound(new NBTTagCompound());
    }
    int curMode = getMode(stack);
    curMode--;
    if (curMode <= 0) {
        curMode = getNumModes(stack) - 1;
    }
    stack.getTagCompound().setInteger("Mode", curMode);
    return true;
}
 
Example 29
Project: Industrial-Foregoing   File: EnchantmentInvokerBlock.java   Source Code and License 5 votes vote down vote up
public void createRecipe() {
    RecipeUtils.addShapedRecipe(new ItemStack(this), "pbp", "dmd", "ooo",
            'p', ItemRegistry.plastic,
            'b', Items.BOOK,
            'd', "gemDiamond",
            'm', MachineCaseItem.INSTANCE,
            'o', Blocks.OBSIDIAN);
}
 
Example 30
Project: Industrial-Foregoing   File: PageItemList.java   Source Code and License 5 votes vote down vote up
public static List<PageItemList> generatePagesFromItemStacks(List<ItemStack> stacks, String display) {
    List<PageItemList> pages = new ArrayList<>();
    while (stacks.size() > 49) {
        pages.add(new PageItemList(stacks.subList(0, 49), display));
        stacks = stacks.subList(49, stacks.size());
    }
    pages.add(new PageItemList(stacks, display));
    return pages;
}
 
Example 31
Project: ModularMachinery   File: ItemBlockMachineComponent.java   Source Code and License 5 votes vote down vote up
@Override
public int getColorFromItemstack(ItemStack stack, int tintIndex) {
    if(stack.isEmpty()) {
        return 0;
    }
    return Config.machineColor;
}
 
Example 32
Project: pnc-repressurized   File: TileEntityOmnidirectionalHopper.java   Source Code and License 5 votes vote down vote up
protected boolean doImport(int maxItems) {
    boolean success = false;

    // Suck from input inventory
    IItemHandler handler = IOHelper.getInventoryForTE(IOHelper.getNeighbor(this, inputDir));
    if (handler != null) {
        for (int i = 0; i < maxItems; i++) {
            LocatedItemStack extracted = IOHelper.extractOneItem(handler, true);
            if (!extracted.stack.isEmpty()) {
                ItemStack excess = ItemHandlerHelper.insertItem(inventory, extracted.stack, false);
                if (excess.isEmpty()) {
                    handler.extractItem(extracted.slot, 1, false);
                    success = true;
                } else {
                    break;
                }
            } else {
                break;
            }
        }
    }

    // Suck in item entities
    for (EntityItem entity : getNeighborItems(this, inputDir)) {
        if (!entity.isDead) {
            ItemStack remainder = IOHelper.insert(this, entity.getItem(), null, false);
            if (remainder.isEmpty()) {
                entity.setDead();
                success = true;
            }
        }
    }

    return success;
}
 
Example 33
Project: Firma   File: ClayBlock2.java   Source Code and License 5 votes vote down vote up
@Override
public String getSpecialName(ItemStack stack) {
	if (stack == null) {
		throw new NullPointerException();
	}
	return RockEnum2.getName(stack.getMetadata());
}
 
Example 34
Project: harshencastle   File: JEIRitualWrapper.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("unchecked")
public JEIRitualWrapper(RitualRecipes recipe) {
	ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
	for(HarshenStack hStack : recipe.getInputs())
		builder.add(hStack.getStackList());
	input = builder.build();
	output = recipe.getOutput();
}
 
Example 35
Project: pnc-repressurized   File: NetworkConnectionAIHandler.java   Source Code and License 5 votes vote down vote up
public NetworkConnectionAIHandler(GuiSecurityStationBase gui, TileEntitySecurityStation station, int baseX,
                                  int baseY, int nodeSpacing, int color) {
    super(gui, station, baseX, baseY, nodeSpacing, color, TileEntityConstants.NETWORK_AI_BRIDGE_SPEED);
    for (int i = 0; i < station.getPrimaryInventory().getSlots(); i++) {
        ItemStack stack = station.getPrimaryInventory().getStackInSlot(i);
        if (stack.getItemDamage() == ItemNetworkComponents.DIAGNOSTIC_SUBROUTINE) {
            slotHacked[i] = true;
        }
    }
}
 
Example 36
Project: ThermionicsWorld   File: ThermionicsWorld.java   Source Code and License 5 votes vote down vote up
public static void addMeatCompressionRecipe(IForgeRegistry<IRecipe> registry, EnumEdibleMeat meat, boolean cooked, ItemStack ingredient) {
	ResourceLocation group = new ResourceLocation("thermionics_world", "compress.meat");
	Ingredient input = Ingredient.fromStacks(ingredient);
	ShapedRecipes recipe = 
			new ShapedRecipes(group.toString(), 3, 3,
			NonNullList.withSize(3*3, input),
			new ItemStack(TWBlocks.MEAT_EDIBLE, 1, BlockMeatEdible.getMetaFromValue(meat, cooked)) );
	recipe.setRegistryName(new ResourceLocation("thermionics_world", meat.getName()+((cooked)?".cooked":".raw")+"_CompressToBlock"));
	registry.register(recipe);
}
 
Example 37
Project: Backmemed   File: RecipesMapCloning.java   Source Code and License 5 votes vote down vote up
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    int i = 0;
    ItemStack itemstack = ItemStack.field_190927_a;

    for (int j = 0; j < inv.getSizeInventory(); ++j)
    {
        ItemStack itemstack1 = inv.getStackInSlot(j);

        if (!itemstack1.func_190926_b())
        {
            if (itemstack1.getItem() == Items.FILLED_MAP)
            {
                if (!itemstack.func_190926_b())
                {
                    return false;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.MAP)
                {
                    return false;
                }

                ++i;
            }
        }
    }

    return !itemstack.func_190926_b() && i > 0;
}
 
Example 38
Project: BaseClient   File: TileEntityHopper.java   Source Code and License 5 votes vote down vote up
private boolean transferItemsOut()
{
    IInventory iinventory = this.getInventoryForHopperTransfer();

    if (iinventory == null)
    {
        return false;
    }
    else
    {
        EnumFacing enumfacing = BlockHopper.getFacing(this.getBlockMetadata()).getOpposite();

        if (this.isInventoryFull(iinventory, enumfacing))
        {
            return false;
        }
        else
        {
            for (int i = 0; i < this.getSizeInventory(); ++i)
            {
                if (this.getStackInSlot(i) != null)
                {
                    ItemStack itemstack = this.getStackInSlot(i).copy();
                    ItemStack itemstack1 = putStackInInventoryAllSlots(iinventory, this.decrStackSize(i, 1), enumfacing);

                    if (itemstack1 == null || itemstack1.stackSize == 0)
                    {
                        iinventory.markDirty();
                        return true;
                    }

                    this.setInventorySlotContents(i, itemstack);
                }
            }

            return false;
        }
    }
}
 
Example 39
Project: pnc-repressurized   File: JEI.java   Source Code and License 5 votes vote down vote up
@Override
public void register(IModRegistry registry) {
    IJeiHelpers jeiHelpers = registry.getJeiHelpers();

    registry.addRecipes(BasicThermopneumaticProcessingPlantRecipe.recipes, ModCategoryUid.THERMO_PNEUMATIC);
    registry.addRecipes(PressureChamberRecipe.chamberRecipes, ModCategoryUid.PRESSURE_CHAMBER);
    registry.addRecipes(new JEIPlasticMixerCategory(jeiHelpers).getAllRecipes(), ModCategoryUid.PLASTIC_MIXER);
    registry.addRecipes(new JEIRefineryCategory(jeiHelpers).getAllRecipes(), ModCategoryUid.REFINERY);
    registry.addRecipes(new JEIEtchingAcidCategory(jeiHelpers).getAllRecipes(), ModCategoryUid.ETCHING_ACID);
    registry.addRecipes(new JEICompressedIronCategory(jeiHelpers).getAllRecipes(), ModCategoryUid.COMPRESSED_IRON_EXPLOSION);
    registry.addRecipes(new JEIUVLightBoxCategory(jeiHelpers).getAllRecipes(), ModCategoryUid.UV_LIGHT_BOX);
    registry.addRecipes(AssemblyRecipe.drillRecipes, ModCategoryUid.ASSEMBLY_CONTROLLER);
    registry.addRecipes(AssemblyRecipe.laserRecipes, ModCategoryUid.ASSEMBLY_CONTROLLER);
    registry.addRecipes(AssemblyRecipe.drillLaserRecipes, ModCategoryUid.ASSEMBLY_CONTROLLER);
    registry.addRecipes(new JEIAmadronTradeCategory(jeiHelpers).getAllRecipes(), ModCategoryUid.AMADRON_TRADE);

    registry.handleRecipes(PressureChamberRecipe.class,
            JEIPressureChamberRecipeCategory.ChamberRecipeWrapper::new, ModCategoryUid.PRESSURE_CHAMBER);
    registry.handleRecipes(BasicThermopneumaticProcessingPlantRecipe.class,
            JEIThermopneumaticProcessingPlantCategory.ThermopneumaticRecipeWrapper::new, ModCategoryUid.THERMO_PNEUMATIC);
    registry.handleRecipes(AssemblyRecipe.class,
            JEIAssemblyControllerCategory.AssemblyRecipeWrapper::new, ModCategoryUid.ASSEMBLY_CONTROLLER);

    registry.addRecipeClickArea(GuiAssemblyController.class, 68, 75, 24, 17, ModCategoryUid.ASSEMBLY_CONTROLLER);
    registry.addRecipeClickArea(GuiPressureChamber.class, 100, 7, 40, 40, ModCategoryUid.PRESSURE_CHAMBER);
    registry.addRecipeClickArea(GuiRefinery.class, 47, 21, 27, 47, ModCategoryUid.REFINERY);
    registry.addRecipeClickArea(GuiThermopneumaticProcessingPlant.class, 30, 31, 48, 20, ModCategoryUid.THERMO_PNEUMATIC);

    registry.addRecipeCatalyst(new ItemStack(Itemss.AMADRON_TABLET), ModCategoryUid.AMADRON_TRADE);
    registry.addRecipeCatalyst(new ItemStack(Blockss.ASSEMBLY_CONTROLLER), ModCategoryUid.ASSEMBLY_CONTROLLER);
    registry.addRecipeCatalyst(FluidUtil.getFilledBucket(new FluidStack(Fluids.ETCHING_ACID, 1000)), ModCategoryUid.ETCHING_ACID);
    registry.addRecipeCatalyst(new ItemStack(Blockss.PLASTIC_MIXER), ModCategoryUid.PLASTIC_MIXER);
    registry.addRecipeCatalyst(new ItemStack(Blockss.PRESSURE_CHAMBER_WALL), ModCategoryUid.PRESSURE_CHAMBER);
    registry.addRecipeCatalyst(new ItemStack(Blockss.REFINERY), ModCategoryUid.REFINERY);
    registry.addRecipeCatalyst(new ItemStack(Blockss.THERMOPNEUMATIC_PROCESSING_PLANT), ModCategoryUid.THERMO_PNEUMATIC);
    registry.addRecipeCatalyst(new ItemStack(Blockss.UV_LIGHT_BOX), ModCategoryUid.UV_LIGHT_BOX);

    registry.addAdvancedGuiHandlers(new GuiTabHandler());
}
 
Example 40
Project: BaseClient   File: BlockTallGrass.java   Source Code and License 5 votes vote down vote up
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 1, ((BlockTallGrass.EnumType)state.getValue(TYPE)).getMeta()));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
 
Example 41
Project: Firma   File: SandBlock.java   Source Code and License 5 votes vote down vote up
@Override
public String getSpecialName(ItemStack stack) {
	if (stack == null) {
		throw new NullPointerException();
	}
	return RockEnum.getName(stack.getMetadata());
}
 
Example 42
Project: connor41-etfuturum2   File: ServerEventHandler.java   Source Code and License 5 votes vote down vote up
private void setAnimalInLove(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
	if (!animal.isInLove()) {
		animal.func_146082_f(player);
		if (!player.capabilities.isCreativeMode)
			if (--stack.stackSize <= 0)
				player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
	}
}
 
Example 43
Project: Backmemed   File: BehaviorDefaultDispenseItem.java   Source Code and License 5 votes vote down vote up
/**
 * Dispenses the specified ItemStack from a dispenser.
 */
public final ItemStack dispense(IBlockSource source, ItemStack stack)
{
    ItemStack itemstack = this.dispenseStack(source, stack);
    this.playDispenseSound(source);
    this.spawnDispenseParticles(source, (EnumFacing)source.getBlockState().getValue(BlockDispenser.FACING));
    return itemstack;
}
 
Example 44
Project: GardenStuff   File: BlockBloomeryFurnace.java   Source Code and License 5 votes vote down vote up
@Override
public void onBlockPlacedBy (World world, BlockPos pos, IBlockState state, EntityLivingBase placer, @Nonnull ItemStack stack) {
    world.setBlockState(pos, state.withProperty(FACING, placer.getHorizontalFacing().getOpposite()), 2);

    if (stack.hasDisplayName()) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof TileBloomeryFurnace)
            ((TileBloomeryFurnace)tile).setInventoryName(stack.getDisplayName());
    }
}
 
Example 45
Project: uniquecrops   File: NBTUtils.java   Source Code and License 4 votes vote down vote up
public static short getShort(ItemStack stack, String tag, short defaultExpected) {
	return verifyExistance(stack, tag) ? getNBT(stack).getShort(tag) : defaultExpected;
}
 
Example 46
Project: harshencastle   File: HarshenArrow.java   Source Code and License 4 votes vote down vote up
@Override
protected ItemStack getArrowStack() {
	if(arrowType == EnumHarshenArrowTypes.RIPPER)
		return ItemStack.EMPTY;
	return new ItemStack(new Random().nextFloat() < chanceThatArrowBreaks ? HarshenItems.BROKEN_ARROW : Items.ARROW);
}
 
Example 47
Project: CustomWorldGen   File: EntityLiving.java   Source Code and License 4 votes vote down vote up
public static EntityEquipmentSlot getSlotForItemStack(ItemStack stack)
{
    return stack.getItem() != Item.getItemFromBlock(Blocks.PUMPKIN) && stack.getItem() != Items.SKULL ? (stack.getItem() instanceof ItemArmor ? ((ItemArmor)stack.getItem()).armorType : (stack.getItem() == Items.ELYTRA ? EntityEquipmentSlot.CHEST : (stack.getItem() == Items.SHIELD ? EntityEquipmentSlot.OFFHAND : EntityEquipmentSlot.MAINHAND))) : EntityEquipmentSlot.HEAD;
}
 
Example 48
Project: Technical   File: TileEntityWasher.java   Source Code and License 4 votes vote down vote up
@Override
public boolean canExtractItem(int side, ItemStack itemStack, int par3) {
	return par3 != 0 || side != 1 || itemStack.getItem() == Items.bucket;
}
 
Example 49
Project: Wurst-MC-1.12   File: BowAimbotMod.java   Source Code and License 4 votes vote down vote up
@Override
public void onUpdate()
{
	// check if using item
	if(!mc.gameSettings.keyBindUseItem.pressed)
	{
		target = null;
		return;
	}
	if(!WMinecraft.getPlayer().isHandActive()
		&& !wurst.mods.fastBowMod.isActive())
	{
		target = null;
		return;
	}
	
	// check if item is bow
	ItemStack item = WMinecraft.getPlayer().inventory.getCurrentItem();
	if(item == null || !(item.getItem() instanceof ItemBow))
	{
		target = null;
		return;
	}
	
	// set target
	if(!EntityUtils.isCorrectEntity(target, targetSettings))
		target = EntityUtils.getBestEntityToAttack(targetSettings);
	if(target == null)
		return;
	
	// set velocity
	velocity = (72000 - WMinecraft.getPlayer().getItemInUseCount()) / 20F;
	velocity = (velocity * velocity + velocity * 2) / 3;
	if(velocity > 1)
		velocity = 1;
	
	// adjust for FastBow
	if(wurst.mods.fastBowMod.isActive())
		velocity = 1;
	
	// set position to aim at
	double d = RotationUtils.getEyesPos()
		.distanceTo(target.boundingBox.getCenter());
	double posX = target.posX + (target.posX - target.prevPosX) * d
		- WMinecraft.getPlayer().posX;
	double posY = target.posY + (target.posY - target.prevPosY) * d
		+ target.height * 0.5 - WMinecraft.getPlayer().posY
		- WMinecraft.getPlayer().getEyeHeight();
	double posZ = target.posZ + (target.posZ - target.prevPosZ) * d
		- WMinecraft.getPlayer().posZ;
	
	// set yaw
	WMinecraft.getPlayer().rotationYaw =
		(float)Math.toDegrees(Math.atan2(posZ, posX)) - 90;
	
	// calculate needed pitch
	double hDistance = Math.sqrt(posX * posX + posZ * posZ);
	double hDistanceSq = hDistance * hDistance;
	float g = 0.006F;
	float velocitySq = velocity * velocity;
	float velocityPow4 = velocitySq * velocitySq;
	float neededPitch = (float)-Math.toDegrees(Math.atan((velocitySq - Math
		.sqrt(velocityPow4 - g * (g * hDistanceSq + 2 * posY * velocitySq)))
		/ (g * hDistance)));
	
	// set pitch
	if(Float.isNaN(neededPitch))
		RotationUtils.faceEntityClient(target);
	else
		WMinecraft.getPlayer().rotationPitch = neededPitch;
}
 
Example 50
Project: pnc-repressurized   File: WailaRedstoneControl.java   Source Code and License 4 votes vote down vote up
@Override
public List<String> getWailaTail(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    return currenttip;
}
 
Example 51
Project: CompositeGear   File: ItemCompositeArmor.java   Source Code and License 4 votes vote down vote up
@Override
@SideOnly(Side.CLIENT)
public EnumRarity getRarity(ItemStack var1)
{
	return this.rarity;
}
 
Example 52
Project: pnc-repressurized   File: ChargeableItemHandler.java   Source Code and License 4 votes vote down vote up
@Override
public boolean test(Integer integer, ItemStack itemStack) {
    return itemStack.isEmpty() || itemStack.getItem() instanceof ItemMachineUpgrade;
}
 
Example 53
Project: BetterBeginningsReborn   File: CampfireConfig.java   Source Code and License 4 votes vote down vote up
public static void addPanRecipe(ItemStack input, ItemStack output, float xp)
{
	initialRecipes.getPanRecipes().add(new JsonCampfirePanRecipe(input, output, xp));
}
 
Example 54
Project: BetterBeginningsReborn   File: SmelterRecipe.java   Source Code and License 4 votes vote down vote up
public ItemStack getOutput()
{
	return outputStack;
}
 
Example 55
Project: ToughExpansion   File: ModCreativeTab.java   Source Code and License 4 votes vote down vote up
@Override
public ItemStack getIconItemStack() {
	return new ItemStack(ModBlocks.TEMP_REGULATOR);
	//return new ItemStack(ModItems.dankNullItem, 1, 5);
}
 
Example 56
Project: TFCPrimitiveTech   File: ItemHardStone.java   Source Code and License 4 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void addInformation(ItemStack is, EntityPlayer player, List arraylist, boolean flag)
{
	ItemTerra.addSizeInformation(is, arraylist);
}
 
Example 57
Project: Industrial-Foregoing   File: CTProteinReactor.java   Source Code and License 4 votes vote down vote up
@ZenMethod
public static void remove(IItemStack input) {
    CraftTweakerAPI.apply(new Remove((ItemStack) input.getInternal()));
}
 
Example 58
Project: Mods   File: TNTCannon.java   Source Code and License 4 votes vote down vote up
public int fireRateMin(ItemStack stack) {
	int base = this.getType(stack) == 1 ? 25 : (this.getType(stack) == 2 ? 15 : this.getType(stack) == 5 ? 30 : 0);
	return base - EnchantmentHelper.getEnchantmentLevel(BlockLauncher.enchHeavy, stack) * 2;
}
 
Example 59
Project: Backmemed   File: EntityPig.java   Source Code and License 4 votes vote down vote up
/**
 * Checks if the parameter is an item which this animal can be fed to breed it (wheat, carrots or seeds depending on
 * the animal type)
 */
public boolean isBreedingItem(ItemStack stack)
{
    return TEMPTATION_ITEMS.contains(stack.getItem());
}
 
Example 60
Project: PurificatiMagicae   File: ItemBlockCodeStorage.java   Source Code and License 4 votes vote down vote up
@Override
public String getItemStackDisplayName(ItemStack stack)
{
    return I18n.translateToLocalFormatted(getUnlocalizedName() + (stack.getMetadata() == 0 ? ".lockable" : ".not_lockable") + ".name");
}