diff --git a/gradle.properties b/gradle.properties index 3a72162..3a5fdc0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ group=me.earthme.lophine version=1.21.5-R0.1-SNAPSHOT mcVersion=1.21.5 -luminolRef=784ce10986c214df322a9289e8ddb0b700759596 +luminolRef=cd8a4e11dce2e85cdef873648e615ae7ca79fd99 org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/lophine-server/build.gradle.kts.patch b/lophine-server/build.gradle.kts.patch index 8648ddd..be98ca5 100644 --- a/lophine-server/build.gradle.kts.patch +++ b/lophine-server/build.gradle.kts.patch @@ -51,7 +51,7 @@ implementation("com.electronwill.night-config:toml:3.8.2") // Luminol - Night config // Abomination start implementation("com.github.luben:zstd-jni:1.5.4-1") -@@ -264,14 +_,14 @@ +@@ -265,14 +_,14 @@ val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim() attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", diff --git a/lophine-server/minecraft-patches/features/0004-Add-config-to-enable-tick-command.patch b/lophine-server/minecraft-patches/features/0004-Add-config-to-enable-tick-command.patch index 92d300c..a96ff0a 100644 --- a/lophine-server/minecraft-patches/features/0004-Add-config-to-enable-tick-command.patch +++ b/lophine-server/minecraft-patches/features/0004-Add-config-to-enable-tick-command.patch @@ -44,7 +44,7 @@ index 8e91ec81128bdbd5f78e1f04fe17bcbd6e5dc280..6b4a33189b4dcd4979fb421248f72530 world.setDayTime(world.levelData.getDayTime() + (long)tickCount); } diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java -index fa6b8d756195c1b430cc11214a901bd42eebc98d..1d79465c9b04c5cdfd299278786916cb10e49522 100644 +index 0357792de0ed8ec9058d1847c8b45c33ff365af6..0bb3752d361bda347646dab5dc83bcf6bd5e717f 100644 --- a/io/papermc/paper/threadedregions/TickRegionScheduler.java +++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java @@ -31,8 +31,8 @@ public final class TickRegionScheduler { @@ -58,7 +58,7 @@ index fa6b8d756195c1b430cc11214a901bd42eebc98d..1d79465c9b04c5cdfd299278786916cb // Folia start - watchdog public static final FoliaWatchdogThread WATCHDOG_THREAD = new FoliaWatchdogThread(); -@@ -375,8 +375,23 @@ public final class TickRegionScheduler { +@@ -394,8 +394,23 @@ public final class TickRegionScheduler { final long cpuStart = MEASURE_CPU_TIME ? THREAD_MX_BEAN.getCurrentThreadCpuTime() : 0L; final long tickStart = System.nanoTime(); @@ -84,7 +84,7 @@ index fa6b8d756195c1b430cc11214a901bd42eebc98d..1d79465c9b04c5cdfd299278786916cb if (!this.tryMarkTicking()) { if (!this.cancelled.get()) { -@@ -416,6 +431,11 @@ public final class TickRegionScheduler { +@@ -435,6 +450,11 @@ public final class TickRegionScheduler { try { // next start isn't updated until the end of this tick this.tickRegion(tickCount, tickStart, scheduledEnd); diff --git a/lophine-server/minecraft-patches/features/0010-Better-ShulkerBox.patch b/lophine-server/minecraft-patches/features/0010-Better-ShulkerBox.patch index 9c648b7..3412226 100644 --- a/lophine-server/minecraft-patches/features/0010-Better-ShulkerBox.patch +++ b/lophine-server/minecraft-patches/features/0010-Better-ShulkerBox.patch @@ -6,28 +6,27 @@ 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 +index 1764875b9024569671bf2be537afb8b492f79102..b395482c6b5609c3b878f4e1ed17861b3b3fe9f7 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; ++ me.earthme.lophine.utils.ShulkerBoxesUtil.clearMap(this); // Lophine - better shulker box } @Override diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java -index 9fbd605df26d388c01d2ed9ca6a6138651e7f9a7..e8141cb25d6b9a433890e2cded188c2eb5bcf755 100644 +index 9fbd605df26d388c01d2ed9ca6a6138651e7f9a7..075526ce459cee3b157d5338ec079ad1515c6640 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 { +@@ -470,6 +470,15 @@ 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) { ++ if (me.earthme.lophine.config.modules.misc.ContainerExpansionConfig.betterShulker) { + boolean isMainHand = index == selected; + boolean isOffHand = index == 40; + if (isMainHand || isOffHand) { @@ -39,50 +38,25 @@ index 9fbd605df26d388c01d2ed9ca6a6138651e7f9a7..e8141cb25d6b9a433890e2cded188c2e 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 +index 27e335e01d8f09f05a4fea5f15407dbe3a4555cb..b1389af2c04527fbc8f62577fad4bc679506a0e9 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 { +@@ -595,11 +595,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; ++ me.earthme.lophine.utils.ShulkerBoxesUtil.clearMap(this); // Lophine - better shulker box } // Paper end - special close for unloaded inventory public void closeContainer() { this.containerMenu = this.inventoryMenu; -+ this.shulkerOpen = false; ++ me.earthme.lophine.utils.ShulkerBoxesUtil.clearMap(this); // Lophine - better shulker box } 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 +index 903025c659e6a9423224fe65973696405c69ec6a..e850b533d89f95d01a3b9d265a70845793e37bd7 100644 --- a/net/minecraft/world/inventory/ShulkerBoxMenu.java +++ b/net/minecraft/world/inventory/ShulkerBoxMenu.java @@ -53,7 +53,7 @@ public class ShulkerBoxMenu extends AbstractContainerMenu { @@ -90,7 +64,7 @@ index 903025c659e6a9423224fe65973696405c69ec6a..545fc46416932db922dc1476b983ac8b @Override public boolean stillValid(Player player) { - if (!this.checkReachable) return true; // CraftBukkit -+ if (!this.checkReachable || player.shulkerOpen) return true; // CraftBukkit // Lophine - better shulker box ++ if (!this.checkReachable || me.earthme.lophine.utils.ShulkerBoxesUtil.checkIfValid(player)) return true; // CraftBukkit // Lophine - better shulker box return this.container.stillValid(player); } @@ -126,7 +100,7 @@ index ecf794f94177fc7b6df483516d920719fbc6fa43..4fda59a4c17009a0009f3d3c13258f4f 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 +index 87ebdb6deb66662a38b3eec0dae27eaf859ecabb..7e97f0e200e7fd83aa9504a5fced83d2d00e0319 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 @@ -135,8 +109,8 @@ index 87ebdb6deb66662a38b3eec0dae27eaf859ecabb..e22114dbfbfd1619260a45929397c11c private float progressOld; + // Lophine start - better shulker box + public boolean haveRealBlock = true; -+ public Player createPlayer; -+ public ItemStack item; ++ public net.minecraft.world.InteractionHand shulkerHand; ++ public ItemStack finalItem; + // Lophine end - better shulker box @Nullable private final DyeColor color; @@ -148,7 +122,7 @@ index 87ebdb6deb66662a38b3eec0dae27eaf859ecabb..e22114dbfbfd1619260a45929397c11c + // 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) { ++ if (me.earthme.lophine.config.modules.misc.ContainerExpansionConfig.betterShulker && !haveRealBlock) { + me.earthme.lophine.utils.ShulkerBoxesUtil.shulkerBoxEntityCallBack(this); + } + } diff --git a/lophine-server/paper-patches/files/src/main/java/me/earthme/lophine/utils/ShulkerBoxesUtil.java.patch b/lophine-server/paper-patches/files/src/main/java/me/earthme/lophine/utils/ShulkerBoxesUtil.java.patch index 2c97e01..93fb3e1 100644 --- a/lophine-server/paper-patches/files/src/main/java/me/earthme/lophine/utils/ShulkerBoxesUtil.java.patch +++ b/lophine-server/paper-patches/files/src/main/java/me/earthme/lophine/utils/ShulkerBoxesUtil.java.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/src/main/java/me/earthme/lophine/utils/ShulkerBoxesUtil.java -@@ -1,0 +_,153 @@ +@@ -1,0 +_,181 @@ +package me.earthme.lophine.utils; + +import me.earthme.lophine.config.modules.misc.ContainerExpansionConfig; @@ -19,12 +19,15 @@ +import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity; +import org.jetbrains.annotations.NotNull; + ++import java.util.HashMap; +import java.util.Objects; +import java.util.Optional; + -+import static net.minecraft.world.inventory.AbstractContainerMenu.dropOrPlaceInInventory; -+ +public class ShulkerBoxesUtil { ++ // Better ShulkerBoxes used ++ public static HashMap shulkerMap = new HashMap<>(); ++ public static HashMap playerMap = new HashMap<>(); ++ + // Stackable ShulkerBoxes part + public static boolean shouldCheck() { + return ContainerExpansionConfig.shulkerCount > 1 && ContainerExpansionConfig.shulkerCount <= 64; @@ -94,7 +97,12 @@ + return checkIsShulkerBox(itemStack) && itemStack.getCount() == 1; + } + -+ public static void openShulkerBox(Player player, ItemStack itemInHand, InteractionHand hand) { ++ public static boolean checkIfValid(Player player) { ++ return shulkerMap.get(player) != null; ++ } ++ ++ public static void openShulkerBox(Player player, ItemStack item, InteractionHand hand) { ++ ItemStack itemInHand = item.copy(); + ShulkerBoxBlockEntity shulkerBoxEntity = new ShulkerBoxBlockEntity( + player.blockPosition(), + ((BlockItem) itemInHand.getItem()).getBlock().defaultBlockState() @@ -111,11 +119,13 @@ + + shulkerBoxEntity.setItems(items); + -+ shulkerBoxEntity.setLevel(player.level()); + shulkerBoxEntity.haveRealBlock = false; -+ shulkerBoxEntity.createPlayer = player; -+ player.shulkerHand = hand; -+ player.shulkerOpen = true; ++ shulkerBoxEntity.shulkerHand = hand; ++ shulkerBoxEntity.finalItem = itemInHand; ++ shulkerBoxEntity.setLevel(player.level()); ++ ++ shulkerMap.put(player, shulkerBoxEntity); ++ playerMap.put(shulkerBoxEntity, player); + + if (player.openMenu(shulkerBoxEntity).isPresent()) { + player.awardStat(Stats.OPEN_SHULKER_BOX); @@ -123,34 +133,52 @@ + } + + public static void shulkerBoxEntityCallBack(ShulkerBoxBlockEntity shulkerBoxEntity) { -+ Player player = shulkerBoxEntity.createPlayer; -+ if (player.shulkerOpen) { -+ InteractionHand hand = player.shulkerHand; ++ Player player = playerMap.get(shulkerBoxEntity); ++ if (player != null) { ++ InteractionHand hand = shulkerBoxEntity.shulkerHand; + ItemStack currentItem = player.getItemInHand(hand); ++ ItemStack copy = currentItem.copy(); + -+ currentItem.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(shulkerBoxEntity.getItems())); ++ copy.set(DataComponents.CONTAINER, ItemContainerContents.fromItems(shulkerBoxEntity.getItems())); + -+ player.setItemInHand(hand, currentItem); ++ player.setItemInHand(hand, copy); ++ ++ shulkerBoxEntity.finalItem = copy; + } + } + + 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; -+ } ++ ShulkerBoxBlockEntity entity = shulkerMap.get(player); ++ if (entity != null && isMainHand == Objects.equals(entity.shulkerHand, InteractionHand.MAIN_HAND)) { ++ closeScreen(entity, player); + } + } + -+ public static void closeScreen(Player player) { -+ if (player instanceof ServerPlayer) { -+ ItemStack stack = player.containerMenu.getCarried(); ++ public static void closeScreen(ShulkerBoxBlockEntity entity, Player player) { ++ if (player instanceof ServerPlayer serverPlayer) { ++ ItemStack stack1 = entity.finalItem; ++ ItemStack stack2 = player.containerMenu.getCarried(); ++ ItemStack stack = stack2.isEmpty() ? stack1 : stack2; + if (!stack.isEmpty()) { -+ dropOrPlaceInInventory(player, stack); ++ if (!player.isAlive() || serverPlayer.hasDisconnected()) { ++ player.drop(stack, false); ++ } else { ++ player.getInventory().placeItemBackInInventory(stack); ++ } + } + } + player.closeContainer(); + } ++ ++ public static void clearMap(Player p) { ++ ShulkerBoxBlockEntity e = shulkerMap.get(p); ++ if (e != null) playerMap.remove(e); ++ shulkerMap.remove(p); ++ } ++ ++ public static void clearMap(ShulkerBoxBlockEntity e) { ++ Player p = playerMap.get(e); ++ if (p != null) shulkerMap.remove(p); ++ playerMap.remove(e); ++ } +}