Strip raytracing for EntityLiving#hasLineOfSight

Co-authored-by: Paul Sauve <paul@technove.co>
This commit is contained in:
Nassim Jahnke
2023-09-10 12:28:03 +10:00
parent 68b63a9341
commit 1f4c201c00
6 changed files with 221 additions and 22 deletions

View File

@@ -12,14 +12,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
ItemEntity entityitem = (ItemEntity) iterator.next();
if (entityitem.isMergable()) {
+ // Paper Start - Fix items merging through walls
+ if (this.level().paperConfig().fixes.fixItemsMergingThroughWalls) {
+ net.minecraft.world.level.ClipContext rayTrace = new net.minecraft.world.level.ClipContext(this.position(), entityitem.position(),
+ net.minecraft.world.level.ClipContext.Block.COLLIDER, net.minecraft.world.level.ClipContext.Fluid.NONE, this);
+ net.minecraft.world.phys.BlockHitResult rayTraceResult = this.level().clip(rayTrace);
+ if (rayTraceResult.getType() == net.minecraft.world.phys.HitResult.Type.BLOCK) continue;
+ }
+ // Paper End
+ // Paper start - Fix items merging through walls
+ if (this.level().clipDirect(this.position(), entityitem.position(),
+ net.minecraft.world.phys.shapes.CollisionContext.of(this)) == net.minecraft.world.phys.HitResult.Type.BLOCK) {
+ continue;
+ }
+ // Paper end - Fix items merging through walls
this.tryToMerge(entityitem);
if (this.isRemoved()) {
break;