-
-
Notifications
You must be signed in to change notification settings - Fork 68
Bedrock block hitboxes #919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
FlorianMichael
merged 21 commits into
ViaVersion:main
from
Exterminate5573:feat/bedrock-hitboxes
Nov 3, 2025
Merged
Changes from 9 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
aef1ad5
Adjust Bedrock Hitboxes
Exterminate5573 58ca0e1
Merge branch 'ViaVersion:main' into feat/bedrock-hitboxes
Exterminate5573 a5c013f
Merge branch 'main' into feat/bedrock-hitboxes
FlorianMichael fc66e79
Revert incorrect changes
Exterminate5573 658e4a3
Merge remote-tracking branch 'origin/feat/bedrock-hitboxes' into feat…
Exterminate5573 7677987
Fix bedrock chest collision
Exterminate5573 5502795
Bro
Exterminate5573 abe1668
Exact bedrock shape
Exterminate5573 602f40f
More block collision shapes
Exterminate5573 a054bb4
trapdoor
Exterminate5573 af28d0e
De-float and fix culling shapes
Exterminate5573 5e3f339
Clean mixins
Exterminate5573 164643c
Finalize block shapes
Exterminate5573 3d911fb
Unify method names
Exterminate5573 bc91881
Dragon egg
Exterminate5573 cc45166
Sea pickle
Exterminate5573 27dd03a
Candle Cake
Exterminate5573 dcd4e76
Fix pickle outline shape
Exterminate5573 694ec07
Fix pickle outline shape
Exterminate5573 72b8357
Merge branch 'main' into feat/bedrock-hitboxes
Exterminate5573 6d11363
Refactor to bedrock package
Exterminate5573 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...a/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinCactusBlock.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
| * Copyright (C) 2021-2025 the original authors | ||
| * - FlorianMichael/EnZaXD <[email protected]> | ||
| * - RK_01/RaphiMC | ||
| * Copyright (C) 2023-2025 ViaVersion and contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.viaversion.viafabricplus.injection.mixin.features.block.shape; | ||
|
|
||
| import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
| import net.minecraft.block.BlockState; | ||
| import net.minecraft.block.CactusBlock; | ||
| import net.minecraft.block.ShapeContext; | ||
| import net.minecraft.util.math.BlockPos; | ||
| import net.minecraft.util.shape.VoxelShape; | ||
| import net.minecraft.util.shape.VoxelShapes; | ||
| import net.minecraft.world.BlockView; | ||
| import net.raphimc.viabedrock.api.BedrockProtocolVersion; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Unique; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
|
||
| @Mixin(CactusBlock.class) | ||
| public abstract class MixinCactusBlock { | ||
|
|
||
| @Unique | ||
| private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.cuboid(0.025, 0, 0.025, 0.975, 1, 0.975); | ||
|
|
||
| @Inject(method = "getCollisionShape", at = @At(value = "RETURN"), cancellable = true) | ||
| private void modifyCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) { | ||
| if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { | ||
| cir.setReturnValue(viaFabricPlus$shape_bedrock); | ||
| } | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
.../com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinConduitBlock.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
| * Copyright (C) 2021-2025 the original authors | ||
| * - FlorianMichael/EnZaXD <[email protected]> | ||
| * - RK_01/RaphiMC | ||
| * Copyright (C) 2023-2025 ViaVersion and contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.viaversion.viafabricplus.injection.mixin.features.block.shape; | ||
|
|
||
| import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
| import net.minecraft.block.BlockState; | ||
| import net.minecraft.block.ConduitBlock; | ||
| import net.minecraft.block.ShapeContext; | ||
| import net.minecraft.util.math.BlockPos; | ||
| import net.minecraft.util.shape.VoxelShape; | ||
| import net.minecraft.util.shape.VoxelShapes; | ||
| import net.minecraft.world.BlockView; | ||
| import net.raphimc.viabedrock.api.BedrockProtocolVersion; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Unique; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
|
||
| @Mixin(ConduitBlock.class) | ||
| public abstract class MixinConduitBlock { | ||
|
|
||
| @Unique | ||
| private static final VoxelShape viaFabricPlus$shape_bedrock = VoxelShapes.cuboid(0.25F, 0, 0.25F, 0.75f, 0.5F, 0.75f); | ||
|
|
||
| @Inject(method = "getOutlineShape", at = @At(value = "RETURN"), cancellable = true) | ||
| private void modifyCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) { | ||
| if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { | ||
| cir.setReturnValue(viaFabricPlus$shape_bedrock); | ||
| } | ||
| } | ||
|
|
||
| } |
77 changes: 77 additions & 0 deletions
77
...ava/com/viaversion/viafabricplus/injection/mixin/features/block/shape/MixinDoorBlock.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /* | ||
| * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus | ||
| * Copyright (C) 2021-2025 the original authors | ||
| * - FlorianMichael/EnZaXD <[email protected]> | ||
| * - RK_01/RaphiMC | ||
| * Copyright (C) 2023-2025 ViaVersion and contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.viaversion.viafabricplus.injection.mixin.features.block.shape; | ||
|
|
||
| import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; | ||
| import net.minecraft.block.BlockState; | ||
| import net.minecraft.block.DoorBlock; | ||
| import net.minecraft.block.ShapeContext; | ||
| import net.minecraft.block.enums.DoorHinge; | ||
| import net.minecraft.state.property.BooleanProperty; | ||
| import net.minecraft.state.property.EnumProperty; | ||
| import net.minecraft.util.math.BlockPos; | ||
| import net.minecraft.util.math.Direction; | ||
| import net.minecraft.util.shape.VoxelShape; | ||
| import net.minecraft.util.shape.VoxelShapes; | ||
| import net.minecraft.world.BlockView; | ||
| import net.raphimc.viabedrock.api.BedrockProtocolVersion; | ||
| import org.spongepowered.asm.mixin.Final; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Shadow; | ||
| import org.spongepowered.asm.mixin.Unique; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
| import java.util.Map; | ||
|
|
||
| @Mixin(DoorBlock.class) | ||
| public abstract class MixinDoorBlock { | ||
|
|
||
| @Unique | ||
| private static final Map<Direction, VoxelShape> viaFabricPlus$shape_bedrock = Map.of( | ||
| Direction.NORTH, VoxelShapes.cuboid(0, 0, 0, 1, 1, 0.1825F), | ||
Exterminate5573 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Direction.SOUTH, VoxelShapes.cuboid(0, 0, 0.8175F, 1, 1, 1), | ||
| Direction.WEST, VoxelShapes.cuboid(0.8175F, 0, 0, 1, 1, 1), | ||
| Direction.EAST, VoxelShapes.cuboid(0, 0, 0, 0.1825F, 1, 1) | ||
| ); | ||
|
|
||
| @Shadow | ||
| @Final | ||
| public static EnumProperty<Direction> FACING; | ||
|
|
||
| @Shadow | ||
| @Final | ||
| public static BooleanProperty OPEN; | ||
|
|
||
| @Shadow | ||
| @Final | ||
| public static EnumProperty<DoorHinge> HINGE; | ||
|
|
||
| @Inject(method = "getOutlineShape", at = @At(value = "RETURN"), cancellable = true) | ||
| private void modifyCollisionShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context, CallbackInfoReturnable<VoxelShape> cir) { | ||
| if (ProtocolTranslator.getTargetVersion().equals(BedrockProtocolVersion.bedrockLatest)) { | ||
| Direction direction = state.get(FACING); | ||
| Direction direction2 = (Boolean)state.get(OPEN) ? (state.get(HINGE) == DoorHinge.RIGHT ? direction.rotateYCounterclockwise() : direction.rotateYClockwise()) : direction; | ||
| cir.setReturnValue(viaFabricPlus$shape_bedrock.get(direction2)); | ||
Exterminate5573 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.