Package com.ldtteam.structurize.items
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 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_SIZEFields inherited from interface net.minecraft.world.flag.FeatureElement
FILTERED_REGISTRIES -
Constructor Summary
ConstructorsConstructorDescriptionCreates default scan tool item.ItemScanTool(net.minecraft.world.item.Item.Properties properties) MC constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidappendHoverText(@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) booleancanAttackBlock(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.BlockPosgetAnchorPos(@NotNull net.minecraft.world.item.ItemStack tool) Loads the anchor coordinates from this stack.static BoxPreviewDatagetBox(@NotNull net.minecraft.world.item.ItemStack tool, @NotNull net.minecraft.world.entity.player.Player player) Gets the coordinates of this tool as aBoxPreviewDatanet.minecraft.network.chat.ComponentgetHighlightTip(@NotNull net.minecraft.world.item.ItemStack stack, @NotNull net.minecraft.network.chat.Component displayName) Uses to search for correct itemstack in both hands.static StringgetStructureName(@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.InteractionResultonAirRightClick(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.InteractionResultonBlockPick(@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.InteractionResultonMouseScroll(@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.booleanonTeleport(@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 voidsaveStructure(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 voidsetAnchorPos(@NotNull net.minecraft.world.item.ItemStack tool, @Nullable net.minecraft.core.BlockPos anchor) Saves the anchor coordinates on this stack.static voidsetStructureName(@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, useOnMethods 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, onCraftedPostProcess, onDestroyed, onUseTick, overrideOtherStackedOnMe, overrideStackedOnOther, releaseUsing, requiredFeatures, shouldOverrideMultiplayerNbt, toString, useOnRelease, verifyTagAfterLoadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.world.flag.FeatureElement
isEnabledMethods inherited from interface net.neoforged.neoforge.common.extensions.IItemExtension
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, getSweepHitBox, getXpRepairRatio, hasCraftingRemainingItem, hasCustomEntity, isBookEnchantable, isCorrectToolForDrops, isDamageable, isDamaged, isEnderMask, isNotReplaceableByPickAction, isPiglinCurrency, makesPiglinsNeutral, onArmorTick, onBlockStartBreak, onDestroyed, onDroppedByPlayer, onEntityItemUpdate, onEntitySwing, onHorseArmorTick, onItemUseFirst, onLeftClickEntity, onStopUsing, 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:AbstractItemWithPosSelectorIs called when player air-right-clicks with item.- Specified by:
onAirRightClickin classAbstractItemWithPosSelector- Parameters:
start- first posend- second posworldIn- event worldplayerIn- event player- Returns:
- event result, typically success
-
getRegisteredItemInstance
Description copied from class:AbstractItemWithPosSelectorUses to search for correct itemstack in both hands.- Specified by:
getRegisteredItemInstancein classAbstractItemWithPosSelector- 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:AbstractItemWithPosSelectorStructurize: Prevent block breaking server side.- Overrides:
canAttackBlockin classAbstractItemWithPosSelector
-
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:
appendHoverTextin classnet.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:
getHighlightTipin interfacenet.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:ISpecialBlockPickItemCalled 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:
onBlockPickin interfaceISpecialBlockPickItem- Parameters:
player- the playerstack- the item stackpos- the focused block, or null if on airctrlKey- 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:IScrollableItemCalled first on client side when the player shift-scrolls with this item selected. If that succeeds, called again on server side.- Specified by:
onMouseScrollin interfaceIScrollableItem- Parameters:
player- the playerstack- the item stackdeltaX- the scroll delta; negative is up, positive is downdeltaY- the scroll delta; negative is up, positive is downctrlKey- 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 playerstack- 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 aBoxPreviewData- 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
Gets the structure name saved on this stack.- Parameters:
tool- The tool stack (assumed already validated)- Returns:
- The structure name (or empty string)
-