44import net .minecraft .core .BlockPos ;
55import net .minecraft .world .entity .player .Player ;
66import net .minecraft .world .level .BlockGetter ;
7+ import net .minecraft .world .level .LevelAccessor ;
78import net .minecraft .world .level .block .Block ;
89import net .minecraft .world .level .block .Blocks ;
10+ import net .minecraft .world .level .block .LiquidBlockContainer ;
911import net .minecraft .world .level .block .SoundType ;
1012import net .minecraft .world .level .block .state .BlockState ;
13+ import net .minecraft .world .level .material .Fluid ;
14+ import net .minecraft .world .level .material .FluidState ;
1115import net .minecraft .world .level .material .MapColor ;
1216import net .minecraft .world .phys .shapes .CollisionContext ;
1317import net .minecraft .world .phys .shapes .EntityCollisionContext ;
1822 * This block is used as a substitution block for the Builder. Every solid block can be substituted by this block in schematics. This helps make schematics independent from
1923 * location and ground.
2024 */
21- public class BlockSubstitution extends Block
25+ public class BlockSubstitution extends Block implements LiquidBlockContainer
2226{
2327 /**
2428 * Constructor for the Substitution block. sets the creative tab, as well as the resistance and the hardness.
2529 */
2630 public BlockSubstitution ()
2731 {
28- super (defaultSubstitutionProperties ());
32+ super (defaultSubstitutionProperties ()
33+ .forceSolidOff ()); // don't kill farmland and path blocks underneath
2934 }
3035
3136 public static Properties defaultSubstitutionProperties ()
@@ -35,8 +40,7 @@ public static Properties defaultSubstitutionProperties()
3540 .sound (SoundType .WOOD )
3641 .instabreak () // must be before explosionResistance
3742 .explosionResistance (Blocks .OAK_PLANKS .getExplosionResistance ())
38- .noOcclusion ()
39- .forceSolidOff ();
43+ .noOcclusion ();
4044 }
4145
4246 @ Override
@@ -65,4 +69,17 @@ public VoxelShape getBlockSupportShape(BlockState state, BlockGetter worldIn, Bl
6569 // Allow torches etc to be placed on the faces regardless of collision shape
6670 return Shapes .block ();
6771 }
72+
73+ @ Override
74+ public boolean canPlaceLiquid (BlockGetter worldIn , BlockPos pos , BlockState state , Fluid fluid )
75+ {
76+ // Don't allow water to flow inside despite being non-solid
77+ return false ;
78+ }
79+
80+ @ Override
81+ public boolean placeLiquid (LevelAccessor worldIn , BlockPos pos , BlockState state , FluidState fluid )
82+ {
83+ return false ;
84+ }
6885}
0 commit comments