84 lines
4.2 KiB
Diff
84 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: MrHua269 <novau233@163.com>
|
|
Date: Sat, 27 Jan 2024 07:40:23 +0000
|
|
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 cc4eb106b3ff1953de11f1faa7c04f3f9982fca2..1cc5acb21363aae7020a0ebf23c00caeab5074b7 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 a0c1db8cfebaa0344012cc0af18d6231cdcdcbb8..96cc3cb8448b58f9ab11558821251996e7560079 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();
|