From ebcfb5f44057f564b90aedd35b5826c4da77cbd4 Mon Sep 17 00:00:00 2001 From: Vlad Vladov Date: Wed, 22 Apr 2026 00:40:11 +0300 Subject: [PATCH 1/3] cattlegrid: Remove 0 velocity and forbid mobs to pathfind it --- .../farm_and_charm/core/block/CattlegridBlock.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java b/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java index f4fd117f..c6845cda 100644 --- a/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java +++ b/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java @@ -18,11 +18,13 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.PathComputationType; +import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.satisfy.farm_and_charm.core.registry.TagRegistry; +import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -54,8 +56,7 @@ public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { return; } - if (entity instanceof Mob mob) { - mob.makeStuckInBlock(state, new Vec3(0.0, 1.0, 0.0)); + if (entity instanceof Mob) { return; } @@ -69,6 +70,11 @@ protected boolean isPathfindable(BlockState state, PathComputationType type) { return false; } + @Override + public @Nullable PathType getBlockPathType(BlockState state, BlockGetter level, BlockPos pos, @Nullable Mob mob) { + return PathType.BLOCKED; + } + @Override public @NotNull VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { return Shapes.block(); @@ -86,4 +92,4 @@ public void appendHoverText(ItemStack itemStack, Item.TooltipContext tooltipCont tooltip.add(Component.translatable("tooltip.farm_and_charm.tooltip_information.hold", shiftKey).withStyle(Style.EMPTY.withColor(TextColor.fromRgb(earthyColor)))); } } -} \ No newline at end of file +} From 465237267bddd04e836d9b622290e9dd1a843e6e Mon Sep 17 00:00:00 2001 From: Vlad Vladov Date: Wed, 22 Apr 2026 01:01:20 +0300 Subject: [PATCH 2/3] cattlegrid: Add collision effect via virtual walls --- .../core/block/CattlegridBlock.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java b/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java index c6845cda..1ed3f971 100644 --- a/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java +++ b/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java @@ -21,6 +21,7 @@ import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.EntityCollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.satisfy.farm_and_charm.core.registry.TagRegistry; @@ -30,6 +31,15 @@ import java.util.List; public class CattlegridBlock extends Block { + private static final VoxelShape FLOOR_COLLISION = Shapes.block(); + private static final VoxelShape MOB_WALLS = Shapes.or( + Block.box(0.0, 16.0, 0.0, 16.0, 28.0, 2.0), + Block.box(0.0, 16.0, 14.0, 16.0, 28.0, 16.0), + Block.box(0.0, 16.0, 0.0, 2.0, 28.0, 16.0), + Block.box(14.0, 16.0, 0.0, 16.0, 28.0, 16.0) + ); + private static final VoxelShape MOB_COLLISION = Shapes.or(FLOOR_COLLISION, MOB_WALLS); + public CattlegridBlock(Properties properties) { super(properties); } @@ -77,7 +87,16 @@ protected boolean isPathfindable(BlockState state, PathComputationType type) { @Override public @NotNull VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { - return Shapes.block(); + if (!(context instanceof EntityCollisionContext entityContext)) { + return MOB_COLLISION; + } + + Entity entity = entityContext.getEntity(); + if (!(entity instanceof Mob) || entity.getType().is(TagRegistry.CAN_WALK_OVER_CATTLEGRID)) { + return FLOOR_COLLISION; + } + + return MOB_COLLISION; } @Override From e99abcd4f0eefecde7519ecad0a680c8cdba7494 Mon Sep 17 00:00:00 2001 From: Vlad Vladov Date: Wed, 22 Apr 2026 01:22:02 +0300 Subject: [PATCH 3/3] cattlegrid: Remove pathfinding because build is failing due `common` source Should be available on Fabric and NeoForge, but `getBlockPathType` available only in NeoForge --- .../satisfy/farm_and_charm/core/block/CattlegridBlock.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java b/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java index 1ed3f971..6faaee27 100644 --- a/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java +++ b/common/src/main/java/net/satisfy/farm_and_charm/core/block/CattlegridBlock.java @@ -18,14 +18,12 @@ import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.pathfinder.PathComputationType; -import net.minecraft.world.level.pathfinder.PathType; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.EntityCollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; import net.satisfy.farm_and_charm.core.registry.TagRegistry; -import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.NotNull; import java.util.List; @@ -80,11 +78,6 @@ protected boolean isPathfindable(BlockState state, PathComputationType type) { return false; } - @Override - public @Nullable PathType getBlockPathType(BlockState state, BlockGetter level, BlockPos pos, @Nullable Mob mob) { - return PathType.BLOCKED; - } - @Override public @NotNull VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { if (!(context instanceof EntityCollisionContext entityContext)) {