From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Wed, 7 Feb 2024 00:53:03 +0000 Subject: [PATCH] Add config for unsafe teleportation diff --git a/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..ea374875f529b30db17e8b8cb07b99a600b722dc --- /dev/null +++ b/src/main/java/me/earthme/luminol/config/modules/fixes/UnsafeTeleportationConfig.java @@ -0,0 +1,20 @@ +package me.earthme.luminol.config.modules.fixes; + +import me.earthme.luminol.config.ConfigInfo; +import me.earthme.luminol.config.EnumConfigCategory; +import me.earthme.luminol.config.IConfigModule; + +public class UnsafeTeleportationConfig implements IConfigModule { + @ConfigInfo(baseName = "enabled", comments = "Allow non player entities enter end portals if enabled.If you want to use sand duping,please turn on this") + public static boolean enabled = false; + + @Override + public EnumConfigCategory getCategory() { + return EnumConfigCategory.FIXES; + } + + @Override + public String getBaseName() { + return "allow_unsafe_teleportation"; + } +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java index 0e71fa29ebfa649bc23899046396a6b01c4bd131..6463a55477b61f8cb3d17159792e5d3f1a87f7b7 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -4065,6 +4065,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S protected boolean tryEndPortal() { io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async"); + if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(this instanceof Player)) return false; //Luminol - Unsafe teleportation BlockPos pos = this.portalBlock; ServerLevel world = this.portalWorld; this.portalBlock = null; diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java index afc9445941b984cc1122839e4a8a17cf27aa966e..0eb328e2b32179ebeefc90063441a1510e0058b8 100644 --- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java +++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java @@ -61,6 +61,13 @@ public class EndPortalBlock extends BaseEntityBlock { // return; // CraftBukkit - always fire event in case plugins wish to change it } + //Luminol start - Unsafe teleportation + if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)){ + entity.endPortalLogicAsync(); + return; + } + //Luminol end - Unsafe teleportation + // Paper start - move all of this logic into portal tick entity.portalWorld = ((ServerLevel)world); entity.portalBlock = pos.immutable();