Skip to content

Commit

Permalink
Grant temporary immunity to hopper minecarts while actively pulling (f…
Browse files Browse the repository at this point in the history
…ixes #8281) (#8282)

Reduce the impact from EAR on hopper minecart based unloaders by making them immune to
EAR while pulling objects. The EAR is still active outside misc activation range when
the hopper minecart is idle, keeping lag low.
  • Loading branch information
petersv5 committed Aug 14, 2022
1 parent 4516aed commit 4ba43fe
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions patches/server/0349-Entity-Activation-Range-2.0.patch
Expand Up @@ -302,6 +302,44 @@ index f957c0aca36b7228ac3a33ca04c948b1d10642d1..39fc94b1e1555fd6706391223dd27831

super.customServerAiStep();
}
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java
index 540c23f6297c34cf8e7bf8312ceaa5fc868f414c..2866385a64b22b7dc82b6122c62bcea6b0908a60 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/MinecartHopper.java
@@ -57,6 +57,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper
if (bl != this.isEnabled()) {
this.setEnabled(bl);
}
+ this.immunize(); // Paper

}

@@ -107,11 +108,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper

public boolean suckInItems() {
if (HopperBlockEntity.suckInItems(this.level, this)) {
+ this.immunize(); // Paper
return true;
} else {
List<ItemEntity> list = this.level.getEntitiesOfClass(ItemEntity.class, this.getBoundingBox().inflate(0.25D, 0.0D, 0.25D), EntitySelector.ENTITY_STILL_ALIVE);
if (!list.isEmpty()) {
HopperBlockEntity.addItem(this, list.get(0));
+ this.immunize(); // Paper
}

return false;
@@ -149,4 +152,11 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper
public AbstractContainerMenu createMenu(int syncId, Inventory playerInventory) {
return new HopperMenu(syncId, playerInventory, this);
}
+
+ // Paper start
+ public void immunize() {
+ this.activatedImmunityTick = Math.max(this.activatedImmunityTick, net.minecraft.server.MinecraftServer.currentTick + 20);
+ }
+ // Paper end
+
}
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index e6bfc9cdf116b2233a638eec369a80eb8536aa18..4c1d34bd274d8e2a4003a286536652367da9488a 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
Expand Down

0 comments on commit 4ba43fe

Please sign in to comment.