Class PrefabEditSession

java.lang.Object
com.hypixel.hytale.builtin.buildertools.prefabeditor.PrefabEditSession
All Implemented Interfaces:
Resource<EntityStore>, Cloneable

public class PrefabEditSession extends Object implements Resource<EntityStore>
Represents an ongoing edit session, with multiple PrefabEditingMetadatas representing the prefabs inside this edit session. It is a resource so that if a server restart happens in the middle of a session, it can resume no problem when the server starts back up
  • Field Details

  • Constructor Details

    • PrefabEditSession

      public PrefabEditSession(@Nonnull String worldName, @Nonnull UUID worldCreator, @Nonnull UUID worldArrivedFrom, @Nonnull Transform transformArrivedFrom)
      Default Constructor for a PrefabEditSession instance.
      Parameters:
      worldName - The name of the world this edit session is in.
      worldCreator - The UUID of the player that created this edit session.
      worldArrivedFrom - The UUID of the world that the user exited from to enter the prefab editing world.
      transformArrivedFrom - The transform in worldArrivedFrom that the worldCreator arrived from.
    • PrefabEditSession

      public PrefabEditSession(@Nonnull PrefabEditSession other)
      Copy Constructor for a PrefabEditSession instance.
      Parameters:
      other - The other PrefabEditSession to copy from.
  • Method Details

    • getResourceType

      @Nonnull public static ResourceType<EntityStore, PrefabEditSession> getResourceType()
      Returns:
      the resource type for the PrefabEditSession resource.
    • addPrefab

      public void addPrefab(@Nonnull Path prefabPath, @Nonnull org.joml.Vector3i minPoint, @Nonnull org.joml.Vector3i maxPoint, @Nonnull org.joml.Vector3i anchorPoint, @Nonnull org.joml.Vector3i pastePosition)
      Create a PrefabEditingMetadata based on the provided details about the prefab
      Parameters:
      prefabPath - The path of the prefab save file
      minPoint - The minimum point in world coordinates of the pasted prefab's bounding box
      maxPoint - The maximum point in world coordinates of the pasted prefab's bounding box
      anchorPoint - The world coordinates of the pasted prefab's anchor point
      pastePosition - The paste position (origin of prefab coordinate system in world space)
    • updatePrefabBounds

      @Nullable public PrefabEditingMetadata updatePrefabBounds(@Nonnull UUID prefab, @Nonnull org.joml.Vector3i newMin, @Nonnull org.joml.Vector3i newMax)
      Update the bounds of the specified prefab (prefab editing metadata)
      Parameters:
      prefab - The UUID of the PrefabEditingMetadata to update the bounds of
      newMin - The minimum point
      newMax - The maximum point
      Returns:
      this
    • setSelectedPrefab

      public void setSelectedPrefab(@Nonnull Ref<EntityStore> ref, @Nonnull PrefabEditingMetadata prefabEditingMetadata, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Set the selected prefab for a given player and send them the anchor highlighting packet and update their builder tools selection
      Parameters:
      ref - The entity reference of the player entity to select this prefab.
      prefabEditingMetadata - The PrefabEditingMetadata prefab to select.
      componentAccessor - The ComponentAccessor<EntityStore> for component access.
    • hidePrefabAnchors

      public void hidePrefabAnchors(@Nonnull PacketHandler packetHandler)
      Stop displaying the prefab anchors to the given PacketHandler
      Parameters:
      packetHandler - The PacketHandler to send the packet to
    • getSelectedPrefab

      @Nullable public PrefabEditingMetadata getSelectedPrefab(@Nonnull UUID playerUuid)
      Get the currently selected prefab for the given player UUID.
      Parameters:
      playerUuid - The UUID of the player to get the selected prefab for.
      Returns:
      The selected PrefabEditingMetadata, or null if none is selected.
    • clearSelectedPrefab

      public boolean clearSelectedPrefab(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor)
      Clear the selected prefab for a given player and hide the anchor display.
      Parameters:
      ref - The entity reference of the player entity.
      componentAccessor - The ComponentAccessor<EntityStore> for component access.
      Returns:
      true if a prefab was unselected, false if no prefab was selected.
    • getWorldName

      @Nonnull public String getWorldName()
      Returns:
      the name of the world that this edit session exists in.
    • getWorldArrivedFrom

      public UUID getWorldArrivedFrom()
      Returns:
      the UUID of the world that the user exited from to enter the prefab editing world.
    • setWorldArrivedFrom

      public void setWorldArrivedFrom(UUID worldUuid)
    • getTransformArrivedFrom

      @Nullable public Transform getTransformArrivedFrom()
      Returns:
      the transform that the player arrived from in the previous world.
    • setTransformArrivedFrom

      public void setTransformArrivedFrom(Transform transform)
    • getWorldCreator

      public UUID getWorldCreator()
      Returns:
      the UUID of the player that created the edit session.
    • getSpawnPoint

      @Nonnull public org.joml.Vector3i getSpawnPoint()
      Returns:
      the spawn point of the world this edit session is in.
    • getLoadedPrefabMetadata

      @Nonnull public Map<UUID, PrefabEditingMetadata> getLoadedPrefabMetadata()
      Returns:
      a map of all the PrefabEditingMetadata instances loaded in this edit session, keyed by their temporary UUID.
    • markPrefabsDirtyAtPosition

      public void markPrefabsDirtyAtPosition(@Nonnull org.joml.Vector3i position)
      Marks any prefabs as dirty if the given position is within their bounding box.
      Parameters:
      position - The position to check.
    • markPrefabsDirtyInBounds

      public void markPrefabsDirtyInBounds(@Nonnull org.joml.Vector3i min, @Nonnull org.joml.Vector3i max)
      Marks any prefabs as dirty if the given bounding box intersects with their bounding box.
      Parameters:
      min - The minimum point of the bounding box.
      max - The maximum point of the bounding box.
    • createPrefabMarkers

      @Nonnull public MapMarker[] createPrefabMarkers()
      Creates world map markers for all prefabs in this edit session. Each marker is placed at the prefab's anchor point with the prefab's filename as the name.
      Returns:
      An array of markers for all loaded prefabs.
    • createPrefabMarker

      @Nonnull public static MapMarker createPrefabMarker(@Nonnull PrefabEditingMetadata metadata)
      Creates a single world map marker for a prefab.
      Parameters:
      metadata - The prefab metadata to create a marker for.
      Returns:
      A marker for the prefab.
    • clone

      @Nonnull public PrefabEditSession clone()
      Specified by:
      clone in interface Resource<EntityStore>
      Returns:
      a clone instance of the original resource instance.