Skip to content

Commit

Permalink
feat: disable entity collision for open Flesh Doors
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Jun 16, 2023
1 parent 4e111e7 commit 1d3fa64
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.pathfinder.PathComputationType;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.*;
import org.jetbrains.annotations.Nullable;

public class FleshDoorBlock extends DoorBlock {
Expand Down Expand Up @@ -199,7 +196,13 @@ public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, Co

@Override
public VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
int idx = isOpen(state) ? OPEN_SHAPE_INDEX + 2 : CLOSED_SHAPE_INDEX;
boolean isOpen = isOpen(state);

if (isOpen && context instanceof EntityCollisionContext entityContext && entityContext.getEntity() != null) {
return Shapes.empty(); //workaround for create contraptions
}

int idx = isOpen ? OPEN_SHAPE_INDEX + 2 : CLOSED_SHAPE_INDEX;

return switch (state.getValue(ORIENTATION)) {
case X_POSITIVE -> X_POS_AABB[idx];
Expand Down

0 comments on commit 1d3fa64

Please sign in to comment.