Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.AbstractGlassBlock;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.LiquidBlockContainer;
import net.minecraft.world.level.block.SoundType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.MapColor;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
Expand All @@ -19,14 +22,15 @@
* 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
* location and ground.
*/
public class BlockSubstitution extends Block
public class BlockSubstitution extends Block implements LiquidBlockContainer
{
/**
* Constructor for the Substitution block. sets the creative tab, as well as the resistance and the hardness.
*/
public BlockSubstitution()
{
super(defaultSubstitutionProperties());
super(defaultSubstitutionProperties()
.forceSolidOff()); // don't kill farmland and path blocks underneath
}

public static Properties defaultSubstitutionProperties()
Expand All @@ -36,8 +40,7 @@ public static Properties defaultSubstitutionProperties()
.sound(SoundType.WOOD)
.instabreak() // must be before explosionResistance
.explosionResistance(Blocks.OAK_PLANKS.getExplosionResistance())
.noOcclusion()
.forceSolidOff();
.noOcclusion();
}

@Override
Expand Down Expand Up @@ -66,4 +69,17 @@ public VoxelShape getBlockSupportShape(BlockState state, BlockGetter worldIn, Bl
// Allow torches etc to be placed on the faces regardless of collision shape
return Shapes.block();
}

@Override
public boolean canPlaceLiquid(BlockGetter worldIn, BlockPos pos, BlockState state, Fluid fluid)
{
// Don't allow water to flow inside despite being non-solid
return false;
}

@Override
public boolean placeLiquid(LevelAccessor worldIn, BlockPos pos, BlockState state, FluidState fluid)
{
return false;
}
}
Loading