From 7070bd03407de2d35c33cbc007f12e6db3cf2ec4 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Thu, 10 Oct 2019 13:23:27 -0500 Subject: [PATCH] Make customClientFactory optional again (#6191) --- .../net/minecraft/entity/EntityType.java.patch | 10 +++++++--- .../minecraftforge/fml/network/FMLPlayMessages.java | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/patches/minecraft/net/minecraft/entity/EntityType.java.patch b/patches/minecraft/net/minecraft/entity/EntityType.java.patch index 53c6d524d..72077aaf1 100644 --- a/patches/minecraft/net/minecraft/entity/EntityType.java.patch +++ b/patches/minecraft/net/minecraft/entity/EntityType.java.patch @@ -85,7 +85,7 @@ } + public T customClientSpawn(net.minecraftforge.fml.network.FMLPlayMessages.SpawnEntity packet, World world) { -+ if (customClientFactory == null) throw new RuntimeException("Missing custom spawn data for entity type "+this); ++ if (customClientFactory == null) return this.func_200721_a(world); + return customClientFactory.apply(packet, world); + } + @@ -111,7 +111,7 @@ private boolean field_225436_f; private EntitySize field_220326_f = EntitySize.func_220314_b(0.6F, 1.8F); -@@ -553,11 +591,31 @@ +@@ -553,11 +591,35 @@ return this; } @@ -130,6 +130,10 @@ + return this; + } + ++ /** ++ * By default, entities are spawned clientside via {@link EntityType#create(World)}. ++ * If you need finer control over the spawning process, use this to get read access to the spawn packet. ++ */ + public EntityType.Builder setCustomClientFactory(java.util.function.BiFunction customClientFactory) { + this.customClientFactory = customClientFactory; + return this; @@ -144,7 +148,7 @@ if (SharedConstants.field_206244_b) { throw illegalstateexception; } -@@ -566,7 +624,7 @@ +@@ -566,7 +628,7 @@ } } diff --git a/src/main/java/net/minecraftforge/fml/network/FMLPlayMessages.java b/src/main/java/net/minecraftforge/fml/network/FMLPlayMessages.java index ff6242a21..209ec8730 100644 --- a/src/main/java/net/minecraftforge/fml/network/FMLPlayMessages.java +++ b/src/main/java/net/minecraftforge/fml/network/FMLPlayMessages.java @@ -52,8 +52,8 @@ public class FMLPlayMessages * Used to spawn a custom entity without the same restrictions as * {@link net.minecraft.network.play.server.SSpawnObjectPacket} or {@link net.minecraft.network.play.server.SSpawnMobPacket} * - * Ensure your {@link EntityType} registration supplies a {@link EntityType.Builder#customClientFactory} or the - * mob won't actually spawn on the client. + * To customize how your entity is created clientside (instead of using the default factory provided to the {@link EntityType}) + * see {@link EntityType.Builder#setCustomClientFactory}. */ public static class SpawnEntity {