From 7f2f07fbdcf276c7926f1e34a375485abdbe1d42 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Mon, 3 Mar 2025 19:08:39 +0300 Subject: [PATCH] fix chunk problems --- .../0038-Add-EntityLoadsProjectileEvent.patch | 73 ------------------- .../0039-Add-EntityStartUsingItemEvent.patch | 28 ------- .../org/bxteam/divinemc/DivineConfig.java | 23 ++++-- 3 files changed, 15 insertions(+), 109 deletions(-) delete mode 100644 divinemc-server/minecraft-patches/features/0038-Add-EntityLoadsProjectileEvent.patch delete mode 100644 divinemc-server/minecraft-patches/features/0039-Add-EntityStartUsingItemEvent.patch diff --git a/divinemc-server/minecraft-patches/features/0038-Add-EntityLoadsProjectileEvent.patch b/divinemc-server/minecraft-patches/features/0038-Add-EntityLoadsProjectileEvent.patch deleted file mode 100644 index e2e4744..0000000 --- a/divinemc-server/minecraft-patches/features/0038-Add-EntityLoadsProjectileEvent.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> -Date: Mon, 3 Mar 2025 01:27:13 +0300 -Subject: [PATCH] Add EntityLoadsProjectileEvent - - -diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index e44c871e86711b343cf8016241e9c8a997c85fe2..03e8147e8315da36914cbbe477a556b72c97fd26 100644 ---- a/net/minecraft/world/entity/LivingEntity.java -+++ b/net/minecraft/world/entity/LivingEntity.java -@@ -4498,6 +4498,22 @@ public abstract class LivingEntity extends Entity implements Attackable { - return ItemStack.EMPTY; - } - -+ // DivineMC start - Add EntityLoadsProjectileEvent -+ public ItemStack getProjectile(ItemStack weapon, ItemStack projectile, Predicate projectileValidator) { -+ var event = new org.bxteam.divinemc.event.entity.EntityLoadsProjectileEvent( -+ getBukkitLivingEntity(), -+ weapon.asBukkitMirror(), -+ projectile.asBukkitMirror(), -+ bukkitItem -> projectileValidator.test(CraftItemStack.asNMSCopy(bukkitItem)) -+ ); -+ event.callEvent(); -+ var item = event.getProjectile(); -+ if (item.isEmpty()) return ItemStack.EMPTY; -+ -+ return item instanceof CraftItemStack craftItem && craftItem.handle != null ? craftItem.handle : CraftItemStack.asNMSCopy(item); -+ } -+ // DivineMC end - Add EntityLoadsProjectileEvent -+ - public static byte entityEventForEquipmentBreak(EquipmentSlot slot) { - return switch (slot) { - case MAINHAND -> 47; -diff --git a/net/minecraft/world/entity/monster/Monster.java b/net/minecraft/world/entity/monster/Monster.java -index c1ebb74b0d4a8e2eb8880ccaf20f0f9bc1940094..8d08fca5d0e234dfc10abb8538483d89789ac617 100644 ---- a/net/minecraft/world/entity/monster/Monster.java -+++ b/net/minecraft/world/entity/monster/Monster.java -@@ -147,7 +147,7 @@ public abstract class Monster extends PathfinderMob implements Enemy { - if (shootable.getItem() instanceof ProjectileWeaponItem) { - Predicate supportedHeldProjectiles = ((ProjectileWeaponItem)shootable.getItem()).getSupportedHeldProjectiles(); - ItemStack heldProjectile = ProjectileWeaponItem.getHeldProjectile(this, supportedHeldProjectiles); -- return heldProjectile.isEmpty() ? new ItemStack(Items.ARROW) : heldProjectile; -+ return getProjectile(shootable, heldProjectile.isEmpty() ? new ItemStack(Items.ARROW) : heldProjectile, supportedHeldProjectiles); // DivineMC - Add EntityLoadsProjectileEvent - } else { - return ItemStack.EMPTY; - } -diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 3572874d755bd0ceff8811634adf99b8c9fabfb1..27eae556fb3f83a729a7f7859347bedd7cfe7257 100644 ---- a/net/minecraft/world/entity/player/Player.java -+++ b/net/minecraft/world/entity/player/Player.java -@@ -2311,19 +2311,19 @@ public abstract class Player extends LivingEntity { - Predicate supportedHeldProjectiles = ((ProjectileWeaponItem)shootable.getItem()).getSupportedHeldProjectiles().and(item -> this.tryReadyArrow(shootable, item, anyEventCancelled)); // Paper - PlayerReadyArrowEvent - ItemStack heldProjectile = ProjectileWeaponItem.getHeldProjectile(this, supportedHeldProjectiles); - if (!heldProjectile.isEmpty()) { -- return heldProjectile; -+ return getProjectile(shootable, heldProjectile, supportedHeldProjectiles); // DivineMC - Add EntityLoadsProjectileEvent - } else { - supportedHeldProjectiles = ((ProjectileWeaponItem)shootable.getItem()).getAllSupportedProjectiles().and(item -> this.tryReadyArrow(shootable, item, anyEventCancelled)); // Paper - PlayerReadyArrowEvent - - for (int i = 0; i < this.inventory.getContainerSize(); i++) { - ItemStack item = this.inventory.getItem(i); - if (supportedHeldProjectiles.test(item)) { -- return item; -+ return getProjectile(shootable, item, supportedHeldProjectiles); // DivineMC - Add EntityLoadsProjectileEvent - } - } - - if (anyEventCancelled.booleanValue() && !this.abilities.instabuild && this instanceof final ServerPlayer player) this.resyncUsingItem(player); // Paper - resync if no item matched the Predicate -- return this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; -+ return getProjectile(shootable, this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY, supportedHeldProjectiles); // DivineMC - Add EntityLoadsProjectileEvent - } - } - } diff --git a/divinemc-server/minecraft-patches/features/0039-Add-EntityStartUsingItemEvent.patch b/divinemc-server/minecraft-patches/features/0039-Add-EntityStartUsingItemEvent.patch deleted file mode 100644 index 8c46cb8..0000000 --- a/divinemc-server/minecraft-patches/features/0039-Add-EntityStartUsingItemEvent.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> -Date: Mon, 3 Mar 2025 01:28:34 +0300 -Subject: [PATCH] Add EntityStartUsingItemEvent - - -diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 03e8147e8315da36914cbbe477a556b72c97fd26..7d6be5ad0c1209429860f2c1edf996d120ed6536 100644 ---- a/net/minecraft/world/entity/LivingEntity.java -+++ b/net/minecraft/world/entity/LivingEntity.java -@@ -4049,8 +4049,16 @@ public abstract class LivingEntity extends Entity implements Attackable { - ItemStack itemInHand = this.getItemInHand(hand); - if (!itemInHand.isEmpty() && !this.isUsingItem() || forceUpdate) { // Paper - Prevent consuming the wrong itemstack - this.useItem = itemInHand; -+ // DivineMC start - Add EntityStartUsingItemEvent -+ var event = new org.bxteam.divinemc.event.entity.EntityStartUsingItemEvent(getBukkitLivingEntity(), itemInHand.asBukkitMirror(), itemInHand.getUseDuration(this)); -+ if (!event.callEvent()) { -+ stopUsingItem(); -+ return; -+ } -+ int useDuration = event.getUseDuration(); -+ // DivineMC end - Add EntityStartUsingItemEvent - // Paper start - lag compensate eating -- this.useItemRemaining = this.totalEatTimeTicks = itemInHand.getUseDuration(this); -+ this.useItemRemaining = this.totalEatTimeTicks = useDuration; // DivineMC - Add EntityStartUsingItemEvent - this.eatStartTime = System.nanoTime(); - // Paper end - lag compensate eating - if (!this.level().isClientSide) { diff --git a/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java b/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java index caad4e7..b17af25 100644 --- a/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java +++ b/divinemc-server/src/main/java/org/bxteam/divinemc/DivineConfig.java @@ -19,7 +19,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.List; -@SuppressWarnings("unused") +@SuppressWarnings({"unused", "SameParameterValue"}) public class DivineConfig { private static final String HEADER = """ This is the main configuration file for DivineMC. @@ -28,7 +28,7 @@ public class DivineConfig { Discord: https://discord.gg/p7cxhw7E2M Docs: https://bxteam.org/docs/divinemc - New builds: https://github.com/BX-Team/DivineMC/releases/latest"""; + Downloads: https://github.com/BX-Team/DivineMC/releases"""; public static final Logger LOGGER = LogManager.getLogger(DivineConfig.class.getSimpleName()); public static final int CONFIG_VERSION = 5; @@ -157,6 +157,11 @@ public class DivineConfig { private static void parallelWorldTicking() { parallelThreadCount = getInt("settings.parallel-world-ticking.thread-count", parallelThreadCount); logContainerCreationStacktraces = getBoolean("settings.parallel-world-ticking.log-container-creation-stacktraces", logContainerCreationStacktraces); + + setComment("settings.parallel-world-ticking", + "Parallel World Ticking executes each world’s tick in a separate thread while ensuring that all worlds complete their tick before the next cycle begins.", + "", + "Read more info about this feature at https://bxteam.org/docs/divinemc/features/parallel-world-ticking"); } public static boolean nativeAccelerationEnabled = true; @@ -182,7 +187,7 @@ public class DivineConfig { "Value must be between 1-9, and -1 to disable override"); if (isaTargetLevelOverride < -1 || isaTargetLevelOverride > 9) { - LOGGER.warn("Invalid ISA target level override: " + isaTargetLevelOverride + ", resetting to -1"); + LOGGER.warn("Invalid ISA target level override: {}, resetting to -1", isaTargetLevelOverride); isaTargetLevelOverride = -1; } @@ -196,7 +201,7 @@ public class DivineConfig { threadPoolPriority = getInt("settings.chunk-generation.thread-pool-priority", threadPoolPriority, "Sets the priority of the thread pool used for chunk generation"); - enableSecureSeed = getBoolean("settings.misc.enable-secure-seed", enableSecureSeed, + enableSecureSeed = getBoolean("settings.chunk-generation.enable-secure-seed", enableSecureSeed, "This feature is based on Secure Seed mod by Earthcomputer.", "", "Terrain and biome generation remains the same, but all the ores and structures are generated with 1024-bit seed, instead of the usual 64-bit seed.", @@ -235,7 +240,9 @@ public class DivineConfig { public static int regionizedChunkTickingExecutorThreadPriority = Thread.NORM_PRIORITY; private static void regionizedChunkTicking() { enableRegionizedChunkTicking = getBoolean("settings.regionized-chunk-ticking.enable", enableRegionizedChunkTicking, - "Enables regionized chunk ticking. This feature is similar to Folia"); + "Enables regionized chunk ticking, similar to like Folia works.", + "", + "Read more info about this feature at https://bxteam.org/docs/divinemc/features/regionized-chunk-ticking"); regionizedChunkTickingExecutorThreadCount = getInt("settings.regionized-chunk-ticking.executor-thread-count", regionizedChunkTickingExecutorThreadCount, "The amount of threads to allocate to regionized chunk ticking."); @@ -243,7 +250,7 @@ public class DivineConfig { "Configures the thread priority of the executor"); if (regionizedChunkTickingExecutorThreadCount < 1 || regionizedChunkTickingExecutorThreadCount > 10) { - LOGGER.warn("Invalid regionized chunk ticking thread count: " + regionizedChunkTickingExecutorThreadCount + ", resetting to default (5)"); + LOGGER.warn("Invalid regionized chunk ticking thread count: {}, resetting to default (5)", regionizedChunkTickingExecutorThreadCount); regionizedChunkTickingExecutorThreadCount = 5; } } @@ -362,7 +369,7 @@ public class DivineConfig { if (!asyncPathfinding) { asyncPathfindingMaxThreads = 0; } else { - LOGGER.info("Using " + asyncPathfindingMaxThreads + " threads for Async Pathfinding"); + LOGGER.info("Using {} threads for Async Pathfinding", asyncPathfindingMaxThreads); } if (asyncPathfindingQueueSize <= 0) asyncPathfindingQueueSize = asyncPathfindingMaxThreads * 256; @@ -400,7 +407,7 @@ public class DivineConfig { if (!multithreadedEnabled) { asyncEntityTrackerMaxThreads = 0; } else { - LOGGER.info("Using " + asyncEntityTrackerMaxThreads + " threads for Async Entity Tracker"); + LOGGER.info("Using {} threads for Async Entity Tracker", asyncEntityTrackerMaxThreads); } if (asyncEntityTrackerQueueSize <= 0) asyncEntityTrackerQueueSize = asyncEntityTrackerMaxThreads * 384;