ImmersiveMC

ImmersiveMC

683k Downloads

Shared Immersive State

hammy275 opened this issue ยท 1 comments

commented

We need a system for shared Immersive state on the server, mainly so players who start tracking an Immersive other players have messed with are "caught up".

Required for #292.

Planning

This is basically just holding a map of block positions to NetworkStorage's in memory, on a per-level basis. There's nothing in ImmersiveHandler to verify that the storage matches, so we can demand the handler as a parameter, and use makeEmptyStorage() to see if the classes match.

The storage is purely meant for shared network state, so it should be destroyed when the block is removed. No callbacks to get items out of it or anything, that's what TrackedImmersives' callbacks are for.

SharedNetworkStorages

This is the API-class. It will expose the following:

  • getOrCreate(Level level, BlockPos pos, ImmersiveHandler<?> handler): Will get the network storage at the provided location, or create one if one isn't there or the types don't match.
  • get(Level level, BlockPos pos, ImmersiveHandler<?> handler): Same as getOrCreate() but returns null instead of creating.
  • remove(Level level, BlockPos pos, ImmersiveHandler<?> handler): Allows a modder to remove a NetworkStorage. Not required, as ImmersiveMC will handle cleanup automatically, but still good to have.

Implementation-wise, we'll hold a map of maps. The outer map is keyed by the level resource locations, and the inner map is keyed by the blockpos, with a value of the NetworkStorage behind held there.

I'll write this for the API for now, but I'm not sure on exposing it, mainly due to WorldStorages not being exposed, nor my intention for other modders to really deal with implementing Immersives for things outside of their own mods, where they should just have this data stored on the block entity directly.

commented

Merged in with #292's completion