BlockWallSign .java

net.minecraft.block.BlockWallSign (class): members: FACING, setBlockBoundsBasedOnState, onNeighborBlockChange, getStateFromMeta, createBlockState.

net.minecraft.blockclass95 linescommonextends BlockSign2.8 KB

API Surface (5)

void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
IBlockState getStateFromMeta(int meta)
int getMetaFromState(IBlockState state)
BlockState createBlockState()

Fields & Constants (1)

FACING

String literals (2)

"facing"
"incomplete-switch"

Full Source

BlockWallSign.java95 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import net.minecraft.block.properties.IProperty;
4
import net.minecraft.block.properties.PropertyDirection;
5
import net.minecraft.block.state.BlockState;
6
import net.minecraft.block.state.IBlockState;
7
import net.minecraft.util.BlockPos;
8
import net.minecraft.util.EnumFacing;
9
import net.minecraft.world.IBlockAccess;
10
import net.minecraft.world.World;
11
12
public class BlockWallSign extends BlockSign
13
{
14
    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
15
16
    public BlockWallSign()
17
    {
18
        this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
19
    }
20
21
    @SuppressWarnings("incomplete-switch")
22
    public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
23
    {
24
        EnumFacing enumfacing = (EnumFacing)worldIn.getBlockState(pos).getValue(FACING);
25
        float f = 0.28125F;
26
        float f1 = 0.78125F;
27
        float f2 = 0.0F;
28
        float f3 = 1.0F;
29
        float f4 = 0.125F;
30
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
31
32
        switch (enumfacing)
33
        {
34
            case NORTH:
35
                this.setBlockBounds(f2, f, 1.0F - f4, f3, f1, 1.0F);
36
                break;
37
38
            case SOUTH:
39
                this.setBlockBounds(f2, f, 0.0F, f3, f1, f4);
40
                break;
41
42
            case WEST:
43
                this.setBlockBounds(1.0F - f4, f, f2, 1.0F, f1, f3);
44
                break;
45
46
            case EAST:
47
                this.setBlockBounds(0.0F, f, f2, f4, f1, f3);
48
        }
49
    }
50
51
    /**
52
     * Called when a neighboring block changes.
53
     */
54
    public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
55
    {
56
        EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
57
58
        if (!worldIn.getBlockState(pos.offset(enumfacing.getOpposite())).getBlock().getMaterial().isSolid())
59
        {
60
            this.dropBlockAsItem(worldIn, pos, state, 0);
61
            worldIn.setBlockToAir(pos);
62
        }
63
64
        super.onNeighborBlockChange(worldIn, pos, state, neighborBlock);
65
    }
66
67
    /**
68
     * Convert the given metadata into a BlockState for this Block
69
     */
70
    public IBlockState getStateFromMeta(int meta)
71
    {
72
        EnumFacing enumfacing = EnumFacing.getFront(meta);
73
74
        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
75
        {
76
            enumfacing = EnumFacing.NORTH;
77
        }
78
79
        return this.getDefaultState().withProperty(FACING, enumfacing);
80
    }
81
82
    /**
83
     * Convert the BlockState into the correct metadata value
84
     */
85
    public int getMetaFromState(IBlockState state)
86
    {
87
        return ((EnumFacing)state.getValue(FACING)).getIndex();
88
    }
89
90
    protected BlockState createBlockState()
91
    {
92
        return new BlockState(this, new IProperty[] {FACING});
93
    }
94
}
95

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