mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Only tick items at hand
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
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 95e03045bcbee74ddac36ae36ce8c8c2f5769fa4..6eee16dccef1d0f04ba3532f5ee064478b842425 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -895,9 +895,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
super.tick();
|
||||
}
|
||||
|
||||
- for (int i = 0; i < this.getInventory().getContainerSize(); i++) {
|
||||
- ItemStack item = this.getInventory().getItem(i);
|
||||
- if (!item.isEmpty()) {
|
||||
+ 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()) continue;
|
||||
this.synchronizeSpecialItemUpdates(item);
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index ffff3c710f6a96de9372fe07ffa69e65d392273f..fb61bf4b69033d856e2ed424a0557d1f6a27e4e7 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -631,7 +631,12 @@ public abstract class Player extends LivingEntity {
|
||||
}
|
||||
|
||||
this.tickRegeneration();
|
||||
- this.inventory.tick();
|
||||
+ if (org.dreeam.leaf.config.modules.opt.OptimizeItemTicking.onlyTickItemsInHand) {
|
||||
+ this.getMainHandItem().inventoryTick(this.level(), this, 0, true);
|
||||
+ this.getOffhandItem().inventoryTick(this.level(), this, 0, true);
|
||||
+ } else {
|
||||
+ this.inventory.tick();
|
||||
+ }
|
||||
this.oBob = this.bob;
|
||||
if (this.abilities.flying && !this.isPassenger()) {
|
||||
this.resetFallDistance();
|
||||
@@ -0,0 +1,21 @@
|
||||
package org.dreeam.leaf.config.modules.opt;
|
||||
|
||||
import org.dreeam.leaf.config.ConfigModules;
|
||||
import org.dreeam.leaf.config.EnumConfigCategory;
|
||||
|
||||
public class OptimizeItemTicking extends ConfigModules {
|
||||
|
||||
public String getBasePath() {
|
||||
return EnumConfigCategory.PERF.getBaseKeyName();
|
||||
}
|
||||
|
||||
public static boolean onlyTickItemsInHand = true;
|
||||
|
||||
@Override
|
||||
public void onLoaded() {
|
||||
onlyTickItemsInHand = config.getBoolean(getBasePath() + ".only-tick-items-in-hand", onlyTickItemsInHand, config.pickStringRegionBased("""
|
||||
Whether to only tick/update items in main hand and offhand instead of the entire inventory.""",
|
||||
"""
|
||||
是否只对主手和副手中的物品进行tick/更新,而不是整个物品栏中的所有物品。"""));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user