Add collisionExtendsVertically hook to allow modded blocks that extend collision into the block above similar to fences. (#6092)

This commit is contained in:
Wire Segal authored and LexManos committed 2019-09-03 14:50:27 -07:00
1 parent 68524ddde9
commit c09fe57031
4 files changed
+31 -2

No files matched your search

@@ -29,6 +29,7 @@ import javax.annotation.Nullable;
import net.minecraft.block.Block;
import net.minecraft.block.BedBlock;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.block.FenceGateBlock;
import net.minecraft.block.FireBlock;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.IBeaconBeamColorProvider;
@@ -1024,4 +1025,13 @@ public interface IForgeBlock
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 3);
getBlock().onExplosionDestroy(world, pos, explosion);
}
/**
* Determines if this block's collision box should be treated as though it can extend above its block space.
* Use this to replicate fence and wall behavior.
*/
default boolean collisionExtendsVertically(BlockState state, IBlockReader world, BlockPos pos, Entity collidingEntity)
{
return getBlock().isIn(BlockTags.FENCES) || getBlock().isIn(BlockTags.WALLS) || getBlock() instanceof FenceGateBlock;
}
}
@@ -867,4 +867,13 @@ public interface IForgeBlockState
{
getBlockState().getBlock().onBlockExploded(getBlockState(), world, pos, explosion);
}
/**
* Determines if this block's collision box should be treated as though it can extend above its block space.
* This can be used to replicate fence and wall behavior.
*/
default boolean collisionExtendsVertically(IBlockReader world, BlockPos pos, Entity collidingEntity)
{
return getBlockState().getBlock().collisionExtendsVertically(getBlockState(), world, pos, collidingEntity);
}
}