mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-29 20:09:17 +00:00
* Add configurable items * del * Fix the configuration name and logic of the previous patch
142 lines
9.3 KiB
Diff
142 lines
9.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: FallingKey <FallingKey@Outlook.com>
|
|
Date: Wed, 14 Aug 2024 00:28:48 +0800
|
|
Subject: [PATCH] Add configurable items
|
|
|
|
|
|
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 14eea6498e04f34a518988c978f27600715fe098..023f4133c802ff0b0cdaf7b2730e09a786be8872 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
@@ -352,10 +352,10 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
ItemStack itemstack = this.getItem();
|
|
|
|
// Leaf start - Change max stack count
|
|
- if (org.dreeam.leaf.config.modules.gameplay.MaxStackCount.count < 1) {
|
|
- return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < itemstack.getMaxStackSize() * org.dreeam.leaf.config.modules.gameplay.ItemStackMultiplier.multiplier; // Paper - Alternative item-despawn-rate
|
|
+ if (org.dreeam.leaf.config.modules.gameplay.MaxEntityItemsStackCount.count < 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.MaxStackCount.count; // Paper - Alternative item-despawn-rate
|
|
+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && itemstack.getCount() < org.dreeam.leaf.config.modules.gameplay.MaxEntityItemsStackCount.count; // Paper - Alternative item-despawn-rate
|
|
}
|
|
// Leaf end - Change max stack count
|
|
}
|
|
@@ -376,10 +376,10 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
|
|
public static boolean areMergable(ItemStack stack1, ItemStack stack2) {
|
|
// Leaf start - Change max stack count
|
|
- if (org.dreeam.leaf.config.modules.gameplay.MaxStackCount.count == 0) {
|
|
- return stack2.getCount() + stack1.getCount() > stack2.getMaxStackSize() * org.dreeam.leaf.config.modules.gameplay.ItemStackMultiplier.multiplier ? false : ItemStack.isSameItemSameComponents(stack1, stack2);
|
|
+ if (org.dreeam.leaf.config.modules.gameplay.MaxEntityItemsStackCount.count == 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.MaxStackCount.count ? false : ItemStack.isSameItemSameComponents(stack1, stack2);
|
|
+ return stack2.getCount() + stack1.getCount() > org.dreeam.leaf.config.modules.gameplay.MaxEntityItemsStackCount.count ? false : ItemStack.isSameItemSameComponents(stack1, stack2);
|
|
}
|
|
// Leaf end - Change max stack count
|
|
}
|
|
@@ -387,10 +387,10 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
public static ItemStack merge(ItemStack stack1, ItemStack stack2, int maxCount) {
|
|
// Leaf start - Change max stack count
|
|
int j;
|
|
- if (org.dreeam.leaf.config.modules.gameplay.MaxStackCount.count == 0) {
|
|
- j = Math.min(Math.min(stack1.getMaxStackSize() * org.dreeam.leaf.config.modules.gameplay.ItemStackMultiplier.multiplier, maxCount) - stack1.getCount(), stack2.getCount());
|
|
+ if (org.dreeam.leaf.config.modules.gameplay.MaxEntityItemsStackCount.count == 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.MaxStackCount.count, maxCount) - stack1.getCount(), stack2.getCount());
|
|
+ j = Math.min(Math.min(org.dreeam.leaf.config.modules.gameplay.MaxEntityItemsStackCount.count, maxCount) - stack1.getCount(), stack2.getCount());
|
|
}
|
|
// Leaf end - Change max stack count
|
|
ItemStack itemstack2 = stack1.copyWithCount(stack1.getCount() + j);
|
|
@@ -402,10 +402,10 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
|
private static void merge(ItemEntity targetEntity, ItemStack stack1, ItemStack stack2) {
|
|
// Leaf start - Change max stack count
|
|
ItemStack itemstack2;
|
|
- if (org.dreeam.leaf.config.modules.gameplay.MaxStackCount.count < 1) {
|
|
+ if (org.dreeam.leaf.config.modules.gameplay.MaxEntityItemsStackCount.count < 1) {
|
|
itemstack2 = ItemEntity.merge(stack1, stack2, 64);
|
|
} else {
|
|
- itemstack2 = ItemEntity.merge(stack1, stack2, org.dreeam.leaf.config.modules.gameplay.MaxStackCount.count);
|
|
+ itemstack2 = ItemEntity.merge(stack1, stack2, org.dreeam.leaf.config.modules.gameplay.MaxEntityItemsStackCount.count);
|
|
}
|
|
// Leaf end - Change max stack count
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/item/BlockItem.java b/src/main/java/net/minecraft/world/item/BlockItem.java
|
|
index 0e5fd0ba84bb139f23fc02482d54e5be582ced3c..0b6c6e3ed65552ee8b1feb9bb1c6669fbf130df9 100644
|
|
--- a/src/main/java/net/minecraft/world/item/BlockItem.java
|
|
+++ b/src/main/java/net/minecraft/world/item/BlockItem.java
|
|
@@ -34,7 +34,6 @@ import net.minecraft.world.phys.shapes.CollisionContext;
|
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
|
import org.bukkit.craftbukkit.block.data.CraftBlockData;
|
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
|
-import org.dreeam.leaf.config.modules.gameplay.MaxStackCount;
|
|
// CraftBukkit end
|
|
|
|
public class BlockItem extends Item {
|
|
@@ -272,16 +271,13 @@ public class BlockItem extends Item {
|
|
if (itemcontainercontents != null) {
|
|
// Leaf start - Change max stack count
|
|
if (entity.level().purpurConfig.shulkerBoxItemDropContentsWhenDestroyed) { // Purpur
|
|
- if (MaxStackCount.count < 1) {
|
|
- ItemUtils.onContainerDestroyed(entity, itemcontainercontents.nonEmptyItemsCopy());
|
|
- } else {
|
|
- Level level = entity.level();
|
|
- if (!level.isClientSide) {
|
|
- for (int Count = Math.min(entity.getItem().getCount(), org.dreeam.leaf.config.modules.gameplay.MaxContainerDestroy.count); Count > 0; Count = Count - 1) {
|
|
- itemcontainercontents.nonEmptyItemsCopy().forEach(stack -> level.addFreshEntity(new ItemEntity(level, entity.getX(), entity.getY(), entity.getZ(), stack)));
|
|
- }
|
|
+ Level level = entity.level();
|
|
+ if (!level.isClientSide) {
|
|
+ for (int Count = Math.min(entity.getItem().getCount(), org.dreeam.leaf.config.modules.gameplay.MaxContainerDestroy.count); Count > 0; Count = Count - 1) {
|
|
+ itemcontainercontents.nonEmptyItemsCopy().forEach(stack -> level.addFreshEntity(new ItemEntity(level, entity.getX(), entity.getY(), entity.getZ(), stack)));
|
|
}
|
|
}
|
|
+
|
|
}
|
|
// Leaf end - Change max stack count
|
|
}
|
|
diff --git a/src/main/java/org/dreeam/leaf/config/modules/gameplay/ItemStackMultiplier.java b/src/main/java/org/dreeam/leaf/config/modules/gameplay/ItemStackMultiplier.java
|
|
deleted file mode 100644
|
|
index 503f80ed917302abdf0ab14c13ce61d14c4b4adc..0000000000000000000000000000000000000000
|
|
--- a/src/main/java/org/dreeam/leaf/config/modules/gameplay/ItemStackMultiplier.java
|
|
+++ /dev/null
|
|
@@ -1,17 +0,0 @@
|
|
-package org.dreeam.leaf.config.modules.gameplay;
|
|
-
|
|
-import org.dreeam.leaf.config.ConfigModules;
|
|
-import org.dreeam.leaf.config.EnumConfigCategory;
|
|
-
|
|
-public class ItemStackMultiplier extends ConfigModules {
|
|
- public String getBasePath() {
|
|
- return EnumConfigCategory.GAMEPLAY.getBaseKeyName() + ".item-stack-multiplier";
|
|
- }
|
|
-
|
|
- public static int multiplier = 1;
|
|
-
|
|
- @Override
|
|
- public void onLoaded() {
|
|
- multiplier = config.getInt(getBasePath(), multiplier);
|
|
- }
|
|
-}
|
|
diff --git a/src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxStackCount.java b/src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxEntityItemsStackCount.java
|
|
similarity index 80%
|
|
rename from src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxStackCount.java
|
|
rename to src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxEntityItemsStackCount.java
|
|
index 01208acaac7ef34a4f6dff51a208ed66d2d28079..858a41df2c29d1f87652dc3a49c739da453294ec 100644
|
|
--- a/src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxStackCount.java
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/gameplay/MaxEntityItemsStackCount.java
|
|
@@ -3,9 +3,9 @@ package org.dreeam.leaf.config.modules.gameplay;
|
|
import org.dreeam.leaf.config.ConfigModules;
|
|
import org.dreeam.leaf.config.EnumConfigCategory;
|
|
|
|
-public class MaxStackCount extends ConfigModules {
|
|
+public class MaxEntityItemsStackCount extends ConfigModules {
|
|
public String getBasePath() {
|
|
- return EnumConfigCategory.GAMEPLAY.getBaseKeyName() + ".change-max-stack-count";
|
|
+ return EnumConfigCategory.GAMEPLAY.getBaseKeyName() + ".max-entity-items-stack-count";
|
|
}
|
|
|
|
public static int count = 0;
|