From 7415dcf70e1ac557c0d0f6d0e7f39ac0fbe85110 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:05:34 -0500 Subject: [PATCH] Allow enabling sand duping (#10191) Because this exploit has been widely known for years and has not been fixed by Mojang, we decided that it was worth allowing people to toggle it on/off due to how easy it is to make it configurable. It should be noted that this decision does not promise all future exploits will be configurable. --- .../Fix-dangerous-end-portal-logic.patch | 10 +++--- patches/server/Fix-sand-duping.patch | 36 ------------------- patches/server/Paper-config-files.patch | 2 ++ 3 files changed, 8 insertions(+), 40 deletions(-) delete mode 100644 patches/server/Fix-sand-duping.patch diff --git a/patches/server/Fix-dangerous-end-portal-logic.patch b/patches/server/Fix-dangerous-end-portal-logic.patch index 8d1c3f46b0..25ce4925e5 100644 --- a/patches/server/Fix-dangerous-end-portal-logic.patch +++ b/patches/server/Fix-dangerous-end-portal-logic.patch @@ -55,7 +55,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } this.processPortalCooldown(); -+ this.tickEndPortal(); // Paper - make end portalling safe ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation) this.tickEndPortal(); // Paper - make end portalling safe } } @@ -74,12 +74,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - if (entity instanceof ServerPlayer) { - ((ServerPlayer) entity).changeDimension(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL); - return; -- } -- // CraftBukkit end -- entity.changeDimension(worldserver); + // Paper start - move all of this logic into portal tick + entity.portalWorld = ((ServerLevel)world); + entity.portalBlock = pos.immutable(); ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation) { ++ entity.tickEndPortal(); + } +- // CraftBukkit end +- entity.changeDimension(worldserver); + // Paper end - move all of this logic into portal tick } diff --git a/patches/server/Fix-sand-duping.patch b/patches/server/Fix-sand-duping.patch deleted file mode 100644 index c912504211..0000000000 --- a/patches/server/Fix-sand-duping.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Fri, 12 Jun 2020 13:33:19 -0700 -Subject: [PATCH] Fix sand duping - -If the falling block dies during teleportation (entity#move), then we need -to detect that by placing a check after the move. - -diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -+++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -0,0 +0,0 @@ public class FallingBlockEntity extends Entity { - - @Override - public void tick() { -+ // Paper start - fix sand duping -+ if (this.isRemoved()) { -+ return; -+ } -+ // Paper end - fix sand duping - if (this.blockState.isAir()) { - this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - } else { -@@ -0,0 +0,0 @@ public class FallingBlockEntity extends Entity { - } - - this.move(MoverType.SELF, this.getDeltaMovement()); -+ // Paper start - fix sand duping -+ if (this.isRemoved()) { -+ return; -+ } -+ // Paper end - fix sand duping - // Paper start - Configurable falling blocks height nerf - if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { - if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 3078a7bbfb..dde3415e5f 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -635,6 +635,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public UnsupportedSettings unsupportedSettings; + + public class UnsupportedSettings extends ConfigurationPart { ++ @Comment("This setting allows for exploits related to end portals, for example sand duping") ++ public boolean allowUnsafeEndPortalTeleportation = false; + @Comment("This setting controls if players should be able to break bedrock, end portals and other intended to be permanent blocks.") + public boolean allowPermanentBlockBreakExploits = false; + @Comment("This setting controls if player should be able to use TNT duplication, but this also allows duplicating carpet, rails and potentially other items")