BlockBush .java

net.minecraft.block.BlockBush (class, 99 lines): members: checkAndDropBlock, canPlaceBlockOn, canBlockStay, canPlaceBlockAt, getBlockLayer, updateTick.

net.minecraft.blockclass99 linescommonextends Block2.8 KB

API Surface (10)

boolean canPlaceBlockAt(World worldIn, BlockPos pos)
boolean canPlaceBlockOn(Block ground)
void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
boolean isOpaqueCube()
boolean isFullCube()
EnumWorldBlockLayer getBlockLayer()

Full Source

BlockBush.java99 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.state.IBlockState;
7
import net.minecraft.creativetab.CreativeTabs;
8
import net.minecraft.init.Blocks;
9
import net.minecraft.util.AxisAlignedBB;
10
import net.minecraft.util.BlockPos;
11
import net.minecraft.util.EnumWorldBlockLayer;
12
import net.minecraft.world.World;
13
14
public class BlockBush extends Block
15
{
16
    protected BlockBush()
17
    {
18
        this(Material.plants);
19
    }
20
21
    protected BlockBush(Material materialIn)
22
    {
23
        this(materialIn, materialIn.getMaterialMapColor());
24
    }
25
26
    protected BlockBush(Material p_i46452_1_, MapColor p_i46452_2_)
27
    {
28
        super(p_i46452_1_, p_i46452_2_);
29
        this.setTickRandomly(true);
30
        float f = 0.2F;
31
        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);
32
        this.setCreativeTab(CreativeTabs.tabDecorations);
33
    }
34
35
    public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
36
    {
37
        return super.canPlaceBlockAt(worldIn, pos) && this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
38
    }
39
40
    /**
41
     * is the block grass, dirt or farmland
42
     */
43
    protected boolean canPlaceBlockOn(Block ground)
44
    {
45
        return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland;
46
    }
47
48
    /**
49
     * Called when a neighboring block changes.
50
     */
51
    public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
52
    {
53
        super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
54
        this.checkAndDropBlock(worldIn, pos, state);
55
    }
56
57
    public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
58
    {
59
        this.checkAndDropBlock(worldIn, pos, state);
60
    }
61
62
    protected void checkAndDropBlock(World worldIn, BlockPos pos, IBlockState state)
63
    {
64
        if (!this.canBlockStay(worldIn, pos, state))
65
        {
66
            this.dropBlockAsItem(worldIn, pos, state, 0);
67
            worldIn.setBlockState(pos, Blocks.air.getDefaultState(), 3);
68
        }
69
    }
70
71
    public boolean canBlockStay(World worldIn, BlockPos pos, IBlockState state)
72
    {
73
        return this.canPlaceBlockOn(worldIn.getBlockState(pos.down()).getBlock());
74
    }
75
76
    public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
77
    {
78
        return null;
79
    }
80
81
    /**
82
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
83
     */
84
    public boolean isOpaqueCube()
85
    {
86
        return false;
87
    }
88
89
    public boolean isFullCube()
90
    {
91
        return false;
92
    }
93
94
    public EnumWorldBlockLayer getBlockLayer()
95
    {
96
        return EnumWorldBlockLayer.CUTOUT;
97
    }
98
}
99

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