Jump to content

[BUG] banners in inventory do not render on the dragon's body if not reopened after quitting world


Recommended Posts

Posted

You need to sync the inventory when the entity is spawned on the client

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • 1 month later...
Posted (edited)
28 minutes ago, TheRPGAdventurer said:

elaborate please? :D

DataManager is the standard (vanilla) way for entities to sync server-side data to the client-side entity.  Modded entities can use it too, and it's not too difficult.  As an example of an entity that sync's an ItemStack, see the vanilla EntityItemFrame and its ITEM field. In summary:

 

  • Declare a static final DataParameter<T> field in your entity (T would be ItemStack in this case)
  • Override entityInit() to register that field with getDataManager().register(field, defaultValue)
  • To sync the data, use getDataManager.set(field, value).  It will automatically sync to the client on the next tick
  • On the client side, use getDataManager.get(field)
  • You can optionally also override notifyDataManagerChange(DataParameter<?>), which is called both client- and server-side (so check world.isRemote) when any data parameter is changed. This could be used to cache values, for example, or carry out some computation you wouldn't want to do every tick.
Edited by desht
Posted

should i write and read it on the nbt aswell?  or straight up make a setter or getter, i registered it in entityInit

private static final DataParameter<ItemStack> BANNER1 = EntityDataManager
      .<ItemStack>createKey(EntityTameableDragon.class, DataSerializers.ITEM_STACK);
private static final DataParameter<ItemStack> BANNER2 = EntityDataManager
      .<ItemStack>createKey(EntityTameableDragon.class, DataSerializers.ITEM_STACK);
private static final DataParameter<ItemStack> BANNER3 = EntityDataManager
      .<ItemStack>createKey(EntityTameableDragon.class, DataSerializers.ITEM_STACK);
private static final DataParameter<ItemStack> BANNER4 = EntityDataManager
      .<ItemStack>createKey(EntityTameableDragon.class, DataSerializers.ITEM_STACK);
Posted

Reading/writing NBT is a separate concern from sync'ing data to the client.

 

If your banner items need to persist across world/server restarts, then yes - you need to serialize them to NBT.  But that has nothing to do with sync'ing the banner items so the client can see them.

 

As for getters/setters, it's valid to have such accessors simply forward to getDataManager.get() or .set().  That also has nothing to do with NBT serialization, though.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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