BlockNetherWart .java

net.minecraft.block.BlockNetherWart (class): members: canPlaceBlockOn, AGE, canBlockStay, dropBlockAsItemWithChance, quantityDropped, getItem, updateTick.

net.minecraft.blockclass126 linescommonextends BlockBush3.5 KB

API Surface (10)

boolean canPlaceBlockOn(Block ground)
boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
Item getItemDropped(IBlockState state, Random rand, int fortune)
int quantityDropped(Random random)
Item getItem(World worldIn, BlockPos pos)
IBlockState getStateFromMeta(int meta)
int getMetaFromState(IBlockState state)
BlockState createBlockState()

Fields & Constants (1)

AGE

Full Source

BlockNetherWart.java126 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.Random;
4
import net.minecraft.block.material.MapColor;
5
import net.minecraft.block.material.Material;
6
import net.minecraft.block.properties.IProperty;
7
import net.minecraft.block.properties.PropertyInteger;
8
import net.minecraft.block.state.BlockState;
9
import net.minecraft.block.state.IBlockState;
10
import net.minecraft.creativetab.CreativeTabs;
11
import net.minecraft.init.Blocks;
12
import net.minecraft.init.Items;
13
import net.minecraft.item.Item;
14
import net.minecraft.item.ItemStack;
15
import net.minecraft.util.BlockPos;
16
import net.minecraft.world.World;
17
18
public class BlockNetherWart extends BlockBush
19
{
20
    public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 3);
21
22
    protected BlockNetherWart()
23
    {
24
        super(Material.plants, MapColor.redColor);
25
        this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
26
        this.setTickRandomly(true);
27
        float f = 0.5F;
28
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);
29
        this.setCreativeTab((CreativeTabs)null);
30
    }
31
32
    /**
33
     * is the block grass, dirt or farmland
34
     */
35
    protected boolean canPlaceBlockOn(Block ground)
36
    {
37
        return ground == Blocks.soul_sand;
38
    }
39
40
    public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
41
    {
42
        return this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
43
    }
44
45
    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
46
    {
47
        int i = ((Integer)state.getValue(AGE)).intValue();
48
49
        if (i < 3 && rand.nextInt(10) == 0)
50
        {
51
            state = state.withProperty(AGE, Integer.valueOf(i + 1));
52
            worldIn.setBlockState(pos, state, 2);
53
        }
54
55
        super.updateTick(worldIn, pos, state, rand);
56
    }
57
58
    /**
59
     * Spawns this Block's drops into the World as EntityItems.
60
     */
61
    public void dropBlockAsItemWithChance(World worldIn, BlockPos pos, IBlockState state, float chance, int fortune)
62
    {
63
        if (!worldIn.isRemote)
64
        {
65
            int i = 1;
66
67
            if (((Integer)state.getValue(AGE)).intValue() >= 3)
68
            {
69
                i = 2 + worldIn.rand.nextInt(3);
70
71
                if (fortune > 0)
72
                {
73
                    i += worldIn.rand.nextInt(fortune + 1);
74
                }
75
            }
76
77
            for (int j = 0; j < i; ++j)
78
            {
79
                spawnAsEntity(worldIn, pos, new ItemStack(Items.nether_wart));
80
            }
81
        }
82
    }
83
84
    /**
85
     * Get the Item that this Block should drop when harvested.
86
     */
87
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
88
    {
89
        return null;
90
    }
91
92
    /**
93
     * Returns the quantity of items to drop on block destruction.
94
     */
95
    public int quantityDropped(Random random)
96
    {
97
        return 0;
98
    }
99
100
    public Item getItem(World worldIn, BlockPos pos)
101
    {
102
        return Items.nether_wart;
103
    }
104
105
    /**
106
     * Convert the given metadata into a BlockState for this Block
107
     */
108
    public IBlockState getStateFromMeta(int meta)
109
    {
110
        return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta));
111
    }
112
113
    /**
114
     * Convert the BlockState into the correct metadata value
115
     */
116
    public int getMetaFromState(IBlockState state)
117
    {
118
        return ((Integer)state.getValue(AGE)).intValue();
119
    }
120
121
    protected BlockState createBlockState()
122
    {
123
        return new BlockState(this, new IProperty[] {AGE});
124
    }
125
}
126

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