From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Wed, 31 Jul 2024 11:59:44 +0800 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/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java index 5d6b1a63a2a213f8a4e81c5e574847007a82007b..77ff2a526a1d2b9307dfc696f9862bfda7407475 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -69,7 +69,7 @@ public class FallingBlockEntity extends Entity { public float fallDamagePerDistance; @Nullable public CompoundTag blockData; - public boolean forceTickAfterTeleportToDuplicate; + public boolean forceTickAfterTeleportToDuplicate = me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled; // Luminol - Unsafe teleportation protected static final EntityDataAccessor DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); public boolean autoExpire = true; // Paper - Expand FallingBlock API @@ -419,7 +419,7 @@ public class FallingBlockEntity extends Entity { boolean flag = (resourcekey1 == Level.END || resourcekey == Level.END) && resourcekey1 != resourcekey; Entity entity = super.changeDimension(teleportTarget); - this.forceTickAfterTeleportToDuplicate = entity != null && flag && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation; // Paper + this.forceTickAfterTeleportToDuplicate = entity != null && flag && (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation || me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled); // Paper // Luminol - Unsafe teleportation return entity; } } 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 58e15d7a5f7997a7aec9edaa5d211807b2b1ef6b..8a71276715c380b5b8510503399f3fde0084c145 100644 --- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java +++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java @@ -70,6 +70,11 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { world.getCraftServer().getPluginManager().callEvent(event); if (event.isCancelled()) return; // Paper - make cancellable // CraftBukkit end + // Luminol start - unsafe teleportation + if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)) { + entity.endPortalLogicAsync(pos); + } + // Luminol end if (!world.isClientSide && world.dimension() == Level.END && entity instanceof ServerPlayer) { ServerPlayer entityplayer = (ServerPlayer) entity;