From c9533ae126ce51bf6cfb0d548ff8659d1f42ea57 Mon Sep 17 00:00:00 2001 From: GioSDA Date: Wed, 10 Mar 2021 10:06:45 -0800 Subject: [PATCH] Add option to fix items merging through walls --- .../world/entity/item/ItemEntity.java.patch | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch index ca9489b6bf..85422a4b93 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -163,7 +163,22 @@ return entityitem != this && entityitem.isMergable(); }); Iterator iterator = list.iterator(); -@@ -251,7 +298,7 @@ +@@ -238,6 +285,14 @@ + ItemEntity entityitem = (ItemEntity) iterator.next(); + + if (entityitem.isMergable()) { ++ // Paper start - Fix items merging through walls ++ if (this.level().paperConfig().fixes.fixItemsMergingThroughWalls) { ++ 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; +@@ -251,7 +306,7 @@ private boolean isMergable() { ItemStack itemstack = this.getItem(); @@ -172,7 +187,7 @@ } private void tryToMerge(ItemEntity other) { -@@ -259,7 +306,7 @@ +@@ -259,7 +314,7 @@ ItemStack itemstack1 = other.getItem(); if (Objects.equals(this.target, other.target) && ItemEntity.areMergable(itemstack, itemstack1)) { @@ -181,7 +196,7 @@ ItemEntity.merge(this, itemstack, other, itemstack1); } else { ItemEntity.merge(other, itemstack1, this, itemstack); -@@ -287,11 +334,16 @@ +@@ -287,11 +342,16 @@ } private static void merge(ItemEntity targetEntity, ItemStack targetStack, ItemEntity sourceEntity, ItemStack sourceStack) { @@ -199,7 +214,7 @@ } } -@@ -320,12 +372,17 @@ +@@ -320,12 +380,17 @@ } else if (!this.getItem().canBeHurtBy(source)) { return false; } else { @@ -218,7 +233,7 @@ } return true; -@@ -382,22 +439,86 @@ +@@ -382,22 +447,86 @@ } if (this.getItem().isEmpty()) { @@ -308,7 +323,7 @@ itemstack.setCount(i); } -@@ -438,6 +559,7 @@ +@@ -438,6 +567,7 @@ public void setItem(ItemStack stack) { this.getEntityData().set(ItemEntity.DATA_ITEM, stack); @@ -316,7 +331,7 @@ } @Override -@@ -492,7 +614,7 @@ +@@ -492,7 +622,7 @@ public void makeFakeItem() { this.setNeverPickUp();