Record Class BattleSceneData

java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.api.battles.scene.BattleSceneData
Record Components:
scene - the selected battle scene definition id
playerAnchor - the target client world position for the player_pos marker
blocks - client-ready scene block snapshots
markers - client-ready parsed scene markers
renderSettings - rendering values and world-state behavior for the client scene

public record BattleSceneData(net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, List<BattleSceneBlockData> blocks, List<BattleSceneMarker> markers, BattleSceneRenderSettings renderSettings) extends Record
Server-built data required for a client to render a battle scene in place of the normal world.

The scene id is the selected battle scene definition, not necessarily the underlying structure id. The playerAnchor is the target world position for the scene's BattleSceneMarker.PLAYER_POS marker. Scene blocks and markers are rotated and shifted before being sent to the client so that marker lands at the player anchor.

  • Constructor Summary

    Constructors
    Constructor
    Description
    BattleSceneData(net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, List<BattleSceneBlockData> blocks, List<BattleSceneMarker> markers, BattleSceneRenderSettings renderSettings)
    Creates an instance of a BattleSceneData record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the blocks record component.
    decode(net.minecraft.network.RegistryFriendlyByteBuf buffer)
    Decodes client-ready battle scene data from the network.
    void
    encode(net.minecraft.network.RegistryFriendlyByteBuf buffer)
    Encodes this client-ready battle scene data for the client.
    final boolean
    Indicates whether some other object is "equal to" this one.
    fromScene(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation sceneId, BattleScene scene, net.minecraft.core.BlockPos playerAnchor)
    Builds client-ready scene data from a datapack battle scene definition.
    fromStructure(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor)
    Builds a client-ready scene directly from a server-side structure.
    fromStructure(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, net.minecraft.world.level.block.Rotation structureRotation)
    Builds a client-ready scene directly from a server-side structure.
    fromStructure(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, net.minecraft.world.level.block.Rotation structureRotation, float markerYawOffset)
    Builds a client-ready scene directly from a server-side structure.
    fromStructure(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, net.minecraft.world.level.block.Rotation structureRotation, float markerYawOffset, BattleSceneRenderSettings renderSettings)
    Builds a client-ready scene directly from a server-side structure.
    final int
    Returns a hash code value for this object.
    marker(String type)
    Finds the first marker of the supplied type.
    marker(String type, String id)
    Finds the first marker matching both type and id.
    Returns the value of the markers record component.
    Returns all markers of the supplied type.
    net.minecraft.core.BlockPos
    Returns the value of the playerAnchor record component.
    Returns the value of the renderSettings record component.
    net.minecraft.resources.ResourceLocation
    Returns the value of the scene record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • BattleSceneData

      public BattleSceneData(net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, List<BattleSceneBlockData> blocks, List<BattleSceneMarker> markers, BattleSceneRenderSettings renderSettings)
      Creates an instance of a BattleSceneData record class.
      Parameters:
      scene - the value for the scene record component
      playerAnchor - the value for the playerAnchor record component
      blocks - the value for the blocks record component
      markers - the value for the markers record component
      renderSettings - the value for the renderSettings record component
  • Method Details

    • fromStructure

      public static BattleSceneData fromStructure(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor)
      Builds a client-ready scene directly from a server-side structure.
      Parameters:
      level - the server level used to resolve the structure
      scene - the structure resource location, also used as the scene id
      playerAnchor - the world position where the player_pos marker should be placed
      Returns:
      the shifted scene data for the client
      Throws:
      IllegalStateException - if the structure does not contain a player_pos marker
    • fromStructure

      public static BattleSceneData fromStructure(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, net.minecraft.world.level.block.Rotation structureRotation)
      Builds a client-ready scene directly from a server-side structure.
      Parameters:
      level - the server level used to resolve the structure
      scene - the structure resource location, also used as the scene id
      playerAnchor - the world position where the player_pos marker should be placed
      structureRotation - the block-grid rotation to apply around the player_pos marker
      Returns:
      the shifted and rotated scene data for the client
      Throws:
      IllegalStateException - if the structure does not contain a player_pos marker
    • fromStructure

      public static BattleSceneData fromStructure(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, net.minecraft.world.level.block.Rotation structureRotation, float markerYawOffset)
      Builds a client-ready scene directly from a server-side structure.
      Parameters:
      level - the server level used to resolve the structure
      scene - the structure resource location, also used as the scene id
      playerAnchor - the world position where the player_pos marker should be placed
      structureRotation - the block-grid rotation to apply around the player_pos marker
      markerYawOffset - arbitrary yaw offset to add to all final marker facings
      Returns:
      the shifted and rotated scene data for the client
      Throws:
      IllegalStateException - if the structure does not contain a player_pos marker
    • fromScene

      public static BattleSceneData fromScene(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation sceneId, BattleScene scene, net.minecraft.core.BlockPos playerAnchor)
      Builds client-ready scene data from a datapack battle scene definition.
      Parameters:
      level - the server level used to resolve the structure
      sceneId - the battle scene definition id
      scene - the battle scene definition
      playerAnchor - the world position where the player_pos marker should be placed
      Returns:
      the shifted and rotated scene data for the client
      Throws:
      IllegalStateException - if the structure does not contain a player_pos marker
    • fromStructure

      public static BattleSceneData fromStructure(net.minecraft.server.level.ServerLevel level, net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, net.minecraft.world.level.block.Rotation structureRotation, float markerYawOffset, BattleSceneRenderSettings renderSettings)
      Builds a client-ready scene directly from a server-side structure.
      Parameters:
      level - the server level used to resolve the structure
      scene - the structure resource location, also used as the scene id
      playerAnchor - the world position where the player_pos marker should be placed
      structureRotation - the block-grid rotation to apply around the player_pos marker
      markerYawOffset - arbitrary yaw offset to add to all final marker facings
      renderSettings - render settings to send with the scene
      Returns:
      the shifted and rotated scene data for the client
      Throws:
      IllegalStateException - if the structure does not contain a player_pos marker
    • markers

      public List<BattleSceneMarker> markers(String type)
      Returns all markers of the supplied type.
      Parameters:
      type - the marker type to match
      Returns:
      matching markers, or an empty list when none exist
    • marker

      public Optional<BattleSceneMarker> marker(String type)
      Finds the first marker of the supplied type.
      Parameters:
      type - the marker type to match
      Returns:
      the first matching marker
    • marker

      public Optional<BattleSceneMarker> marker(String type, String id)
      Finds the first marker matching both type and id.
      Parameters:
      type - the marker type to match
      id - the marker id to match
      Returns:
      the first matching marker
    • decode

      public static BattleSceneData decode(net.minecraft.network.RegistryFriendlyByteBuf buffer)
      Decodes client-ready battle scene data from the network.
      Parameters:
      buffer - the packet buffer to read from
      Returns:
      the decoded scene data
    • encode

      public void encode(net.minecraft.network.RegistryFriendlyByteBuf buffer)
      Encodes this client-ready battle scene data for the client.
      Parameters:
      buffer - the packet buffer to write to
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • scene

      public net.minecraft.resources.ResourceLocation scene()
      Returns the value of the scene record component.
      Returns:
      the value of the scene record component
    • playerAnchor

      public net.minecraft.core.BlockPos playerAnchor()
      Returns the value of the playerAnchor record component.
      Returns:
      the value of the playerAnchor record component
    • blocks

      public List<BattleSceneBlockData> blocks()
      Returns the value of the blocks record component.
      Returns:
      the value of the blocks record component
    • markers

      public List<BattleSceneMarker> markers()
      Returns the value of the markers record component.
      Returns:
      the value of the markers record component
    • renderSettings

      public BattleSceneRenderSettings renderSettings()
      Returns the value of the renderSettings record component.
      Returns:
      the value of the renderSettings record component