ItemSeeds .java

net.minecraft.item.ItemSeeds (class, 49 lines): extends Item. members: soilBlockID, crops, onItemUse. imports: CreativeTabs.

net.minecraft.itemclass49 linescommonextends Item1.3 KB

API Surface (1)

boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)

Fields & Constants (2)

crops
soilBlockID

Full Source

ItemSeeds.java49 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.item;
2
3
import net.minecraft.block.Block;
4
import net.minecraft.creativetab.CreativeTabs;
5
import net.minecraft.entity.player.EntityPlayer;
6
import net.minecraft.util.BlockPos;
7
import net.minecraft.util.EnumFacing;
8
import net.minecraft.world.World;
9
10
public class ItemSeeds extends Item
11
{
12
    private Block crops;
13
14
    /** BlockID of the block the seeds can be planted on. */
15
    private Block soilBlockID;
16
17
    public ItemSeeds(Block crops, Block soil)
18
    {
19
        this.crops = crops;
20
        this.soilBlockID = soil;
21
        this.setCreativeTab(CreativeTabs.tabMaterials);
22
    }
23
24
    /**
25
     * Called when a Block is right-clicked with this Item
26
     */
27
    public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
28
    {
29
        if (side != EnumFacing.UP)
30
        {
31
            return false;
32
        }
33
        else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
34
        {
35
            return false;
36
        }
37
        else if (worldIn.getBlockState(pos).getBlock() == this.soilBlockID && worldIn.isAirBlock(pos.up()))
38
        {
39
            worldIn.setBlockState(pos.up(), this.crops.getDefaultState());
40
            --stack.stackSize;
41
            return true;
42
        }
43
        else
44
        {
45
            return false;
46
        }
47
    }
48
}
49

Deobfuscated MCP 1.8.9 source of ItemSeeds from Marcelektro/MavenMCP-1.8.9 (net/minecraft/item/ItemSeeds.java), stored verbatim.