Jump to content

Recommended Posts

Posted

Hello, I have some questions about these way to sync data.

 

1) Custom Packets

    a. I shouldn't use them for update values in the GUIs, rigth?

 

2) BlockEvents

    a. On which side should I call them?

    b. Are they a good way to update values in the GUIs?

    c. Now I know this: World#addBlockEvent (called server-side) fires Block#onBlockEventReceived (both sides) and here I have to call TileEntity#receiveClientEvent (both sides) and update values.      It is right?

 

3) IInventory Fields

    a. Are these the better way to update values in the GUIs?

    b. Why these methods are on the IInventory interface instead of an ISyncable or something like this?

 

So, what should I choose to sync values in the GUIs?

 

Thanks

 

 

Posted

It would be MUCH better if you could describe what are you after.

 

1.a. Packets as in IMessage and PacketHandler can be used to do anything for any side. That includes GUI updaes, Tile updates, Entity update, etc. You can even send configs and global-like data (e.g on client connection).

This covers how to deal with them: http://www.minecraftforge.net/forum/index.php/topic,20135.0.html

 

2.a. "Block Events" is a VERY wide term. There are "events" as in methods inside Block.class which you can override when making YOUR OWN blocks. Most of them will be called on both sides - you can use if(!world.isRemote) to execute them only on server.

I higly recommend reading this, before continuing:

http://mcforge.readthedocs.org/en/latest/concepts/sides

As to "actual" Events - Forge Events - we are talking about @SubscribeEvent annotation. Those are fired for any blocks.

Again - there are a LOT of different Block-based events. You need to be more specific.

Most of them, again - fire for both sides. If you want to make them run only on server thread - you again use if(!world.isRemote).

 

GENERALLY: All data manipulation can only ever happen on server. Client should only ever display stuff (eventually modify it for display purposes) or send requests/actions to server.

 

2.b. Values anywhere including GUI can be updated in literally any way. If the event is fired on both sides and you expect outcome to be exacly the same - you can freely use those actions to update gui. Just note - client has no access to actual data - what client only does is display, so if outcome of event will vary depending on side (server or client) you need to update client from server - and that you do with packets.

 

2.c. Well, this thingy has not very wide range of uses. Sure - whatever works for you. Again - remember that server is the one that should manipulate data.

 

3.a. Again - GUI values can be updated by anything. Most of dynamic updates will simply NEED you to have custom IMessage. Then you can (from handler class) access currently opened screen and change values.

Big note:

http://greyminecraftcoder.blogspot.com.au/2015/01/thread-safety-with-network-messages.html

 

3.b. What methods? Are you talking about those shits that seem like they are used for syncing? Well - they are not (at least not if you don't make them to). Generally - IInventory is quite useless for mods (it lacks compatybility and is really just failed interface in my opinion).

Note: As of 1.8.9 Forge has new Capability system:

http://mcforge.readthedocs.org/en/latest/datastorage/capabilities/

Use this is favor of any IInventory implementation (or actually any other).

 

"So, what should I choose to sync values in the GUIs?"

I recommend IMessages mentioned earlier.

 

Lemme just stress this out: It would be MUCH better if you could describe what are you after.

1.7.10 is no longer supported by forge, you are on your own.

Posted

IIRC, Forge's wrapper calls events, and our mods subscribe to (handle) them. If you're thinking about calling (firing) events, then you're either way more advanced than I, or else you're asking for trouble.

 

For starter tile entities, just writing a useful pair of NBT methods (override the read & write) and marking a tile "dirty" should suffice.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

I need to update values for the GUI (energy bar and progress bar), I already use IMessage for things that need to sync all the clients in a range, but I don't want to use them because I need to send message only to player who have the gui open.

 

About Block Events, I apologize for not being specific, I mean World#addBlockEvent, Block#onBlockEventReceived and TileEntity#receiveClientEvent and I need to know if these methods are a good way to update values in the GUI.

 

About the third question, I mean IInventory#getField,  IInventory#setField and IInventory#getFieldCount. These methods are use by vanilla furnace to update the GUI, I  just wondering why these methods are inside IInventory interface and not in a ISyncable interface or something like this.

Posted

Those types of GUIs use the Container as an intermediary between the server and the client.

 

If you take a look at the ContainerFurnace class, you will see how it calls the IInventory methods as well as #detectAndSendChanges and another method like #addCraftingToCrafters - the former is the one responsible for updating the GUI values from the TE values, and the latter is one that typically adds players that need to be informed of changes.

 

Ideally, your TE-based Container/GUI combo wouldn't ever need to explicitly send messages or block updates, but would all be handled via the Container.

Posted

Those types of GUIs use the Container as an intermediary between the server and the client.

 

If you take a look at the ContainerFurnace class, you will see how it calls the IInventory methods as well as #detectAndSendChanges and another method like #addCraftingToCrafters - the former is the one responsible for updating the GUI values from the TE values, and the latter is one that typically adds players that need to be informed of changes.

 

Ideally, your TE-based Container/GUI combo wouldn't ever need to explicitly send messages or block updates, but would all be handled via the Container.

 

Thanks, but I already knew that, I was just asking if there was other ways better than vanilla way. I think I will use containers so :)

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

    • I need to know what mod is doing this crash, i mean the mod xenon is doing the crash but i want to know who mod is incompatible with xenon, but please i need to know a solution if i need to replace xenon, i cant use optifine anymore and all the other mods i tried(sodium, lithium, vulkan, etc) doesn't work, it crash the game.
    • I have been trying to solve a consistent crashing issue on my brother's computer where it will crash during the "Scanning Mod Candidates" phase of the loading process that starts when you click the play button on the Minecraft launcher. The issue seems to stem from a missing library that it mentions in the log file I provide below. I might I'm missing the bigger issue here for a smaller one but hopefully someone can find what I'm missing. Here's all of the stuff that I've been able to figure out so far: 1. It has nothing to do with mods, the crash happened with a real modpack, and even when I made a custom modpack and launched it without putting ANY mods into it (That is where the log file comes from by the way). 2. I have tried to find this class like a file in the Minecraft folders, but I've had no luck finding it (I don't think it works like that, but since I really don't understand how it works, I just figured I'd try). 3. I haven't seen anyone else have this issue before. 4. I know that my modpack (with mods) does work since I've run it on my computer, and it works fantastic. For some reason my brother's computer can't seem to run anything through curseforge. 5. This is for Minecraft version 1.20.1, Minecraft launcher version 3.4.50-2.1.3, forge 47.3.0, and curseforge app version 1.256.0.21056 6. My brother is using a Dell laptop from 6 years ago running Windows 10 (If you think more info on this would help, please ask as I do have it. I'm just choosing not to put it here for now). 7. I have reinstalled the curseforge app and installed Minecraft version 1.20.1. I have not reinstalled Minecraft or forge 47.3.0 but I didn't know if that would help. 8. I had an error code of 1 Please let me know if there is anything else that I am missing that you would like me to add to this post/add in a comment! Lastly, many thanks in advance to whoever can help! ------------- LOG FILE (latest.log) ------------- (from /Users/<NAME OF USER>/cursforge/minecraft/Instances/<THE NAME OF MY EMPTY MODPACK>/logs/latest.log) (This was made after running an empty modpack with same versions for all apps) ("[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/hxXvGGEK ------------- DEBUG.LOG (I realized that I should have put this here first after I had done all of the work on putting latest.log in) -------------------- (again, "[REDACTED]" is not the actual text from the log, it is me replacing text I figured wouldn't be necessary for fixing and would hurt my privacy) https://pastebin.com/Fmh8GHYs
    • Pastebin... https://pastebin.com/Y3iZ85L5   Brand new profile, does not point to a mod as far as I can tell, my fatal message just has something about mixins. Don't know much about reading logs like this, but am genuinely stuck, please help. Java updated, pc restarted.
    • I was playing minecraft, forge 47.3.0 and 1.20.1, but when i tried to play minecraft now only crashes, i need help please. here is the crash report: https://securelogger.net/files/e6640a4f-9ed0-4acc-8d06-2e500c77aaaf.txt
  • Topics

×
×
  • Create New...

Important Information

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