Skip to content

Commit e8840a2

Browse files
authored
Fix placeholders being destroyed by water (#831)
1 parent 9ea1528 commit e8840a2

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +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.block.AbstractGlassBlock;
7+
import net.minecraft.world.level.LevelAccessor;
88
import net.minecraft.world.level.block.Block;
99
import net.minecraft.world.level.block.Blocks;
10+
import net.minecraft.world.level.block.LiquidBlockContainer;
1011
import net.minecraft.world.level.block.SoundType;
1112
import net.minecraft.world.level.block.state.BlockState;
13+
import net.minecraft.world.level.material.Fluid;
14+
import net.minecraft.world.level.material.FluidState;
1215
import net.minecraft.world.level.material.MapColor;
1316
import net.minecraft.world.phys.shapes.CollisionContext;
1417
import net.minecraft.world.phys.shapes.EntityCollisionContext;
@@ -19,14 +22,15 @@
1922
* 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
2023
* location and ground.
2124
*/
22-
public class BlockSubstitution extends Block
25+
public class BlockSubstitution extends Block implements LiquidBlockContainer
2326
{
2427
/**
2528
* Constructor for the Substitution block. sets the creative tab, as well as the resistance and the hardness.
2629
*/
2730
public BlockSubstitution()
2831
{
29-
super(defaultSubstitutionProperties());
32+
super(defaultSubstitutionProperties()
33+
.forceSolidOff()); // don't kill farmland and path blocks underneath
3034
}
3135

3236
public static Properties defaultSubstitutionProperties()
@@ -36,8 +40,7 @@ public static Properties defaultSubstitutionProperties()
3640
.sound(SoundType.WOOD)
3741
.instabreak() // must be before explosionResistance
3842
.explosionResistance(Blocks.OAK_PLANKS.getExplosionResistance())
39-
.noOcclusion()
40-
.forceSolidOff();
43+
.noOcclusion();
4144
}
4245

4346
@Override
@@ -66,4 +69,17 @@ public VoxelShape getBlockSupportShape(BlockState state, BlockGetter worldIn, Bl
6669
// Allow torches etc to be placed on the faces regardless of collision shape
6770
return Shapes.block();
6871
}
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+
}
6985
}

0 commit comments

Comments
 (0)