From 940bbc4e91656c87bcb0ab0ddf2435ef7004dea9 Mon Sep 17 00:00:00 2001 From: tterrag Date: Thu, 10 Oct 2019 16:02:09 -0400 Subject: [PATCH] Better sanity checks in ModelDataManager --- .../net/minecraftforge/client/model/ModelDataManager.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraftforge/client/model/ModelDataManager.java b/src/main/java/net/minecraftforge/client/model/ModelDataManager.java index 780de4a68..b5dca13cf 100644 --- a/src/main/java/net/minecraftforge/client/model/ModelDataManager.java +++ b/src/main/java/net/minecraftforge/client/model/ModelDataManager.java @@ -53,6 +53,8 @@ public class ModelDataManager private static void cleanCaches(World world) { + Preconditions.checkNotNull(world, "World must not be null"); + Preconditions.checkArgument(world == Minecraft.getInstance().world, "Cannot use model data for a world other than the current client world"); if (world != currentWorld.get()) { currentWorld = new WeakReference<>(world); @@ -63,9 +65,8 @@ public class ModelDataManager public static void requestModelDataRefresh(TileEntity te) { + Preconditions.checkNotNull(te, "Tile entity must not be null"); World world = te.getWorld(); - Preconditions.checkNotNull(world, "Tile entity world must not be null"); - Preconditions.checkArgument(world == Minecraft.getInstance().world, "Cannot request a model data refresh for a world other than the current client world"); cleanCaches(world); needModelDataRefresh.computeIfAbsent(new ChunkPos(te.getPos()), $ -> Collections.synchronizedSet(new HashSet<>())) @@ -108,7 +109,7 @@ public class ModelDataManager public static Map getModelData(World world, ChunkPos pos) { - Preconditions.checkArgument(world.isRemote, "Asked ModelDataManager from server world!"); + Preconditions.checkArgument(world.isRemote, "Cannot request model data for server world"); refreshModelData(world, pos); return modelDataCache.getOrDefault(pos, Collections.emptyMap()); }