diff --git a/patches/server/0070-Configurable-bamboo-collision.patch b/patches/server/0070-Configurable-bamboo-collision.patch new file mode 100644 index 00000000..2608e6a6 --- /dev/null +++ b/patches/server/0070-Configurable-bamboo-collision.patch @@ -0,0 +1,78 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: HaHaWTH +Date: Sun, 12 May 2024 16:04:13 +0800 +Subject: [PATCH] Configurable-bamboo-collision + + +diff --git a/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java b/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java +index e2951dd077441fe9cda461a2d3ef0c0671308316..3c3372fe12ced30e5f1f66ec15233ca6c4880034 100644 +--- a/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/BambooStalkBlock.java +@@ -35,7 +35,7 @@ public class BambooStalkBlock extends Block implements BonemealableBlock { + protected static final float COLLISION_AABB_OFFSET = 1.5F; + protected static final VoxelShape SMALL_SHAPE = Block.box(5.0D, 0.0D, 5.0D, 11.0D, 16.0D, 11.0D); + protected static final VoxelShape LARGE_SHAPE = Block.box(3.0D, 0.0D, 3.0D, 13.0D, 16.0D, 13.0D); +- protected static final VoxelShape COLLISION_SHAPE = Block.box(6.5D, 0.0D, 6.5D, 9.5D, 16.0D, 9.5D); ++ protected static final VoxelShape COLLISION_SHAPE = org.dreeam.leaf.config.modules.gameplay.ConfigurableBambooCollision.enableCollision ? Block.box(6.5D, 0.0D, 6.5D, 9.5D, 16.0D, 9.5D) : Block.box(0.0D, 15.9D, 0.0D, 16.0D, 16.0D, 16.0D); // Leaf - Configurable bamboo collision + public static final IntegerProperty AGE = BlockStateProperties.AGE_1; + public static final EnumProperty LEAVES = BlockStateProperties.BAMBOO_LEAVES; + public static final IntegerProperty STAGE = BlockStateProperties.STAGE; +@@ -80,9 +80,17 @@ public class BambooStalkBlock extends Block implements BonemealableBlock { + + @Override + protected VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { +- Vec3 vec3d = state.getOffset(world, pos); ++ // Leaf start - Configurable bamboo collision ++ if (org.dreeam.leaf.config.modules.gameplay.ConfigurableBambooCollision.enableCollision) { ++ Vec3 vec3d = state.getOffset(world, pos); + +- return BambooStalkBlock.COLLISION_SHAPE.move(vec3d.x, vec3d.y, vec3d.z); ++ return BambooStalkBlock.COLLISION_SHAPE.move(vec3d.x, vec3d.y, vec3d.z); ++ } else { ++ return context.isAbove(net.minecraft.world.phys.shapes.Shapes.block(), pos, true) ++ ? COLLISION_SHAPE // Prevent desync ++ : net.minecraft.world.phys.shapes.Shapes.empty(); ++ } ++ // Leaf end + } + + @Override +diff --git a/src/main/java/org/dreeam/leaf/config/modules/gameplay/ConfigurableBambooCollision.java b/src/main/java/org/dreeam/leaf/config/modules/gameplay/ConfigurableBambooCollision.java +new file mode 100644 +index 0000000000000000000000000000000000000000..c40ba24f1bdcdbb9d1c2acab46ff2985ce8c3dc3 +--- /dev/null ++++ b/src/main/java/org/dreeam/leaf/config/modules/gameplay/ConfigurableBambooCollision.java +@@ -0,0 +1,33 @@ ++package org.dreeam.leaf.config.modules.gameplay; ++ ++import com.electronwill.nightconfig.core.file.CommentedFileConfig; ++import org.dreeam.leaf.config.ConfigInfo; ++import org.dreeam.leaf.config.EnumConfigCategory; ++import org.dreeam.leaf.config.HotReloadUnsupported; ++import org.dreeam.leaf.config.IConfigModule; ++ ++public class ConfigurableBambooCollision implements IConfigModule { ++ ++ @Override ++ public EnumConfigCategory getCategory() { ++ return EnumConfigCategory.GAMEPLAY; ++ } ++ ++ @Override ++ public String getBaseName() { ++ return "configurable_bamboo_collision"; ++ } ++ ++ @HotReloadUnsupported ++ @ConfigInfo(baseName = "enable-collision") ++ public static boolean enableCollision = true; ++ ++ @Override ++ public void onLoaded(CommentedFileConfig config) { ++ config.setComment("gameplay.configurable_bamboo_collision", """ ++ Should we enable the collision of bamboo? ++ Disable collision will fix Geyser players' buggy movement when they close to these blocks ++ But all players can pass through Bamboo blocks directly ++ """); ++ } ++}