Bassebombecraft

Bassebombecraft

18.5k Downloads

Refactor access to repositories via sided proxy only

Closed this issue ยท 3 comments

commented

Access to repositories is refactored to the client/server proxy classes.
The purpose is to make it more clear which repositories are server or client side only.
An UnsupportedOperationException is thrown if a repository is access from an "illegal" side.

This issues is related to #710 where guard methods are implemented for all event handlers.
See #740 for an analysis of "sides".

commented

Minecraft comes in three configurations that that the concept of sides supports:

Minecraft configurations

Configuration 1: Physical client in multiplayer

Physical client contains: Logical client

World values for Logical client :

  • (Field for logical side, is logical client) world.isRemote = true
  • (Field for physical side) FMLEnvironment.dist=CLIENT

Configuration 2: Physical client in singleplayer

Physical client contains: Logical client and Logical server.

World values for Logical client :

  • (Field for logical side, is logical client) world.isRemote = true
  • (Field for physical side) FMLEnvironment.dist=CLIENT

World values for Logical server:

  • (Field for logical side, is logical client) world.isRemote = false
  • (Field for physical side) FMLEnvironment.dist=CLIENT

Configuration 3: Physical server in multiplayer

Physical server contains: Logical server.

World values for Logical server:

  • (Field for logical side, is logical client) world.isRemote = false
  • (Field for physical side) FMLEnvironment.dist=DEDICATED_SERVER

Minecraft configurations

Proxies are separated by physical side (i.e. the value of FMLEnvironment.dist).

ClientProxy

FMLEnvironment.dist=CLIENT
Is used by configurations: 1+2

ServerProxy

FMLEnvironment.dist=DEDICATED_SERVER
Is used by configurations: 3

commented

Placement of repositories:

NetworkChannelHelper

Used to send network packages from logical server til logical client(s).
Is used by configurations: 2,3 (i.e. when world.isRemote = false)
Is available by:

  • ServerProxy
  • ClientProxy (throws exception if at logical client, i.e. world.isRemote = false)

See #740.

FrequencyRepository

Used to calculate timing for when a task should be done.
Is used by configurations: 1,2,3
Is available by:

  • ServerProxy
  • ClientProxy

DurationRepository

Used to store and calculate the expiry of state.
Is used by configurations: 1,2,3
Is available by:

  • ServerProxy
  • ClientProxy

ParticleRenderingRepository

Used to store particles to be rendered.
Is used by configurations: 1,2 (i.e. when FMLEnvironment.dist=CLIENT)
Is available by:

  • ClientProxy

Uses the duration repository as backend.

CharmedMobsRepository

Two implementation of the repository:

  • ServerSideCharmedMobsRepository
  • ClientSideCharmedMobsRepository

ServerSideCharmedMobsRepository

Used to to store state about charmed mobs
Is used by configurations: 2,3 (i.e. when world.isRemote = false)
Is available by:

  • ServerProxy
  • ClientProxy (if world.isRemote = false)

ClientSideCharmedMobsRepository

Used to store a bit information about charmed mobs to support rendering.
Is used by configurations: 1,2 (i.e. when FMLEnvironment.dist=CLIENT)
Is available by:

  • ClientProxy (if world.isRemote = true)

Both implementations uses the duration repository as backend.

BlockDirectivesRepository

Used to process blocks.
Is used by configurations: 2,3 (i.e. when world.isRemote = false)
Is available by:

  • ServerProxy
  • ClientProxy (throws exception if at logical client, i.e. world.isRemote = false)

TemporaryBlockRepository

Used to process temporary blocks.
Is used by configurations: 2,3 (i.e. when world.isRemote = false)
Is available by:

  • ServerProxy
  • ClientProxy (throws exception if at logical client, i.e. world.isRemote = false)

MobCommanderRepository

Used to store commander state.
Is used by configurations: 2,3 (i.e. when world.isRemote = false)
Is available by:

  • ServerProxy
  • ClientProxy (throws exception if at logical client, i.e. world.isRemote = false)

See #745 for current lack of rendering in commit fa08adb.

TeamRepository

Used to store team members.
Is used by configurations: 2,3 (i.e. when world.isRemote = false)
Is available by:

  • ServerProxy
  • ClientProxy (throws exception if at logical client, i.e. world.isRemote = false)

See #746 for current lack of rendering in commit dc158e9.

TargetRepository

Used to store targeted entities .
Is used by configurations: 2,3 (i.e. when world.isRemote = false)
Is available by:

  • ServerProxy
  • ClientProxy (throws exception if at logical client, i.e. world.isRemote = false)

See #747 for current lack of rendering in commit dc158e9.

commented

Closed with commit dc158e9.