Contents
- Description
- Constructor Summary
- Method Summary
- Constructor Details
- Method Details
- tickFarming(CommandBuffer, BlockModule.BlockStateInfo, BlockSection, Ref, Ref, FarmingBlock, int, int, int, boolean)
- harvest(ComponentAccessor, ComponentAccessor, Ref, Vector3i)
- harvest(ComponentAccessor, ComponentAccessor, Ref, BlockType, int, Vector3i)
- generateCapturedNPCMetadata(ComponentAccessor, Ref, String)
Class FarmingUtil
java.lang.Object
com.hypixel.hytale.builtin.adventure.farming.FarmingUtil
A utility class for farming-related operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic CapturedNPCMetadatagenerateCapturedNPCMetadata(ComponentAccessor<EntityStore> componentAccessor, Ref<EntityStore> entityRef, String npcNameKey) Called to generate captured NPC metadata for a farming NPC.static booleanharvest(ComponentAccessor<ChunkStore> chunkStore, ComponentAccessor<EntityStore> entityStore, Ref<EntityStore> ref, BlockType blockType, int rotationIndex, org.joml.Vector3i blockPosition) Called to attempt to harvest a fully grown farming block, giving drops and resetting or removing the block as appropriate.static booleanharvest(ComponentAccessor<ChunkStore> chunkStore, ComponentAccessor<EntityStore> entityStore, Ref<EntityStore> ref, 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.static voidtickFarming(CommandBuffer<ChunkStore> commandBuffer, BlockModule.BlockStateInfo blockStateInfo, BlockSection blockSection, Ref<ChunkStore> sectionRef, Ref<ChunkStore> blockRef, FarmingBlock farmingBlock, int x, int y, int z, boolean initialTick) Called to tick the farming block, progressing its growth as appropriate.
-
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- TheCommandBuffer<ChunkStore>for component access.blockStateInfo- TheBlockModule.BlockStateInfoof the block.blockSection- TheBlockSectioncontaining the block.sectionRef- The entity reference of the chunk section.blockRef- The entity reference of the block.farmingBlock- TheFarmingBlockcomponent 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 anullinstigator 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 withworld.getEntityStore().getStore().- Parameters:
chunkStore- TheComponentAccessor<ChunkStore>for block access and reset.entityStore- TheComponentAccessor<EntityStore>for the drops.ref- The entity reference of the instigating entity, ornullfor 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- TheComponentAccessor<ChunkStore>for block access and reset.entityStore- TheComponentAccessor<EntityStore>for the drops.ref- The entity reference of the instigating entity, ornullfor no instigator.blockType- TheBlockTypeof 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- TheComponentAccessor<EntityStore>for component access.entityRef- The entity reference of the NPC entity.npcNameKey- The asset identifier of the NPC.- Returns:
- the generated
CapturedNPCMetadata, ornullif no metadata could be generated.
-