mirror of
https://github.com/Samsuik/Sakura.git
synced 2025-12-27 18:59:06 +00:00
Configure players colliding with cobwebs
This commit is contained in:
@@ -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<WebBlock> 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) {
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user