ItemSeedFood .java

net.minecraft.item.ItemSeedFood (class, 48 lines): extends ItemFood. members: soilId, crops, onItemUse. imports: Block.

net.minecraft.itemclass48 linescommonextends ItemFood1.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
soilId

Code Graph: Dependencies (7)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

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

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