1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
--- a/net/minecraft/world/level/BlockGetter.java
+++ b/net/minecraft/world/level/BlockGetter.java
@@ -64,22 +58,30 @@
);
}
+ // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
+ default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) {
+ IBlockData iblockdata = this.getBlockState(blockposition);
+ FluidState fluid = this.getFluidState(blockposition);
+ Vec3 vec3d = raytrace1.getFrom();
+ Vec3 vec3d1 = raytrace1.getTo();
+ VoxelShape voxelshape = raytrace1.getBlockShape(iblockdata, this, blockposition);
+ BlockHitResult movingobjectpositionblock = this.clipWithInteractionOverride(vec3d, vec3d1, blockposition, voxelshape, iblockdata);
+ VoxelShape voxelshape1 = raytrace1.getFluidShape(fluid, this, blockposition);
+ BlockHitResult movingobjectpositionblock1 = voxelshape1.clip(vec3d, vec3d1, blockposition);
+ double d0 = movingobjectpositionblock == null ? Double.MAX_VALUE : raytrace1.getFrom().distanceToSqr(movingobjectpositionblock.getLocation());
+ double d1 = movingobjectpositionblock1 == null ? Double.MAX_VALUE : raytrace1.getFrom().distanceToSqr(movingobjectpositionblock1.getLocation());
+
+ return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1;
+ }
+ // CraftBukkit end
+
default BlockHitResult clip(ClipContext context) {
- return traverseBlocks(context.getFrom(), context.getTo(), context, (traverseContext, traversePos) -> {
- BlockState blockState = this.getBlockState(traversePos);
- FluidState fluidState = this.getFluidState(traversePos);
- Vec3 from = traverseContext.getFrom();
- Vec3 to = traverseContext.getTo();
- VoxelShape blockShape = traverseContext.getBlockShape(blockState, this, traversePos);
- BlockHitResult blockHitResult = this.clipWithInteractionOverride(from, to, traversePos, blockShape, blockState);
- VoxelShape fluidShape = traverseContext.getFluidShape(fluidState, this, traversePos);
- BlockHitResult blockHitResult1 = fluidShape.clip(from, to, traversePos);
- double d = blockHitResult == null ? Double.MAX_VALUE : traverseContext.getFrom().distanceToSqr(blockHitResult.getLocation());
- double d1 = blockHitResult1 == null ? Double.MAX_VALUE : traverseContext.getFrom().distanceToSqr(blockHitResult1.getLocation());
- return d <= d1 ? blockHitResult : blockHitResult1;
- }, failContext -> {
- Vec3 vec3 = failContext.getFrom().subtract(failContext.getTo());
- return BlockHitResult.miss(failContext.getTo(), Direction.getNearest(vec3.x, vec3.y, vec3.z), BlockPos.containing(failContext.getTo()));
+ return (BlockHitResult) traverseBlocks(context.getFrom(), context.getTo(), context, (raytrace1, blockposition) -> {
+ return this.clip(raytrace1, blockposition); // CraftBukkit - moved into separate method
+ }, (raytrace1) -> {
+ Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo());
+
+ return BlockHitResult.miss(raytrace1.getTo(), Direction.getNearest(vec3d.x, vec3d.y, vec3d.z), BlockPos.containing(raytrace1.getTo()));
});
}
|