From 2b12d671fa7d5545a87c01099bfad62718c82de9 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 21 Apr 2021 20:05:50 +0100 Subject: [PATCH] don't throw when loading TE with invalid keys --- ...don-t-throw-when-loading-invalid-TEs.patch | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Spigot-Server-Patches/don-t-throw-when-loading-invalid-TEs.patch diff --git a/Spigot-Server-Patches/don-t-throw-when-loading-invalid-TEs.patch b/Spigot-Server-Patches/don-t-throw-when-loading-invalid-TEs.patch new file mode 100644 index 0000000000..13776f1d01 --- /dev/null +++ b/Spigot-Server-Patches/don-t-throw-when-loading-invalid-TEs.patch @@ -0,0 +1,33 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Tue, 20 Apr 2021 01:15:04 +0100 +Subject: [PATCH] don't throw when loading invalid TEs + + +diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntity.java +@@ -0,0 +0,0 @@ package net.minecraft.world.level.block.entity; + + import javax.annotation.Nullable; + import net.minecraft.CrashReportSystemDetails; ++import net.minecraft.ResourceKeyInvalidException; + import net.minecraft.core.BlockPosition; + import net.minecraft.core.IRegistry; + import net.minecraft.nbt.NBTTagCompound; +@@ -0,0 +0,0 @@ public abstract class TileEntity implements net.minecraft.server.KeyedObject { / + public static TileEntity create(IBlockData iblockdata, NBTTagCompound nbttagcompound) { + String s = nbttagcompound.getString("id"); + +- return (TileEntity) IRegistry.BLOCK_ENTITY_TYPE.getOptional(new MinecraftKey(s)).map((tileentitytypes) -> { ++ // Paper ++ MinecraftKey minecraftKey = null; ++ try { ++ minecraftKey = new MinecraftKey(s); ++ } catch (ResourceKeyInvalidException ex) {} ++ // Paper end ++ return (TileEntity) IRegistry.BLOCK_ENTITY_TYPE.getOptional(minecraftKey).map((tileentitytypes) -> { + try { + return tileentitytypes.a(); + } catch (Throwable throwable) {