9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0166-Only-tick-items-at-hand.patch
2025-06-11 03:59:45 +08:00

50 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Taiyou06 <kaandindar21@gmail.com>
Date: Fri, 9 May 2025 23:50:55 +0200
Subject: [PATCH] Only tick items at hand
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
index 0ba7cf69eda2d952ac2ffecf9167f3f5d43c4c63..4d32ba245eb204231af791a65142932a18b4f3f6 100644
--- a/net/minecraft/server/level/ServerPlayer.java
+++ b/net/minecraft/server/level/ServerPlayer.java
@@ -888,12 +888,19 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
super.tick();
}
+ // Leaf start - Only tick items at hand
+ if (org.dreeam.leaf.config.modules.opt.OptimizeItemTicking.onlyTickItemsInHand) {
+ this.synchronizeSpecialItemUpdates(this.getMainHandItem());
+ this.synchronizeSpecialItemUpdates(this.getOffhandItem());
+ } else {
for (int i = 0; i < this.getInventory().getContainerSize(); i++) {
ItemStack item = this.getInventory().getItem(i);
if (!item.isEmpty()) {
this.synchronizeSpecialItemUpdates(item);
}
}
+ }
+ // Leaf end - Only tick items at hand
if (this.getHealth() != this.lastSentHealth
|| this.lastSentFood != this.foodData.getFoodLevel()
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
index 8469cf9cacebea3fdd855f6c3e9e2cf61c78b8ac..76d85632e1364e71a2aa15dbef41c62422ffd7af 100644
--- a/net/minecraft/world/entity/player/Player.java
+++ b/net/minecraft/world/entity/player/Player.java
@@ -631,7 +631,14 @@ public abstract class Player extends LivingEntity {
}
this.tickRegeneration();
+ // Leaf start - Only tick items at hand
+ if (org.dreeam.leaf.config.modules.opt.OptimizeItemTicking.onlyTickItemsInHand) {
+ this.getMainHandItem().inventoryTick(this.level(), this, 0, true);
+ this.getOffhandItem().inventoryTick(this.level(), this, 1, true);
+ } else {
this.inventory.tick();
+ }
+ // Leaf end - Only tick items at hand
this.oBob = this.bob;
if (this.abilities.flying && !this.isPassenger()) {
this.resetFallDistance();