Package com.ldtteam.structurize.util
Record Class ScanToolData
java.lang.Object
java.lang.Record
com.ldtteam.structurize.util.ScanToolData
- Record Components:
slots- the list of slot data.currentSlotId- the currently selected slot id.commandPos- the location of the linked command block.dimension- the dimension of the linked command block.
public record ScanToolData(List<ScanToolData.Slot> slots, int currentSlotId, @Nullable net.minecraft.core.BlockPos commandPos, @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
extends Record
Data representing a set of scans in the scan tool.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ScanToolData> static ScanToolDatastatic final intThe number of scan slots.static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, ScanToolData> -
Constructor Summary
ConstructorsConstructorDescriptionScanToolData(List<ScanToolData.Slot> slots, int currentSlotId, @Nullable net.minecraft.core.BlockPos commandPos, @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) Creates an instance of aScanToolDatarecord class. -
Method Summary
Modifier and TypeMethodDescription@Nullable net.minecraft.core.BlockPosReturns the value of thecommandPosrecord component.Gets the currently selected slotintReturns the value of thecurrentSlotIdrecord component.@Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> Returns the value of thedimensionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.moveTo(int slot) Moves to the specified slot numbernextSlot()Moves to the next slot, wrapping back to the start if neededprevSlot()Moves to the previous slot, wrapping to the end if neededstatic ScanToolDatareadFromItemStack(net.minecraft.world.item.ItemStack stack) Gets theScanToolDatafrom anItemStack.slots()Returns the value of theslotsrecord component.final StringtoString()Returns a string representation of this record class.static ScanToolDataupdateItemStack(net.minecraft.world.item.ItemStack stack, UnaryOperator<ScanToolData> updater) Modifies theScanToolDataon anItemStack.withCommandBlock(@Nullable net.minecraft.world.level.block.entity.CommandBlockEntity commandBlock) Sets the command block position and dimension.withCurrentSlot(@Nullable ScanToolData.Slot data) Saves the specified data in the current slot.voidwriteToItemStack(net.minecraft.world.item.ItemStack itemStack) Writes theScanToolDatainto anItemStack.
-
Field Details
-
NUM_SLOTS
public static final int NUM_SLOTSThe number of scan slots. We keep 10 so that we can map them to 0-9 keys.- See Also:
-
CODEC
-
STREAM_CODEC
public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf,ScanToolData> STREAM_CODEC -
EMPTY
-
-
Constructor Details
-
ScanToolData
public ScanToolData(List<ScanToolData.Slot> slots, int currentSlotId, @Nullable @Nullable net.minecraft.core.BlockPos commandPos, @Nullable @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension) Creates an instance of aScanToolDatarecord class.- Parameters:
slots- the value for theslotsrecord componentcurrentSlotId- the value for thecurrentSlotIdrecord componentcommandPos- the value for thecommandPosrecord componentdimension- the value for thedimensionrecord component
-
-
Method Details
-
currentSlot
Gets the currently selected slot- Returns:
- the slot data for the current slot
-
withCurrentSlot
Saves the specified data in the current slot.- Parameters:
data- the new slot data.- Returns:
- the new
ScanToolData.
-
nextSlot
Moves to the next slot, wrapping back to the start if needed -
prevSlot
Moves to the previous slot, wrapping to the end if needed -
moveTo
Moves to the specified slot number- Parameters:
slot- the new slot number
-
withCommandBlock
public ScanToolData withCommandBlock(@Nullable @Nullable net.minecraft.world.level.block.entity.CommandBlockEntity commandBlock) Sets the command block position and dimension.- Parameters:
commandBlock- the command block entity.- Returns:
- the updated
ScanToolData.
-
readFromItemStack
Gets theScanToolDatafrom anItemStack.- Parameters:
stack- the stack to query.- Returns:
- the associated data or immutable empty instance.
-
writeToItemStack
public void writeToItemStack(net.minecraft.world.item.ItemStack itemStack) Writes theScanToolDatainto anItemStack.- Parameters:
itemStack- the stack to save into.
-
updateItemStack
public static ScanToolData updateItemStack(net.minecraft.world.item.ItemStack stack, UnaryOperator<ScanToolData> updater) Modifies theScanToolDataon anItemStack.- Parameters:
stack- the stack to update.updater- the update actions to apply.- Returns:
- the updated data (also stored on the stack).
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
slots
Returns the value of theslotsrecord component.- Returns:
- the value of the
slotsrecord component
-
currentSlotId
public int currentSlotId()Returns the value of thecurrentSlotIdrecord component.- Returns:
- the value of the
currentSlotIdrecord component
-
commandPos
@Nullable public @Nullable net.minecraft.core.BlockPos commandPos()Returns the value of thecommandPosrecord component.- Returns:
- the value of the
commandPosrecord component
-
dimension
@Nullable public @Nullable net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension()Returns the value of thedimensionrecord component.- Returns:
- the value of the
dimensionrecord component
-