2
2
3
3
import com .ryorama .terrariamod .blocks .BlocksT ;
4
4
import com .ryorama .terrariamod .items .impl .*;
5
- import net .minecraft .block .Block ;
6
- import net .minecraft .block .BlockState ;
7
- import net .minecraft .block .entity .BlockEntity ;
8
- import net .minecraft .entity .player .PlayerEntity ;
9
- import net .minecraft .item .ItemStack ;
10
- import net .minecraft .util .math .BlockPos ;
11
- import net .minecraft .world .BlockView ;
12
- import net .minecraft .world .World ;
13
- import net .minecraft .world .WorldAccess ;
14
- import org .jetbrains .annotations .Nullable ;
5
+ import net .minecraft .core .BlockPos ;
6
+ import net .minecraft .world .entity .player .Player ;
7
+ import net .minecraft .world .level .BlockGetter ;
8
+ import net .minecraft .world .level .LevelAccessor ;
9
+ import net .minecraft .world .level .block .Block ;
10
+ import net .minecraft .world .level .block .state .BlockBehaviour ;
11
+ import net .minecraft .world .level .block .state .BlockState ;
15
12
16
13
import java .util .ArrayList ;
17
14
import java .util .Random ;
@@ -37,15 +34,15 @@ public class BlockT extends Block {
37
34
public String name ;
38
35
public String shape = "" ;
39
36
40
- protected ArrayList <String > allowed = new ArrayList <String >();
37
+ protected ArrayList <String > allowed = new ArrayList <>();
41
38
42
- public BlockT (Settings properties , float hardness , float difficulty ) {
43
- super (properties .hardness (hardness * 0.03f ));
39
+ public BlockT (BlockBehaviour . Properties properties , float hardness , float difficulty ) {
40
+ super (properties .destroyTime (hardness * 0.03f ));
44
41
this .difficulty = difficulty ;
45
42
}
46
43
47
- public BlockT (Settings properties , float hardness , float difficulty , int luminance ) {
48
- super (properties .hardness (hardness * 0.03f ).nonOpaque ().luminance (new ToIntFunction <BlockState >() {
44
+ public BlockT (BlockBehaviour . Properties properties , float hardness , float difficulty , int luminance ) {
45
+ super (properties .destroyTime (hardness * 0.03f ).noOcclusion ().lightLevel (new ToIntFunction <BlockState >() {
49
46
@ Override
50
47
public int applyAsInt (BlockState value ) {
51
48
return luminance ;
@@ -87,13 +84,13 @@ public BlockT setAxe(boolean axe) {
87
84
}
88
85
89
86
@ Override
90
- public void onBroken (WorldAccess world , BlockPos pos , BlockState state ) {
87
+ public void onBroken (LevelAccessor world , BlockPos pos , BlockState state ) {
91
88
for (int t = 0 ; t <= 20 ; t ++) {
92
89
BlockPos abovePos = new BlockPos (pos .getX (), pos .getY () + t , pos .getZ ());
93
90
Block aboveBlock = world .getBlockState (abovePos ).getBlock ();
94
91
95
92
if (aboveBlock instanceof PlantT && aboveBlock != BlocksT .VINE .get () || aboveBlock instanceof TreeSegment ) {
96
- world .breakBlock (abovePos , true );
93
+ world .destroyBlock (abovePos , true );
97
94
}
98
95
}
99
96
@@ -102,15 +99,15 @@ public void onBroken(WorldAccess world, BlockPos pos, BlockState state) {
102
99
Block bottomBlock = world .getBlockState (bottomPos ).getBlock ();
103
100
104
101
if (bottomBlock == BlocksT .VINE .get ()) {
105
- world .breakBlock (bottomPos , false );
102
+ world .destroyBlock (bottomPos , false );
106
103
}
107
104
}
108
105
}
109
106
110
107
@ Override
111
- public float calcBlockBreakingDelta (BlockState state , PlayerEntity player , BlockView world , BlockPos pos ) {
112
- if (player .getMainHandStack ().getItem () instanceof ItemT || player .getMainHandStack ().getItem () instanceof PickaxeT || player .getMainHandStack ().getItem () instanceof AxeT || player .getMainHandStack ().getItem () instanceof ShortswordT || player .getMainHandStack ().getItem () instanceof BroadswordT ) {
113
- return getMiningSpeed ((ItemT ) player .getMainHandStack ().getItem ());
108
+ public float calcBlockBreakingDelta (BlockState state , Player player , BlockGetter world , BlockPos pos ) {
109
+ if (player .getMainHandItem ().getItem () instanceof ItemT || player .getMainHandItem ().getItem () instanceof PickaxeT || player .getMainHandStack ().getItem () instanceof AxeT || player .getMainHandItem ().getItem () instanceof ShortswordT || player .getMainHandItem ().getItem () instanceof BroadswordT ) {
110
+ return getMiningSpeed ((ItemT ) player .getMainHandItem ().getItem ());
114
111
} else {
115
112
return -1 ;
116
113
}
0 commit comments