Class ItemScanTool

java.lang.Object
net.minecraft.world.item.Item
com.ldtteam.structurize.items.AbstractItemWithPosSelector
com.ldtteam.structurize.items.ItemScanTool
All Implemented Interfaces:
IScrollableItem, ISpecialBlockPickItem, net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike, net.neoforged.neoforge.common.extensions.IItemExtension

public class ItemScanTool extends AbstractItemWithPosSelector implements IScrollableItem, ISpecialBlockPickItem
Item used to scan structures.
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.ldtteam.structurize.items.AbstractItemWithPosSelector

    AbstractItemWithPosSelector.PosSelection

    Nested classes/interfaces inherited from class net.minecraft.world.item.Item

    net.minecraft.world.item.Item.Properties, net.minecraft.world.item.Item.TooltipContext
  • Field Summary

    Fields inherited from class net.minecraft.world.item.Item

    ABSOLUTE_MAX_STACK_SIZE, BASE_ATTACK_DAMAGE_ID, BASE_ATTACK_SPEED_ID, BY_BLOCK, canRepair, DEFAULT_MAX_STACK_SIZE, MAX_BAR_WIDTH

    Fields inherited from interface net.minecraft.world.flag.FeatureElement

    FILTERED_REGISTRIES
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates default scan tool item.
    ItemScanTool(net.minecraft.world.item.Item.Properties properties)
    MC constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendHoverText(@NotNull net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.world.item.Item.TooltipContext world, @NotNull List<net.minecraft.network.chat.Component> tooltip, @NotNull net.minecraft.world.item.TooltipFlag flags)
     
    boolean
    canAttackBlock(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
    Structurize: Prevent block breaking server side.
    static @Nullable net.minecraft.core.BlockPos
    getAnchorPos(@NotNull net.minecraft.world.item.ItemStack tool)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static @Nullable BoxPreviewData
    getBox(@NotNull net.minecraft.world.item.ItemStack tool, @NotNull net.minecraft.world.entity.player.Player player)
    Gets the coordinates of this tool as a BoxPreviewData
    net.minecraft.network.chat.Component
    getHighlightTip(@NotNull net.minecraft.world.item.ItemStack stack, @NotNull net.minecraft.network.chat.Component displayName)
     
    Uses to search for correct itemstack in both hands.
    static String
    getStructureName(@NotNull net.minecraft.world.item.ItemStack tool)
    Deprecated, for removal: This API element is subject to removal in a future version.
    loadSlot(@NotNull ScanToolData data, @NotNull net.minecraft.world.item.ItemStack stack)
     
    net.minecraft.world.InteractionResult
    onAirRightClick(net.minecraft.core.BlockPos start, net.minecraft.core.BlockPos end, net.minecraft.world.level.Level worldIn, net.minecraft.world.entity.player.Player playerIn, net.minecraft.world.item.ItemStack itemStack)
    Is called when player air-right-clicks with item.
    @NotNull net.minecraft.world.InteractionResult
    onBlockPick(@NotNull net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.world.item.ItemStack stack, @Nullable net.minecraft.core.BlockPos pos, boolean ctrlKey)
    Called first on client side when the player presses "pick block" (default middle mouse) with this item selected.
    @NotNull net.minecraft.world.InteractionResult
    onMouseScroll(@NotNull net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.world.item.ItemStack stack, double deltaX, double deltaY, boolean ctrlKey)
    Called first on client side when the player shift-scrolls with this item selected.
    boolean
    onTeleport(@NotNull net.minecraft.world.entity.player.Player player, @NotNull net.minecraft.world.item.ItemStack stack)
    Called on both client and server when the player presses the Teleport keybind while holding a scan tool.
    static void
    saveStructure(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, ScanToolData.Slot slot, boolean saveEntities)
    Scan the structure and save it to the disk.
    static void
    setAnchorPos(@NotNull net.minecraft.world.item.ItemStack tool, @Nullable net.minecraft.core.BlockPos anchor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static void
    setStructureName(@NotNull net.minecraft.world.item.ItemStack tool, @Nullable String name)
    Deprecated, for removal: This API element is subject to removal in a future version.

    Methods inherited from class com.ldtteam.structurize.items.AbstractItemWithPosSelector

    getBounds, getDestroySpeed, setBounds, use, useOn

    Methods inherited from class net.minecraft.world.item.Item

    asItem, builtInRegistryHolder, byBlock, byId, canFitInsideContainerItems, components, finishUsingItem, getAttackDamageBonus, getBarColor, getBarWidth, getBreakingSound, getCraftingRemainingItem, getDefaultAttributeModifiers, getDefaultInstance, getDefaultMaxStackSize, getDescription, getDescriptionId, getDescriptionId, getDrinkingSound, getEatingSound, getEnchantmentValue, getId, getName, getOrCreateDescriptionId, getPlayerPOVHitResult, getTooltipImage, getUseAnimation, getUseDuration, hasCraftingRemainingItem, hurtEnemy, initializeClient, interactLivingEntity, inventoryTick, isBarVisible, isComplex, isCorrectToolForDrops, isEnchantable, isFoil, isRepairable, isValidRepairItem, mineBlock, modifyDefaultComponentsFrom, onCraftedBy, onCraftedPostProcess, onDestroyed, onUseTick, overrideOtherStackedOnMe, overrideStackedOnOther, postHurtEnemy, releaseUsing, requiredFeatures, toString, useOnRelease, verifyComponentsAfterLoad

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.minecraft.world.flag.FeatureElement

    isEnabled

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IItemExtension

    applyEnchantments, canBeHurtBy, canContinueUsing, canDisableShield, canElytraFly, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, elytraFlightTick, getAllEnchantments, getArmorTexture, getBurnTime, getCraftingRemainingItem, getCreatorModId, getDamage, getDefaultAttributeModifiers, getEnchantmentLevel, getEnchantmentValue, getEntityLifespan, getEquipmentSlot, getFoodProperties, getMaxDamage, getMaxStackSize, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, hasCustomEntity, isBookEnchantable, isDamageable, isDamaged, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, isPrimaryItemFor, makesPiglinsNeutral, onAnimalArmorTick, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onEntitySwing, onItemUseFirst, onLeftClickEntity, onStopUsing, setDamage, shouldCauseBlockBreakReset, shouldCauseReequipAnimation, supportsEnchantment
  • Constructor Details

    • ItemScanTool

      public ItemScanTool()
      Creates default scan tool item.
    • ItemScanTool

      public ItemScanTool(net.minecraft.world.item.Item.Properties properties)
      MC constructor.
      Parameters:
      properties - properties
  • Method Details

    • onAirRightClick

      public net.minecraft.world.InteractionResult onAirRightClick(net.minecraft.core.BlockPos start, net.minecraft.core.BlockPos end, net.minecraft.world.level.Level worldIn, net.minecraft.world.entity.player.Player playerIn, net.minecraft.world.item.ItemStack itemStack)
      Description copied from class: AbstractItemWithPosSelector
      Is called when player air-right-clicks with item.
      Specified by:
      onAirRightClick in class AbstractItemWithPosSelector
      Parameters:
      start - first pos
      end - second pos
      worldIn - event world
      playerIn - event player
      Returns:
      event result, typically success
    • getRegisteredItemInstance

      public AbstractItemWithPosSelector getRegisteredItemInstance()
      Description copied from class: AbstractItemWithPosSelector
      Uses to search for correct itemstack in both hands.
      Specified by:
      getRegisteredItemInstance in class AbstractItemWithPosSelector
      Returns:
      item reference from ModItems
    • saveStructure

      public static void saveStructure(net.minecraft.world.level.Level world, net.minecraft.world.entity.player.Player player, ScanToolData.Slot slot, boolean saveEntities)
      Scan the structure and save it to the disk.
      Parameters:
      world - Current world.
      player - causing this action.
      slot - the scan data.
      saveEntities - whether to scan in entities
    • canAttackBlock

      public boolean canAttackBlock(net.minecraft.world.level.block.state.BlockState state, net.minecraft.world.level.Level worldIn, net.minecraft.core.BlockPos pos, net.minecraft.world.entity.player.Player player)
      Description copied from class: AbstractItemWithPosSelector
      Structurize: Prevent block breaking server side.
      Overrides:
      canAttackBlock in class AbstractItemWithPosSelector
    • appendHoverText

      public void appendHoverText(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.world.item.Item.TooltipContext world, @NotNull @NotNull List<net.minecraft.network.chat.Component> tooltip, @NotNull @NotNull net.minecraft.world.item.TooltipFlag flags)
      Overrides:
      appendHoverText in class net.minecraft.world.item.Item
    • getHighlightTip

      public net.minecraft.network.chat.Component getHighlightTip(@NotNull @NotNull net.minecraft.world.item.ItemStack stack, @NotNull @NotNull net.minecraft.network.chat.Component displayName)
      Specified by:
      getHighlightTip in interface net.neoforged.neoforge.common.extensions.IItemExtension
    • onBlockPick

      @NotNull public @NotNull net.minecraft.world.InteractionResult onBlockPick(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.world.item.ItemStack stack, @Nullable @Nullable net.minecraft.core.BlockPos pos, boolean ctrlKey)
      Description copied from interface: ISpecialBlockPickItem
      Called first on client side when the player presses "pick block" (default middle mouse) with this item selected. If that succeeds, called again on server side.
      Specified by:
      onBlockPick in interface ISpecialBlockPickItem
      Parameters:
      player - the player
      stack - the item stack
      pos - the focused block, or null if on air
      ctrlKey - ctrl key is pressed too
      Returns:
      (client) return SUCCESS to send to server, FAIL to cancel, or PASS to do normal pick action. (server) return value is ignored.
    • onMouseScroll

      @NotNull public @NotNull net.minecraft.world.InteractionResult onMouseScroll(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.world.item.ItemStack stack, double deltaX, double deltaY, boolean ctrlKey)
      Description copied from interface: IScrollableItem
      Called first on client side when the player shift-scrolls with this item selected. If that succeeds, called again on server side.
      Specified by:
      onMouseScroll in interface IScrollableItem
      Parameters:
      player - the player
      stack - the item stack
      deltaX - the scroll delta; negative is up, positive is down
      deltaY - the scroll delta; negative is up, positive is down
      ctrlKey - the ctrl key is held
      Returns:
      (client) return SUCCESS to pass to server, FAIL to cancel, or PASS to do normal scrolling. (server) return value is ignored.
    • loadSlot

      public ScanToolData.Slot loadSlot(@NotNull @NotNull ScanToolData data, @NotNull @NotNull net.minecraft.world.item.ItemStack stack)
    • onTeleport

      public boolean onTeleport(@NotNull @NotNull net.minecraft.world.entity.player.Player player, @NotNull @NotNull net.minecraft.world.item.ItemStack stack)
      Called on both client and server when the player presses the Teleport keybind while holding a scan tool.
      Parameters:
      player - the player
      stack - the scan tool
      Returns:
      (client) true to pass to server, false to drop; (server) don't care
    • getBox

      @Nullable public static @Nullable BoxPreviewData getBox(@NotNull @NotNull net.minecraft.world.item.ItemStack tool, @NotNull @NotNull net.minecraft.world.entity.player.Player player)
      Gets the coordinates of this tool as a BoxPreviewData
      Parameters:
      tool - The tool stack (assumed already been validated)
      player - The player who will be notified if it has a bad anchor position
      Returns:
      the box
    • setAnchorPos

      @Deprecated(forRemoval=true, since="1.21") public static void setAnchorPos(@NotNull @NotNull net.minecraft.world.item.ItemStack tool, @Nullable @Nullable net.minecraft.core.BlockPos anchor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Saves the anchor coordinates on this stack.
      Parameters:
      tool - The tool stack (assumed already been validated)
      anchor - The new anchor position (or null to clear)
    • getAnchorPos

      @Nullable @Deprecated(forRemoval=true, since="1.21") public static @Nullable net.minecraft.core.BlockPos getAnchorPos(@NotNull @NotNull net.minecraft.world.item.ItemStack tool)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Loads the anchor coordinates from this stack.
      Parameters:
      tool - The tool stack (assumed already been validated)
      Returns:
      the anchor position or null
    • setStructureName

      @Deprecated(forRemoval=true, since="1.21") public static void setStructureName(@NotNull @NotNull net.minecraft.world.item.ItemStack tool, @Nullable @Nullable String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Saves the structure name on this stack.
      Parameters:
      tool - The tool stack (assumed already validated)
      name - The structure name (or null/empty to clear)
    • getStructureName

      @Deprecated(forRemoval=true, since="1.21") public static String getStructureName(@NotNull @NotNull net.minecraft.world.item.ItemStack tool)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the structure name saved on this stack.
      Parameters:
      tool - The tool stack (assumed already validated)
      Returns:
      The structure name (or empty string)