NPException / Dimensional-Pockets

GNU Lesser General Public License v3.0
8 stars 4 forks source link

PocketRegistry need to be server side only #43

Closed NPException closed 9 years ago

NPException commented 9 years ago

The pockets from the PocketRegistry need to be ServerSide only.

The PocketRegistry on the client should just get pushed the data from the Server. Maybe just send over the Gson'ed Pockets that are relevant to the Player atm.

Jezza commented 9 years ago

maybe a PocketRegistry.requestPocket(TileDimensionalPocket pocket);

NPException commented 9 years ago

we should go with a "hybrid" approach:

the client will request a Pocket if he does not have it. The server will send changed Pockets to a player if he requested the Pocket before.

Jezza commented 9 years ago

We don't have to write much code for this. Let me grab example code.

Jezza commented 9 years ago

https://github.com/Jezza/OmnisCore/blob/master/common/me/jezza/oc/common/tile/TileAbstract.java

onDataPacket, getDescriptionPacket, and markForUpdate.

All are default minecraft stuff, and you can send a nbt tag, most generally send the tag they use to write, but you can just write what you need.

Also this is OmnisCore, so you could change TileDimensionalPocket to extend TileAbstract and just override the getDescriptionPacket and write your own stuff.

NPException commented 9 years ago

Sounds good to me. I'll look into it further when I get home today. When should I call the markForUpdate() method? It does not have an @Override annotation, so I assume it's not something inherent to every TileEntity.

Jezza commented 9 years ago

markForUpdate is not a super method. So yes, nothing would inherit it from TileEntity

NPException commented 9 years ago

So in what cases do I call it? And what exactly does it do to the server and client side?

Jezza commented 9 years ago

Whenever a pocket changes?

It sends the packet that getDescriptionPacket returns to the client to be read, so when a flowstate was changed, etc.

Jezza commented 9 years ago

In this case, I'm preparing a default minecraft packet to send to the client.

NPException commented 9 years ago

okay, thanks :)

NPException commented 9 years ago

After wasting hours before figuring that @SideOnly(Side.SERVER) marked methods and classes will only be visible to a fucking DEDICATED server, and never be accessible when playing SinglePlayer, I pretty much got this done. All that is left to do, is to call the new utility method Utils.enforceServer() everywhere that should only be called by a non remote instance.

Will finish that today.

NPException commented 9 years ago

done