1
1
package com .renevo .nethercore .blocks ;
2
2
3
3
import net .minecraft .block .Block ;
4
- import net .minecraft .block .BlockFenceGate ;
5
- import net .minecraft .block .material .Material ;
6
- import net .minecraft .block .properties .PropertyBool ;
4
+ import net .minecraft .block .BlockWall ;
7
5
import net .minecraft .block .properties .PropertyEnum ;
8
6
import net .minecraft .block .state .BlockStateContainer ;
9
7
import net .minecraft .block .state .IBlockState ;
10
8
import net .minecraft .creativetab .CreativeTabs ;
11
- import net .minecraft .init .Blocks ;
12
9
import net .minecraft .item .Item ;
13
10
import net .minecraft .item .ItemStack ;
14
- import net .minecraft .util .EnumFacing ;
15
11
import net .minecraft .util .IStringSerializable ;
16
- import net .minecraft .util .math .AxisAlignedBB ;
17
12
import net .minecraft .util .math .BlockPos ;
18
13
import net .minecraft .world .IBlockAccess ;
19
- import net .minecraft .world .World ;
20
14
import net .minecraftforge .fml .relauncher .Side ;
21
15
import net .minecraftforge .fml .relauncher .SideOnly ;
22
16
23
17
import java .util .List ;
24
18
25
- public class EnumBlockWall <E extends Enum <E > & EnumBlockWall .IEnumMeta & IStringSerializable > extends Block {
26
- public static final PropertyBool UP = PropertyBool .create ("up" );
27
- public static final PropertyBool NORTH = PropertyBool .create ("north" );
28
- public static final PropertyBool EAST = PropertyBool .create ("east" );
29
- public static final PropertyBool SOUTH = PropertyBool .create ("south" );
30
- public static final PropertyBool WEST = PropertyBool .create ("west" );
31
- protected static final AxisAlignedBB [] BASE_BBS = new AxisAlignedBB []{new AxisAlignedBB (0.25D , 0.0D , 0.25D , 0.75D , 1.0D , 0.75D ), new AxisAlignedBB (0.25D , 0.0D , 0.25D , 0.75D , 1.0D , 1.0D ), new AxisAlignedBB (0.0D , 0.0D , 0.25D , 0.75D , 1.0D , 0.75D ), new AxisAlignedBB (0.0D , 0.0D , 0.25D , 0.75D , 1.0D , 1.0D ), new AxisAlignedBB (0.25D , 0.0D , 0.0D , 0.75D , 1.0D , 0.75D ), new AxisAlignedBB (0.3125D , 0.0D , 0.0D , 0.6875D , 0.875D , 1.0D ), new AxisAlignedBB (0.0D , 0.0D , 0.0D , 0.75D , 1.0D , 0.75D ), new AxisAlignedBB (0.0D , 0.0D , 0.0D , 0.75D , 1.0D , 1.0D ), new AxisAlignedBB (0.25D , 0.0D , 0.25D , 1.0D , 1.0D , 0.75D ), new AxisAlignedBB (0.25D , 0.0D , 0.25D , 1.0D , 1.0D , 1.0D ), new AxisAlignedBB (0.0D , 0.0D , 0.3125D , 1.0D , 0.875D , 0.6875D ), new AxisAlignedBB (0.0D , 0.0D , 0.25D , 1.0D , 1.0D , 1.0D ), new AxisAlignedBB (0.25D , 0.0D , 0.0D , 1.0D , 1.0D , 0.75D ), new AxisAlignedBB (0.25D , 0.0D , 0.0D , 1.0D , 1.0D , 1.0D ), new AxisAlignedBB (0.0D , 0.0D , 0.0D , 1.0D , 1.0D , 0.75D ), new AxisAlignedBB (0.0D , 0.0D , 0.0D , 1.0D , 1.0D , 1.0D )};
32
- protected static final AxisAlignedBB [] ACTUAL_BBS ;
33
-
19
+ public class EnumBlockWall <E extends Enum <E > & EnumBlockWall .IEnumMeta & IStringSerializable > extends BlockWall {
34
20
private final E [] values ;
35
21
public final PropertyEnum <E > prop ;
36
22
private static PropertyEnum <?> tmp ;
37
23
38
- public EnumBlockWall (Material material , PropertyEnum <E > prop , Class <E > clazz ) {
39
- super (preInit (material , prop ));
24
+ public EnumBlockWall (Block block , PropertyEnum <E > prop , Class <E > clazz ) {
25
+ super (preInit (block , prop ));
40
26
this .prop = prop ;
41
27
values = clazz .getEnumConstants ();
42
28
}
43
29
44
- @ SuppressWarnings ("unchecked" )
45
- private static Material preInit (Material material , PropertyEnum <?> property ) {
30
+ private static Block preInit (Block block , PropertyEnum <?> property ) {
46
31
tmp = property ;
47
- return material ;
48
- }
49
-
50
- @ Override
51
- public boolean isFullCube (IBlockState blockState ) {
52
- return false ;
53
- }
54
-
55
- @ Override
56
- public boolean isPassable (IBlockAccess blockAccess , BlockPos blockPos ) {
57
- return false ;
58
- }
59
-
60
- @ Override
61
- public boolean isOpaqueCube (IBlockState blockState ) {
62
- return false ;
63
- }
64
-
65
- @ Override
66
- public AxisAlignedBB getBoundingBox (IBlockState p_getBoundingBox_1_ , IBlockAccess p_getBoundingBox_2_ , BlockPos p_getBoundingBox_3_ ) {
67
- p_getBoundingBox_1_ = this .getActualState (p_getBoundingBox_1_ , p_getBoundingBox_2_ , p_getBoundingBox_3_ );
68
- return BASE_BBS [getFacingFlags (p_getBoundingBox_1_ )];
69
- }
70
-
71
- @ Override
72
- public AxisAlignedBB getSelectedBoundingBox (IBlockState p_getSelectedBoundingBox_1_ , World p_getSelectedBoundingBox_2_ , BlockPos p_getSelectedBoundingBox_3_ ) {
73
- p_getSelectedBoundingBox_1_ = this .getActualState (p_getSelectedBoundingBox_1_ , p_getSelectedBoundingBox_2_ , p_getSelectedBoundingBox_3_ );
74
- return ACTUAL_BBS [getFacingFlags (p_getSelectedBoundingBox_1_ )];
75
- }
76
-
77
- // face flags... GET YO FACE... not sure what better to call this
78
- // basically, this selects the Bounding Box based on the sides that are connected.
79
- private static int getFacingFlags (IBlockState blockState ) {
80
- int faceFlags = 0 ;
81
- if (blockState .getValue (NORTH )) {
82
- faceFlags |= 1 << EnumFacing .NORTH .getHorizontalIndex ();
83
- }
84
-
85
- if (blockState .getValue (EAST )) {
86
- faceFlags |= 1 << EnumFacing .EAST .getHorizontalIndex ();
87
- }
88
-
89
- if (blockState .getValue (SOUTH )) {
90
- faceFlags |= 1 << EnumFacing .SOUTH .getHorizontalIndex ();
91
- }
92
-
93
- if (blockState .getValue (WEST )) {
94
- faceFlags |= 1 << EnumFacing .WEST .getHorizontalIndex ();
95
- }
96
-
97
- return faceFlags ;
98
- }
99
-
100
- @ SuppressWarnings ("SimplifiableConditionalExpression" ) // more readable this way
101
- protected boolean canConnectTo (IBlockAccess blockAccess , BlockPos blockPos ) {
102
- IBlockState block = blockAccess .getBlockState (blockPos );
103
- return block .getBlock () == Blocks .barrier
104
- ? false
105
- : (block .getBlock () != this && !(block .getBlock () instanceof BlockFenceGate )
106
- ? (block .getMaterial ().isOpaque () && block .isFullCube ()
107
- ? block .getMaterial () != Material .gourd
108
- : false )
109
- : true );
32
+ return block ;
110
33
}
111
34
112
35
@ Override
@@ -127,12 +50,6 @@ public int damageDropped(IBlockState state) {
127
50
return getMetaFromState (state );
128
51
}
129
52
130
- @ SideOnly (Side .CLIENT )
131
- @ Override
132
- public boolean shouldSideBeRendered (IBlockState blockState , IBlockAccess blockAccess , BlockPos blockPos , EnumFacing enumFacing ) {
133
- return enumFacing != EnumFacing .DOWN || super .shouldSideBeRendered (blockState , blockAccess , blockPos , enumFacing );
134
- }
135
-
136
53
@ Override
137
54
public IBlockState getStateFromMeta (int meta ) {
138
55
return this .getDefaultState ().withProperty (prop , fromMeta (meta ));
@@ -145,12 +62,12 @@ public int getMetaFromState(IBlockState state) {
145
62
146
63
@ Override
147
64
public IBlockState getActualState (IBlockState blockState , IBlockAccess blockAccess , BlockPos blockPos ) {
148
- return blockState . withProperty ( UP , ! blockAccess . isAirBlock ( blockPos . up ())). withProperty ( NORTH , this . canConnectTo ( blockAccess , blockPos . north ())) .withProperty (EAST , this . canConnectTo ( blockAccess , blockPos . east ())). withProperty ( SOUTH , this . canConnectTo ( blockAccess , blockPos . south ())). withProperty ( WEST , this . canConnectTo ( blockAccess , blockPos . west ( )));
65
+ return super . getActualState ( blockState , blockAccess , blockPos ) .withProperty (prop , fromMeta ( getMetaFromState ( blockState )));
149
66
}
150
67
151
68
@ Override
152
69
protected BlockStateContainer createBlockState () {
153
- return new BlockStateContainer (this , UP , NORTH , EAST , WEST , SOUTH , prop == null ? tmp : prop );
70
+ return new BlockStateContainer (this , VARIANT , UP , NORTH , EAST , WEST , SOUTH , prop == null ? tmp : prop );
154
71
}
155
72
156
73
protected E fromMeta (int meta ) {
@@ -161,10 +78,6 @@ protected E fromMeta(int meta) {
161
78
return values [meta ];
162
79
}
163
80
164
- static {
165
- ACTUAL_BBS = new AxisAlignedBB []{BASE_BBS [0 ].setMaxY (1.5D ), BASE_BBS [1 ].setMaxY (1.5D ), BASE_BBS [2 ].setMaxY (1.5D ), BASE_BBS [3 ].setMaxY (1.5D ), BASE_BBS [4 ].setMaxY (1.5D ), BASE_BBS [5 ].setMaxY (1.5D ), BASE_BBS [6 ].setMaxY (1.5D ), BASE_BBS [7 ].setMaxY (1.5D ), BASE_BBS [8 ].setMaxY (1.5D ), BASE_BBS [9 ].setMaxY (1.5D ), BASE_BBS [10 ].setMaxY (1.5D ), BASE_BBS [11 ].setMaxY (1.5D ), BASE_BBS [12 ].setMaxY (1.5D ), BASE_BBS [13 ].setMaxY (1.5D ), BASE_BBS [14 ].setMaxY (1.5D ), BASE_BBS [15 ].setMaxY (1.5D )};
166
- }
167
-
168
81
public interface IEnumMeta {
169
82
int getMeta ();
170
83
}
0 commit comments