Class FarmingUtil

java.lang.Object
com.hypixel.hytale.builtin.adventure.farming.FarmingUtil

public class FarmingUtil extends Object
A utility class for farming-related operations.
  • Constructor Details

    • FarmingUtil

      public FarmingUtil()
  • Method Details

    • tickFarming

      public static void tickFarming(@Nonnull CommandBuffer<ChunkStore> commandBuffer, @Nonnull BlockModule.BlockStateInfo blockStateInfo, @Nonnull BlockSection blockSection, @Nonnull Ref<ChunkStore> sectionRef, @Nonnull Ref<ChunkStore> blockRef, @Nonnull FarmingBlock farmingBlock, int x, int y, int z, boolean initialTick)
      Called to tick the farming block, progressing its growth as appropriate.
      Parameters:
      commandBuffer - The CommandBuffer<ChunkStore> for component access.
      blockStateInfo - The BlockModule.BlockStateInfo of the block.
      blockSection - The BlockSection containing the block.
      sectionRef - The entity reference of the chunk section.
      blockRef - The entity reference of the block.
      farmingBlock - The FarmingBlock component of the block.
      x - The X position of the block within the section.
      y - The Y position of the block within the section.
      z - The Z position of the block within the section.
      initialTick - Whether this is the initial tick for the block.
    • harvest

      public static boolean harvest(@Nonnull ComponentAccessor<ChunkStore> chunkStore, @Nonnull ComponentAccessor<EntityStore> entityStore, @Nullable Ref<EntityStore> ref, @Nonnull org.joml.Vector3i blockPosition)
      Called to attempt to harvest a fully grown farming block by position, resolving the block type and rotation from the block section. Use this when the caller has only a position. Pass a null instigator to harvest without an entity, for example from an automation plugin. The drops then fall into the world instead of being picked up.

      Pass a command buffer for the store that is processing and the direct store for the other. From an entity system, pass world.getChunkStore().getStore() with the entity command buffer. From a block tick, pass the chunk command buffer with world.getEntityStore().getStore().

      Parameters:
      chunkStore - The ComponentAccessor<ChunkStore> for block access and reset.
      entityStore - The ComponentAccessor<EntityStore> for the drops.
      ref - The entity reference of the instigating entity, or null for no instigator.
      blockPosition - The position of the block being harvested.
      Returns:
      whether the block was successfully harvested.
    • harvest

      public static boolean harvest(@Nonnull ComponentAccessor<ChunkStore> chunkStore, @Nonnull ComponentAccessor<EntityStore> entityStore, @Nullable Ref<EntityStore> ref, @Nonnull BlockType blockType, int rotationIndex, @Nonnull org.joml.Vector3i blockPosition)
      Called to attempt to harvest a fully grown farming block, giving drops and resetting or removing the block as appropriate. Use this fast path when the caller already has the block type and rotation, to skip the section lookup.
      Parameters:
      chunkStore - The ComponentAccessor<ChunkStore> for block access and reset.
      entityStore - The ComponentAccessor<EntityStore> for the drops.
      ref - The entity reference of the instigating entity, or null for no instigator.
      blockType - The BlockType of the block being harvested.
      rotationIndex - The rotation index of the block being harvested.
      blockPosition - The position of the block being harvested.
      Returns:
      whether the block was successfully harvested.
    • generateCapturedNPCMetadata

      @Nullable public static CapturedNPCMetadata generateCapturedNPCMetadata(@Nonnull ComponentAccessor<EntityStore> componentAccessor, @Nonnull Ref<EntityStore> entityRef, String npcNameKey)
      Called to generate captured NPC metadata for a farming NPC.
      Parameters:
      componentAccessor - The ComponentAccessor<EntityStore> for component access.
      entityRef - The entity reference of the NPC entity.
      npcNameKey - The asset identifier of the NPC.
      Returns:
      the generated CapturedNPCMetadata, or null if no metadata could be generated.