Jump to content

[1.8.9] I need some explanations about tile syncing


Ermans

Recommended Posts

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I cant craft any of the epic fight mod weapons. I try using the recipes in the crafting table but nothing is working. and when i click on the epic fight weapon in jei there is no recipe at all.
    • Oklahoma Nation Cowboys at Youngstown Country PenguinsYoungstown, Ohio; Wednesday, 7 p.m. EDTBOTTOM LINE: The Youngstown Region Penguins facial area the Oklahoma Country Cowboys within the Countrywide Invitation Penguins include absent 15-5 versus Horizon League rivals, with a 9-4 history within non-meeting participate in. Youngstown Region is 1-2 inside online games resolved as a result of considerably less than 4 facts. The Cowboys are 8-10 in just Massive 12 engage in. Oklahoma Region ranks 9th within just the Large 12 taking pictures 31.1% towards 3-stage wide PERFORMERS: Dwayne Cohill is averaging 17.8 details and 4.8 helps for the Penguins. Adrian Nelson is averaging 17.1 info higher than the remaining 10 game titles for Youngstown Thompson is averaging 11.7 details for the Cowboys. Caleb Asberry is averaging 13.1 facts about the very last 10 video games for Oklahoma last 10 Video games: Penguins: 7-3 Zeke Zaragoza Jersey, averaging 79.7 info, 33.4 rebounds, 14.8 helps, 5.3 steals and 2.7 blocks for each video game despite the fact that capturing 48.1% versus the marketplace. Their rivals incorporate averaged 72.4 details for every : 4-6, averaging 66.4 specifics, 33.1 rebounds, 11.1 helps Jake Henry Jersey, 4.9 steals and 3.6 blocks for each sport even though taking pictures 41.3% towards the sector. Their rivals consist of averaged 72.0 info. The made this tale making use of technological innovation delivered by means of Information and facts Skrive and info against Sportradar. Cowboys Shop
    • Oklahoma Nation Cowboys at Youngstown Country PenguinsYoungstown, Ohio; Wednesday, 7 p.m. EDTBOTTOM LINE: The Youngstown Region Penguins facial area the Oklahoma Country Cowboys within the Countrywide Invitation Penguins include absent 15-5 versus Horizon League rivals, with a 9-4 history within non-meeting participate in. Youngstown Region is 1-2 inside online games resolved as a result of considerably less than 4 facts. The Cowboys are 8-10 in just Massive 12 engage in. Oklahoma Region ranks 9th within just the Large 12 taking pictures 31.1% towards 3-stage wide PERFORMERS: Dwayne Cohill is averaging 17.8 details and 4.8 helps for the Penguins. Adrian Nelson is averaging 17.1 info higher than the remaining 10 game titles for Youngstown Thompson is averaging 11.7 details for the Cowboys. Caleb Asberry is averaging 13.1 facts about the very last 10 video games for Oklahoma last 10 Video games: Penguins: 7-3 Zeke Zaragoza Jersey, averaging 79.7 info, 33.4 rebounds, 14.8 helps, 5.3 steals and 2.7 blocks for each video game despite the fact that capturing 48.1% versus the marketplace. Their rivals incorporate averaged 72.4 details for every : 4-6, averaging 66.4 specifics, 33.1 rebounds, 11.1 helps Jake Henry Jersey, 4.9 steals and 3.6 blocks for each sport even though taking pictures 41.3% towards the sector. Their rivals consist of averaged 72.0 info. The made this tale making use of technological innovation delivered by means of Information and facts Skrive and info against Sportradar. Cowboys Shop
    • DUTA89 agen slot online terbaik dan sering memberikan kemenangan kepada setiap member yang deposit diatas 50k dengan tidak klaim bonus sepeser pun.   Link daftar : https://heylink.me/DUTA89OFFICIAL/  
    • Hello All! Started a MC Eternal 1.6.2.2 server on Shockbyte hosting. The only other mod I added was betterfarmland v0.0.8BETA. Server is 16GB and Shockbyte wont tell me how many CPU cores i have.  We are having problems now when players log in it seems to crash the server. At other times it seems fine and we can have 3 people playing for hours at a time. Usually always when it does crash it is when someone logs in. Crash Reports Below. To the person who can post the fix I will reward $100 via Paypal.   ---- Minecraft Crash Report ---- // This is a token for 1 free hug. Redeem at your nearest Mojangsta: [~~HUG~~] Time: 2024-09-19 21:04:58 UTC Description: Exception in server tick loop java.lang.StackOverflowError     at net.minecraft.advancements.PlayerAdvancements.hasCompletedChildrenOrSelf(PlayerAdvancements.java:451)     at net.minecraft.advancements.PlayerAdvancements.shouldBeVisible(PlayerAdvancements.java:419)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:385)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:406)     at net.minecraft.advancements.PlayerAdvancements.ensureVisibility(PlayerAdvancements.java:411)     at net.minecraft.advancements.P  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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