Class BlockSelection

java.lang.Object
com.hypixel.hytale.server.core.prefab.selection.standard.BlockSelection
All Implemented Interfaces:
MetricProvider, NetworkSerializable<EditorBlocksChange>

public class BlockSelection extends Object implements NetworkSerializable<EditorBlocksChange>, MetricProvider
  • Field Details

  • Constructor Details

    • BlockSelection

      public BlockSelection()
    • BlockSelection

      public BlockSelection(int initialBlockCapacity, int initialEntityCapacity)
    • BlockSelection

      public BlockSelection(@Nonnull BlockSelection other)
  • Method Details

    • getX

      public int getX()
    • getY

      public int getY()
    • getZ

      public int getZ()
    • getAnchorX

      public int getAnchorX()
    • getAnchorY

      public int getAnchorY()
    • getAnchorZ

      public int getAnchorZ()
    • getSelectionMin

      @Nonnull public org.joml.Vector3i getSelectionMin()
    • getSelectionMax

      @Nonnull public org.joml.Vector3i getSelectionMax()
    • hasSelectionBounds

      public boolean hasSelectionBounds()
    • getBlockCount

      public int getBlockCount()
    • getFluidCount

      public int getFluidCount()
    • getTintCount

      public int getTintCount()
    • getSelectionVolume

      public long getSelectionVolume()
    • getEntityCount

      public int getEntityCount()
    • setPosition

      public void setPosition(int x, int y, int z)
    • setAnchorAtWorldPos

      public void setAnchorAtWorldPos(int anchorX, int anchorY, int anchorZ)
    • setAnchor

      public void setAnchor(int anchorX, int anchorY, int anchorZ)
    • setSelectionArea

      public void setSelectionArea(@Nonnull org.joml.Vector3ic min, @Nonnull org.joml.Vector3ic max)
    • setPrefabId

      public void setPrefabId(int id)
    • getPrefabId

      public int getPrefabId()
    • copyPropertiesFrom

      public void copyPropertiesFrom(@Nonnull BlockSelection other)
    • compare

      public boolean compare(@Nonnull BlockSelection.BlockComparingIterator iterator)
    • hasBlockAtWorldPos

      public boolean hasBlockAtWorldPos(int x, int y, int z)
    • hasBlockAtLocalPos

      public boolean hasBlockAtLocalPos(int x, int y, int z)
    • getBlockAtWorldPos

      public int getBlockAtWorldPos(int x, int y, int z)
    • getBlockHolderAtWorldPos

      public BlockSelection.BlockHolder getBlockHolderAtWorldPos(int x, int y, int z)
    • getFluidAtWorldPos

      public int getFluidAtWorldPos(int x, int y, int z)
    • getFluidLevelAtWorldPos

      public byte getFluidLevelAtWorldPos(int x, int y, int z)
    • getSupportValueAtWorldPos

      public int getSupportValueAtWorldPos(int x, int y, int z)
    • getStateAtWorldPos

      @Nullable public Holder<ChunkStore> getStateAtWorldPos(int x, int y, int z)
    • forEachBlock

      public void forEachBlock(@Nonnull BlockSelection.BlockIterator iterator)
    • addTintAtLocalPos

      public void addTintAtLocalPos(int x, int z, int color)
    • addTintAtWorldPos

      public void addTintAtWorldPos(int worldX, int worldZ, int color)
    • getTintAtWorldPos

      public int getTintAtWorldPos(int worldX, int worldZ)
    • hasTintAtWorldPos

      public boolean hasTintAtWorldPos(int worldX, int worldZ)
    • forEachTint

      public void forEachTint(@Nonnull BlockSelection.TintIterator iterator)
    • forEachFluid

      public void forEachFluid(@Nonnull BlockSelection.FluidIterator iterator)
    • forEachEntity

      public void forEachEntity(Consumer<Holder<EntityStore>> consumer)
    • addEmptyAtWorldPos

      public void addEmptyAtWorldPos(int x, int y, int z)
    • addBlockAtWorldPos

      public void addBlockAtWorldPos(int x, int y, int z, int block, int rotation, int filler, int supportValue)
    • addBlockAtWorldPos

      public void addBlockAtWorldPos(int x, int y, int z, int block, int rotation, int filler, int supportValue, Holder<ChunkStore> state)
    • addBlockAtLocalPos

      public void addBlockAtLocalPos(int x, int y, int z, int block, int rotation, int filler, int supportValue)
    • addBlockAtLocalPos

      public void addBlockAtLocalPos(int x, int y, int z, int block, int rotation, int filler, int supportValue, Holder<ChunkStore> state)
    • beginHolderInterning

      public void beginHolderInterning()
    • endHolderInterning

      public void endHolderInterning()
    • trimToSize

      public void trimToSize()
    • addFluidAtWorldPos

      public void addFluidAtWorldPos(int x, int y, int z, int fluidId, byte fluidLevel)
    • addFluidAtLocalPos

      public void addFluidAtLocalPos(int x, int y, int z, int fluidId, byte fluidLevel)
    • reserializeBlockStates

      public void reserializeBlockStates(ChunkStore store, boolean destructive)
    • clearAllSupportValues

      public void clearAllSupportValues()
    • setAllSupportValues

      public void setAllSupportValues(int supportValue)
    • setSupportValueAtLocalPos

      public void setSupportValueAtLocalPos(int x, int y, int z, int supportValue)
    • addEntityFromWorld

      public void addEntityFromWorld(@Nonnull Holder<EntityStore> entityHolder)
    • addEntityHolderRaw

      public void addEntityHolderRaw(Holder<EntityStore> entityHolder)
    • sortEntitiesByPosition

      public void sortEntitiesByPosition()
    • placeNoReturn

      public void placeNoReturn(@Nonnull World world, org.joml.Vector3i position, ComponentAccessor<EntityStore> componentAccessor)
    • placeNoReturn

      public void placeNoReturn(String feedbackKey, CommandSender feedback, @Nonnull World outerWorld, ComponentAccessor<EntityStore> componentAccessor)
    • placeNoReturn

      public void placeNoReturn(String feedbackKey, CommandSender feedback, @Nonnull FeedbackConsumer feedbackConsumer, @Nonnull World outerWorld, ComponentAccessor<EntityStore> componentAccessor)
    • placeNoReturn

      public void placeNoReturn(@Nullable String feedbackKey, @Nullable CommandSender feedback, @Nonnull FeedbackConsumer feedbackConsumer, @Nonnull World outerWorld, @Nullable org.joml.Vector3ic position, @Nullable BlockMask blockMask, ComponentAccessor<EntityStore> componentAccessor)
    • computePlacementBounds

      public boolean computePlacementBounds(@Nullable org.joml.Vector3ic position, @Nonnull org.joml.Vector3i minOut, @Nonnull org.joml.Vector3i maxOut)
      Computes the world bounds that place(CommandSender, World) writes to. Blocks and fluids move by the position and the anchor. Tints move by the selection position only.
      Returns:
      false if the selection holds no cells. The output vectors then stay unchanged.
    • place

      @Nonnull public BlockSelection place(CommandSender feedback, @Nonnull World outerWorld)
    • place

      @Nonnull public BlockSelection place(CommandSender feedback, @Nonnull World outerWorld, BlockMask blockMask)
    • place

      @Nonnull public BlockSelection place(CommandSender feedback, @Nonnull World outerWorld, org.joml.Vector3ic position, BlockMask blockMask)
    • place

      @Nonnull public BlockSelection place(CommandSender feedback, @Nonnull World outerWorld, @Nullable org.joml.Vector3ic position, @Nullable BlockMask blockMask, @Nonnull Consumer<Ref<EntityStore>> entityConsumer)
    • place

      @Nonnull public BlockSelection place(CommandSender feedback, @Nonnull World outerWorld, @Nullable org.joml.Vector3ic position, @Nullable BlockMask blockMask, @Nonnull Consumer<Ref<EntityStore>> entityConsumer, boolean skipEmptyBlocks)
    • place

      @Nonnull public BlockSelection place(CommandSender feedback, @Nonnull World outerWorld, @Nullable org.joml.Vector3ic position, @Nullable BlockMask blockMask, @Nonnull Consumer<Ref<EntityStore>> entityConsumer, boolean skipEmptyBlocks, @Nullable IntUnaryOperator blockIdMapper)
    • place

      @Nonnull public BlockSelection place(CommandSender feedback, @Nonnull World outerWorld, @Nullable org.joml.Vector3ic position, @Nullable BlockMask blockMask, @Nonnull Consumer<Ref<EntityStore>> entityConsumer, boolean skipEmptyBlocks, @Nullable IntUnaryOperator blockIdMapper, boolean skipEmptyBlocksBeforeMapping)
    • rotate

      @Nonnull public BlockSelection rotate(@Nonnull Axis axis, int angle)
    • rotate

      @Nonnull public BlockSelection rotate(@Nonnull Axis axis, int angle, @Nonnull RotateBlockMode rotateBlockMode)
      Rotates the selection by the given angle around the given axis.
      Parameters:
      rotateBlockMode - controls which blocks have their orientation rotated: "All" – all blocks use composeOnAxis (default); "NonFullBlocks" – only blocks whose hitbox is not "Full" are rotated; "NonUniform" – only blocks with non-uniform cube textures are rotated (i.e. blocks that look different from different angles); uniform blocks like cobblestone or gravel keep their orientation while directional blocks like logs and grass do rotate; "Nothing" – block positions move but all orientations are preserved.
    • rotate

      @Nonnull public BlockSelection rotate(@Nonnull Axis axis, int angle, @Nonnull org.joml.Vector3d originOfRotation)
    • rotateArbitrary

      @Nonnull public BlockSelection rotateArbitrary(float yawDegrees, float pitchDegrees, float rollDegrees)
      Rotates the selection by arbitrary yaw, pitch, and roll angles in degrees.

      This method uses inverse mapping (destination-to-source) to ensure no gaps in the output. For each position in the destination bounding box, the inverse rotation is applied to find the corresponding source position, then the nearest source block is sampled.

      Block-level rotation metadata is snapped to the nearest 90-degree increments since individual blocks only support 90-degree rotation steps.

      Parameters:
      yawDegrees - Rotation around the Y-axis (vertical) in degrees
      pitchDegrees - Rotation around the X-axis in degrees
      rollDegrees - Rotation around the Z-axis in degrees
      Returns:
      A new BlockSelection containing the rotated blocks
    • flip

      @Nonnull public BlockSelection flip(@Nonnull Axis axis)
    • relativize

      @Nonnull public BlockSelection relativize()
    • relativize

      @Nonnull public BlockSelection relativize(int originX, int originY, int originZ)
    • relativizeInPlace

      public void relativizeInPlace()
      Relativizes this selection against its anchor in place. Unlike relativize() this mutates the selection and reuses its holders instead of allocating a full copy, so it must only be called on a selection that is not shared with anything else.
    • relativizeInPlace

      public void relativizeInPlace(int originX, int originY, int originZ)
    • cloneSelection

      @Nonnull public BlockSelection cloneSelection()
    • add

      public void add(@Nonnull BlockSelection other)
    • toMetricResults

      @Nonnull public MetricResults toMetricResults()
      Specified by:
      toMetricResults in interface MetricProvider
    • toPacket

      @Nonnull public EditorBlocksChange toPacket()
      Specified by:
      toPacket in interface NetworkSerializable<EditorBlocksChange>
    • toClipboardEntityChange

      @Nullable public static ClipboardEntityChange toClipboardEntityChange(@Nonnull Holder<EntityStore> holder, double anchorX, double anchorY, double anchorZ)
    • toEditorSelectionBounds

      @Nonnull public EditorSelection toEditorSelectionBounds()
    • toSelectionPacket

      @Nonnull public EditorBlocksChange toSelectionPacket()
    • toBoundsOnlyPacket

      @Nonnull public EditorBlocksChange toBoundsOnlyPacket()
    • toShapePacket

      @Nonnull public EditorBlocksChange toShapePacket(int maxVolume)
    • toPacketWithSelection

      @Nonnull public EditorBlocksChange toPacketWithSelection()
    • tryFixFiller

      public void tryFixFiller(boolean allowDestructive)
    • reserializeEntities

      public void reserializeEntities(@Nonnull Store<EntityStore> store, boolean destructive) throws IOException
      Throws:
      IOException
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object