84 lines
4.2 KiB
Diff
84 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: M2ke4U <79621885+MrHua269@users.noreply.github.com>
|
|
Date: Sun, 24 Dec 2023 08:12:09 +0800
|
|
Subject: [PATCH] Add config for unsafe teleportation
|
|
|
|
|
|
diff --git a/src/main/java/me/earthme/luminol/LuminolConfig.java b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
index 1f9ff0fc33fa36c90fc4cbbd21b7b790de581632..36ca0b94d29d81e5f1f2aff4a38ead0b363dd1c7 100644
|
|
--- a/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
+++ b/src/main/java/me/earthme/luminol/LuminolConfig.java
|
|
@@ -14,6 +14,8 @@ public class LuminolConfig {
|
|
public static String serverModName = "Luminol";
|
|
public static boolean fakeVanillaModeEnabled = false;
|
|
|
|
+ public static boolean safeTeleportation = true;
|
|
+
|
|
public static void init() throws IOException {
|
|
PARENT_FOLDER.mkdir();
|
|
|
|
@@ -31,6 +33,8 @@ public class LuminolConfig {
|
|
public static void initValues(){
|
|
serverModName = get("misc.server_mod_name",serverModName,"The servermod name will be sent to players,and you can see it in F3 or motd responses");
|
|
fakeVanillaModeEnabled = get("misc.enable_fake_vanilla_mode",fakeVanillaModeEnabled,"Enable this to make the ping response of your server like a vanilla server");
|
|
+
|
|
+ safeTeleportation = get("fixes.enable_safe_teleportation",safeTeleportation,"If this enabled,the end portals will not teleport removed entities.");
|
|
}
|
|
|
|
public static <T> T get(String key,T def){
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
index 0a060023da8c1ca1e4a0646e94170c8f489f48b1..2461ac52e007fe20fe36b607795000cddcb058e6 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
@@ -24,6 +24,8 @@ import java.util.function.BiConsumer;
|
|
import java.util.function.Predicate;
|
|
import java.util.stream.Stream;
|
|
import javax.annotation.Nullable;
|
|
+
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
import net.minecraft.BlockUtil;
|
|
import net.minecraft.CrashReport;
|
|
import net.minecraft.CrashReportCategory;
|
|
@@ -4055,6 +4057,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 (!LuminolConfig.safeTeleportation && !(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 c82ebcac07033d887af499f81520982fbe5ed4f1..f2063a38f7d0aaef58a02d5ea29f1c3975347ede 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java
|
|
@@ -8,6 +8,7 @@ import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraft.util.RandomSource;
|
|
import net.minecraft.world.entity.Entity;
|
|
+import net.minecraft.world.entity.player.Player;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.level.BlockGetter;
|
|
import net.minecraft.world.level.Level;
|
|
@@ -25,6 +26,7 @@ import net.minecraft.world.phys.shapes.VoxelShape;
|
|
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
|
// CraftBukkit end
|
|
+import me.earthme.luminol.LuminolConfig;
|
|
|
|
public class EndPortalBlock extends BaseEntityBlock {
|
|
|
|
@@ -61,6 +63,13 @@ public class EndPortalBlock extends BaseEntityBlock {
|
|
// return; // CraftBukkit - always fire event in case plugins wish to change it
|
|
}
|
|
|
|
+ //Luminol start - Unsafe teleportation
|
|
+ if (!LuminolConfig.safeTeleportation && !(entity instanceof 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();
|