From b6b2ce6e7aa4e5cf0ce030c76d7da755a2dfa525 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Tue, 28 Jan 2025 21:50:07 +0800 Subject: [PATCH] Skip collision check if the block is not belong to current tick region(Replace piston fixes) Fixes: https://github.com/PaperMC/Folia/issues/311 https://github.com/PaperMC/Folia/issues/314 Related to : https://bugs.mojang.com/browse/MC-92875 --- ...d-pos-before-moving-entity-by-piston.patch | 18 ---------- ...heck-if-the-block-is-not-belong-to-c.patch | 35 +++++++++++++++++++ ...iju-Vanilla-end-portal-teleportation.patch | 8 ++--- ...PI-and-display-of-chunkhot-in-tpsbar.patch | 4 +-- ...Skip-entity-move-if-movement-is-zero.patch | 4 +-- ...eck-if-the-block-is-not-belong-to-c.patch} | 13 +++---- 6 files changed, 50 insertions(+), 32 deletions(-) delete mode 100644 luminol-server/minecraft-patches/features/0020-Set-old-pos-before-moving-entity-by-piston.patch create mode 100644 luminol-server/minecraft-patches/features/0020-Skip-collision-check-if-the-block-is-not-belong-to-c.patch rename luminol-server/paper-patches/features/{0020-Set-old-pos-before-moving-entity-by-piston.patch => 0020-Skip-collision-check-if-the-block-is-not-belong-to-c.patch} (63%) diff --git a/luminol-server/minecraft-patches/features/0020-Set-old-pos-before-moving-entity-by-piston.patch b/luminol-server/minecraft-patches/features/0020-Set-old-pos-before-moving-entity-by-piston.patch deleted file mode 100644 index 2427dd8..0000000 --- a/luminol-server/minecraft-patches/features/0020-Set-old-pos-before-moving-entity-by-piston.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sun, 12 Jan 2025 11:02:06 +0800 -Subject: [PATCH] Set old pos before moving entity by piston - - -diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index 3df23feff6937b6a2dbeff82e489a9a4ff644843..5d98069b61df57792e6b0cab809f2996b7d45c88 100644 ---- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -+++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -195,6 +195,7 @@ public class PistonMovingBlockEntity extends BlockEntity { - - private static void moveEntityByPiston(Direction noClipDirection, Entity entity, double progress, Direction direction) { - NOCLIP.set(noClipDirection); -+ if (me.earthme.luminol.config.modules.fixes.FoliaPistonIssueFixConfig.enabled) entity.setOldPosAndRot(); // Luminol- Try fixing folia issue #311 - entity.move(MoverType.PISTON, new Vec3(progress * direction.getStepX(), progress * direction.getStepY(), progress * direction.getStepZ())); - entity.applyEffectsFromBlocks(); - NOCLIP.set(null); diff --git a/luminol-server/minecraft-patches/features/0020-Skip-collision-check-if-the-block-is-not-belong-to-c.patch b/luminol-server/minecraft-patches/features/0020-Skip-collision-check-if-the-block-is-not-belong-to-c.patch new file mode 100644 index 0000000..ef4a482 --- /dev/null +++ b/luminol-server/minecraft-patches/features/0020-Skip-collision-check-if-the-block-is-not-belong-to-c.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MrHua269 +Date: Sun, 12 Jan 2025 11:02:06 +0800 +Subject: [PATCH] Skip collision check if the block is not belong to current + tick region + + +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index c87db2d497ca9ed2e8aad5f1bc52555ff0952b80..759db5813cc83daa6f0e397483fdb8bd90950a72 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -1675,6 +1675,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + return; + } + ++ if(!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.level, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaOldPositionIssueFixConfig.enabled) { ++ continue; ++ } ++ + BlockState blockState = this.level().getBlockState(blockPos); + if (!blockState.isAir() && set.add(blockPos.asLong())) { + try { +diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +index 3df23feff6937b6a2dbeff82e489a9a4ff644843..ab33af9ea9e7729abb7cc0073c468c2f8ecbcbb9 100644 +--- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java ++++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +@@ -2,6 +2,8 @@ package net.minecraft.world.level.block.piston; + + import java.util.Iterator; + import java.util.List; ++ ++import me.earthme.luminol.config.modules.fixes.FoliaOldPositionIssueFixConfig; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.core.HolderGetter; diff --git a/luminol-server/minecraft-patches/features/0024-Kaiiju-Vanilla-end-portal-teleportation.patch b/luminol-server/minecraft-patches/features/0024-Kaiiju-Vanilla-end-portal-teleportation.patch index 33edb84..5d3e791 100644 --- a/luminol-server/minecraft-patches/features/0024-Kaiiju-Vanilla-end-portal-teleportation.patch +++ b/luminol-server/minecraft-patches/features/0024-Kaiiju-Vanilla-end-portal-teleportation.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Kaiiju Vanilla end portal teleportation diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index c87db2d497ca9ed2e8aad5f1bc52555ff0952b80..88ca22ed6af613370ca8691ad9ebeb113e1637fe 100644 +index 759db5813cc83daa6f0e397483fdb8bd90950a72..975c6bdbfbf3ff5f721b98e561b3bb0f0ca943b9 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -110,6 +110,7 @@ import net.minecraft.world.level.block.Rotation; @@ -16,7 +16,7 @@ index c87db2d497ca9ed2e8aad5f1bc52555ff0952b80..88ca22ed6af613370ca8691ad9ebeb11 import net.minecraft.world.level.entity.EntityAccess; import net.minecraft.world.level.entity.EntityInLevelCallback; import net.minecraft.world.level.gameevent.DynamicGameEventListener; -@@ -4265,13 +4266,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4269,13 +4270,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess targetPos, 16, // load 16 blocks to be safe from block physics ca.spottedleaf.concurrentutil.util.Priority.HIGH, (chunks) -> { @@ -37,7 +37,7 @@ index c87db2d497ca9ed2e8aad5f1bc52555ff0952b80..88ca22ed6af613370ca8691ad9ebeb11 TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL ) -@@ -4467,6 +4473,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4471,6 +4477,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess if (!this.canPortalAsync(destination, takePassengers)) { return false; } @@ -48,7 +48,7 @@ index c87db2d497ca9ed2e8aad5f1bc52555ff0952b80..88ca22ed6af613370ca8691ad9ebeb11 Vec3 initialPosition = this.position(); ChunkPos initialPositionChunk = new ChunkPos( -@@ -4531,9 +4541,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4535,9 +4545,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess info.postTeleportTransition().onTransition(teleported); } diff --git a/luminol-server/minecraft-patches/features/0026-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch b/luminol-server/minecraft-patches/features/0026-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch index 47411ee..3fe9efe 100644 --- a/luminol-server/minecraft-patches/features/0026-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch +++ b/luminol-server/minecraft-patches/features/0026-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch @@ -159,10 +159,10 @@ index 23b342cc31c7e72ade0e1ccad86a9ccf34380f13..249cb7326c8e4012dcffdb6bbb7bfc1f + // KioCG end } diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 88ca22ed6af613370ca8691ad9ebeb113e1637fe..41313532c739027351d6fd848aa1c515aa4acd4a 100644 +index 975c6bdbfbf3ff5f721b98e561b3bb0f0ca943b9..71b751ec16ecbbcc18bcc228d0ebe7bfea0eb15d 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -5940,4 +5940,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5944,4 +5944,6 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return ((ServerLevel) this.level).isPositionEntityTicking(this.blockPosition()); } // Paper end - Expose entity id counter diff --git a/luminol-server/minecraft-patches/features/0033-Gale-Skip-entity-move-if-movement-is-zero.patch b/luminol-server/minecraft-patches/features/0033-Gale-Skip-entity-move-if-movement-is-zero.patch index 7559137..002bbe1 100644 --- a/luminol-server/minecraft-patches/features/0033-Gale-Skip-entity-move-if-movement-is-zero.patch +++ b/luminol-server/minecraft-patches/features/0033-Gale-Skip-entity-move-if-movement-is-zero.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Gale Skip entity move if movement is zero diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 41313532c739027351d6fd848aa1c515aa4acd4a..d58f2bfde617ab55a550cbf8eb0187c9663d38fc 100644 +index 71b751ec16ecbbcc18bcc228d0ebe7bfea0eb15d..1a011dccbf116410d6b268917965f89c206ea693 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1104,7 +1104,14 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -23,7 +23,7 @@ index 41313532c739027351d6fd848aa1c515aa4acd4a..d58f2bfde617ab55a550cbf8eb0187c9 final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity // Paper start - detailed watchdog information ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main"); -@@ -5031,6 +5038,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5035,6 +5042,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public final void setBoundingBox(AABB bb) { diff --git a/luminol-server/paper-patches/features/0020-Set-old-pos-before-moving-entity-by-piston.patch b/luminol-server/paper-patches/features/0020-Skip-collision-check-if-the-block-is-not-belong-to-c.patch similarity index 63% rename from luminol-server/paper-patches/features/0020-Set-old-pos-before-moving-entity-by-piston.patch rename to luminol-server/paper-patches/features/0020-Skip-collision-check-if-the-block-is-not-belong-to-c.patch index 8a99088..2e68834 100644 --- a/luminol-server/paper-patches/features/0020-Set-old-pos-before-moving-entity-by-piston.patch +++ b/luminol-server/paper-patches/features/0020-Skip-collision-check-if-the-block-is-not-belong-to-c.patch @@ -1,14 +1,15 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Sun, 12 Jan 2025 11:02:07 +0800 -Subject: [PATCH] Set old pos before moving entity by piston +Subject: [PATCH] Skip collision check if the block is not belong to current + tick region -diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPistonIssueFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPistonIssueFixConfig.java +diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaOldPositionIssueFixConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaOldPositionIssueFixConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..6edfb1d36a88d319151d28ba14873269736f84b6 +index 0000000000000000000000000000000000000000..7294792d934e7374dcf335135dda739702fdcc62 --- /dev/null -+++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaPistonIssueFixConfig.java ++++ b/src/main/java/me/earthme/luminol/config/modules/fixes/FoliaOldPositionIssueFixConfig.java @@ -0,0 +1,20 @@ +package me.earthme.luminol.config.modules.fixes; + @@ -16,7 +17,7 @@ index 0000000000000000000000000000000000000000..6edfb1d36a88d319151d28ba14873269 +import me.earthme.luminol.config.EnumConfigCategory; +import me.earthme.luminol.config.IConfigModule; + -+public class FoliaPistonIssueFixConfig implements IConfigModule { ++public class FoliaOldPositionIssueFixConfig implements IConfigModule { + @ConfigInfo(baseName = "enabled") + public static boolean enabled = false; + @@ -27,6 +28,6 @@ index 0000000000000000000000000000000000000000..6edfb1d36a88d319151d28ba14873269 + + @Override + public String getBaseName() { -+ return "folia.fix_piston_moving_issue"; ++ return "folia.fix_old_position_issue"; + } +}