Package tschipp.linear.build
Record Class BlockSource.HeldBlock
java.lang.Object
java.lang.Record
tschipp.linear.build.BlockSource.HeldBlock
- All Implemented Interfaces:
BlockSource
- Enclosing interface:
BlockSource
public static record BlockSource.HeldBlock(net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack template)
extends Record
implements BlockSource
A block in hand. Uses the held stack first, then matching stacks in the inventory, then each
BlockSupply. The last block in hand is only used once everything else is empty.-
Nested Class Summary
Nested classes/interfaces inherited from interface tschipp.linear.build.BlockSource
BlockSource.HeldBlock, BlockSource.HeldItem -
Constructor Summary
ConstructorsConstructorDescriptionHeldBlock(net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack template) Creates an instance of aHeldBlockrecord 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.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.net.minecraft.world.item.ItemStacktemplate()Returns the value of thetemplaterecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
HeldBlock
public HeldBlock(net.minecraft.world.InteractionHand hand, net.minecraft.world.item.ItemStack template) Creates an instance of aHeldBlockrecord class.- Parameters:
hand- the value for thehandrecord componenttemplate- the value for thetemplaterecord 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
-
template
public net.minecraft.world.item.ItemStack template()Returns the value of thetemplaterecord component.- Returns:
- the value of the
templaterecord component
-