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.minecraftforge.common.extensions.IForgeItem

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

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

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

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

    BASE_ATTACK_DAMAGE_UUID, BASE_ATTACK_SPEED_UUID, BY_BLOCK, canRepair, EAT_DURATION, MAX_BAR_WIDTH, MAX_STACK_SIZE

    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.level.Level 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)
    Loads the anchor coordinates from this stack.
    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)
    Gets the structure name saved on this stack.
    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 delta, 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)
    Saves the anchor coordinates on this stack.
    static void
    setStructureName(@NotNull net.minecraft.world.item.ItemStack tool, @Nullable String name)
    Saves the structure name on this stack.

    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, canBeDepleted, canBeHurtBy, canFitInsideContainerItems, finishUsingItem, getBarColor, getBarWidth, getCraftingRemainingItem, getDefaultAttributeModifiers, getDefaultInstance, getDescription, getDescriptionId, getDescriptionId, getDrinkingSound, getEatingSound, getEnchantmentValue, getFoodProperties, getId, getMaxDamage, getMaxStackSize, getName, getOrCreateDescriptionId, getPlayerPOVHitResult, getRarity, getRenderPropertiesInternal, getTooltipImage, getUseAnimation, getUseDuration, hasCraftingRemainingItem, hurtEnemy, initializeClient, interactLivingEntity, inventoryTick, isBarVisible, isComplex, isCorrectToolForDrops, isEdible, isEnchantable, isFireResistant, isFoil, isRepairable, isValidRepairItem, mineBlock, onCraftedBy, onDestroyed, onUseTick, overrideOtherStackedOnMe, overrideStackedOnOther, releaseUsing, requiredFeatures, shouldOverrideMultiplayerNbt, toString, useOnRelease, verifyTagAfterLoad

    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.minecraftforge.common.extensions.IForgeItem

    canApplyAtEnchantingTable, canContinueUsing, canDisableShield, canElytraFly, canEquip, canGrindstoneRepair, canPerformAction, canWalkOnPowderedSnow, createEntity, damageItem, doesSneakBypassUse, elytraFlightTick, getAllEnchantments, getArmorTexture, getAttributeModifiers, getBurnTime, getCraftingRemainingItem, getCreatorModId, getDamage, getDefaultTooltipHideFlags, getEnchantmentLevel, getEnchantmentValue, getEntityLifespan, getEquipmentSlot, getFoodProperties, getMaxDamage, getMaxStackSize, getShareTag, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, hasCustomEntity, initCapabilities, isBookEnchantable, isCorrectToolForDrops, isDamageable, isDamaged, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, makesPiglinsNeutral, onArmorTick, onBlockStartBreak, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onHorseArmorTick, onItemUseFirst, onLeftClickEntity, onStopUsing, readShareTag, setDamage, shouldCauseBlockBreakReset, shouldCauseReequipAnimation
  • 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.level.Level 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.minecraftforge.common.extensions.IForgeItem
    • 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 delta, 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
      delta - 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

      public static 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

      public static void setAnchorPos(@NotNull @NotNull net.minecraft.world.item.ItemStack tool, @Nullable @Nullable net.minecraft.core.BlockPos anchor)
      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 public static @Nullable net.minecraft.core.BlockPos getAnchorPos(@NotNull @NotNull net.minecraft.world.item.ItemStack tool)
      Loads the anchor coordinates from this stack.
      Parameters:
      tool - The tool stack (assumed already been validated)
      Returns:
      the anchor position or null
    • setStructureName

      public static void setStructureName(@NotNull @NotNull net.minecraft.world.item.ItemStack tool, @Nullable @Nullable String name)
      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

      public static String getStructureName(@NotNull @NotNull net.minecraft.world.item.ItemStack tool)
      Gets the structure name saved on this stack.
      Parameters:
      tool - The tool stack (assumed already validated)
      Returns:
      The structure name (or empty string)