Class SimulationController

java.lang.Object
me.desht.pneumaticcraft.common.hacking.secstation.SimulationController
All Implemented Interfaces:
ISimulationController

public class SimulationController extends Object implements ISimulationController
Runs both the player and AI simulation objects and mediates between them. This is done on both client and server side. Both sides will be ticked but the server will periodically sync its state to the client, so client is using dead reckoning with periodic updates from the server. Only the server state actually matters for security station hacking, of course; the client state is purely for display by SecurityStationHackingScreen.
  • Constructor Details

    • SimulationController

      public SimulationController(SecurityStationBlockEntity te, net.minecraft.world.entity.player.Player hacker, boolean justTesting)
      Called server-side when a hack is started
      Parameters:
      te - the security station
      hacker - the hacking player
    • SimulationController

      public SimulationController(SecurityStationBlockEntity te, net.minecraft.world.entity.player.Player hacker, HackSimulation playerSimulation, HackSimulation aiSimulation, boolean justTesting)
      Called client-side on start of hack to sync the initial simulation state.
      Parameters:
      te - the security station
      hacker - the hacking player (will be the client player)
      playerSimulation - the hacking player's simulation object
      aiSimulation - the security station's simulation object
  • Method Details

    • onConnectionStarted

      public void onConnectionStarted(HackSimulation hackSimulation, int fromPos, int toPos, float initialProgress)
      Description copied from interface: ISimulationController
      A connection from one node to another has just begun.
      Specified by:
      onConnectionStarted in interface ISimulationController
      Parameters:
      hackSimulation - the simulation
      fromPos - position of the hacking node
      toPos - position of the target node
      initialProgress - initial progress of the connection (usually but not necessarily 0)
    • isJustTesting

      public boolean isJustTesting()
      Description copied from interface: ISimulationController
      Is this just a test by the station's owner, or other whitelisted player? If just testing, the security station will not retaliate on a failed hack.
      Specified by:
      isJustTesting in interface ISimulationController
      Returns:
      true if just testing, false otherwise
    • toBytes

      public void toBytes(net.minecraft.network.FriendlyByteBuf buffer)
      Description copied from interface: ISimulationController
      Serialize the simulation controller for sync to client on open of hacking GUI
      Specified by:
      toBytes in interface ISimulationController
      Parameters:
      buffer - packet buffer
    • onNodeHacked

      public void onNodeHacked(HackSimulation hackSimulation, int pos)
      Description copied from interface: ISimulationController
      A simulation has just had a node hacked (connection completed).
      Specified by:
      onNodeHacked in interface ISimulationController
      Parameters:
      hackSimulation - the simulation
      pos - position of the newly hacked node
    • onNodeFortified

      public void onNodeFortified(HackSimulation hackSimulation, int pos)
      Description copied from interface: ISimulationController
      A simulation has just had a hacked node fortified by the player
      Specified by:
      onNodeFortified in interface ISimulationController
      Parameters:
      hackSimulation - the simulation
      pos - position of the newly fortified node
    • tick

      public void tick()
      Description copied from interface: ISimulationController
      Called every game tick (both client and server) by the owning security station block entity.
      Specified by:
      tick in interface ISimulationController
    • isSimulationDone

      public boolean isSimulationDone()
      Description copied from interface: ISimulationController
      Are we done with this hack simulation?
      Specified by:
      isSimulationDone in interface ISimulationController
      Returns:
      true if finished, false otherwise
    • getSimulation

      Description copied from interface: ISimulationController
      Get the simulation object for the given side (player or AI)
      Specified by:
      getSimulation in interface ISimulationController
      Parameters:
      side - the side to get
      Returns:
      the simulation
    • getHacker

      public net.minecraft.world.entity.player.Player getHacker()
      Description copied from interface: ISimulationController
      Get the player currently trying to hack the security station. This does not validate if the player is still online.
      Specified by:
      getHacker in interface ISimulationController
      Returns:
      the player