Record Class SwapResultImpl
java.lang.Object
java.lang.Record
com.hammy275.immersivemc.server.api_impl.SwapResultImpl
- All Implemented Interfaces:
SwapResult
public record SwapResultImpl(net.minecraft.world.item.ItemStack playerHandStack, net.minecraft.world.item.ItemStack immersiveStack, net.minecraft.world.item.ItemStack leftoverStack)
extends Record
implements SwapResult
-
Constructor Summary
ConstructorDescriptionSwapResultImpl
(net.minecraft.world.item.ItemStack playerHandStack, net.minecraft.world.item.ItemStack immersiveStack, net.minecraft.world.item.ItemStack leftoverStack) Creates an instance of aSwapResultImpl
record class. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
Indicates whether some other object is "equal to" this one.void
giveToPlayer
(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand) Give theSwapResult.playerHandStack()
andSwapResult.leftoverStack()
to the player specified as appropriate.final int
hashCode()
Returns a hash code value for this object.net.minecraft.world.item.ItemStack
Returns the value of theimmersiveStack
record component.net.minecraft.world.item.ItemStack
Returns the value of theleftoverStack
record component.net.minecraft.world.item.ItemStack
Returns the value of theplayerHandStack
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
SwapResultImpl
public SwapResultImpl(net.minecraft.world.item.ItemStack playerHandStack, net.minecraft.world.item.ItemStack immersiveStack, net.minecraft.world.item.ItemStack leftoverStack) Creates an instance of aSwapResultImpl
record class.- Parameters:
playerHandStack
- the value for theplayerHandStack
record componentimmersiveStack
- the value for theimmersiveStack
record componentleftoverStack
- the value for theleftoverStack
record component
-
-
Method Details
-
giveToPlayer
public void giveToPlayer(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand) Description copied from interface:SwapResult
Give theSwapResult.playerHandStack()
andSwapResult.leftoverStack()
to the player specified as appropriate. This function should only be called once per swap operation.
TheSwapResult.immersiveStack()
needs to be handled separately.- Specified by:
giveToPlayer
in interfaceSwapResult
- Parameters:
player
- The player to give items to.hand
- The hand the player used to interact with the Immersive.
-
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)
. -
playerHandStack
public net.minecraft.world.item.ItemStack playerHandStack()Returns the value of theplayerHandStack
record component.- Specified by:
playerHandStack
in interfaceSwapResult
- Returns:
- the value of the
playerHandStack
record component
-
immersiveStack
public net.minecraft.world.item.ItemStack immersiveStack()Returns the value of theimmersiveStack
record component.- Specified by:
immersiveStack
in interfaceSwapResult
- Returns:
- the value of the
immersiveStack
record component
-
leftoverStack
public net.minecraft.world.item.ItemStack leftoverStack()Returns the value of theleftoverStack
record component.- Specified by:
leftoverStack
in interfaceSwapResult
- Returns:
- the value of the
leftoverStack
record component
-