9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2026-01-04 15:31:45 +00:00
Files
Gale/patches/server/0110-Ignore-durability-change-equipment-updates.patch
2023-03-22 16:49:11 +01:00

68 lines
3.9 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 30 Nov 2022 15:01:42 +0100
Subject: [PATCH] Ignore durability change equipment updates
License: MIT (https://opensource.org/licenses/MIT)
Gale - https://galemc.org
This patch is based on the following patch:
"Ignore durability change equipment updates"
By: Cryptite <cryptite@gmail.com>
As part of: Slice (https://github.com/Cryptite/Slice)
Licensed under: MIT (https://opensource.org/licenses/MIT)
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 423f3f073e63be06e37af46f5497ba20f3f10664..17dbade3fa91ccc3db8792b5c2c9374ad3d61337 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3113,7 +3113,7 @@ public abstract class LivingEntity extends Entity implements Attackable {
}
public boolean equipmentHasChanged(ItemStack stack, ItemStack stack2) {
- return !ItemStack.matches(stack2, stack);
+ return this.level.galeConfig().smallOptimizations.processFullEquipmentChangeIfOnlyDurabilityChanged ? !ItemStack.matches(stack2, stack) : !ItemStack.isSameIgnoreDurability(stack2, stack); // Gale - Slice - ignore durability change equipment updates
}
private void handleHandSwap(Map<EquipmentSlot, ItemStack> equipmentChanges) {
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index 8155a806ccb200b8883ce6734c5b7e34338060ee..08638e5982083835cd90243e6edf45088ab695be 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -740,10 +740,22 @@ public final class ItemStack {
return left == right ? true : (!left.isEmpty() && !right.isEmpty() ? left.sameItem(right) : false);
}
+ // Gale start - Slice - ignore durability change equipment updates
+ public static boolean isSameIgnoreDurability(ItemStack left, ItemStack right) {
+ return left == right ? true : (!left.isEmpty() && !right.isEmpty() ? left.sameItemStackIgnoreDurability(right) : false);
+ }
+ // Gale end - Slice - ignore durability change equipment updates
+
public boolean sameItem(ItemStack stack) {
return !stack.isEmpty() && this.is(stack.getItem());
}
+ // Gale start - Slice - ignore durability change equipment updates
+ public boolean sameItemStackIgnoreDurability(ItemStack stack) {
+ return !this.isDamageableItem() ? this.sameItem(stack) : !stack.isEmpty() && this.is(stack.getItem());
+ }
+ // Gale end - Slice - ignore durability change equipment updates
+
public static boolean isSameItemSameTags(ItemStack stack, ItemStack otherStack) {
return stack.is(otherStack.getItem()) && ItemStack.tagMatches(stack, otherStack);
}
diff --git a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
index 3ebd9c177453bf720c40c7f9d41e28a234c80467..cdc53823b4903ab6a443a626503f62b732cc97cb 100644
--- a/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
+++ b/src/main/java/org/galemc/gale/configuration/GaleWorldConfiguration.java
@@ -62,6 +62,8 @@ public class GaleWorldConfiguration extends ConfigurationPart {
public boolean useOptimizedSheepOffspringColor = true;
// Gale end - carpet-fixes - optimize sheep offspring color
+ public boolean processFullEquipmentChangeIfOnlyDurabilityChanged = false; // Gale - Slice - ignore durability change equipment updates
+
// Gale start - Airplane - reduce projectile chunk loading
public MaxProjectileChunkLoads maxProjectileChunkLoads;
public class MaxProjectileChunkLoads extends ConfigurationPart {