Jump to content

Recommended Posts

Posted

Hello, I am doing my mod where I have steam being generated, I know the differens between server/client and .isRemote and such but the server and client get's out of sync where one side has more or less steam than the other, shouldn't it be equal? Is there a way to make them update more or?

 

This especially occures for tileentity data that is saved onto the server but then not loaded into the client (I have checked the data, they are close to identical when it starts, I save and quit and then reopen and the client side has low data while the server data is where it should be, having been saved)

 

Kind Regards

Posted

You have two options:

 

1) Server contains all variables, and sends a 'syncing' packet whenever the value is either changed. This would involve overriding getDescriptionPacket (I'm assuming you're using a TileEntity) so that the client also gets the values whenever it loads the TileEntity. This is a great tutorial on Packet (or more correctly, IMessage?) handling. Some people prefer using the vanilla packet instead, I personally don't like that. Personal preference, really. To make sure you send update whenever the important values that need to be synced are changed, just make sure you create getters and setters, and send the packet from the setter.

2) Update the values that you need whenever the server recognises that the player needs them - for example if they're only needed to be displayed on a GUI, then only update the values before the GUI opening (and maybe during the GUI being open if the values are changed).

 

Make sure that you only send the packets to players that are near the TileEntity.

 

Basically the same thing happens to update variables from the Client to the Server. Send the server the value that needs to be changed, and what is should be changed to, have the server verify that the value is possible (to prevent 'cheating'), and after changing then send the variable to any players around the TileEntity again.

 

Hope this helps~

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

Posted

Well, I haven't seen your code, so I can't tell you. Whenever the client exits the world, all Client data relating to the tile entity is gone. It is then synced again through getDescriptionPacket, onDescriptionPacket and possibly readFromNBT (or is it loadFromNBT?).

 

Only the Server actually saves the information.

 

 

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

Posted

Alright, I have managed to solve it but I have the issue of metadata of a block (which changes as the steam pressure increases) starts at 0 when the world is loaded and remains at 0 until it changes from it's data point (let's say the pressure is 2 for the sake of arguement) and then when ti changes to 3, the client gets the change and shows correct but until then it does not. How would I fix that?

Posted

How important is it for them to be in sync? It sounds to me like the steam is something you render on the client but hold the data for on the server? Is it affecting gameplay? If its just rendering and has no effect on gameplay, I would basically expect them to be out of sync and you as the debugger are most likely the only one who will ever even realize they are out of sync, and only from watching so closely in your debugging. If it DOES effect gameplay and needs to be the same across all clients then you may have an issue and need to send a LOT of packets or follow the advice from above, but you may be able to at least make the logic make sense per player by handling as much as you can on the client, like you would particles or a gui, and most clients wouldn't know the difference. Maybe a more in depth description of what this "steam" is doing in your game and post some more code?

I'll need help, and I'll give help. Just ask, you know I will!

Posted

I have acctually done huge progress so most of it is solved, the issue seems to be more metadata related now.

 

Anotehr example I worked throughout the day is a pressure gauge pipe that generates a redstone signal who's strength depends on the pressure inside, the metadata of the pipe changes and as such generates more redstone power but the redstone connected doesn't react to the new strength, when I remove the closest redstone and replace it it goes as far as it should 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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
    • Crashes the server when trying to start. Error code -1. Log  
×
×
  • Create New...

Important Information

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