Jump to content

Recommended Posts

Posted (edited)

Hey there,

I need to synchronize the inventory of my custom entity (not the player) with the client. How can i do this?

So i'm attaching a CapabilityItemHandler to my entity and when the player is riding the entity he should get information from the inventory of the entity displayed. But i currently have to open the inventory once and only then the player can see the information from the inventory of the entity.

Edited by Meldexun
Posted

So i'm now sending a packet when the item stack changes while the entity is being ridden and when a player starts riding. But what should i do when the player is riding the entity while the world is loaded. I tried sending a packet inside the onAddedToWorld method of my entity but then the entity isn't loaded client side and nothing will get synchronized.

Posted
  On 7/15/2019 at 9:36 PM, diesieben07 said:

PlayerLoggedInEvent, PlayerRespawnEvent and PlayerChangedDimensionEvent.

Expand  

Maybe i didn't described my issue good enough.

So lets say you start a singleplayer world and spawn my custom entity. Then you put an item in the inventory of the entity. After that you start riding the entity. And while you are still riding the entity you are leaving the world and go in the main menu. Now you join the world again.

The problem is that every event i'm trying to use to send a packet is called to early on the server. So in the end the client receives a packet but the entity isn't there already so nothing can be synchronized. In java the problem is: Minecraft.getMinecraft().world.getEntityByID(message.getEntityId()) returns null because the entity isn't created on the client.

Posted

Sure.

EventHandler class:

  Reveal hidden contents

 

Entity class:

  Reveal hidden contents

 

Packet class:

  Reveal hidden contents

 

PacketHandler class:

  Reveal hidden contents

 

ClientProxy class:

  Reveal hidden contents

 

When i start the game it prints null in the console.

Posted

Yes, i tried this too. But the problem is that still the entity is loaded on the server but not on the client. -> nothing can synchronize. The only solution i see  could be to send a packet from the client and then send an answer packet from the server.

Posted

Then you misunderstood me.

The player and the entity are loaded server side.

Then an event is fired and sends a packet from the server side to the client side.

The packet is received on the client side but the entity is NOT loaded on the client side. So nothing can be done.

  • 5 months later...
Posted

I have the same issue where the data I send from the server to the client about an entity cannot be used at that time because the entity has not loaded yet on the client

 

My solution was to store the message until the entity actually loaded, and to process the message during the EntityJoinWorldEvent event

Hopefully that was the right way to do it

 

You can find an example implementation here https://github.com/Ephys/mc-who-let-the-dogs-out/blob/5d38102cefde1648809db9006708b5d8d1487be2/src/main/java/be/ephys/wltdo/NewSkinMessageHandler.java

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • A few months ago, I was approached online by a so-called investment broker. Everything looked professional — flashy websites, fake but convincing reviews, even video calls with people who seemed legitimate. They promised unbelievable returns on Bitcoin investments, and I, eager to grow my crypto holdings, fell for it. Over a few weeks, I transferred Bitcoin worth around $360,000 to what I thought was a secured investment wallet. The “broker” kept assuring me my money was growing, even showing fake dashboards with fabricated profits. But when I tried to withdraw my funds, they demanded additional fees — taxes, account, activation, and release charges. That’s when the truth hit me I had been scammed. Devastated, I started searching for solutions. But then, a glimmer of hope. A cybersecurity contact muttered Try Dexdert Net Recovery. They hunt crypto ghosts. Dexdert Net had real testimonials, detailed explanations of their process, and most importantly, they didn’t ask for any suspicious upfront fees. After contacting them, their team patiently walked me through the steps gathering all evidence of the scam, tracking the Bitcoin transactions on the blockchain, and using legal recovery channels and cyber forensic methods. They kept me updated at every stage. 4 days later, I got the email I’ll never forget: Funds Recovered. Dexdert Net Recovery successfully trace and retrieve the entire $360,000 worth of Bitcoin from the scammer’s wallets. Thanks to Dexdert Net Pro Recovery, not only did I reclaim my lost Bitcoin, but I also regained a sense of justice — and a serious lesson learned. If you’re ever in a situation like I was, know this: there’s hope, and there are real experts out there who can help. Dexdert Net Recovery proved it to me. CONTACT DEXDERT NET RECOVERY VIA INFORMATION BELOW   Telegram: (@Dexdertprorecovery)      
    • So I just try to remove mods and see what works?
    • Hello, I want to change some things about a specific mod. I made some small mods for myself before, but I don't know how to use other mods as a dependencie and add the repositories. My build.gradle file looks something like this:   repositories { flatDir { dirs 'libs' } } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation fg.deobf("libs:create-1.20.1:0.5.1.f") implementation fg.deobf("libs:create-stuff-additions1.20.1:2.0.4a") } I have the folder libs in my root folder. If I start the gradlew.exe, I get the following output: > Configure project : Java: 17.0.15, JVM: 17.0.15+6 (Eclipse Adoptium), Arch: amd64 files(...) dependencies are not deobfuscated. Use a flatDir repository instead: https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver Cannot deobfuscate dependency of type DefaultSelfResolvingDependency_Decorated, using obfuscated version! files(...) dependencies are not deobfuscated. Use a flatDir repository instead: https://docs.gradle.org/current/userguide/declaring_repositories.html#sub:flat_dir_resolver Cannot deobfuscate dependency of type DefaultSelfResolvingDependency_Decorated, using obfuscated version! I don't know why this warning occurs or how to fix it. If I try to build the whole thing, I get the same message, but this time as an error and the build process crashes. I looked at the gradle dependencies website (https://docs.gradle.org/current/userguide/dependency_management_for_java_projects.html), but everything I tried did not work.   I use the Minecaft version 1.20.1 and the Forge version 47.2.17. Both mods don't have other dependencies and work perfectly fine if I start the game normaly.   Can someone explain to me why it does not work and/or where I can get help? Something like a documentation would be enough.
    • im just going to play without shaders(my friends will be dissapointed)
    • crashed the game // Embeddium instance tainted by mods: [oculus] // Please do not reach out for Embeddium support without removing these mods first. // ------- // Why did you do that? flywheel is needed for oculus but when i go into mc it then says sodium is 0.5.3(rubidum fork of sodium ported to forge)
  • Topics

×
×
  • Create New...

Important Information

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