mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-27 02:49:19 +00:00
Format & Fix patches
This commit is contained in:
121
patches/server/0103-Change-max-stack-count.patch
Normal file
121
patches/server/0103-Change-max-stack-count.patch
Normal file
@@ -0,0 +1,121 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: FallingKey <FallingKey@Outlook.com>
|
||||
Date: Sun, 11 Aug 2024 14:20:37 +0800
|
||||
Subject: [PATCH] Change max stack count
|
||||
|
||||
|
||||
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 fd96a97d35fcd422c3f99aa379a0daf9e5c2a695..5633ecea8639dd8564eb7f61aa9d366b552407a1 100644
|
||||
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -351,7 +351,13 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
private boolean isMergable() {
|
||||
ItemStack itemstack = this.getItem();
|
||||
|
||||
- return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - Alternative item-despawn-rate
|
||||
+ // Leaf start - Change max stack count
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxItemStackCount < 1) {
|
||||
+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize(); // Paper - Alternative item-despawn-rate
|
||||
+ } else {
|
||||
+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxItemStackCount; // Paper - Alternative item-despawn-rate
|
||||
+ }
|
||||
+ // Leaf end - Change max stack count
|
||||
}
|
||||
|
||||
private void tryToMerge(ItemEntity other) {
|
||||
@@ -369,11 +375,24 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
}
|
||||
|
||||
public static boolean areMergable(ItemStack stack1, ItemStack stack2) {
|
||||
- return stack2.getCount() + stack1.getCount() > stack2.getMaxStackSize() ? false : ItemStack.isSameItemSameComponents(stack1, stack2);
|
||||
+ // Leaf start - Change max stack count
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxItemStackCount == 0) {
|
||||
+ return stack2.getCount() + stack1.getCount() > stack2.getMaxStackSize() ? false : ItemStack.isSameItemSameComponents(stack1, stack2);
|
||||
+ } else {
|
||||
+ return stack2.getCount() + stack1.getCount() > org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxItemStackCount ? false : ItemStack.isSameItemSameComponents(stack1, stack2);
|
||||
+ }
|
||||
+ // Leaf end - Change max stack count
|
||||
}
|
||||
|
||||
public static ItemStack merge(ItemStack stack1, ItemStack stack2, int maxCount) {
|
||||
- int j = Math.min(Math.min(stack1.getMaxStackSize(), maxCount) - stack1.getCount(), stack2.getCount());
|
||||
+ // Leaf start - Change max stack count
|
||||
+ int j;
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxItemStackCount == 0) {
|
||||
+ j = Math.min(Math.min(stack1.getMaxStackSize(), maxCount) - stack1.getCount(), stack2.getCount());
|
||||
+ } else {
|
||||
+ j = Math.min(Math.min(org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxItemStackCount, maxCount) - stack1.getCount(), stack2.getCount());
|
||||
+ }
|
||||
+ // Leaf end - Change max stack count
|
||||
ItemStack itemstack2 = stack1.copyWithCount(stack1.getCount() + j);
|
||||
|
||||
stack2.shrink(j);
|
||||
@@ -381,7 +400,14 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
}
|
||||
|
||||
private static void merge(ItemEntity targetEntity, ItemStack stack1, ItemStack stack2) {
|
||||
- ItemStack itemstack2 = ItemEntity.merge(stack1, stack2, 64);
|
||||
+ // Leaf start - Change max stack count
|
||||
+ ItemStack itemstack2;
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxItemStackCount < 1) {
|
||||
+ itemstack2 = ItemEntity.merge(stack1, stack2, 64);
|
||||
+ } else {
|
||||
+ itemstack2 = ItemEntity.merge(stack1, stack2, org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxItemStackCount);
|
||||
+ }
|
||||
+ // Leaf end - Change max stack count
|
||||
|
||||
targetEntity.setItem(itemstack2);
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/world/item/ItemUtils.java b/src/main/java/net/minecraft/world/item/ItemUtils.java
|
||||
index 66f88f44eb74dfbdafe0d6257dc1ef46238aaa92..e0a5d485989dd9e9c9d33f57929aa3dd79294bc9 100644
|
||||
--- a/src/main/java/net/minecraft/world/item/ItemUtils.java
|
||||
+++ b/src/main/java/net/minecraft/world/item/ItemUtils.java
|
||||
@@ -41,7 +41,17 @@ public class ItemUtils {
|
||||
public static void onContainerDestroyed(ItemEntity itemEntity, Iterable<ItemStack> contents) {
|
||||
Level level = itemEntity.level();
|
||||
if (!level.isClientSide) {
|
||||
+ // Leaf start - Change max stack count
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxContainerDestroyCount == 0)
|
||||
contents.forEach(stack -> level.addFreshEntity(new ItemEntity(level, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), stack)));
|
||||
+ else
|
||||
+ for (int count = Math.min(itemEntity.getItem().getCount(), org.dreeam.leaf.config.modules.gameplay.MaxItemsStackCount.maxContainerDestroyCount); count > 0; count--) {
|
||||
+ if (!contents.iterator().hasNext()) break;
|
||||
+
|
||||
+ ItemStack stack = contents.iterator().next();
|
||||
+ level.addFreshEntity(new ItemEntity(level, itemEntity.getX(), itemEntity.getY(), itemEntity.getZ(), stack));
|
||||
+ }
|
||||
+ // Leaf end - Change max stack count
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxItemsStackCount.java b/src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxItemsStackCount.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4a895897111454dc3558aa491b9d81cf610b5bbf
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxItemsStackCount.java
|
||||
@@ -0,0 +1,25 @@
|
||||
+package org.dreeam.leaf.config.modules.gameplay;
|
||||
+
|
||||
+import org.dreeam.leaf.config.ConfigModules;
|
||||
+import org.dreeam.leaf.config.EnumConfigCategory;
|
||||
+
|
||||
+public class MaxItemsStackCount extends ConfigModules {
|
||||
+
|
||||
+ public String getBasePath() {
|
||||
+ return EnumConfigCategory.GAMEPLAY.getBaseKeyName() + ".max-item-stack-count";
|
||||
+ }
|
||||
+
|
||||
+ public static int maxItemStackCount = 0;
|
||||
+ public static int maxContainerDestroyCount = 0;
|
||||
+
|
||||
+ @Override
|
||||
+ public void onLoaded() {
|
||||
+ config.addComment(getBasePath(), "Don't touch this unless you know what you are doing!");
|
||||
+
|
||||
+ maxItemStackCount = config.getInt(getBasePath() + ".max-dropped-items-stack-count", maxItemStackCount);
|
||||
+ maxContainerDestroyCount = config.getInt(getBasePath() + ".max-container-destroy-count", maxContainerDestroyCount);
|
||||
+
|
||||
+ if (maxItemStackCount < 0) maxItemStackCount = 0;
|
||||
+ if (maxContainerDestroyCount < 0) maxContainerDestroyCount = 0;
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user