Posted October 14, 20214 yr Hi, I'm new on this, 1. can anyone tell me why use deferred and not use static? 2. If I use deferred, how can I take a "declared" item/entity/block... Example: public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, "livinglife"); public static final RegistryObject<EntityType<verruct>> VERRUCT = ENTITIES..register("verruct", () -> EntityType.Builder.<verruct>of(verruct::new, EntityClassification.MISC) .sized(0.98F, 0.7F) .clientTrackingRange(8) .build("verruct")); vs public static final EntityType<verruct> VERRUCT = (EntityType<verruct>) EntityType.Builder.of(verruct::new, EntityClassification.MONSTER).build("verruct") .setRegistryName("livinglife", "verruct"); why i ask that? because in second I can call "VERRUCT", in first idk how can i call it :(, any help it's fine ❤️ and is because i need to register render and register entity, code of register render: public class onRendersEntity { public static void onRendersRegistry() { RenderingRegistry.registerEntityRenderingHandler((EntityType<verruct>) "HERE I PUT VERRUCT" , verructRenderer::new); LifeAndLive.LOGGER.debug("LIFE AND LIVE - Entity rendered"); } } but idk how to call the entity when using deferred, i came to this because i'm having same problem of this thread: PDT, I'm still learning, sorry if this is obvious. Edited October 19, 20214 yr by TonyOneG112 Solved, close thread
October 15, 20214 yr If you're asking how to get the EntityType when using the DeferredRegister way, you can call VERRUCT.get() and that will get you the EntityType out of the registry object. You can do the same for any other type of registry object. The only thing to be careful about is to make sure that the entities have actually been registered by the time you call VERRUCT.get(), but if you register your renderer at the right time that won't be a problem. In 1.17.1 you register renderers with the EntityRenderersEvent.RegisterRenderers event, I'm not sure about 1.16.5 but it's probably similar. This event will always fire after entities have been registered, so you can safely call the getter. You should use deferred registration because it ensures that your entities (or blocks, or whatever else you register) get registered at the right time. If everyone did this, it would allow forge to introduce a lot of useful features, such as reloading/enabling/disabling mods while the game is running. This is impossible to do with static initialisers. By the way, you can click the <> button while drafting your post and it will let you format your code like this: RenderingRegistry.registerEntityRenderingHandler(VERRUCT.get(), verructRenderer::new); LifeAndLive.LOGGER.debug("LIFE AND LIVE - Entity rendered");
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.