Record Class BattleSceneData
java.lang.Object
java.lang.Record
com.pixelmonmod.pixelmon.api.battles.scene.BattleSceneData
- Record Components:
scene- the selected battle scene definition idplayerAnchor- the target client world position for theplayer_posmarkerblocks- client-ready scene block snapshotsmarkers- client-ready parsed scene markersrenderSettings- 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
ConstructorsConstructorDescriptionBattleSceneData(net.minecraft.resources.ResourceLocation scene, net.minecraft.core.BlockPos playerAnchor, List<BattleSceneBlockData> blocks, List<BattleSceneMarker> markers, BattleSceneRenderSettings renderSettings) Creates an instance of aBattleSceneDatarecord class. -
Method Summary
Modifier and TypeMethodDescriptionblocks()Returns the value of theblocksrecord component.static BattleSceneDatadecode(net.minecraft.network.RegistryFriendlyByteBuf buffer) Decodes client-ready battle scene data from the network.voidencode(net.minecraft.network.RegistryFriendlyByteBuf buffer) Encodes this client-ready battle scene data for the client.final booleanIndicates whether some other object is "equal to" this one.static BattleSceneDatafromScene(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.static BattleSceneDatafromStructure(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.static BattleSceneDatafromStructure(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.static BattleSceneDatafromStructure(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.static BattleSceneDatafromStructure(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 inthashCode()Returns a hash code value for this object.Finds the first marker of the supplied type.Finds the first marker matching both type and id.markers()Returns the value of themarkersrecord component.Returns all markers of the supplied type.net.minecraft.core.BlockPosReturns the value of theplayerAnchorrecord component.Returns the value of therenderSettingsrecord component.net.minecraft.resources.ResourceLocationscene()Returns the value of thescenerecord component.final StringtoString()Returns a string representation of this record class.
-
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 aBattleSceneDatarecord class.- Parameters:
scene- the value for thescenerecord componentplayerAnchor- the value for theplayerAnchorrecord componentblocks- the value for theblocksrecord componentmarkers- the value for themarkersrecord componentrenderSettings- the value for therenderSettingsrecord 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 structurescene- the structure resource location, also used as the scene idplayerAnchor- the world position where theplayer_posmarker should be placed- Returns:
- the shifted scene data for the client
- Throws:
IllegalStateException- if the structure does not contain aplayer_posmarker
-
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 structurescene- the structure resource location, also used as the scene idplayerAnchor- the world position where theplayer_posmarker should be placedstructureRotation- the block-grid rotation to apply around theplayer_posmarker- Returns:
- the shifted and rotated scene data for the client
- Throws:
IllegalStateException- if the structure does not contain aplayer_posmarker
-
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 structurescene- the structure resource location, also used as the scene idplayerAnchor- the world position where theplayer_posmarker should be placedstructureRotation- the block-grid rotation to apply around theplayer_posmarkermarkerYawOffset- 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 aplayer_posmarker
-
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 structuresceneId- the battle scene definition idscene- the battle scene definitionplayerAnchor- the world position where theplayer_posmarker should be placed- Returns:
- the shifted and rotated scene data for the client
- Throws:
IllegalStateException- if the structure does not contain aplayer_posmarker
-
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 structurescene- the structure resource location, also used as the scene idplayerAnchor- the world position where theplayer_posmarker should be placedstructureRotation- the block-grid rotation to apply around theplayer_posmarkermarkerYawOffset- arbitrary yaw offset to add to all final marker facingsrenderSettings- 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 aplayer_posmarker
-
markers
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
Finds the first marker of the supplied type.- Parameters:
type- the marker type to match- Returns:
- the first matching marker
-
marker
Finds the first marker matching both type and id.- Parameters:
type- the marker type to matchid- the marker id to match- Returns:
- the first matching marker
-
decode
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
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
scene
public net.minecraft.resources.ResourceLocation scene()Returns the value of thescenerecord component.- Returns:
- the value of the
scenerecord component
-
playerAnchor
public net.minecraft.core.BlockPos playerAnchor()Returns the value of theplayerAnchorrecord component.- Returns:
- the value of the
playerAnchorrecord component
-
blocks
Returns the value of theblocksrecord component.- Returns:
- the value of the
blocksrecord component
-
markers
Returns the value of themarkersrecord component.- Returns:
- the value of the
markersrecord component
-
renderSettings
Returns the value of therenderSettingsrecord component.- Returns:
- the value of the
renderSettingsrecord component
-