9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-21 15:59:33 +00:00
Files
LeavesMC/patches/server/0086-Use-fast-item-merge-raytracing.patch
2023-07-17 22:44:16 +08:00

34 lines
2.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: violetc <58360096+s-yh-china@users.noreply.github.com>
Date: Mon, 17 Jul 2023 22:27:12 +0800
Subject: [PATCH] Use fast item merge raytracing
This patch is Powered by Gale(https://github.com/GaleMC/Gale)
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index 46d51b33cf68eaf759b437862778006e95861942..064f9ea24bb9d2fce45a94a5b6f9ea2469f2b80a 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -280,10 +280,17 @@ public class ItemEntity extends Entity implements TraceableEntity {
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;
+ // Leaves start - use fast item merge raytracing
+ if (!top.leavesmc.leaves.LeavesConfig.useFastItemMergeRaytracing) {
+ 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;
+ } else {
+ if (level().rayTraceDirect(this.position(), entityitem.position(), net.minecraft.world.phys.shapes.CollisionContext.of(this)) ==
+ net.minecraft.world.phys.HitResult.Type.BLOCK) continue;
+ }
+ // Leaves end - use fast item merge raytracing
}
// Paper End
this.tryToMerge(entityitem);