Package tschipp.linear.build
Record Class BlockSource.HeldItem
java.lang.Object
java.lang.Record
tschipp.linear.build.BlockSource.HeldItem
- All Implemented Interfaces:
BlockSource
- Enclosing interface:
BlockSource
public static record BlockSource.HeldItem(net.minecraft.world.InteractionHand hand, HeldItemHandler handler)
extends Record
implements BlockSource
A non-block item that places blocks, see
HeldItemHandler.-
Nested Class Summary
Nested classes/interfaces inherited from interface tschipp.linear.build.BlockSource
BlockSource.HeldBlock, BlockSource.HeldItem -
Constructor Summary
ConstructorsConstructorDescriptionHeldItem(net.minecraft.world.InteractionHand hand, HeldItemHandler handler) Creates an instance of aHeldItemrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintavailable(net.minecraft.world.entity.player.Player player, int wanted) How many blocks there are for the line, at mostwanted.final booleanIndicates whether some other object is "equal to" this one.voidgiveBack(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack block) Puts back a block that was taken but not placed.net.minecraft.world.InteractionHandhand()Returns the value of thehandrecord component.handler()Returns the value of thehandlerrecord component.final inthashCode()Returns a hash code value for this object.net.minecraft.world.item.ItemStackpreview(net.minecraft.world.entity.player.Player player) The block the preview shows.net.minecraft.world.item.ItemStacktakeOne(net.minecraft.server.level.ServerPlayer player) Takes the next block, or returns empty if there are none left.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
HeldItem
Creates an instance of aHeldItemrecord class.- Parameters:
hand- the value for thehandrecord componenthandler- the value for thehandlerrecord component
-
-
Method Details
-
preview
public net.minecraft.world.item.ItemStack preview(net.minecraft.world.entity.player.Player player) Description copied from interface:BlockSourceThe block the preview shows.- Specified by:
previewin interfaceBlockSource
-
available
public int available(net.minecraft.world.entity.player.Player player, int wanted) Description copied from interface:BlockSourceHow many blocks there are for the line, at mostwanted. Creative players have no limit.- Specified by:
availablein interfaceBlockSource
-
takeOne
public net.minecraft.world.item.ItemStack takeOne(net.minecraft.server.level.ServerPlayer player) Description copied from interface:BlockSourceTakes the next block, or returns empty if there are none left.- Specified by:
takeOnein interfaceBlockSource
-
giveBack
public void giveBack(net.minecraft.server.level.ServerPlayer player, net.minecraft.world.item.ItemStack block) Description copied from interface:BlockSourcePuts back a block that was taken but not placed.- Specified by:
giveBackin interfaceBlockSource
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
hand
public net.minecraft.world.InteractionHand hand()Returns the value of thehandrecord component.- Returns:
- the value of the
handrecord component
-
handler
Returns the value of thehandlerrecord component.- Returns:
- the value of the
handlerrecord component
-