Class PersistentPrefabPreview

java.lang.Object
com.hypixel.hytale.server.core.modules.entity.component.PersistentPrefabPreview
All Implemented Interfaces:
Component<EntityStore>, Cloneable

public class PersistentPrefabPreview extends Object implements Component<EntityStore>
Persists a prefab-preview ("hologram") anchor: which prefab to show and how many bottom layers of it are currently visible. The resolved block data is not persisted. On load the runtime PrefabPreview component re-resolves the blocks from the prefab key.

Tint is derived from the anchor's world position by default. A caller may instead pin an explicit biome/water tint, which is persisted so it survives restarts.

See Also:
  • Field Details

  • Constructor Details

    • PersistentPrefabPreview

      public PersistentPrefabPreview(@Nonnull String prefabKey, int visibleLayerCount)
    • PersistentPrefabPreview

      public PersistentPrefabPreview(@Nonnull String prefabKey, int visibleLayerCount, int biomeTint, int waterTint)
  • Method Details

    • getComponentType

      public static ComponentType<EntityStore, PersistentPrefabPreview> getComponentType()
    • spawn

      @Nonnull public static Ref<EntityStore> spawn(@Nonnull Store<EntityStore> store, @Nonnull org.joml.Vector3d position, @Nonnull Rotation3f rotation, @Nonnull String prefabKey, int visibleLayerCount)
      Spawns a prefab-preview ("hologram") entity showing the lowest visibleLayerCount layers of the prefab at the given position, tinted to match the local biome. The prefab resolves to blocks on the world thread, so call this from the thread that owns the store.
    • spawn

      @Nonnull public static Ref<EntityStore> spawn(@Nonnull Store<EntityStore> store, @Nonnull org.joml.Vector3d position, @Nonnull Rotation3f rotation, @Nonnull String prefabKey, int visibleLayerCount, int biomeTint, int waterTint)
      Spawns a prefab preview with an explicit biome/water tint instead of deriving one from the world.
    • updateLayers

      public static void updateLayers(@Nonnull Store<EntityStore> store, @Nonnull Ref<EntityStore> ref, int visibleLayerCount)
      Changes how many bottom layers a spawned preview shows, updating both the persisted state and the live synced component.
    • remove

      public static void remove(@Nonnull Store<EntityStore> store, @Nonnull Ref<EntityStore> ref)
    • getPrefabKey

      @Nonnull public String getPrefabKey()
    • getVisibleLayerCount

      public int getVisibleLayerCount()
    • hasTintOverride

      public boolean hasTintOverride()
    • getBiomeTint

      public int getBiomeTint()
    • getWaterTint

      public int getWaterTint()
    • setVisibleLayerCount

      public void setVisibleLayerCount(int visibleLayerCount)
    • clone

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