1
1
package com .uraneptus .sullysmod .common .blocks ;
2
2
3
+ import com .uraneptus .sullysmod .core .registry .SMBlockEntityTypes ;
4
+ import com .uraneptus .sullysmod .core .registry .SMBlocks ;
3
5
import net .minecraft .core .BlockPos ;
6
+ import net .minecraft .core .particles .ParticleTypes ;
7
+ import net .minecraft .util .Mth ;
8
+ import net .minecraft .util .RandomSource ;
4
9
import net .minecraft .world .entity .Entity ;
5
10
import net .minecraft .world .entity .LivingEntity ;
11
+ import net .minecraft .world .entity .Mob ;
12
+ import net .minecraft .world .entity .player .Player ;
6
13
import net .minecraft .world .level .BlockGetter ;
7
14
import net .minecraft .world .level .Level ;
8
15
import net .minecraft .world .level .LightLayer ;
16
+ import net .minecraft .world .level .block .BaseEntityBlock ;
9
17
import net .minecraft .world .level .block .HalfTransparentBlock ;
18
+ import net .minecraft .world .level .block .entity .BlockEntity ;
10
19
import net .minecraft .world .level .block .state .BlockState ;
20
+ import net .minecraft .world .phys .Vec3 ;
11
21
import net .minecraft .world .phys .shapes .CollisionContext ;
12
22
import net .minecraft .world .phys .shapes .EntityCollisionContext ;
13
23
import net .minecraft .world .phys .shapes .Shapes ;
14
24
import net .minecraft .world .phys .shapes .VoxelShape ;
25
+ import org .jetbrains .annotations .Nullable ;
15
26
16
- public class AmberBlock extends HalfTransparentBlock {
27
+ public class AmberBlock extends BaseEntityBlock {
17
28
18
29
private static final VoxelShape MELTING_COLLISION_SHAPE = Shapes .box (0.0D , 0.0D , 0.0D , 1.0D , (double )0.0F , 1.0D );
19
30
20
- LivingEntity ENTITY_STUCK ;
21
31
public AmberBlock (Properties pProperties ) {
22
32
super (pProperties );
23
33
}
@@ -37,8 +47,27 @@ public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, Block
37
47
return Shapes .block ();
38
48
}
39
49
40
- /*
50
+ public void onRemove ( BlockState pState , Level pLevel , BlockPos pPos , BlockState pNewState , boolean pIsMoving ) {
41
51
52
+ //Entity entity = pLevel.getNearestEntity(new ArrayList<>(), TargetingConditions.DEFAULT, null, pPos.getX(), pPos.getY(), pPos.getZ());
53
+ BlockEntity blockEntity = pLevel .getBlockEntity (pPos );
54
+ assert blockEntity != null ;
55
+ Entity entity = pLevel .getEntity (((AmberBlockEntity ) blockEntity ).getStuckMob ());
56
+ if (entity instanceof Mob mob ) {
57
+ mob .setNoAi (false );
58
+ }
59
+ System .out .println ("AMBER BROKE" );
60
+ super .onRemove (pState , pLevel , pPos , pNewState , pIsMoving );
61
+ }
62
+
63
+ @ Nullable
64
+ @ Override
65
+ public BlockEntity newBlockEntity (BlockPos pPos , BlockState pState ) {
66
+ return SMBlockEntityTypes .AMBER .get ().create (pPos , pState );
67
+ }
68
+
69
+
70
+ /*
42
71
public void entityInside(BlockState pState, Level pLevel, BlockPos pPos, Entity pEntity) {
43
72
if (!(pEntity instanceof LivingEntity) || pEntity.getFeetBlockState().is(this)) {
44
73
if (pEntity instanceof Player) {
@@ -50,7 +79,7 @@ public void entityInside(BlockState pState, Level pLevel, BlockPos pPos, Entity
50
79
mob.setRemainingFireTicks(0);
51
80
mob.setInvulnerable(true);
52
81
mob.setNoAi(true);
53
- ENTITY_STUCK = mob ;
82
+ System.out.println("MOB STUCK IN AMBER") ;
54
83
}
55
84
}
56
85
if (pLevel.isClientSide) {
@@ -63,5 +92,6 @@ public void entityInside(BlockState pState, Level pLevel, BlockPos pPos, Entity
63
92
}
64
93
}
65
94
66
- */
95
+ */
96
+
67
97
}
0 commit comments