Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 24d4ebdc7c | |||
| 4ca6d9fe09 | |||
| c35817411a | |||
| cf491363f6 | |||
| 19b773d256 | |||
| 700d270b1d | |||
| fb3fef1fc7 | |||
| f0981b2781 | |||
| 6f9f5eb4e2 | |||
| 983be775ff |
@@ -4,6 +4,7 @@ description:
|
||||
Report issues with plugin incompatbility or other behavior related issues.
|
||||
labels:
|
||||
- bug
|
||||
- pending
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@@ -4,6 +4,7 @@ description:
|
||||
Suggest an idea for Lophine.
|
||||
labels:
|
||||
- enhancement
|
||||
- pending
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[//]: # (<img src="./public/image/Lophine_LL方_白_字.png" alt="Logo" align="right" width="250">)
|
||||
<img src="public/image/lophine/lophine3.png" alt="Logo" align="right" width="250">
|
||||
|
||||
# Lophine
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
- 更多有用的功能
|
||||
|
||||
## 下载
|
||||
任何版本都可以在 [Release](https://github.com/LuminolMC/LightingLuminol/releases), 中找到,你也可以通过[以下步骤](./README.md#构建)自己构建。
|
||||
任何版本都可以在 [Release](https://github.com/LuminolMC/Lophine/releases), 中找到,你也可以通过[以下步骤](./README.md#构建)自己构建。
|
||||
|
||||
## 构建
|
||||
要构建一个paperclip jar,你需要运行以下命令。你可以在lightingluminol-server/build/libs中找到jar(注意:需要`JDK21`)
|
||||
要构建一个paperclip jar,你需要运行以下命令。你可以在lophine-server/build/libs中找到jar(注意:需要`JDK21`)
|
||||
```shell
|
||||
./gradlew applyAllPatches && ./gradlew createMojmapPaperclipJar
|
||||
```
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
[//]: # (<img src="./public/image/Lophine_LL方_白_字.png" alt="Logo" align="right" width="250">)
|
||||
<img src="public/image/lophine/lophine3.png" alt="Logo" align="right" width="250">
|
||||
|
||||
# Lophine
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
- More functions
|
||||
|
||||
## Download
|
||||
Any versions are available in the [release](https://github.com/LuminolMC/LightingLuminol/releases), also you can build it by yourself through [the following steps](./README_EN.md#Build).
|
||||
Any versions are available in the [release](https://github.com/LuminolMC/Lophine/releases), also you can build it by yourself through [the following steps](./README_EN.md#Build).
|
||||
|
||||
## Build
|
||||
To build a paperclip jar, you need to run the following command. You can find the jar in build/libs(Note: JDK21 is needed)
|
||||
To build a paperclip jar, you need to run the following command. You can find the jar in lophine-server/build/libs(Note: `JDK21` is needed)
|
||||
```shell
|
||||
./gradlew applyPatches && ./gradlew createMojmapPaperclipJar
|
||||
./gradlew applyAllPatches && ./gradlew createMojmapPaperclipJar
|
||||
```
|
||||
## Using API
|
||||
For gradle:
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ group=me.earthme.lophine
|
||||
version=1.21.5-R0.1-SNAPSHOT
|
||||
mcVersion=1.21.5
|
||||
|
||||
luminolRef=07f2fcd4051f140a32ff491bbe0c64dfb5c2aabf
|
||||
luminolRef=784ce10986c214df322a9289e8ddb0b700759596
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
org.gradle.caching=true
|
||||
|
||||
@@ -5,16 +5,15 @@ Subject: [PATCH] Rebrand to Lophine
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java
|
||||
index fcf599846a38beeb8f094d5376c01d5a690f7a2f..9ddcb2b5ced68ff619516ddbac2327c23e316438 100644
|
||||
index fcf599846a38beeb8f094d5376c01d5a690f7a2f..a70c04dc72a15e4e8de8de677951f1eb605057b0 100644
|
||||
--- a/net/minecraft/server/Main.java
|
||||
+++ b/net/minecraft/server/Main.java
|
||||
@@ -108,7 +108,8 @@ public class Main {
|
||||
@@ -108,7 +108,7 @@ public class Main {
|
||||
JvmProfiler.INSTANCE.start(Environment.SERVER);
|
||||
}
|
||||
|
||||
- me.earthme.luminol.config.LuminolConfig.preLoadConfig(); // Luminol - Luminol config
|
||||
+ me.earthme.lophine.config.LophineConfig.initConfigs(); // Lophine - Lophine config
|
||||
+ me.earthme.lophine.config.LophineConfig.preLoad(); // Luminol - Luminol config // Lophine - Lophine config
|
||||
io.papermc.paper.plugin.PluginInitializerManager.load(optionSet); // Paper
|
||||
Bootstrap.bootStrap();
|
||||
Bootstrap.validate();
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ index ee53f78396f4377d3e5c2998826f231208066ef6..607091ecbd4a7261f2c0d839ee4dd1d2
|
||||
double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1);
|
||||
if (rangeY != -1) {
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 0814ad6820b08a856f7bd261e96143568e772ac4..b7ef7df56e94b6af9398d0a4768747a35ac6f4fd 100644
|
||||
index a023cc399fc8bfee7771e5ca6716578f89b7072f..f487b44174678196e2bade0066511daf58e93876 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -140,7 +140,7 @@ import net.minecraft.world.scores.ScoreHolder;
|
||||
@@ -30,7 +30,7 @@ index 0814ad6820b08a856f7bd261e96143568e772ac4..b7ef7df56e94b6af9398d0a4768747a3
|
||||
// CraftBukkit start
|
||||
private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger();
|
||||
private static final int CURRENT_LEVEL = 2;
|
||||
@@ -6107,4 +6107,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
@@ -6106,4 +6106,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
// Paper end - Expose entity id counter
|
||||
|
||||
public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG
|
||||
|
||||
@@ -0,0 +1,528 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Mon, 9 Jun 2025 19:23:10 +0800
|
||||
Subject: [PATCH] Stackable ShulkerBoxes
|
||||
|
||||
Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Some of changes is a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/9d32c5bd3df7c76055aff886ed9efda02e45a45a/leaves-server/minecraft-patches/features/0034-Stackable-ShulkerBoxes.patch)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
diff --git a/net/minecraft/commands/arguments/item/ItemInput.java b/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
index 643797124fe5a4489d0b7419b7e600c04f283ef2..3c0d01d444210029b6380417c6ee0e6408f89c18 100644
|
||||
--- a/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
+++ b/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
@@ -39,8 +39,9 @@ public class ItemInput {
|
||||
public ItemStack createItemStack(int count, boolean allowOversizedStacks) throws CommandSyntaxException {
|
||||
ItemStack itemStack = new ItemStack(this.item, count);
|
||||
itemStack.applyComponents(this.components);
|
||||
- if (allowOversizedStacks && count > itemStack.getMaxStackSize()) {
|
||||
- throw ERROR_STACK_TOO_BIG.create(this.getItemName(), itemStack.getMaxStackSize());
|
||||
+ int maxCount = me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemStack); // Lophine - Stackable ShulkerBoxes
|
||||
+ if (allowOversizedStacks && count > maxCount) { // Lophine - Stackable ShulkerBoxes
|
||||
+ throw ERROR_STACK_TOO_BIG.create(this.getItemName(), maxCount); // Lophine - Stackable ShulkerBoxes
|
||||
} else {
|
||||
return itemStack;
|
||||
}
|
||||
diff --git a/net/minecraft/server/commands/GiveCommand.java b/net/minecraft/server/commands/GiveCommand.java
|
||||
index c1c0dea9f5ac3101c2f12714c8dd460457d45cb7..f94fc39297caebd0cb14d7b71c865f13b5c3b17c 100644
|
||||
--- a/net/minecraft/server/commands/GiveCommand.java
|
||||
+++ b/net/minecraft/server/commands/GiveCommand.java
|
||||
@@ -52,7 +52,7 @@ public class GiveCommand {
|
||||
private static int giveItem(CommandSourceStack source, ItemInput item, Collection<ServerPlayer> targets, int count) throws CommandSyntaxException {
|
||||
ItemStack itemStack = item.createItemStack(1, false);
|
||||
final Component displayName = itemStack.getDisplayName(); // Paper - get display name early
|
||||
- int maxStackSize = itemStack.getMaxStackSize();
|
||||
+ int maxStackSize = me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemStack); // Lophine - Stackable ShulkerBoxes
|
||||
int i = maxStackSize * 100;
|
||||
if (count > i) {
|
||||
source.sendFailure(Component.translatable("commands.give.failed.toomanyitems", i, itemStack.getDisplayName()));
|
||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 4fc3c9f2b04711569c12a0efa027601fdd0a40b5..e1e68cc934f8b5a8606a553f3e0a939c61a70377 100644
|
||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -3056,7 +3056,7 @@ public class ServerGamePacketListenerImpl
|
||||
} else if (slot.mayPlace(cursor)) {
|
||||
if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) {
|
||||
int toPlace = packet.buttonNum() == 0 ? cursor.getCount() : 1;
|
||||
- toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount());
|
||||
+ toPlace = Math.min(toPlace, me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(clickedItem) - clickedItem.getCount()); // Lophine - Stackable ShulkerBoxes
|
||||
toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount());
|
||||
if (toPlace == 1) {
|
||||
action = InventoryAction.PLACE_ONE;
|
||||
@@ -3092,7 +3092,7 @@ public class ServerGamePacketListenerImpl
|
||||
}
|
||||
} else if (ItemStack.isSameItemSameComponents(cursor, clickedItem)) {
|
||||
if (clickedItem.getCount() >= 0) {
|
||||
- if (clickedItem.getCount() + cursor.getCount() <= cursor.getMaxStackSize()) {
|
||||
+ if (clickedItem.getCount() + cursor.getCount() <= me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(cursor)) { // Lophine - Stackable ShulkerBoxes
|
||||
// As of 1.5, this is result slots only
|
||||
action = InventoryAction.PICKUP_ALL;
|
||||
}
|
||||
@@ -3351,6 +3351,7 @@ public class ServerGamePacketListenerImpl
|
||||
this.player.containerMenu.broadcastFullState();
|
||||
} else {
|
||||
this.player.containerMenu.broadcastChanges();
|
||||
+ if (me.earthme.lophine.utils.ShulkerBoxesUtil.shouldCheck()) this.player.containerMenu.broadcastCarriedItem(); // Lophine - Stackable ShulkerBoxes
|
||||
}
|
||||
if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
|
||||
}
|
||||
@@ -3463,7 +3464,7 @@ public class ServerGamePacketListenerImpl
|
||||
}
|
||||
|
||||
boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45;
|
||||
- boolean flag2 = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize();
|
||||
+ boolean flag2 = itemStack.isEmpty() || itemStack.getCount() <= me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemStack); // Lophine - Stackable ShulkerBoxes
|
||||
if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packet.slotNum()).getItem(), packet.itemStack()))) { // Insist on valid slot
|
||||
// CraftBukkit start - Call click event
|
||||
org.bukkit.inventory.InventoryView inventory = this.player.inventoryMenu.getBukkitView();
|
||||
@@ -3505,6 +3506,7 @@ public class ServerGamePacketListenerImpl
|
||||
this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemStack);
|
||||
this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemStack);
|
||||
this.player.inventoryMenu.broadcastChanges();
|
||||
+ if (me.earthme.lophine.utils.ShulkerBoxesUtil.shouldCheck()) this.player.containerMenu.broadcastCarriedItem(); // Lophine - Stackable ShulkerBoxes
|
||||
if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes.
|
||||
} else if (flag && flag2) {
|
||||
if (this.dropSpamThrottler.isUnderThreshold()) {
|
||||
diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java
|
||||
index b382665cc125b8b5c0938e5e55984e4bf91d37ff..8ff16372df12f07e47d81fe45ad7270bb5c2b052 100644
|
||||
--- a/net/minecraft/world/Container.java
|
||||
+++ b/net/minecraft/world/Container.java
|
||||
@@ -32,6 +32,12 @@ public interface Container extends Clearable, Iterable<ItemStack> {
|
||||
return Math.min(this.getMaxStackSize(), stack.getMaxStackSize());
|
||||
}
|
||||
|
||||
+ // Leaves start - stackable shulker boxes
|
||||
+ default int getMaxStackLeaves(ItemStack stack) {
|
||||
+ return Math.min(this.getMaxStackSize(), me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(stack));
|
||||
+ }
|
||||
+ // Leaves end - stackable shulker boxes
|
||||
+
|
||||
void setChanged();
|
||||
|
||||
boolean stillValid(Player player);
|
||||
diff --git a/net/minecraft/world/SimpleContainer.java b/net/minecraft/world/SimpleContainer.java
|
||||
index 133e042371bcf84f1935903ec57d204e3b7abd84..201599988e20219b6a99bf1594ad6c0c19e09038 100644
|
||||
--- a/net/minecraft/world/SimpleContainer.java
|
||||
+++ b/net/minecraft/world/SimpleContainer.java
|
||||
@@ -211,7 +211,7 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
|
||||
@Override
|
||||
public void setItem(int index, ItemStack stack) {
|
||||
this.items.set(index, stack);
|
||||
- stack.limitSize(this.getMaxStackSize(stack));
|
||||
+ stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - stackable shulker boxes
|
||||
this.setChanged();
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ public class SimpleContainer implements Container, StackedContentsCompatible {
|
||||
}
|
||||
|
||||
private void moveItemsBetweenStacks(ItemStack stack, ItemStack other) {
|
||||
- int maxStackSize = this.getMaxStackSize(other);
|
||||
+ int maxStackSize = this.getMaxStackLeaves(other); // Leaves - stackable shulker boxes
|
||||
int min = Math.min(stack.getCount(), maxStackSize - other.getCount());
|
||||
if (min > 0) {
|
||||
other.grow(min);
|
||||
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index a9cc35b4b253d9a7fd90f811af9be629b164fad0..5c548cb30565d156c6eeb316b0c0ce8be93ad0d7 100644
|
||||
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -281,10 +281,45 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
|
||||
private boolean isMergable() {
|
||||
ItemStack item = this.getItem();
|
||||
- return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && item.getCount() < item.getMaxStackSize(); // Paper - Alternative item-despawn-rate
|
||||
+ return this.isAlive() && this.pickupDelay != 32767 && this.age != -32768 && this.age < this.despawnRate && item.getCount() < me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(item); // Paper - Alternative item-despawn-rate // Lophine - Stackable ShulkerBoxes
|
||||
+ }
|
||||
+
|
||||
+ // Lophine start - Stackable ShulkerBoxes
|
||||
+ private boolean tryMergeShulkerBox(ItemEntity ote) {
|
||||
+ ItemStack sf = this.getItem();
|
||||
+ ItemStack ot = ote.getItem();
|
||||
+ if (!me.earthme.lophine.utils.ShulkerBoxesUtil.checkShulkerBox(sf)) return false;
|
||||
+ if (sf.getItem().equals(ot.getItem())
|
||||
+ && me.earthme.lophine.utils.ShulkerBoxesUtil.emptyShulkerBoxCheck(sf)
|
||||
+ && me.earthme.lophine.utils.ShulkerBoxesUtil.emptyShulkerBoxCheck(ot)
|
||||
+ && Objects.equals(sf.getComponents(), ot.getComponents()) // empty block entity tags are cleaned up when spawning
|
||||
+ && sf.getCount() != me.earthme.lophine.utils.ShulkerBoxesUtil.getShulkerBoxesMaxCountUnsafe()) {
|
||||
+ int count = Math.min(ot.getCount(), me.earthme.lophine.utils.ShulkerBoxesUtil.getShulkerBoxesMaxCountUnsafe() - sf.getCount());
|
||||
+ sf.grow(count);
|
||||
+ this.setItem(sf);
|
||||
+
|
||||
+ this.pickupDelay = Math.max(ote.pickupDelay, this.pickupDelay);
|
||||
+ this.age = Math.min(ote.getAge(), this.age);
|
||||
+ ot.shrink(count);
|
||||
+ if (ot.isEmpty()) {
|
||||
+ ote.discard();
|
||||
+ }
|
||||
+ else {
|
||||
+ ote.setItem(ot);
|
||||
+ }
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
}
|
||||
+ // Lophine end - Stackable ShulkerBoxes
|
||||
|
||||
private void tryToMerge(ItemEntity itemEntity) {
|
||||
+ // Lophine start - Stackable ShulkerBoxes
|
||||
+ if (me.earthme.lophine.utils.ShulkerBoxesUtil.shouldCheck()
|
||||
+ && this.tryMergeShulkerBox(itemEntity)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // Lophine end - Stackable ShulkerBoxes
|
||||
ItemStack item = this.getItem();
|
||||
ItemStack item1 = itemEntity.getItem();
|
||||
if (Objects.equals(this.target, itemEntity.target) && areMergable(item, item1)) {
|
||||
diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java
|
||||
index d9cb4f0ed0c4f63362c837aeef3c4194911455c9..9fbd605df26d388c01d2ed9ca6a6138651e7f9a7 100644
|
||||
--- a/net/minecraft/world/entity/player/Inventory.java
|
||||
+++ b/net/minecraft/world/entity/player/Inventory.java
|
||||
@@ -149,8 +149,8 @@ public class Inventory implements Container, Nameable {
|
||||
|
||||
private boolean hasRemainingSpaceForItem(ItemStack destination, ItemStack origin) {
|
||||
return !destination.isEmpty()
|
||||
- && destination.isStackable()
|
||||
- && destination.getCount() < this.getMaxStackSize(destination)
|
||||
+ && me.earthme.lophine.utils.ShulkerBoxesUtil.isStackable(destination) // Lophine - Stackable ShulkerBoxes
|
||||
+ && destination.getCount() < me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(destination) // Lophine - Stackable ShulkerBoxes
|
||||
&& ItemStack.isSameItemSameComponents(destination, origin); // Paper - check if itemstack is stackable first
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ public class Inventory implements Container, Nameable {
|
||||
}
|
||||
|
||||
if (this.hasRemainingSpaceForItem(itemInSlot, itemStack)) {
|
||||
- remains -= (itemInSlot.getMaxStackSize() < this.getMaxStackSize() ? itemInSlot.getMaxStackSize() : this.getMaxStackSize()) - itemInSlot.getCount();
|
||||
+ remains -= (me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemInSlot) < this.getMaxStackSize() ? me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemInSlot) : this.getMaxStackSize()) - itemInSlot.getCount(); // Lophine - Stackable ShulkerBoxes
|
||||
}
|
||||
if (remains <= 0) {
|
||||
return itemStack.getCount();
|
||||
@@ -173,7 +173,7 @@ public class Inventory implements Container, Nameable {
|
||||
|
||||
ItemStack itemInOffhand = this.equipment.get(EquipmentSlot.OFFHAND);
|
||||
if (this.hasRemainingSpaceForItem(itemInOffhand, itemStack)) {
|
||||
- remains -= (itemInOffhand.getMaxStackSize() < this.getMaxStackSize() ? itemInOffhand.getMaxStackSize() : this.getMaxStackSize()) - itemInOffhand.getCount();
|
||||
+ remains -= (me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemInOffhand) < this.getMaxStackSize() ? me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemInOffhand) : this.getMaxStackSize()) - itemInOffhand.getCount(); // Lophine - Stackable ShulkerBoxes
|
||||
}
|
||||
if (remains <= 0) {
|
||||
return itemStack.getCount();
|
||||
@@ -297,7 +297,7 @@ public class Inventory implements Container, Nameable {
|
||||
this.setItem(slot, item);
|
||||
}
|
||||
|
||||
- int i = this.getMaxStackSize(item) - item.getCount();
|
||||
+ int i = this.getMaxStackLeaves(item) - item.getCount();
|
||||
int min = Math.min(count, i);
|
||||
if (min == 0) {
|
||||
return count;
|
||||
@@ -403,7 +403,7 @@ public class Inventory implements Container, Nameable {
|
||||
break;
|
||||
}
|
||||
|
||||
- int i = stack.getMaxStackSize() - this.getItem(slotWithRemainingSpace).getCount();
|
||||
+ int i = me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(stack) - this.getItem(slotWithRemainingSpace).getCount(); // Lophine - Stackable ShulkerBoxes
|
||||
if (this.add(slotWithRemainingSpace, stack.split(i)) && sendPacket && this.player instanceof ServerPlayer serverPlayer) {
|
||||
serverPlayer.connection.send(this.createInventoryUpdatePacket(slotWithRemainingSpace));
|
||||
}
|
||||
diff --git a/net/minecraft/world/entity/player/StackedItemContents.java b/net/minecraft/world/entity/player/StackedItemContents.java
|
||||
index 83ccde54c625d40dc595e000c533f60aa929bd5a..16e9ac7449761c1427a528be60e964ef737ce897 100644
|
||||
--- a/net/minecraft/world/entity/player/StackedItemContents.java
|
||||
+++ b/net/minecraft/world/entity/player/StackedItemContents.java
|
||||
@@ -23,7 +23,7 @@ public class StackedItemContents {
|
||||
}
|
||||
|
||||
public void accountStack(ItemStack stack) {
|
||||
- this.accountStack(stack, stack.getMaxStackSize());
|
||||
+ this.accountStack(stack, me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(stack)); // Lophine - Stackable Shulker Boxes
|
||||
}
|
||||
|
||||
public void accountStack(ItemStack stack, int maxStackSize) {
|
||||
diff --git a/net/minecraft/world/entity/vehicle/ContainerEntity.java b/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
index feebd1610ebd3c26a337259c14f5c774dc72b937..7df6ff842e41763aec2d88d1f8a5f7503932d905 100644
|
||||
--- a/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
+++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java
|
||||
@@ -163,7 +163,7 @@ public interface ContainerEntity extends Container, MenuProvider {
|
||||
default void setChestVehicleItem(int slot, ItemStack stack) {
|
||||
this.unpackChestVehicleLootTable(null);
|
||||
this.getItemStacks().set(slot, stack);
|
||||
- stack.limitSize(this.getMaxStackSize(stack));
|
||||
+ stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - stackable shulker boxes
|
||||
}
|
||||
|
||||
default SlotAccess getChestVehicleSlot(final int index) {
|
||||
diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||
index a9cf0ef95b706f05060bbcd2a4f5a03c60f783d2..6c5a01b065c7daa37219a8ab2a471d93e882e756 100644
|
||||
--- a/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||
+++ b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||
@@ -234,6 +234,14 @@ public abstract class AbstractContainerMenu {
|
||||
return list;
|
||||
}
|
||||
|
||||
+ // Lophine start - Stackable ShulkerBoxes
|
||||
+ public void boardcastChangesSigleSlot(int slot, ItemStack item) {
|
||||
+ if (this.synchronizer != null) {
|
||||
+ this.synchronizer.sendSlotChange(this, slot, item);
|
||||
+ }
|
||||
+ }
|
||||
+ // Lophine end - Stackable ShulkerBoxes
|
||||
+
|
||||
public void broadcastChanges() {
|
||||
for (int i = 0; i < this.slots.size(); i++) {
|
||||
ItemStack item = this.slots.get(i).getItem();
|
||||
@@ -427,7 +435,7 @@ public abstract class AbstractContainerMenu {
|
||||
&& (this.quickcraftType == 2 || carried1.getCount() >= this.quickcraftSlots.size())
|
||||
&& this.canDragTo(slot1)) {
|
||||
int i2 = slot1.hasItem() ? slot1.getItem().getCount() : 0;
|
||||
- int min = Math.min(itemStack.getMaxStackSize(), slot1.getMaxStackSize(itemStack));
|
||||
+ int min = Math.min(me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemStack), slot1.getMaxStackSize(itemStack)); // Lophine - Stackable ShulkerBoxes
|
||||
int min1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemStack) + i2, min);
|
||||
count -= min1 - i2;
|
||||
// slot1.setByPlayer(itemStack.copyWithCount(min1));
|
||||
@@ -541,7 +549,7 @@ public abstract class AbstractContainerMenu {
|
||||
slot.setByPlayer(carried2);
|
||||
}
|
||||
} else if (ItemStack.isSameItemSameComponents(carried, carried2)) {
|
||||
- Optional<ItemStack> optional1 = slot.tryRemove(carried.getCount(), carried2.getMaxStackSize() - carried2.getCount(), player);
|
||||
+ Optional<ItemStack> optional1 = slot.tryRemove(carried.getCount(), me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(carried2) - carried2.getCount(), player); // Lophine - Stackable ShulkerBoxes
|
||||
optional1.ifPresent(itemStack2 -> {
|
||||
carried2.grow(itemStack2.getCount());
|
||||
slot.onTake(player, itemStack2);
|
||||
@@ -603,7 +611,7 @@ public abstract class AbstractContainerMenu {
|
||||
Slot slot2 = this.slots.get(slotId);
|
||||
if (slot2.hasItem()) {
|
||||
ItemStack itemStack = slot2.getItem();
|
||||
- this.setCarried(itemStack.copyWithCount(itemStack.getMaxStackSize()));
|
||||
+ this.setCarried(itemStack.copyWithCount(me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemStack))); // Lophine - Stackable ShulkerBoxes
|
||||
}
|
||||
} else if (clickType == ClickType.THROW && this.getCarried().isEmpty() && slotId >= 0) {
|
||||
Slot slot2 = this.slots.get(slotId);
|
||||
@@ -634,15 +642,15 @@ public abstract class AbstractContainerMenu {
|
||||
int maxStackSize = button == 0 ? 1 : -1;
|
||||
|
||||
for (int i3 = 0; i3 < 2; i3++) {
|
||||
- for (int i4 = count; i4 >= 0 && i4 < this.slots.size() && itemStack.getCount() < itemStack.getMaxStackSize(); i4 += maxStackSize) {
|
||||
+ for (int i4 = count; i4 >= 0 && i4 < this.slots.size() && itemStack.getCount() < me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemStack); i4 += maxStackSize) { // Lophine - Stackable ShulkerBoxes
|
||||
Slot slot3 = this.slots.get(i4);
|
||||
if (slot3.hasItem()
|
||||
&& canItemQuickReplace(slot3, itemStack, true)
|
||||
&& slot3.mayPickup(player)
|
||||
&& this.canTakeItemForPickAll(itemStack, slot3)) {
|
||||
ItemStack item1 = slot3.getItem();
|
||||
- if (i3 != 0 || item1.getCount() != item1.getMaxStackSize()) {
|
||||
- ItemStack itemStack1 = slot3.safeTake(item1.getCount(), itemStack.getMaxStackSize() - itemStack.getCount(), player);
|
||||
+ if (i3 != 0 || item1.getCount() != me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(item1)) { // Lophine - stackable shulker boxes
|
||||
+ ItemStack itemStack1 = slot3.safeTake(item1.getCount(), me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemStack) - itemStack.getCount(), player); // Lophine - stackable shulker boxes
|
||||
itemStack.grow(itemStack1.getCount());
|
||||
}
|
||||
}
|
||||
@@ -744,7 +752,7 @@ public abstract class AbstractContainerMenu {
|
||||
i = endIndex - 1;
|
||||
}
|
||||
|
||||
- if (stack.isStackable()) {
|
||||
+ if (me.earthme.lophine.utils.ShulkerBoxesUtil.isStackable(stack)) { // Lophine - Stackable ShulkerBoxes
|
||||
while (!stack.isEmpty() && (reverseDirection ? i >= startIndex : i < endIndex)) {
|
||||
Slot slot = this.slots.get(i);
|
||||
ItemStack item = slot.getItem();
|
||||
@@ -845,7 +853,7 @@ public abstract class AbstractContainerMenu {
|
||||
public static boolean canItemQuickReplace(@Nullable Slot slot, ItemStack stack, boolean stackSizeMatters) {
|
||||
boolean flag = slot == null || !slot.hasItem();
|
||||
return !flag && ItemStack.isSameItemSameComponents(stack, slot.getItem())
|
||||
- ? slot.getItem().getCount() + (stackSizeMatters ? 0 : stack.getCount()) <= stack.getMaxStackSize()
|
||||
+ ? slot.getItem().getCount() + (stackSizeMatters ? 0 : stack.getCount()) <= me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(stack) // Lophine - Stackable ShulkerBoxes
|
||||
: flag;
|
||||
}
|
||||
|
||||
@@ -853,7 +861,7 @@ public abstract class AbstractContainerMenu {
|
||||
return switch (type) {
|
||||
case 0 -> Mth.floor((float)stack.getCount() / slots.size());
|
||||
case 1 -> 1;
|
||||
- case 2 -> stack.getMaxStackSize();
|
||||
+ case 2 -> me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(stack); // Lophine - Stackable ShulkerBoxes
|
||||
default -> stack.getCount();
|
||||
};
|
||||
}
|
||||
@@ -875,7 +883,7 @@ public abstract class AbstractContainerMenu {
|
||||
for (int i = 0; i < container.getContainerSize(); i++) {
|
||||
ItemStack item = container.getItem(i);
|
||||
if (!item.isEmpty()) {
|
||||
- f += (float)item.getCount() / container.getMaxStackSize(item);
|
||||
+ f += (float)item.getCount() / container.getMaxStackLeaves(item); // Leaves - stackable shulker boxes
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/inventory/MerchantContainer.java b/net/minecraft/world/inventory/MerchantContainer.java
|
||||
index 1e5dfb1f9e371fa23cdfa9280797aa0e183d4cd2..cf87267130c0aebd38206556261929d6f6383bc9 100644
|
||||
--- a/net/minecraft/world/inventory/MerchantContainer.java
|
||||
+++ b/net/minecraft/world/inventory/MerchantContainer.java
|
||||
@@ -109,7 +109,7 @@ public class MerchantContainer implements Container {
|
||||
@Override
|
||||
public void setItem(int index, ItemStack stack) {
|
||||
this.itemStacks.set(index, stack);
|
||||
- stack.limitSize(this.getMaxStackSize(stack));
|
||||
+ stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - stackable shulker boxes
|
||||
if (this.isPaymentSlot(index)) {
|
||||
this.updateSellItem();
|
||||
}
|
||||
diff --git a/net/minecraft/world/inventory/Slot.java b/net/minecraft/world/inventory/Slot.java
|
||||
index 5ceb8964476b40db4511bec91ff13c4f522a1357..170353b8d1d330e54d9836e78ba2d41d023e0f51 100644
|
||||
--- a/net/minecraft/world/inventory/Slot.java
|
||||
+++ b/net/minecraft/world/inventory/Slot.java
|
||||
@@ -75,7 +75,7 @@ public class Slot {
|
||||
}
|
||||
|
||||
public int getMaxStackSize(ItemStack stack) {
|
||||
- return Math.min(this.getMaxStackSize(), stack.getMaxStackSize());
|
||||
+ return Math.min(this.getMaxStackSize(), me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(stack)); // Lophine - Stackable ShulkerBoxes
|
||||
}
|
||||
|
||||
@Nullable
|
||||
diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java
|
||||
index 09455150810e4fb6e4637fdb9e2e8a30fe0bc247..5d2571d0199a25087954b4e67bc7551f282c6bd2 100644
|
||||
--- a/net/minecraft/world/item/ItemStack.java
|
||||
+++ b/net/minecraft/world/item/ItemStack.java
|
||||
@@ -165,7 +165,7 @@ public final class ItemStack implements DataComponentHolder {
|
||||
@Deprecated
|
||||
@Nullable
|
||||
private Item item;
|
||||
- PatchedDataComponentMap components;
|
||||
+ public PatchedDataComponentMap components; // Leaves - stackable shulker boxes
|
||||
@Nullable
|
||||
private Entity entityRepresentation;
|
||||
|
||||
@@ -192,7 +192,8 @@ public final class ItemStack implements DataComponentHolder {
|
||||
} else {
|
||||
Holder<Item> holder = Item.STREAM_CODEC.decode(buffer);
|
||||
DataComponentPatch dataComponentPatch = codec.decode(buffer);
|
||||
- return new ItemStack(holder, varInt, dataComponentPatch);
|
||||
+ ItemStack itemStack = new ItemStack(holder, varInt, dataComponentPatch);
|
||||
+ return me.earthme.lophine.utils.ShulkerBoxesUtil.decodeMaxStackSize(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,13 +202,15 @@ public final class ItemStack implements DataComponentHolder {
|
||||
if (value.isEmpty() || value.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem()
|
||||
buffer.writeVarInt(0);
|
||||
} else {
|
||||
- buffer.writeVarInt(io.papermc.paper.util.sanitizer.ItemComponentSanitizer.sanitizeCount(io.papermc.paper.util.sanitizer.ItemObfuscationSession.currentSession(), value, value.getCount())); // Paper - potentially sanitize count
|
||||
- Item.STREAM_CODEC.encode(buffer, value.getItemHolder());
|
||||
+ // Leaves start - stackable shulker boxes
|
||||
+ final ItemStack itemStack = me.earthme.lophine.utils.ShulkerBoxesUtil.encodeMaxStackSize(value.copy());
|
||||
+ buffer.writeVarInt(io.papermc.paper.util.sanitizer.ItemComponentSanitizer.sanitizeCount(io.papermc.paper.util.sanitizer.ItemObfuscationSession.currentSession(), itemStack, itemStack.getCount())); // Paper - potentially sanitize count
|
||||
+ Item.STREAM_CODEC.encode(buffer, itemStack.getItemHolder());
|
||||
// Paper start - adventure; conditionally render translatable components
|
||||
boolean prev = net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.get();
|
||||
- try (final io.papermc.paper.util.SafeAutoClosable ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.withContext(c -> c.itemStack(value))) { // pass the itemstack as context to the obfuscation session
|
||||
+ try (final io.papermc.paper.util.SafeAutoClosable ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.withContext(c -> c.itemStack(itemStack))) { // pass the itemstack as context to the obfuscation session
|
||||
net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true);
|
||||
- codec.encode(buffer, value.components.asPatch());
|
||||
+ codec.encode(buffer, itemStack.components.asPatch());
|
||||
} finally {
|
||||
net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(prev);
|
||||
}
|
||||
@@ -302,7 +305,7 @@ public final class ItemStack implements DataComponentHolder {
|
||||
|
||||
for (ItemStack itemStack : itemContainerContents.nonEmptyItems()) {
|
||||
int count = itemStack.getCount();
|
||||
- int maxStackSize = itemStack.getMaxStackSize();
|
||||
+ int maxStackSize = me.earthme.lophine.utils.ShulkerBoxesUtil.getItemMaxCount(itemStack); // Leaves - stackable shulker boxes
|
||||
if (count > maxStackSize) {
|
||||
return DataResult.error(() -> "Item stack with count of " + count + " was larger than maximum: " + maxStackSize);
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/block/AbstractCauldronBlock.java b/net/minecraft/world/level/block/AbstractCauldronBlock.java
|
||||
index ad3f32888afd8b5f0038445a1b0fcc8cacec9fe2..ee0315ff52914666e3e3cfc38f726512e3301986 100644
|
||||
--- a/net/minecraft/world/level/block/AbstractCauldronBlock.java
|
||||
+++ b/net/minecraft/world/level/block/AbstractCauldronBlock.java
|
||||
@@ -62,9 +62,27 @@ public abstract class AbstractCauldronBlock extends Block {
|
||||
ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult
|
||||
) {
|
||||
CauldronInteraction cauldronInteraction = this.interactions.map().get(stack.getItem());
|
||||
- return cauldronInteraction.interact(state, level, pos, player, hand, stack, hitResult.getDirection()); // Paper - pass hit direction
|
||||
+ return wrapInteractor(cauldronInteraction, state, level, pos, player, hand, stack, hitResult.getDirection()); // Paper - pass hit direction // Leaves - stackable shulker boxes
|
||||
}
|
||||
|
||||
+ // Leaves start - stackable shulker boxes
|
||||
+ private InteractionResult wrapInteractor(CauldronInteraction cauldronBehavior, BlockState blockState, Level world, BlockPos blockPos, Player playerEntity, InteractionHand hand, ItemStack itemStack, net.minecraft.core.Direction hitDirection) {
|
||||
+ int count = -1;
|
||||
+ if (me.earthme.lophine.utils.ShulkerBoxesUtil.shouldCheck() && itemStack.getItem() instanceof net.minecraft.world.item.BlockItem bi &&
|
||||
+ bi.getBlock() instanceof ShulkerBoxBlock) {
|
||||
+ count = itemStack.getCount();
|
||||
+ }
|
||||
+ InteractionResult result = cauldronBehavior.interact(blockState, world, blockPos, playerEntity, hand, itemStack, hitDirection);
|
||||
+ if (count > 0 && result.consumesAction()) {
|
||||
+ ItemStack current = playerEntity.getItemInHand(hand);
|
||||
+ if (current.getItem() instanceof net.minecraft.world.item.BlockItem bi && bi.getBlock() instanceof ShulkerBoxBlock) {
|
||||
+ current.setCount(count);
|
||||
+ }
|
||||
+ }
|
||||
+ return result;
|
||||
+ }
|
||||
+ // Leaves end - stackable shulker boxes
|
||||
+
|
||||
@Override
|
||||
protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
|
||||
return SHAPE;
|
||||
diff --git a/net/minecraft/world/level/block/CrafterBlock.java b/net/minecraft/world/level/block/CrafterBlock.java
|
||||
index 38b03c7b02bdfc579e5e126c12de3d878e26d188..33e24f2c3b63b2d3b55dfae2f2e55869abeed055 100644
|
||||
--- a/net/minecraft/world/level/block/CrafterBlock.java
|
||||
+++ b/net/minecraft/world/level/block/CrafterBlock.java
|
||||
@@ -192,7 +192,7 @@ public class CrafterBlock extends BaseEntityBlock {
|
||||
Direction direction = state.getValue(ORIENTATION).front();
|
||||
Container containerAt = HopperBlockEntity.getContainerAt(level, pos.relative(direction));
|
||||
ItemStack itemStack = stack.copy();
|
||||
- if (containerAt != null && (containerAt instanceof CrafterBlockEntity || stack.getCount() > containerAt.getMaxStackSize(stack))) {
|
||||
+ if (containerAt != null && (containerAt instanceof CrafterBlockEntity || stack.getCount() > containerAt.getMaxStackLeaves(stack))) { // Leaves - stackable shulker boxes
|
||||
// CraftBukkit start - InventoryMoveItemEvent
|
||||
org.bukkit.craftbukkit.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack);
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
index c5b3b5e5f621f8db152aa190374ae0fe567d6828..0ca27b83151c3e7be3d681aa087fa72fb5bef0c3 100644
|
||||
--- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
|
||||
@@ -409,7 +409,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit
|
||||
ItemStack itemStack = this.items.get(index);
|
||||
boolean flag = !stack.isEmpty() && ItemStack.isSameItemSameComponents(itemStack, stack);
|
||||
this.items.set(index, stack);
|
||||
- stack.limitSize(this.getMaxStackSize(stack));
|
||||
+ stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - stackable shulker boxes
|
||||
if (index == 0 && !flag && this.level instanceof ServerLevel serverLevel) {
|
||||
this.cookingTotalTime = getTotalCookTime(serverLevel, this, this.recipeType, this.cookSpeedMultiplier); // Paper - cook speed multiplier API
|
||||
this.cookingTimer = 0;
|
||||
diff --git a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||
index c63370fd458fb4f7190b79b1a8174fcc92d88f9c..4cca3fbbb93bb76d5d501dfad6997d909211809e 100644
|
||||
--- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java
|
||||
@@ -148,7 +148,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co
|
||||
@Override
|
||||
public void setItem(int slot, ItemStack stack) {
|
||||
this.getItems().set(slot, stack);
|
||||
- stack.limitSize(this.getMaxStackSize(stack));
|
||||
+ stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - stackable shulker boxes
|
||||
this.setChanged();
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 6f5a47a3e9452f25b318e4a7a628e917da99c96f..52032c6bbc7e1c37a50d9b7334f1830896cb462d 100644
|
||||
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -123,7 +123,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
public void setItem(int index, ItemStack stack) {
|
||||
this.unpackLootTable(null);
|
||||
this.getItems().set(index, stack);
|
||||
- stack.limitSize(this.getMaxStackSize(stack));
|
||||
+ stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - stackable shulker boxes
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -690,9 +690,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
if (item.isEmpty()) {
|
||||
// Spigot start - SPIGOT-6693, SimpleContainer#setItem
|
||||
ItemStack leftover = ItemStack.EMPTY; // Paper - Make hoppers respect inventory max stack size
|
||||
- if (!stack.isEmpty() && stack.getCount() > destination.getMaxStackSize()) {
|
||||
+ if (!stack.isEmpty() && (stack.getCount() > destination.getMaxStackSize() || stack.getCount() > stack.getMaxStackSize())) {
|
||||
leftover = stack; // Paper - Make hoppers respect inventory max stack size
|
||||
- stack = stack.split(destination.getMaxStackSize());
|
||||
+ stack = stack.split(Math.min(destination.getMaxStackSize(), stack.getMaxStackSize()));
|
||||
}
|
||||
// Spigot end
|
||||
IGNORE_TILE_UPDATES.set(Boolean.TRUE); // Paper - Perf: Optimize Hoppers // Folia - region threading
|
||||
@@ -0,0 +1,174 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Sat, 14 Jun 2025 05:32:51 +0800
|
||||
Subject: [PATCH] Better ShulkerBox
|
||||
|
||||
You can open shulker box with shift & right click
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 1764875b9024569671bf2be537afb8b492f79102..0ae350d7e4b63abad1666c84df6925c71b73a013 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -2351,6 +2351,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.containerMenu.removed(this);
|
||||
this.inventoryMenu.transferState(this.containerMenu);
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
+ this.shulkerOpen = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java
|
||||
index 9fbd605df26d388c01d2ed9ca6a6138651e7f9a7..e8141cb25d6b9a433890e2cded188c2eb5bcf755 100644
|
||||
--- a/net/minecraft/world/entity/player/Inventory.java
|
||||
+++ b/net/minecraft/world/entity/player/Inventory.java
|
||||
@@ -470,6 +470,16 @@ public class Inventory implements Container, Nameable {
|
||||
if (equipmentSlot != null) {
|
||||
this.equipment.set(equipmentSlot, stack);
|
||||
}
|
||||
+
|
||||
+ // Lophine start - better shulker box
|
||||
+ if (me.earthme.lophine.config.modules.misc.ContainerExpansionConfig.betterShulker && !this.player.pendingClosingShulker) {
|
||||
+ boolean isMainHand = index == selected;
|
||||
+ boolean isOffHand = index == 40;
|
||||
+ if (isMainHand || isOffHand) {
|
||||
+ me.earthme.lophine.utils.ShulkerBoxesUtil.inventoryCallBack(isMainHand, this.player);
|
||||
+ }
|
||||
+ }
|
||||
+ // Lophine end - better shulker box
|
||||
}
|
||||
|
||||
public ListTag save(ListTag listTag) {
|
||||
diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java
|
||||
index 27e335e01d8f09f05a4fea5f15407dbe3a4555cb..fbb9fee8223cc27125e4c0c94a7eb8acab5e9a13 100644
|
||||
--- a/net/minecraft/world/entity/player/Player.java
|
||||
+++ b/net/minecraft/world/entity/player/Player.java
|
||||
@@ -211,6 +211,11 @@ public abstract class Player extends LivingEntity {
|
||||
public boolean affectsSpawning = true; // Paper - Affects Spawning API
|
||||
public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage
|
||||
public int enderChestSlotCount = -1; // Purpur - Barrels and enderchests 6 rows
|
||||
+ // Lophine start - better shulker box
|
||||
+ public net.minecraft.world.InteractionHand shulkerHand;
|
||||
+ public boolean pendingClosingShulker = false;
|
||||
+ public boolean shulkerOpen = false;
|
||||
+ // Lophine end - better shulker box
|
||||
|
||||
// CraftBukkit start
|
||||
public boolean fauxSleeping;
|
||||
@@ -595,11 +600,13 @@ public abstract class Player extends LivingEntity {
|
||||
// Paper start - special close for unloaded inventory
|
||||
public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) {
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
+ this.shulkerOpen = false;
|
||||
}
|
||||
// Paper end - special close for unloaded inventory
|
||||
|
||||
public void closeContainer() {
|
||||
this.containerMenu = this.inventoryMenu;
|
||||
+ this.shulkerOpen = false;
|
||||
}
|
||||
|
||||
protected void doCloseContainer() {
|
||||
diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||
index 6c5a01b065c7daa37219a8ab2a471d93e882e756..7b49b35e7a0b9872daceb620cf83b06ae61c3df9 100644
|
||||
--- a/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||
+++ b/net/minecraft/world/inventory/AbstractContainerMenu.java
|
||||
@@ -697,7 +697,7 @@ public abstract class AbstractContainerMenu {
|
||||
}
|
||||
}
|
||||
|
||||
- private static void dropOrPlaceInInventory(Player player, ItemStack stack) {
|
||||
+ public static void dropOrPlaceInInventory(Player player, ItemStack stack) { // Lophine - better shulker box
|
||||
boolean flag = !player.isAlive(); //player.isRemoved() && player.getRemovalReason() != Entity.RemovalReason.CHANGED_DIMENSION; // Luminol - Fix uncorrected death check of folia
|
||||
boolean flag1 = player instanceof ServerPlayer serverPlayer && serverPlayer.hasDisconnected();
|
||||
if (flag || flag1) {
|
||||
diff --git a/net/minecraft/world/inventory/ShulkerBoxMenu.java b/net/minecraft/world/inventory/ShulkerBoxMenu.java
|
||||
index 903025c659e6a9423224fe65973696405c69ec6a..545fc46416932db922dc1476b983ac8b9b9f3c7b 100644
|
||||
--- a/net/minecraft/world/inventory/ShulkerBoxMenu.java
|
||||
+++ b/net/minecraft/world/inventory/ShulkerBoxMenu.java
|
||||
@@ -53,7 +53,7 @@ public class ShulkerBoxMenu extends AbstractContainerMenu {
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
- if (!this.checkReachable) return true; // CraftBukkit
|
||||
+ if (!this.checkReachable || player.shulkerOpen) return true; // CraftBukkit // Lophine - better shulker box
|
||||
return this.container.stillValid(player);
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/item/Item.java b/net/minecraft/world/item/Item.java
|
||||
index c52fb17d1e496a91223b7387cacb128c1865caee..86d43c4e81dfe9775400e09ae706d4e9cc640bd8 100644
|
||||
--- a/net/minecraft/world/item/Item.java
|
||||
+++ b/net/minecraft/world/item/Item.java
|
||||
@@ -187,6 +187,13 @@ public class Item implements FeatureElement, ItemLike {
|
||||
player.startUsingItem(hand);
|
||||
return InteractionResult.CONSUME;
|
||||
} else {
|
||||
+ // Lophine start - better shulker box
|
||||
+ if (me.earthme.lophine.config.modules.misc.ContainerExpansionConfig.betterShulker
|
||||
+ && player.isShiftKeyDown()
|
||||
+ && me.earthme.lophine.utils.ShulkerBoxesUtil.checkIfCanOpen(itemInHand)) {
|
||||
+ me.earthme.lophine.utils.ShulkerBoxesUtil.openShulkerBox(player, itemInHand, hand);
|
||||
+ }
|
||||
+ // Lophine end - better shulker box
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/item/component/ItemContainerContents.java b/net/minecraft/world/item/component/ItemContainerContents.java
|
||||
index ecf794f94177fc7b6df483516d920719fbc6fa43..4fda59a4c17009a0009f3d3c13258f4ffcb300c3 100644
|
||||
--- a/net/minecraft/world/item/component/ItemContainerContents.java
|
||||
+++ b/net/minecraft/world/item/component/ItemContainerContents.java
|
||||
@@ -33,7 +33,7 @@ public final class ItemContainerContents implements TooltipProvider {
|
||||
public final NonNullList<ItemStack> items;
|
||||
private final int hashCode;
|
||||
|
||||
- private ItemContainerContents(NonNullList<ItemStack> items) {
|
||||
+ public ItemContainerContents(NonNullList<ItemStack> items) { // Lophine - better shulker box
|
||||
if (items.size() > 256) {
|
||||
throw new IllegalArgumentException("Got " + items.size() + " items, but maximum is 256");
|
||||
} else {
|
||||
diff --git a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
index 87ebdb6deb66662a38b3eec0dae27eaf859ecabb..e22114dbfbfd1619260a45929397c11c9356b8a0 100644
|
||||
--- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java
|
||||
@@ -46,6 +46,11 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||
private ShulkerBoxBlockEntity.AnimationStatus animationStatus = ShulkerBoxBlockEntity.AnimationStatus.CLOSED;
|
||||
private float progress;
|
||||
private float progressOld;
|
||||
+ // Lophine start - better shulker box
|
||||
+ public boolean haveRealBlock = true;
|
||||
+ public Player createPlayer;
|
||||
+ public ItemStack item;
|
||||
+ // Lophine end - better shulker box
|
||||
@Nullable
|
||||
private final DyeColor color;
|
||||
|
||||
@@ -236,6 +241,15 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||
return Component.translatable("container.shulkerBox");
|
||||
}
|
||||
|
||||
+ // Lophine start - better shulker box
|
||||
+ public void setItem(int index, ItemStack stack) {
|
||||
+ super.setItem(index, stack);
|
||||
+ if (!createPlayer.pendingClosingShulker && !haveRealBlock && me.earthme.lophine.config.modules.misc.ContainerExpansionConfig.betterShulker) {
|
||||
+ me.earthme.lophine.utils.ShulkerBoxesUtil.shulkerBoxEntityCallBack(this);
|
||||
+ }
|
||||
+ }
|
||||
+ // Lophine end - better shulker box
|
||||
+
|
||||
@Override
|
||||
protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) {
|
||||
super.loadAdditional(tag, registries);
|
||||
@@ -258,12 +272,12 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected NonNullList<ItemStack> getItems() {
|
||||
+ public NonNullList<ItemStack> getItems() { // Lophine - better shulker box
|
||||
return this.itemStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void setItems(NonNullList<ItemStack> items) {
|
||||
+ public void setItems(NonNullList<ItemStack> items) { // Lophine - better shulker box
|
||||
this.itemStacks = items;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Mon, 19 May 2025 00:06:03 +0800
|
||||
Subject: [PATCH] Spawn invulnerable time
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java
|
||||
index 1764875b9024569671bf2be537afb8b492f79102..473f9de0908d3fb2cfb640ff7c6f7b78c1280721 100644
|
||||
--- a/net/minecraft/server/level/ServerPlayer.java
|
||||
+++ b/net/minecraft/server/level/ServerPlayer.java
|
||||
@@ -221,6 +221,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
private int lastSentFood = -99999999;
|
||||
private boolean lastFoodSaturationZero = true;
|
||||
public int lastSentExp = -99999999;
|
||||
+ private int spawnInvulnerableTime = 60; // Lophine - spawn invulnerable time
|
||||
private ChatVisiblity chatVisibility = ChatVisiblity.FULL;
|
||||
public ParticleStatus particleStatus = ParticleStatus.ALL;
|
||||
private boolean canChatColor = true;
|
||||
@@ -923,6 +924,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
this.tickClientLoadTimeout();
|
||||
this.gameMode.tick();
|
||||
this.wardenSpawnTracker.tick();
|
||||
+ if (me.earthme.lophine.config.modules.misc.OldFeatureConfig.spawnInvulnerableTime && this.invulnerableTime > 0) --this.spawnInvulnerableTime; // Lophine - spawn invulnerable time
|
||||
if (this.invulnerableTime > 0) {
|
||||
this.invulnerableTime--;
|
||||
}
|
||||
@@ -1420,6 +1422,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc
|
||||
if (this.isInvulnerableTo(level, damageSource)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // Lophine start - spawn invulnerable time
|
||||
+ if (me.earthme.lophine.config.modules.misc.OldFeatureConfig.spawnInvulnerableTime) {
|
||||
+ if (this.spawnInvulnerableTime > 0 && !damageSource.is(net.minecraft.tags.DamageTypeTags.BYPASSES_INVULNERABILITY)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // Lophine end - spawn invulnerable time
|
||||
Entity entity = damageSource.getEntity();
|
||||
if (!( // Paper - split the if statement. If below statement is false, hurtServer would not have been evaluated. Return false.
|
||||
!(entity instanceof Player player && !this.canHarmPlayer(player))
|
||||
@@ -0,0 +1,20 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Sun, 18 May 2025 23:48:59 +0800
|
||||
Subject: [PATCH] Old nether portal collision
|
||||
|
||||
This patch should removed in 1.21.6 when mojang revert it.
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/NetherPortalBlock.java b/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
index 421ea9c748159ac989900427a13abe9b244dc7aa..ecdecf0484137e0f98bf41d09e0dc7dc7715fd35 100644
|
||||
--- a/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
+++ b/net/minecraft/world/level/block/NetherPortalBlock.java
|
||||
@@ -65,7 +65,7 @@ public class NetherPortalBlock extends Block implements Portal {
|
||||
|
||||
@Override
|
||||
protected VoxelShape getEntityInsideCollisionShape(BlockState state, BlockGetter level, BlockPos pos, Entity entity) {
|
||||
- return state.getShape(level, pos);
|
||||
+ return me.earthme.lophine.config.modules.misc.OldFeatureConfig.oldNetherPortalCollision ? Shapes.block() : state.getShape(level, pos); // Lophine - Old nether portal collision
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Mon, 19 May 2025 00:42:17 +0800
|
||||
Subject: [PATCH] Old zombie reinforcement
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/monster/Zombie.java b/net/minecraft/world/entity/monster/Zombie.java
|
||||
index 4395947fc8c719864ac2afde5e6bbb53da5129c2..348e2b6020de8584b512ec849a5fba484380930e 100644
|
||||
--- a/net/minecraft/world/entity/monster/Zombie.java
|
||||
+++ b/net/minecraft/world/entity/monster/Zombie.java
|
||||
@@ -342,7 +342,7 @@ public class Zombie extends Monster {
|
||||
int floor = Mth.floor(this.getX());
|
||||
int floor1 = Mth.floor(this.getY());
|
||||
int floor2 = Mth.floor(this.getZ());
|
||||
- EntityType<? extends Zombie> type = this.getType();
|
||||
+ EntityType<? extends Zombie> type = me.earthme.lophine.config.modules.misc.OldFeatureConfig.oldZombieReinforcement ? EntityType.ZOMBIE : this.getType(); // Lophine - old zombie reinforcement
|
||||
Zombie zombie = type.create(level, EntitySpawnReason.REINFORCEMENT);
|
||||
if (zombie == null) {
|
||||
return true;
|
||||
@@ -0,0 +1,18 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
Date: Thu, 12 Jun 2025 04:44:24 +0800
|
||||
Subject: [PATCH] I18n support
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index ba0cdba050cd3bf9231e15dd9543d34f37d9dae5..33e7cb15ceafdb246bb9cc1a43d9968d3f28ca6b 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -172,6 +172,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess());
|
||||
// Paper end - initialize global and world-defaults configuration
|
||||
me.earthme.lophine.config.LophineConfig.loadConfigFiles(); //Luminol - load config file // Lophine - load config file
|
||||
+ me.earthme.lophine.utils.ServerI18nUtil.init(); // Lophine - I18n support
|
||||
if (false) this.server.spark.enableEarlyIfRequested(); // Paper - spark // Luminol - Force disable builtin spark
|
||||
// Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save
|
||||
if (this.convertOldUsers()) {
|
||||
File diff suppressed because it is too large
Load Diff
+3
-2
@@ -1,6 +1,6 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/lophine/config/LophineConfig.java
|
||||
@@ -1,0 +_,32 @@
|
||||
@@ -1,0 +_,33 @@
|
||||
+package me.earthme.lophine.config;
|
||||
+
|
||||
+import me.earthme.luminol.config.LuminolConfig;
|
||||
@@ -15,9 +15,10 @@
|
||||
+ private static final File luminolConfigFolder = new File("luminol_config");
|
||||
+ private static final File lophineConfigFolder = new File("lophine_config");
|
||||
+
|
||||
+ public static void initConfigs() {
|
||||
+ public static void initConfigs() throws IOException {
|
||||
+ configfiles.put("luminol", new LuminolConfig(luminolConfigFolder, "luminol", "me.earthme.luminol.config.modules"));
|
||||
+ configfiles.put("lophine", new LuminolConfig(lophineConfigFolder, "lophine", "me.earthme.lophine.config.modules"));
|
||||
+ preLoad();
|
||||
+ }
|
||||
+
|
||||
+ public static void preLoad() throws IOException {
|
||||
|
||||
+13
-3
@@ -1,6 +1,6 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/lophine/config/modules/misc/ContainerExpansionConfig.java
|
||||
@@ -1,0 +_,27 @@
|
||||
@@ -1,0 +_,37 @@
|
||||
+package me.earthme.lophine.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
@@ -10,14 +10,24 @@
|
||||
+public class ContainerExpansionConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "barrel_rows", comments =
|
||||
+ """
|
||||
+ range: 1~6\s""")
|
||||
+ range: 1~6""")
|
||||
+ public static int barrelRows = 3;
|
||||
+
|
||||
+ @ConfigInfo(baseName = "enderchest_rows", comments =
|
||||
+ """
|
||||
+ range: 1~6\s""")
|
||||
+ range: 1~6""")
|
||||
+ public static int enderchestRows = 3;
|
||||
+
|
||||
+ @ConfigInfo(baseName = "shulker_stackable_count", comments =
|
||||
+ """
|
||||
+ range: 1~64""")
|
||||
+ public static int shulkerCount = 1;
|
||||
+
|
||||
+ @ConfigInfo(baseName = "better_shulker_box", comments =
|
||||
+ """
|
||||
+ Enable sneak + use to open shulker box.""")
|
||||
+ public static boolean betterShulker = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/lophine/config/modules/misc/OldFeatureConfig.java
|
||||
@@ -1,0 +_,26 @@
|
||||
+package me.earthme.lophine.config.modules.misc;
|
||||
+
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
+
|
||||
+public class OldFeatureConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "old_nether_portal_collision")
|
||||
+ public static boolean oldNetherPortalCollision = false;
|
||||
+
|
||||
+ @ConfigInfo(baseName = "spawn_invulnerable_time")
|
||||
+ public static boolean spawnInvulnerableTime = false;
|
||||
+
|
||||
+ @ConfigInfo(baseName = "old_zombie_reinforcement")
|
||||
+ public static boolean oldZombieReinforcement = false;
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.MISC;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "old-feature";
|
||||
+ }
|
||||
+}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/lophine/config/modules/optimizations/LanguageConfig.java
|
||||
@@ -1,0 +_,22 @@
|
||||
+package me.earthme.lophine.config.modules.optimizations;
|
||||
+
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
+
|
||||
+public class LanguageConfig implements IConfigModule {
|
||||
+ @ConfigInfo(baseName = "lang", comments = """
|
||||
+ Please use the key from https://minecraft.wiki/w/Language
|
||||
+ Sample of format: en_us zh_cn zh_hk zh_tw""")
|
||||
+ public static String lang = "en_us";
|
||||
+
|
||||
+ @Override
|
||||
+ public EnumConfigCategory getCategory() {
|
||||
+ return EnumConfigCategory.OPTIMIZATIONS;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String getBaseName() {
|
||||
+ return "language";
|
||||
+ }
|
||||
+}
|
||||
+1
-2
@@ -1,12 +1,11 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/lophine/config/modules/removed/RemovedConfig.java
|
||||
@@ -1,0 +_,25 @@
|
||||
@@ -1,0 +_,24 @@
|
||||
+package me.earthme.lophine.config.modules.removed;
|
||||
+
|
||||
+import me.earthme.luminol.config.EnumConfigCategory;
|
||||
+import me.earthme.luminol.config.IConfigModule;
|
||||
+import me.earthme.luminol.config.flags.ConfigInfo;
|
||||
+import me.earthme.luminol.config.flags.DoNotLoad;
|
||||
+import me.earthme.luminol.config.flags.TransformedConfig;
|
||||
+
|
||||
+public class RemovedConfig implements IConfigModule {
|
||||
|
||||
+254
@@ -0,0 +1,254 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/lophine/utils/ServerI18nUtil.java
|
||||
@@ -1,0 +_,251 @@
|
||||
+package me.earthme.lophine.utils;
|
||||
+
|
||||
+import com.google.gson.JsonElement;
|
||||
+import com.google.gson.JsonObject;
|
||||
+import com.google.gson.JsonParser;
|
||||
+import com.google.gson.JsonSyntaxException;
|
||||
+import me.earthme.lophine.config.modules.optimizations.LanguageConfig;
|
||||
+import net.minecraft.locale.DeprecatedTranslationsInfo;
|
||||
+import net.minecraft.locale.Language;
|
||||
+import net.minecraft.network.chat.FormattedText;
|
||||
+import net.minecraft.network.chat.Style;
|
||||
+import net.minecraft.util.FormattedCharSequence;
|
||||
+import net.minecraft.util.StringDecomposer;
|
||||
+import org.apache.commons.io.FileUtils;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.io.IOException;
|
||||
+import java.io.InputStream;
|
||||
+import java.io.UnsupportedEncodingException;
|
||||
+import java.net.URI;
|
||||
+import java.net.http.HttpClient;
|
||||
+import java.net.http.HttpRequest;
|
||||
+import java.net.http.HttpResponse;
|
||||
+import java.nio.file.*;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+import java.util.Objects;
|
||||
+import java.util.Optional;
|
||||
+import java.util.concurrent.CompletableFuture;
|
||||
+import java.util.function.BiConsumer;
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
+/*
|
||||
+* authored by: Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
+* modified by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
|
||||
+* Some of diff form Leaves
|
||||
+*/
|
||||
+public class ServerI18nUtil {
|
||||
+
|
||||
+ private static final Logger logger = Logger.getLogger("LangLoader");
|
||||
+ private static final String VERSION = "1.21.5";
|
||||
+ private static final String BASE_PATH = "cache/lophine/" + VERSION + "/";
|
||||
+ private static final String manifestUrl = "https://launchermeta.mojang.com/mc/game/version_manifest.json";
|
||||
+ private static final String resourceBaseUrl = "https://resources.download.minecraft.net/";
|
||||
+
|
||||
+ private static String langPath;
|
||||
+ private static String assetsPath;
|
||||
+ private static String versionPath;
|
||||
+ private static String manifestPath;
|
||||
+ private static String langJsonPath;
|
||||
+
|
||||
+ public static void init() {
|
||||
+ if (Objects.equals(LanguageConfig.lang, "en_us")) {
|
||||
+ return;
|
||||
+ }
|
||||
+ langPath = BASE_PATH + "lang/" + LanguageConfig.lang + ".json";
|
||||
+ assetsPath = BASE_PATH + "assets.json";
|
||||
+ versionPath = BASE_PATH + VERSION + ".json";
|
||||
+ manifestPath = BASE_PATH + "manifest.json";
|
||||
+ langJsonPath = "minecraft/lang/" + LanguageConfig.lang + ".json";
|
||||
+ logger.info("Starting load language: " + LanguageConfig.lang);
|
||||
+ CompletableFuture.runAsync(() -> loadI18n(LanguageConfig.lang, 2));
|
||||
+ }
|
||||
+
|
||||
+ private static void loadI18n(String lang, int retryTime) {
|
||||
+ try {
|
||||
+ if (!Files.exists(Path.of(langPath))) {
|
||||
+ downloadLang(true);
|
||||
+ }
|
||||
+ Language.inject(createLangInstance());
|
||||
+ logger.info("Successfully loaded language: " + lang);
|
||||
+ } catch (Exception e) {
|
||||
+ logger.warning("Failed to load language file for " + lang + "\n" + e);
|
||||
+ if (retryTime > 0) {
|
||||
+ cleanCache();
|
||||
+ loadI18n(lang, retryTime - 1);
|
||||
+ } else {
|
||||
+ logger.severe("Failed to load for many times, use default lang \"en_us\" instead");
|
||||
+ cleanCache();
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void downloadLang(boolean fetchFromAssets) throws Exception {
|
||||
+ JsonObject json;
|
||||
+ if (!Files.exists(Path.of(assetsPath)) || (json = loadJson(assetsPath)) == null) {
|
||||
+ if (fetchFromAssets) {
|
||||
+ downloadAssets(true);
|
||||
+ downloadLang(false);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ JsonObject langEntry = json.getAsJsonObject("objects").getAsJsonObject(langJsonPath);
|
||||
+
|
||||
+ String hash = langEntry.get("hash").getAsString();
|
||||
+ if (hash == null || hash.length() < 2) {
|
||||
+ throw new IllegalArgumentException("Invalid hash value");
|
||||
+ }
|
||||
+
|
||||
+ String langUrl = resourceBaseUrl + hash.substring(0, 2) + "/" + hash;
|
||||
+ fetchAndSave(langUrl, langPath);
|
||||
+ }
|
||||
+
|
||||
+ private static void downloadAssets(boolean fetchFromVersion) throws Exception {
|
||||
+ JsonObject json;
|
||||
+ if (!Files.exists(Path.of(versionPath)) || (json = loadJson(versionPath)) == null) {
|
||||
+ if (fetchFromVersion) {
|
||||
+ downloadVersion(true);
|
||||
+ downloadAssets(false);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ JsonObject assetIndex = json.getAsJsonObject("assetIndex");
|
||||
+ String assetUrl = assetIndex.get("url").getAsString();
|
||||
+ fetchAndSave(assetUrl, assetsPath);
|
||||
+ }
|
||||
+
|
||||
+ private static void downloadVersion(boolean fetchFromManifest) throws Exception {
|
||||
+ JsonObject json;
|
||||
+ if (!Files.exists(Path.of(manifestPath)) || (json = loadJson(manifestPath)) == null) {
|
||||
+ if (fetchFromManifest) {
|
||||
+ fetchAndSave(manifestUrl, manifestPath);
|
||||
+ downloadVersion(false);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ String versionUrl = null;
|
||||
+ for (JsonElement element : json.getAsJsonArray("versions")) {
|
||||
+ String id = element.getAsJsonObject().get("id").getAsString();
|
||||
+ String url = element.getAsJsonObject().get("url").getAsString();
|
||||
+ if (VERSION.equals(id)) {
|
||||
+ versionUrl = url;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (versionUrl == null) {
|
||||
+ throw new RuntimeException("Could not find version URL");
|
||||
+ }
|
||||
+
|
||||
+ fetchAndSave(versionUrl, versionPath);
|
||||
+ }
|
||||
+
|
||||
+ private static String createHttpResponse(String path) throws IOException, InterruptedException {
|
||||
+ try {
|
||||
+ HttpResponse<String> response;
|
||||
+ try (HttpClient httpClient = HttpClient.newHttpClient()) {
|
||||
+
|
||||
+ HttpRequest request = HttpRequest.newBuilder()
|
||||
+ .uri(URI.create(path))
|
||||
+ .build();
|
||||
+
|
||||
+ response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
|
||||
+ }
|
||||
+
|
||||
+ int responseCode = response.statusCode();
|
||||
+ if (responseCode != 200) {
|
||||
+ logger.info("Unexpected response code: " + responseCode);
|
||||
+ logger.info("Response body: " + response.body());
|
||||
+ throw new UnsupportedEncodingException("Unexpected response code");
|
||||
+ } else {
|
||||
+ return response.body();
|
||||
+ }
|
||||
+ } catch (Exception e) {
|
||||
+ logger.warning("Error in getting info: " + e.getMessage());
|
||||
+ throw e;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static byte[] fetch(String urlString) throws IOException, InterruptedException {
|
||||
+ String ret = createHttpResponse(urlString);
|
||||
+ return ret.getBytes();
|
||||
+ }
|
||||
+
|
||||
+ private static void fetchAndSave(String url, String savePath) throws IOException, InterruptedException {
|
||||
+ byte[] data = fetch(url);
|
||||
+ Path outputPath = Path.of(savePath);
|
||||
+ Files.createDirectories(outputPath.getParent());
|
||||
+ Files.write(outputPath, data, StandardOpenOption.CREATE, StandardOpenOption.WRITE);
|
||||
+ }
|
||||
+
|
||||
+ private static void cleanCache() {
|
||||
+ try {
|
||||
+ FileUtils.deleteDirectory(Path.of(BASE_PATH).toFile());
|
||||
+ } catch (IOException e) {
|
||||
+ logger.severe("Cache cleanup failed: " + e);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static JsonObject loadJson(String path) {
|
||||
+ try {
|
||||
+ byte[] data = Files.readAllBytes(Paths.get(path));
|
||||
+ return JsonParser.parseString(new String(data)).getAsJsonObject();
|
||||
+ } catch (JsonSyntaxException e) {
|
||||
+ logger.warning("Corrupt json file: " + e);
|
||||
+ throw e;
|
||||
+ } catch (Exception e) {
|
||||
+ logger.warning("Failed to load local JSON: " + e);
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static Language createLangInstance() throws IOException {
|
||||
+ DeprecatedTranslationsInfo deprecatedTranslationsInfo = DeprecatedTranslationsInfo.loadFromDefaultResource();
|
||||
+ Map<String, String> map = new HashMap<>();
|
||||
+ parseTranslations(map::put);
|
||||
+ deprecatedTranslationsInfo.applyToMap(map);
|
||||
+ final Map<String, String> map1 = Map.copyOf(map);
|
||||
+ return new Language() {
|
||||
+ @Override
|
||||
+ public @NotNull String getOrDefault(@NotNull String key, @NotNull String defaultValue) {
|
||||
+ return map1.getOrDefault(key, defaultValue);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean has(@NotNull String id) {
|
||||
+ return map1.containsKey(id);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean isDefaultRightToLeft() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public @NotNull FormattedCharSequence getVisualOrder(@NotNull FormattedText text) {
|
||||
+ return sink -> text.visit(
|
||||
+ (style, content) -> StringDecomposer.iterateFormatted(content, style, sink) ? Optional.empty() : FormattedText.STOP_ITERATION,
|
||||
+ Style.EMPTY
|
||||
+ )
|
||||
+ .isPresent();
|
||||
+ }
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ private static void parseTranslations(BiConsumer<String, String> output) throws IOException {
|
||||
+ Path filePath = Path.of(langPath);
|
||||
+ try (InputStream fileStream = Files.newInputStream(filePath)) {
|
||||
+ Language.loadFromJson(fileStream, output);
|
||||
+ } catch (NoSuchFileException noSuchFileException) {
|
||||
+ logger.warning("Couldn't find language file: " + langPath);
|
||||
+ throw noSuchFileException;
|
||||
+ } catch (Exception e) {
|
||||
+ logger.warning("Failed to load language from filesystem " + filePath + "\n" + e);
|
||||
+ throw e;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/me/earthme/lophine/utils/ShulkerBoxesUtil.java
|
||||
@@ -1,0 +_,153 @@
|
||||
+package me.earthme.lophine.utils;
|
||||
+
|
||||
+import me.earthme.lophine.config.modules.misc.ContainerExpansionConfig;
|
||||
+import net.minecraft.core.NonNullList;
|
||||
+import net.minecraft.core.component.DataComponents;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import net.minecraft.stats.Stats;
|
||||
+import net.minecraft.world.InteractionHand;
|
||||
+import net.minecraft.world.entity.player.Player;
|
||||
+import net.minecraft.world.item.BlockItem;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import net.minecraft.world.item.component.CustomData;
|
||||
+import net.minecraft.world.item.component.ItemContainerContents;
|
||||
+import net.minecraft.world.level.block.ShulkerBoxBlock;
|
||||
+import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+
|
||||
+import java.util.Objects;
|
||||
+import java.util.Optional;
|
||||
+
|
||||
+import static net.minecraft.world.inventory.AbstractContainerMenu.dropOrPlaceInInventory;
|
||||
+
|
||||
+public class ShulkerBoxesUtil {
|
||||
+ // Stackable ShulkerBoxes part
|
||||
+ public static boolean shouldCheck() {
|
||||
+ return ContainerExpansionConfig.shulkerCount > 1 && ContainerExpansionConfig.shulkerCount <= 64;
|
||||
+ }
|
||||
+
|
||||
+ public static boolean checkShulkerBox(ItemStack itemStack) {
|
||||
+ return shouldCheck() && checkIsShulkerBox(itemStack);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean checkIsShulkerBox(ItemStack itemStack) {
|
||||
+ return itemStack.getItem() instanceof BlockItem b && b.getBlock() instanceof ShulkerBoxBlock;
|
||||
+ }
|
||||
+
|
||||
+ public static int getItemMaxCount(ItemStack itemStack) {
|
||||
+ if (checkShulkerBox(itemStack)) {
|
||||
+ return Math.clamp(ContainerExpansionConfig.shulkerCount, 1, 64);
|
||||
+ }
|
||||
+ return itemStack.getMaxStackSize();
|
||||
+ }
|
||||
+
|
||||
+ public static int getShulkerBoxesMaxCountUnsafe() {
|
||||
+ return Math.clamp(ContainerExpansionConfig.shulkerCount, 1, 64);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean emptyShulkerBoxCheck(@NotNull ItemStack stack) {
|
||||
+ return stack.getComponents().getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY).stream().findAny().isEmpty();
|
||||
+ }
|
||||
+
|
||||
+ public static boolean isStackable(ItemStack itemStack) {
|
||||
+ return getItemMaxCount(itemStack) > 1 && (!itemStack.isDamageableItem() || !itemStack.isDamaged());
|
||||
+ }
|
||||
+
|
||||
+ public static int getItemStackMaxCountReal(ItemStack stack) {
|
||||
+ CompoundTag nbt = Optional.ofNullable(stack.get(DataComponents.CUSTOM_DATA)).orElse(CustomData.EMPTY).copyTag();
|
||||
+ return nbt.getInt("Lophine.RealStackSize").orElse(stack.getMaxStackSize());
|
||||
+ }
|
||||
+
|
||||
+ public static ItemStack encodeMaxStackSize(ItemStack itemStack) {
|
||||
+ int realMaxStackSize = getItemStackMaxCountReal(itemStack);
|
||||
+ int modifiedMaxStackSize = getItemMaxCount(itemStack);
|
||||
+ if (itemStack.getMaxStackSize() != modifiedMaxStackSize) {
|
||||
+ itemStack.set(DataComponents.MAX_STACK_SIZE, modifiedMaxStackSize);
|
||||
+ CompoundTag nbt = itemStack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag();
|
||||
+ nbt.putInt("Lophine.RealStackSize", realMaxStackSize);
|
||||
+ itemStack.set(DataComponents.CUSTOM_DATA, CustomData.of(nbt));
|
||||
+ }
|
||||
+ return itemStack;
|
||||
+ }
|
||||
+
|
||||
+ public static ItemStack decodeMaxStackSize(ItemStack itemStack) {
|
||||
+ int realMaxStackSize = getItemStackMaxCountReal(itemStack);
|
||||
+ if (itemStack.getMaxStackSize() != realMaxStackSize) {
|
||||
+ itemStack.set(DataComponents.MAX_STACK_SIZE, realMaxStackSize);
|
||||
+ CompoundTag nbt = itemStack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag();
|
||||
+ nbt.remove("Lophine.RealStackSize");
|
||||
+ if (nbt.isEmpty()) {
|
||||
+ itemStack.remove(DataComponents.CUSTOM_DATA);
|
||||
+ } else {
|
||||
+ itemStack.set(DataComponents.CUSTOM_DATA, CustomData.of(nbt));
|
||||
+ }
|
||||
+ }
|
||||
+ return itemStack;
|
||||
+ }
|
||||
+
|
||||
+ // Better ShulkerBox part
|
||||
+ public static boolean checkIfCanOpen(ItemStack itemStack) {
|
||||
+ return checkIsShulkerBox(itemStack) && itemStack.getCount() == 1;
|
||||
+ }
|
||||
+
|
||||
+ public static void openShulkerBox(Player player, ItemStack itemInHand, InteractionHand hand) {
|
||||
+ ShulkerBoxBlockEntity shulkerBoxEntity = new ShulkerBoxBlockEntity(
|
||||
+ player.blockPosition(),
|
||||
+ ((BlockItem) itemInHand.getItem()).getBlock().defaultBlockState()
|
||||
+ );
|
||||
+ ItemContainerContents container = itemInHand.getOrDefault(
|
||||
+ DataComponents.CONTAINER,
|
||||
+ ItemContainerContents.EMPTY
|
||||
+ );
|
||||
+
|
||||
+ NonNullList<ItemStack> items = NonNullList.withSize(27, ItemStack.EMPTY);
|
||||
+ for (int i = 0; i < container.items.size(); i++) {
|
||||
+ items.set(i, container.items.get(i));
|
||||
+ }
|
||||
+
|
||||
+ shulkerBoxEntity.setItems(items);
|
||||
+
|
||||
+ shulkerBoxEntity.setLevel(player.level());
|
||||
+ shulkerBoxEntity.haveRealBlock = false;
|
||||
+ shulkerBoxEntity.createPlayer = player;
|
||||
+ player.shulkerHand = hand;
|
||||
+ player.shulkerOpen = true;
|
||||
+
|
||||
+ if (player.openMenu(shulkerBoxEntity).isPresent()) {
|
||||
+ player.awardStat(Stats.OPEN_SHULKER_BOX);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void shulkerBoxEntityCallBack(ShulkerBoxBlockEntity shulkerBoxEntity) {
|
||||
+ Player player = shulkerBoxEntity.createPlayer;
|
||||
+ if (player.shulkerOpen) {
|
||||
+ InteractionHand hand = player.shulkerHand;
|
||||
+ ItemStack currentItem = player.getItemInHand(hand);
|
||||
+
|
||||
+ currentItem.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(shulkerBoxEntity.getItems()));
|
||||
+
|
||||
+ player.setItemInHand(hand, currentItem);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void inventoryCallBack(boolean isMainHand, Player player) {
|
||||
+ if (player.shulkerOpen) {
|
||||
+ if (isMainHand == Objects.equals(player.shulkerHand, InteractionHand.MAIN_HAND)) {
|
||||
+ player.pendingClosingShulker = true;
|
||||
+ closeScreen(player);
|
||||
+ player.pendingClosingShulker = false;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static void closeScreen(Player player) {
|
||||
+ if (player instanceof ServerPlayer) {
|
||||
+ ItemStack stack = player.containerMenu.getCarried();
|
||||
+ if (!stack.isEmpty()) {
|
||||
+ dropOrPlaceInInventory(player, stack);
|
||||
+ }
|
||||
+ }
|
||||
+ player.closeContainer();
|
||||
+ }
|
||||
+}
|
||||
@@ -0,0 +1,3 @@
|
||||
Special thanks (Logo author):
|
||||
Helvetica Volubi <suisuroru@blue-millennium.fun>
|
||||
bdlvl <bdlvl@mc-mygo.top>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 523 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 779 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 552 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 890 KiB |
Reference in New Issue
Block a user