6
6
import net .minecraft .core .Direction ;
7
7
import net .minecraft .sounds .SoundEvent ;
8
8
import net .minecraft .sounds .SoundEvents ;
9
+ import net .minecraft .tags .FluidTags ;
9
10
import net .minecraft .world .InteractionHand ;
10
11
import net .minecraft .world .InteractionResult ;
11
12
import net .minecraft .world .entity .Entity ;
14
15
import net .minecraft .world .entity .player .Player ;
15
16
import net .minecraft .world .item .ItemStack ;
16
17
import net .minecraft .world .item .Items ;
18
+ import net .minecraft .world .item .context .BlockPlaceContext ;
17
19
import net .minecraft .world .level .BlockGetter ;
18
20
import net .minecraft .world .level .Level ;
19
21
import net .minecraft .world .level .LevelAccessor ;
23
25
import net .minecraft .world .level .block .entity .BlockEntity ;
24
26
import net .minecraft .world .level .block .state .BlockBehaviour ;
25
27
import net .minecraft .world .level .block .state .BlockState ;
28
+ import net .minecraft .world .level .gameevent .GameEvent ;
26
29
import net .minecraft .world .level .material .FluidState ;
27
30
import net .minecraft .world .level .material .Material ;
31
+ import net .minecraft .world .level .material .MaterialColor ;
28
32
import net .minecraft .world .level .pathfinder .BlockPathTypes ;
29
33
import net .minecraft .world .phys .BlockHitResult ;
30
34
import net .minecraft .world .phys .Vec3 ;
31
35
import net .minecraft .world .phys .shapes .CollisionContext ;
32
36
import net .minecraft .world .phys .shapes .EntityCollisionContext ;
33
37
import net .minecraft .world .phys .shapes .Shapes ;
34
38
import net .minecraft .world .phys .shapes .VoxelShape ;
39
+ import net .minecraftforge .client .IBlockRenderProperties ;
35
40
36
41
import javax .annotation .Nullable ;
37
42
import java .util .Optional ;
43
+ import java .util .function .Consumer ;
38
44
39
45
public class MoltenLeadBlock extends Block implements BucketPickup {
40
46
public MoltenLeadBlock () {
41
- super (BlockBehaviour .Properties .of (Material .LAVA )
47
+ super (BlockBehaviour .Properties .of (( new Material .Builder ( MaterialColor . COLOR_PURPLE )). noCollider (). nonSolid (). liquid (). build () )
42
48
.strength (-1.0F , 3600000.0F )
43
49
.noDrops ()
44
50
.requiresCorrectToolForDrops ());
45
51
}
46
52
47
53
54
+
55
+ @ Override
56
+ public boolean skipRendering (BlockState p_60532_ , BlockState p_60533_ , Direction p_60534_ ) {
57
+ return super .skipRendering (p_60532_ , p_60533_ , p_60534_ );
58
+ }
59
+
60
+ @ Override
61
+ public BlockState updateShape (BlockState state , Direction p_60542_ , BlockState neighbour , LevelAccessor level , BlockPos pos , BlockPos neighbourPos ) {
62
+ if (level .isWaterAt (neighbourPos )) {
63
+ level .levelEvent (1501 , pos , 0 );
64
+
65
+ return RegistryHandler .LEAD_BLOCK .get ().defaultBlockState ();
66
+ }
67
+
68
+ return super .updateShape (state , p_60542_ , neighbour , level , pos , neighbourPos );
69
+ }
70
+
71
+ @ Override
72
+ public void neighborChanged (BlockState p_60509_ , Level level , BlockPos pos , Block p_60512_ , BlockPos neighbourPos , boolean p_60514_ ) {
73
+ if (level .getFluidState (neighbourPos ).is (FluidTags .WATER )) {
74
+ level .setBlockAndUpdate (pos , RegistryHandler .LEAD_BLOCK .get ().defaultBlockState ());
75
+
76
+ level .levelEvent (1501 , pos , 0 );
77
+ } else if (level .getFluidState (neighbourPos ).is (FluidTags .LAVA )) {
78
+
79
+ }
80
+
81
+
82
+ super .neighborChanged (p_60509_ , level , pos , p_60512_ , neighbourPos , p_60514_ );
83
+ }
84
+
48
85
/**
49
86
* Get the {@code PathNodeType} for this block. Return {@code null} for vanilla behavior.
50
87
*
@@ -74,33 +111,6 @@ public boolean canEntityDestroy(BlockState state, BlockGetter world, BlockPos po
74
111
return false ;
75
112
}
76
113
77
- @ Override
78
- public void playerWillDestroy (Level p_49852_ , BlockPos p_49853_ , BlockState p_49854_ , Player p_49855_ ) { }
79
-
80
- /**
81
- * Called when a player removes a block. This is responsible for
82
- * actually destroying the block, and the block is intact at time of call.
83
- * This is called regardless of whether the player can harvest the block or
84
- * not.
85
- * <p>
86
- * Return true if the block is actually destroyed.
87
- * <p>
88
- * Note: When used in multiplayer, this is called on both client and
89
- * server sides!
90
- *
91
- * @param state The current state.
92
- * @param world The current world
93
- * @param pos Block position in world
94
- * @param player The player damaging the block, may be null
95
- * @param willHarvest True if Block.harvestBlock will be called after this, if the return in true.
96
- * Can be useful to delay the destruction of tile entities till after harvestBlock
97
- * @param fluid The current fluid state at current position
98
- * @return True if the block is actually destroyed.
99
- */
100
- @ Override
101
- public boolean removedByPlayer (BlockState state , Level world , BlockPos pos , Player player , boolean willHarvest , FluidState fluid ) {
102
- return false ;
103
- }
104
114
105
115
@ Override
106
116
public int getLightBlock (BlockState p_60585_ , BlockGetter p_60586_ , BlockPos p_60587_ ) {
@@ -118,25 +128,16 @@ public VoxelShape getCollisionShape(BlockState p_60572_, BlockGetter p_60573_, B
118
128
}
119
129
return Shapes .empty ();
120
130
}
121
-
122
- @ Override
123
- public FluidState getFluidState (BlockState p_60577_ ) {
124
- return RegistryHandler .LEAD_FLUID .get ().defaultFluidState ();
125
- }
126
-
131
+
127
132
@ Override
128
133
public VoxelShape getShape (BlockState p_60555_ , BlockGetter p_60556_ , BlockPos p_60557_ , CollisionContext p_60558_ ) {
129
- //return p_60558_.isHoldingItem(Items.BUCKET) || p_60558_.isHoldingItem(RegistryHandler.MOLTEN_LEAD_BUCKET.get()) ? Shapes.block() : Shapes.empty();
130
- return Shapes .empty ();
131
- }
132
-
133
- /*@Override
134
- public InteractionResult use(BlockState p_60503_, Level p_60504_, BlockPos p_60505_, Player p_60506_, InteractionHand p_60507_, BlockHitResult p_60508_) {
135
- if (p_60506_.getItemInHand(p_60507_).getItem().equals(Items.BUCKET) || p_60506_.getItemInHand(p_60507_).getItem().equals(RegistryHandler.MOLTEN_LEAD_BUCKET.get())){
136
- return InteractionResult.SUCCESS;
134
+ if (((EntityCollisionContext )p_60558_ ).getEntity ().isPresent ()) {
135
+ return p_60558_ .isHoldingItem (Items .BUCKET )
136
+ || p_60558_ .isHoldingItem (RegistryHandler .MOLTEN_LEAD_BUCKET .get ()) ? Shapes .block () : Shapes .empty ();
137
137
}
138
- return InteractionResult.PASS;
139
- }*/
138
+
139
+ return Shapes .block ();
140
+ }
140
141
141
142
/**
142
143
* Determines if the player can harvest this block, obtaining it's drops when the block is destroyed.
@@ -178,8 +179,4 @@ public Optional<SoundEvent> getPickupSound() {
178
179
return Optional .of (SoundEvents .BUCKET_FILL_LAVA );
179
180
}
180
181
181
- /*@Override
182
- public boolean isSideInvisible(BlockState state, BlockState adjacentBlockState, Direction side) {
183
- return state.getBlock().equals(adjacentBlockState.getBlock());
184
- }*/
185
182
}
0 commit comments