Jump to content

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


TheRPGAdventurer

Recommended Posts

so i have a dragon gui inventroy where you can open the dragon and put the banner on it, it will render on the body, the problem is that it disappears after i quit the world and i need to reopen the inventory again, i use  ItemRenderer.renderItem

 

https://pastebin.com/AEcjLJsd

Edited by TheRPGAdventurer
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

2 hours ago, TheRPGAdventurer said:

how?

 

Packets or the DataManager thing for entities.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

  • 1 month later...
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
Link to comment
Share on other sites

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);
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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