Fix fixItemsMergingThroughWalls check (#9707)

This commit is contained in:
violetc 2023-09-11 12:46:02 +08:00 committed by GitHub
parent e2b197132d
commit c9cd94f3c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 10 deletions

View File

@ -5,17 +5,19 @@ Subject: [PATCH] Add option to fix items merging through walls
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 5d742d072d2cc532ce86bff3de15a5f0f381d1c5..3f479cdca77ad051a8fcf56e99c7811998a92f2a 100644
index 5d742d072d2cc532ce86bff3de15a5f0f381d1c5..b8db8750125315b15cc3d3e76ee629a60c4546a1 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -258,6 +258,12 @@ public class ItemEntity extends Entity implements TraceableEntity {
@@ -258,6 +258,14 @@ public class ItemEntity extends Entity implements TraceableEntity {
ItemEntity entityitem = (ItemEntity) iterator.next();
if (entityitem.isMergable()) {
+ // 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;
+ 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);

View File

@ -19,10 +19,10 @@ index 653c9c41ab7c5cd332565436564396d18f26c17c..06df21e55fdb70558b85fc095a04b3bb
if (captureDrops != null && entity instanceof net.minecraft.world.entity.item.ItemEntity) {
captureDrops.add((net.minecraft.world.entity.item.ItemEntity) entity);
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 3f479cdca77ad051a8fcf56e99c7811998a92f2a..3b8c76a89249ea4edcae4b59f1fe828f584fb1c1 100644
index b8db8750125315b15cc3d3e76ee629a60c4546a1..6b3a17e6717b8c03c5bd674771b29e4becd42c71 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -518,7 +518,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
@@ -520,7 +520,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
}
public void setItem(ItemStack stack) {

View File

@ -54,7 +54,7 @@ index f5eb57cf35a11d135e3bf998d1cb1ce06fc360ce..279d3ff3e1568fdf396faf635854e5f8
if (nbt.contains("Attributes", 9) && this.level() != null && !this.level().isClientSide) {
this.getAttributes().load(nbt.getList("Attributes", 10));
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 f9c2274c060efdd9b6627ced8485b766aca8951c..b3d809c48b041af03471942213070cc3e0b19f2f 100644
index 22d29a2e58c5615dcee04ba68752fb76489c8a28..d39f31e7cf315c7cdc1daab28164380e44dd8341 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -55,6 +55,7 @@ public class ItemEntity extends Entity implements TraceableEntity {
@ -78,7 +78,7 @@ index f9c2274c060efdd9b6627ced8485b766aca8951c..b3d809c48b041af03471942213070cc3
f1 = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F;
}
@@ -367,6 +372,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
@@ -369,6 +374,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
@Override
public void addAdditionalSaveData(CompoundTag nbt) {
@ -90,7 +90,7 @@ index f9c2274c060efdd9b6627ced8485b766aca8951c..b3d809c48b041af03471942213070cc3
nbt.putShort("Health", (short) this.health);
nbt.putShort("Age", (short) this.age);
nbt.putShort("PickupDelay", (short) this.pickupDelay);
@@ -400,6 +410,17 @@ public class ItemEntity extends Entity implements TraceableEntity {
@@ -402,6 +412,17 @@ public class ItemEntity extends Entity implements TraceableEntity {
this.thrower = nbt.getUUID("Thrower");
}