Skip to content

Commit 70bb389

Browse files
committed
Fix placeholders being destroyed by water (#831)
1 parent e909e77 commit 70bb389

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

src/main/java/com/ldtteam/structurize/blocks/schematic/BlockSubstitution.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,14 @@
44
import net.minecraft.core.BlockPos;
55
import net.minecraft.world.entity.player.Player;
66
import net.minecraft.world.level.BlockGetter;
7+
import net.minecraft.world.level.LevelAccessor;
78
import net.minecraft.world.level.block.Block;
89
import net.minecraft.world.level.block.Blocks;
10+
import net.minecraft.world.level.block.LiquidBlockContainer;
911
import net.minecraft.world.level.block.SoundType;
1012
import net.minecraft.world.level.block.state.BlockState;
13+
import net.minecraft.world.level.material.Fluid;
14+
import net.minecraft.world.level.material.FluidState;
1115
import net.minecraft.world.level.material.MapColor;
1216
import net.minecraft.world.phys.shapes.CollisionContext;
1317
import net.minecraft.world.phys.shapes.EntityCollisionContext;
@@ -18,14 +22,15 @@
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

Comments
 (0)