Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by TonyOneG112
Solved, close thread

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"); 

 

  • TonyOneG112 changed the title to [SOLVED][1.16.5] Deferred register vs static register

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.