Class GPSAreaToolItem

java.lang.Object
net.minecraft.world.item.Item
me.desht.pneumaticcraft.common.item.GPSAreaToolItem
All Implemented Interfaces:
IPositionProvider, IGPSToolSync, net.minecraft.world.flag.FeatureElement, net.minecraft.world.level.ItemLike, net.minecraftforge.common.extensions.IForgeItem

public class GPSAreaToolItem extends net.minecraft.world.item.Item implements IPositionProvider, IGPSToolSync
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     

    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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    appendHoverText(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level worldIn, List<net.minecraft.network.chat.Component> infoList, net.minecraft.world.item.TooltipFlag par4)
     
    boolean
    Whether or not the rendered positions should be visible through the world.
    getArea(UUID playerId, net.minecraft.world.item.ItemStack stack)
     
    getArea(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
     
    static Optional<net.minecraft.core.BlockPos>
    getGPSLocation(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack gpsTool, int index)
     
    List<net.minecraft.core.BlockPos>
    getRawStoredPositions(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
    Gets the raw stored positions in this provider.
    int
    getRenderColor(int index)
    Color that should be used to highlight the stored block positions if & when they are rendered on-screen.
    List<net.minecraft.core.BlockPos>
    getStoredPositions(UUID playerId, net.minecraft.world.item.ItemStack stack)
    Get block position data from the given ItemStack.
    static String
    getVariable(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack gpsTool, int index)
     
    void
    inventoryTick(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level world, net.minecraft.world.entity.Entity entity, int slot, boolean heldItem)
     
    static void
    setGPSPosAndNotify(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, int index)
     
    static void
    setGPSPosAndNotify(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, net.minecraft.core.BlockPos pos, int index)
     
    static void
    setVariable(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack gpsTool, String variable, int index)
     
    void
    syncFromClient(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, int index, net.minecraft.core.BlockPos pos, String varName)
    Called when the GPS (Area) Tool GUI is closed, to send position & variable information to server
    void
    syncVariables(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack stack)
    If the item stores any global variables which the client needs to know about (e.g.
    net.minecraft.world.InteractionResultHolder<net.minecraft.world.item.ItemStack>
    use(net.minecraft.world.level.Level worldIn, net.minecraft.world.entity.player.Player playerIn, net.minecraft.world.InteractionHand handIn)
     
    net.minecraft.world.InteractionResult
    useOn(net.minecraft.world.item.context.UseOnContext ctx)
     

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

    asItem, builtInRegistryHolder, byBlock, byId, canAttackBlock, canBeDepleted, canBeHurtBy, canFitInsideContainerItems, finishUsingItem, getBarColor, getBarWidth, getCraftingRemainingItem, getDefaultAttributeModifiers, getDefaultInstance, getDescription, getDescriptionId, getDescriptionId, getDestroySpeed, getDrinkingSound, getEatingSound, getEnchantmentValue, getFoodProperties, getId, getMaxDamage, getMaxStackSize, getName, getOrCreateDescriptionId, getPlayerPOVHitResult, getRarity, getRenderPropertiesInternal, getTooltipImage, getUseAnimation, getUseDuration, hasCraftingRemainingItem, hurtEnemy, initializeClient, interactLivingEntity, 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, getHighlightTip, getMaxDamage, getMaxStackSize, getShareTag, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, hasCustomEntity, initCapabilities, isBookEnchantable, isCorrectToolForDrops, isDamageable, isDamaged, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, makesPiglinsNeutral, onArmorTick, onBlockStartBreak, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onHorseArmorTick, onInventoryTick, onItemUseFirst, onLeftClickEntity, onStopUsing, readShareTag, setDamage, shouldCauseBlockBreakReset, shouldCauseReequipAnimation
  • Constructor Details

    • GPSAreaToolItem

      public GPSAreaToolItem()
  • Method Details

    • useOn

      public net.minecraft.world.InteractionResult useOn(net.minecraft.world.item.context.UseOnContext ctx)
      Overrides:
      useOn in class net.minecraft.world.item.Item
    • use

      public net.minecraft.world.InteractionResultHolder<net.minecraft.world.item.ItemStack> use(net.minecraft.world.level.Level worldIn, net.minecraft.world.entity.player.Player playerIn, net.minecraft.world.InteractionHand handIn)
      Overrides:
      use in class net.minecraft.world.item.Item
    • setGPSPosAndNotify

      public static void setGPSPosAndNotify(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, net.minecraft.core.BlockPos pos, int index)
    • setGPSPosAndNotify

      public static void setGPSPosAndNotify(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, int index)
    • appendHoverText

      public void appendHoverText(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level worldIn, List<net.minecraft.network.chat.Component> infoList, net.minecraft.world.item.TooltipFlag par4)
      Overrides:
      appendHoverText in class net.minecraft.world.item.Item
    • inventoryTick

      public void inventoryTick(net.minecraft.world.item.ItemStack stack, net.minecraft.world.level.Level world, net.minecraft.world.entity.Entity entity, int slot, boolean heldItem)
      Overrides:
      inventoryTick in class net.minecraft.world.item.Item
    • getArea

      @Nonnull public static ProgWidgetArea getArea(UUID playerId, net.minecraft.world.item.ItemStack stack)
    • getArea

      public static ProgWidgetArea getArea(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
    • getGPSLocation

      public static Optional<net.minecraft.core.BlockPos> getGPSLocation(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack gpsTool, int index)
    • setVariable

      public static void setVariable(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack gpsTool, String variable, int index)
    • getVariable

      public static String getVariable(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack gpsTool, int index)
    • syncVariables

      public void syncVariables(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack stack)
      Description copied from interface: IPositionProvider
      If the item stores any global variables which the client needs to know about (e.g. for area rendering), override this method to sync their values to the client. This method is called server-side when an item in any player's inventory (which implements IPositionProvider) changes in any way.

      See IMiscHelpers.syncGlobalVariable(ServerPlayer, String) for a convenience method to send the necessary sync packet.

      Specified by:
      syncVariables in interface IPositionProvider
      Parameters:
      player - the player to sync to
      stack - the itemstack
    • getStoredPositions

      public List<net.minecraft.core.BlockPos> getStoredPositions(UUID playerId, @Nonnull net.minecraft.world.item.ItemStack stack)
      Description copied from interface: IPositionProvider
      Get block position data from the given ItemStack. It is up to the implementor to decide how the block positions should be stored on the itemstack and in what order they should be returned.
      Specified by:
      getStoredPositions in interface IPositionProvider
      Parameters:
      playerId - the player, for player-global variable context (may be null)
      stack - the itemstack
      Returns:
      a list of block positions that has been retrieved from the itemstack
    • getRawStoredPositions

      public List<net.minecraft.core.BlockPos> getRawStoredPositions(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack)
      Description copied from interface: IPositionProvider
      Gets the raw stored positions in this provider. E.g. for the GPS Area Tool, just the two clicked positions, not the whole set of positions defined by the tool's area type.
      Specified by:
      getRawStoredPositions in interface IPositionProvider
      Parameters:
      player - the player, for player-global variable context
      stack - the itemstack
      Returns:
      the raw positions stored on the itemstack
    • getRenderColor

      public int getRenderColor(int index)
      Description copied from interface: IPositionProvider
      Color that should be used to highlight the stored block positions if & when they are rendered on-screen.
      Specified by:
      getRenderColor in interface IPositionProvider
      Parameters:
      index - the index in the list returned by getStoredPositions()
      Returns:
      a color in ARGB format, or 0 to skip rendering completely
    • disableDepthTest

      public boolean disableDepthTest()
      Description copied from interface: IPositionProvider
      Whether or not the rendered positions should be visible through the world.
      Specified by:
      disableDepthTest in interface IPositionProvider
      Returns:
      true if visible through the world, false if not.
    • syncFromClient

      public void syncFromClient(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, int index, net.minecraft.core.BlockPos pos, String varName)
      Description copied from interface: IGPSToolSync
      Called when the GPS (Area) Tool GUI is closed, to send position & variable information to server
      Specified by:
      syncFromClient in interface IGPSToolSync
      Parameters:
      player - the player
      stack - the gps (area) tool itemstack
      index - index of the pos & var (ignore for GPS Tool)
      pos - the new position for this index
      varName - the new variable name for this index (empty string if absent)