From 1f7c1af374e960330ebf2e66c91cee89c316346d Mon Sep 17 00:00:00 2001 From: Samsuik Date: Sun, 28 Sep 2025 16:43:30 +0100 Subject: [PATCH] Configure players colliding with cobwebs --- .../world/level/block/WebBlock.java.patch | 42 +++++++++++++++++++ .../configuration/WorldConfiguration.java | 1 + 2 files changed, 43 insertions(+) create mode 100644 sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/WebBlock.java.patch diff --git a/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/WebBlock.java.patch b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/WebBlock.java.patch new file mode 100644 index 0000000..9a9d901 --- /dev/null +++ b/sakura-server/minecraft-patches/sources/net/minecraft/world/level/block/WebBlock.java.patch @@ -0,0 +1,42 @@ +--- a/net/minecraft/world/level/block/WebBlock.java ++++ b/net/minecraft/world/level/block/WebBlock.java +@@ -10,6 +_,7 @@ + import net.minecraft.world.level.block.state.BlockBehaviour; + import net.minecraft.world.level.block.state.BlockState; + import net.minecraft.world.phys.Vec3; ++import net.minecraft.world.phys.shapes.EntityCollisionContext; + + public class WebBlock extends Block { + public static final MapCodec CODEC = simpleCodec(WebBlock::new); +@@ -22,6 +_,31 @@ + public WebBlock(BlockBehaviour.Properties properties) { + super(properties); + } ++ ++ // Sakura start - configure players colliding with cobwebs ++ @Override ++ protected final net.minecraft.world.phys.shapes.VoxelShape getCollisionShape( ++ final BlockState state, ++ final net.minecraft.world.level.BlockGetter blockGetter, ++ final BlockPos pos, ++ final net.minecraft.world.phys.shapes.CollisionContext context ++ ) { ++ if (blockGetter instanceof Level level ++ && level.sakuraConfig().players.collideWithCobwebs ++ && context instanceof EntityCollisionContext entityContext ++ && entityContext.getEntity() instanceof net.minecraft.world.entity.player.Player) { ++ final BlockPos blockPosAbove = pos.above(); ++ final BlockState stateAbove = level.getBlockState(blockPosAbove); ++ ++ // If the block above is a full block then this cobweb should have a solid collision (for players) ++ if (stateAbove.getCollisionShape(level, blockPosAbove, context).moonrise$isFullBlock()) { ++ return net.minecraft.world.phys.shapes.Shapes.block(); ++ } ++ } ++ ++ return super.getCollisionShape(state, blockGetter, pos, context); ++ } ++ // Sakura end - configure players colliding with cobwebs + + @Override + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { diff --git a/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java index 92abed0..edf3a71 100644 --- a/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java +++ b/sakura-server/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java @@ -188,6 +188,7 @@ public final class WorldConfiguration extends ConfigurationPart { public boolean posesShrinkCollisionBox = true; public boolean fishingHooksPullEntities = true; public boolean preventPlacingSpawnEggsInsideBlocks = false; + public boolean collideWithCobwebs = false; } public Entity entity;