BlockPane .java

net.minecraft.block.BlockPane (class, 205 lines): members: canPaneConnectToBlock, canDrop, canSilkHarvest, NORTH, SOUTH, EAST, WEST, shouldSideBeRendered.

net.minecraft.blockclass205 linescommonextends Block7.2 KB

API Surface (13)

IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
Item getItemDropped(IBlockState state, Random rand, int fortune)
boolean isOpaqueCube()
boolean isFullCube()
boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
void setBlockBoundsForItemRender()
void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
boolean canPaneConnectToBlock(Block blockIn)
boolean canSilkHarvest()
EnumWorldBlockLayer getBlockLayer()
int getMetaFromState(IBlockState state)
BlockState createBlockState()

Fields & Constants (5)

NORTH
EAST
SOUTH
WEST
canDrop

String literals (4)

"north"
"east"
"south"
"west"

Full Source

BlockPane.java205 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.List;
4
import java.util.Random;
5
import net.minecraft.block.material.Material;
6
import net.minecraft.block.properties.IProperty;
7
import net.minecraft.block.properties.PropertyBool;
8
import net.minecraft.block.state.BlockState;
9
import net.minecraft.block.state.IBlockState;
10
import net.minecraft.creativetab.CreativeTabs;
11
import net.minecraft.entity.Entity;
12
import net.minecraft.init.Blocks;
13
import net.minecraft.item.Item;
14
import net.minecraft.util.AxisAlignedBB;
15
import net.minecraft.util.BlockPos;
16
import net.minecraft.util.EnumFacing;
17
import net.minecraft.util.EnumWorldBlockLayer;
18
import net.minecraft.world.IBlockAccess;
19
import net.minecraft.world.World;
20
21
public class BlockPane extends Block
22
{
23
    public static final PropertyBool NORTH = PropertyBool.create("north");
24
    public static final PropertyBool EAST = PropertyBool.create("east");
25
    public static final PropertyBool SOUTH = PropertyBool.create("south");
26
    public static final PropertyBool WEST = PropertyBool.create("west");
27
    private final boolean canDrop;
28
29
    protected BlockPane(Material materialIn, boolean canDrop)
30
    {
31
        super(materialIn);
32
        this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)));
33
        this.canDrop = canDrop;
34
        this.setCreativeTab(CreativeTabs.tabDecorations);
35
    }
36
37
    /**
38
     * Get the actual Block state of this Block at the given position. This applies properties not visible in the
39
     * metadata, such as fence connections.
40
     */
41
    public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
42
    {
43
        return state.withProperty(NORTH, Boolean.valueOf(this.canPaneConnectToBlock(worldIn.getBlockState(pos.north()).getBlock()))).withProperty(SOUTH, Boolean.valueOf(this.canPaneConnectToBlock(worldIn.getBlockState(pos.south()).getBlock()))).withProperty(WEST, Boolean.valueOf(this.canPaneConnectToBlock(worldIn.getBlockState(pos.west()).getBlock()))).withProperty(EAST, Boolean.valueOf(this.canPaneConnectToBlock(worldIn.getBlockState(pos.east()).getBlock())));
44
    }
45
46
    /**
47
     * Get the Item that this Block should drop when harvested.
48
     */
49
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
50
    {
51
        return !this.canDrop ? null : super.getItemDropped(state, rand, fortune);
52
    }
53
54
    /**
55
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
56
     */
57
    public boolean isOpaqueCube()
58
    {
59
        return false;
60
    }
61
62
    public boolean isFullCube()
63
    {
64
        return false;
65
    }
66
67
    public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
68
    {
69
        return worldIn.getBlockState(pos).getBlock() == this ? false : super.shouldSideBeRendered(worldIn, pos, side);
70
    }
71
72
    /**
73
     * Add all collision boxes of this Block to the list that intersect with the given mask.
74
     */
75
    public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity)
76
    {
77
        boolean flag = this.canPaneConnectToBlock(worldIn.getBlockState(pos.north()).getBlock());
78
        boolean flag1 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.south()).getBlock());
79
        boolean flag2 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.west()).getBlock());
80
        boolean flag3 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.east()).getBlock());
81
82
        if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
83
        {
84
            if (flag2)
85
            {
86
                this.setBlockBounds(0.0F, 0.0F, 0.4375F, 0.5F, 1.0F, 0.5625F);
87
                super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
88
            }
89
            else if (flag3)
90
            {
91
                this.setBlockBounds(0.5F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
92
                super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
93
            }
94
        }
95
        else
96
        {
97
            this.setBlockBounds(0.0F, 0.0F, 0.4375F, 1.0F, 1.0F, 0.5625F);
98
            super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
99
        }
100
101
        if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
102
        {
103
            if (flag)
104
            {
105
                this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 0.5F);
106
                super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
107
            }
108
            else if (flag1)
109
            {
110
                this.setBlockBounds(0.4375F, 0.0F, 0.5F, 0.5625F, 1.0F, 1.0F);
111
                super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
112
            }
113
        }
114
        else
115
        {
116
            this.setBlockBounds(0.4375F, 0.0F, 0.0F, 0.5625F, 1.0F, 1.0F);
117
            super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity);
118
        }
119
    }
120
121
    /**
122
     * Sets the block's bounds for rendering it as an item
123
     */
124
    public void setBlockBoundsForItemRender()
125
    {
126
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
127
    }
128
129
    public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
130
    {
131
        float f = 0.4375F;
132
        float f1 = 0.5625F;
133
        float f2 = 0.4375F;
134
        float f3 = 0.5625F;
135
        boolean flag = this.canPaneConnectToBlock(worldIn.getBlockState(pos.north()).getBlock());
136
        boolean flag1 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.south()).getBlock());
137
        boolean flag2 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.west()).getBlock());
138
        boolean flag3 = this.canPaneConnectToBlock(worldIn.getBlockState(pos.east()).getBlock());
139
140
        if ((!flag2 || !flag3) && (flag2 || flag3 || flag || flag1))
141
        {
142
            if (flag2)
143
            {
144
                f = 0.0F;
145
            }
146
            else if (flag3)
147
            {
148
                f1 = 1.0F;
149
            }
150
        }
151
        else
152
        {
153
            f = 0.0F;
154
            f1 = 1.0F;
155
        }
156
157
        if ((!flag || !flag1) && (flag2 || flag3 || flag || flag1))
158
        {
159
            if (flag)
160
            {
161
                f2 = 0.0F;
162
            }
163
            else if (flag1)
164
            {
165
                f3 = 1.0F;
166
            }
167
        }
168
        else
169
        {
170
            f2 = 0.0F;
171
            f3 = 1.0F;
172
        }
173
174
        this.setBlockBounds(f, 0.0F, f2, f1, 1.0F, f3);
175
    }
176
177
    public final boolean canPaneConnectToBlock(Block blockIn)
178
    {
179
        return blockIn.isFullBlock() || blockIn == this || blockIn == Blocks.glass || blockIn == Blocks.stained_glass || blockIn == Blocks.stained_glass_pane || blockIn instanceof BlockPane;
180
    }
181
182
    protected boolean canSilkHarvest()
183
    {
184
        return true;
185
    }
186
187
    public EnumWorldBlockLayer getBlockLayer()
188
    {
189
        return EnumWorldBlockLayer.CUTOUT_MIPPED;
190
    }
191
192
    /**
193
     * Convert the BlockState into the correct metadata value
194
     */
195
    public int getMetaFromState(IBlockState state)
196
    {
197
        return 0;
198
    }
199
200
    protected BlockState createBlockState()
201
    {
202
        return new BlockState(this, new IProperty[] {NORTH, EAST, WEST, SOUTH});
203
    }
204
}
205

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