BlockWall .java

net.minecraft.block.BlockWall (class): members: canConnectTo, UP, NORTH, SOUTH, EAST, WEST, isPassable, getLocalizedName, EnumType, VARIANT, damageDropped.

net.minecraft.blockclass238 linescommonextends Block7.7 KB

API Surface (19)

String getLocalizedName()
boolean isFullCube()
boolean isPassable(IBlockAccess worldIn, BlockPos pos)
boolean isOpaqueCube()
void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
boolean canConnectTo(IBlockAccess worldIn, BlockPos pos)
void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
int damageDropped(IBlockState state)
boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
IBlockState getStateFromMeta(int meta)
int getMetaFromState(IBlockState state)
IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
BlockState createBlockState()
int getMetadata()
String toString()
BlockWall.EnumType byMetadata(int meta)
String getName()
String getUnlocalizedName()

Fields & Constants (6)

UP
NORTH
EAST
SOUTH
WEST
VARIANT

String literals (10)

"north"
"east"
"south"
"west"
"variant"
".name"
"cobblestone"
"normal"
"mossy_cobblestone"
"mossy"

Full Source

BlockWall.java238 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.block;
2
3
import java.util.List;
4
import net.minecraft.block.material.Material;
5
import net.minecraft.block.properties.IProperty;
6
import net.minecraft.block.properties.PropertyBool;
7
import net.minecraft.block.properties.PropertyEnum;
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.item.Item;
13
import net.minecraft.item.ItemStack;
14
import net.minecraft.util.AxisAlignedBB;
15
import net.minecraft.util.BlockPos;
16
import net.minecraft.util.EnumFacing;
17
import net.minecraft.util.IStringSerializable;
18
import net.minecraft.util.StatCollector;
19
import net.minecraft.world.IBlockAccess;
20
import net.minecraft.world.World;
21
22
public class BlockWall extends Block
23
{
24
    public static final PropertyBool UP = PropertyBool.create("up");
25
    public static final PropertyBool NORTH = PropertyBool.create("north");
26
    public static final PropertyBool EAST = PropertyBool.create("east");
27
    public static final PropertyBool SOUTH = PropertyBool.create("south");
28
    public static final PropertyBool WEST = PropertyBool.create("west");
29
    public static final PropertyEnum<BlockWall.EnumType> VARIANT = PropertyEnum.<BlockWall.EnumType>create("variant", BlockWall.EnumType.class);
30
31
    public BlockWall(Block modelBlock)
32
    {
33
        super(modelBlock.blockMaterial);
34
        this.setDefaultState(this.blockState.getBaseState().withProperty(UP, Boolean.valueOf(false)).withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false)).withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)).withProperty(VARIANT, BlockWall.EnumType.NORMAL));
35
        this.setHardness(modelBlock.blockHardness);
36
        this.setResistance(modelBlock.blockResistance / 3.0F);
37
        this.setStepSound(modelBlock.stepSound);
38
        this.setCreativeTab(CreativeTabs.tabBlock);
39
    }
40
41
    /**
42
     * Gets the localized name of this block. Used for the statistics page.
43
     */
44
    public String getLocalizedName()
45
    {
46
        return StatCollector.translateToLocal(this.getUnlocalizedName() + "." + BlockWall.EnumType.NORMAL.getUnlocalizedName() + ".name");
47
    }
48
49
    public boolean isFullCube()
50
    {
51
        return false;
52
    }
53
54
    public boolean isPassable(IBlockAccess worldIn, BlockPos pos)
55
    {
56
        return false;
57
    }
58
59
    /**
60
     * Used to determine ambient occlusion and culling when rebuilding chunks for render
61
     */
62
    public boolean isOpaqueCube()
63
    {
64
        return false;
65
    }
66
67
    public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
68
    {
69
        boolean flag = this.canConnectTo(worldIn, pos.north());
70
        boolean flag1 = this.canConnectTo(worldIn, pos.south());
71
        boolean flag2 = this.canConnectTo(worldIn, pos.west());
72
        boolean flag3 = this.canConnectTo(worldIn, pos.east());
73
        float f = 0.25F;
74
        float f1 = 0.75F;
75
        float f2 = 0.25F;
76
        float f3 = 0.75F;
77
        float f4 = 1.0F;
78
79
        if (flag)
80
        {
81
            f2 = 0.0F;
82
        }
83
84
        if (flag1)
85
        {
86
            f3 = 1.0F;
87
        }
88
89
        if (flag2)
90
        {
91
            f = 0.0F;
92
        }
93
94
        if (flag3)
95
        {
96
            f1 = 1.0F;
97
        }
98
99
        if (flag && flag1 && !flag2 && !flag3)
100
        {
101
            f4 = 0.8125F;
102
            f = 0.3125F;
103
            f1 = 0.6875F;
104
        }
105
        else if (!flag && !flag1 && flag2 && flag3)
106
        {
107
            f4 = 0.8125F;
108
            f2 = 0.3125F;
109
            f3 = 0.6875F;
110
        }
111
112
        this.setBlockBounds(f, 0.0F, f2, f1, f4, f3);
113
    }
114
115
    public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
116
    {
117
        this.setBlockBoundsBasedOnState(worldIn, pos);
118
        this.maxY = 1.5D;
119
        return super.getCollisionBoundingBox(worldIn, pos, state);
120
    }
121
122
    public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos)
123
    {
124
        Block block = worldIn.getBlockState(pos).getBlock();
125
        return block == Blocks.barrier ? false : (block != this && !(block instanceof BlockFenceGate) ? (block.blockMaterial.isOpaque() && block.isFullCube() ? block.blockMaterial != Material.gourd : false) : true);
126
    }
127
128
    /**
129
     * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
130
     */
131
    public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list)
132
    {
133
        for (BlockWall.EnumType blockwall$enumtype : BlockWall.EnumType.values())
134
        {
135
            list.add(new ItemStack(itemIn, 1, blockwall$enumtype.getMetadata()));
136
        }
137
    }
138
139
    /**
140
     * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It
141
     * returns the metadata of the dropped item based on the old metadata of the block.
142
     */
143
    public int damageDropped(IBlockState state)
144
    {
145
        return ((BlockWall.EnumType)state.getValue(VARIANT)).getMetadata();
146
    }
147
148
    public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
149
    {
150
        return side == EnumFacing.DOWN ? super.shouldSideBeRendered(worldIn, pos, side) : true;
151
    }
152
153
    /**
154
     * Convert the given metadata into a BlockState for this Block
155
     */
156
    public IBlockState getStateFromMeta(int meta)
157
    {
158
        return this.getDefaultState().withProperty(VARIANT, BlockWall.EnumType.byMetadata(meta));
159
    }
160
161
    /**
162
     * Convert the BlockState into the correct metadata value
163
     */
164
    public int getMetaFromState(IBlockState state)
165
    {
166
        return ((BlockWall.EnumType)state.getValue(VARIANT)).getMetadata();
167
    }
168
169
    /**
170
     * Get the actual Block state of this Block at the given position. This applies properties not visible in the
171
     * metadata, such as fence connections.
172
     */
173
    public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
174
    {
175
        return state.withProperty(UP, Boolean.valueOf(!worldIn.isAirBlock(pos.up()))).withProperty(NORTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.north()))).withProperty(EAST, Boolean.valueOf(this.canConnectTo(worldIn, pos.east()))).withProperty(SOUTH, Boolean.valueOf(this.canConnectTo(worldIn, pos.south()))).withProperty(WEST, Boolean.valueOf(this.canConnectTo(worldIn, pos.west())));
176
    }
177
178
    protected BlockState createBlockState()
179
    {
180
        return new BlockState(this, new IProperty[] {UP, NORTH, EAST, WEST, SOUTH, VARIANT});
181
    }
182
183
    public static enum EnumType implements IStringSerializable
184
    {
185
        NORMAL(0, "cobblestone", "normal"),
186
        MOSSY(1, "mossy_cobblestone", "mossy");
187
188
        private static final BlockWall.EnumType[] META_LOOKUP = new BlockWall.EnumType[values().length];
189
        private final int meta;
190
        private final String name;
191
        private String unlocalizedName;
192
193
        private EnumType(int meta, String name, String unlocalizedName)
194
        {
195
            this.meta = meta;
196
            this.name = name;
197
            this.unlocalizedName = unlocalizedName;
198
        }
199
200
        public int getMetadata()
201
        {
202
            return this.meta;
203
        }
204
205
        public String toString()
206
        {
207
            return this.name;
208
        }
209
210
        public static BlockWall.EnumType byMetadata(int meta)
211
        {
212
            if (meta < 0 || meta >= META_LOOKUP.length)
213
            {
214
                meta = 0;
215
            }
216
217
            return META_LOOKUP[meta];
218
        }
219
220
        public String getName()
221
        {
222
            return this.name;
223
        }
224
225
        public String getUnlocalizedName()
226
        {
227
            return this.unlocalizedName;
228
        }
229
230
        static {
231
            for (BlockWall.EnumType blockwall$enumtype : values())
232
            {
233
                META_LOOKUP[blockwall$enumtype.getMetadata()] = blockwall$enumtype;
234
            }
235
        }
236
    }
237
}
238

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