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
49
|
--- a/net/minecraft/world/level/BlockGetter.java
+++ b/net/minecraft/world/level/BlockGetter.java
@@ -58,24 +58,30 @@
});
}
- default BlockHitResult clip(ClipContext clipcontext) {
- return (BlockHitResult) traverseBlocks(clipcontext.getFrom(), clipcontext.getTo(), clipcontext, (clipcontext1, blockpos) -> {
- BlockState blockstate = this.getBlockState(blockpos);
- FluidState fluidstate = this.getFluidState(blockpos);
- Vec3 vec3 = clipcontext1.getFrom();
- Vec3 vec31 = clipcontext1.getTo();
- VoxelShape voxelshape = clipcontext1.getBlockShape(blockstate, this, blockpos);
- BlockHitResult blockhitresult = this.clipWithInteractionOverride(vec3, vec31, blockpos, voxelshape, blockstate);
- VoxelShape voxelshape1 = clipcontext1.getFluidShape(fluidstate, this, blockpos);
- BlockHitResult blockhitresult1 = voxelshape1.clip(vec3, vec31, blockpos);
- double d0 = blockhitresult == null ? Double.MAX_VALUE : clipcontext1.getFrom().distanceToSqr(blockhitresult.getLocation());
- double d1 = blockhitresult1 == null ? Double.MAX_VALUE : clipcontext1.getFrom().distanceToSqr(blockhitresult1.getLocation());
+ // 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 ? blockhitresult : blockhitresult1;
- }, (clipcontext1) -> {
- Vec3 vec3 = clipcontext1.getFrom().subtract(clipcontext1.getTo());
+ return d0 <= d1 ? movingobjectpositionblock : movingobjectpositionblock1;
+ }
+ // CraftBukkit end
- return BlockHitResult.miss(clipcontext1.getTo(), Direction.getNearest(vec3.x, vec3.y, vec3.z), BlockPos.containing(clipcontext1.getTo()));
+ default BlockHitResult clip(ClipContext context) {
+ 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()));
});
}
|