Class PCStorage
java.lang.Object
com.pixelmonmod.pixelmon.api.storage.PokemonStorage
com.pixelmonmod.pixelmon.api.storage.PCStorage
- Direct Known Subclasses:
PCStorageSearch
-
Field Summary
Modifier and TypeFieldDescriptionprotected PCBox[]
protected StoragePosition
protected int
protected String
protected UUID
Fields inherited from class com.pixelmonmod.pixelmon.api.storage.PokemonStorage
hasChanged, shouldSendUpdates, storageType, trackingPlayers, uuid
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Clears all the pokemon from the storagevoid
decode
(net.minecraft.network.FriendlyByteBuf buf) Reads the storage from the given buffervoid
encode
(net.minecraft.network.FriendlyByteBuf buffer) Writes the storage to the given bufferget
(int box, int slot) get
(StoragePosition position) Gets the pokemon at the given position in the storage
Will return null if there is no pokemon at the given positionPokemon[]
getAll()
Gets a array of all pokemon within this storage.Same asPokemonStorage.getAll()
, but forStoragePosition
s.getBox
(int boxNumber) int
PCBox[]
getBoxes()
Gets the first position where there is no pokemon in the storageint
net.minecraft.server.level.ServerPlayer
getPosition
(Pokemon pokemon) Gets the position of the given pokemon in the storage
Will return null if the pokemon is not in the storageboolean
iterator()
int
maxSize()
void
open
(net.minecraft.server.level.ServerPlayer player) Opens the storage for the given playerreadFromNBT
(net.minecraft.nbt.CompoundTag nbt) Reads the storage from the given NBT tagvoid
sendContents
(net.minecraft.server.level.ServerPlayer player) void
void
set
(StoragePosition position, Pokemon pokemon) Sets the given pokemon at the given position in the storagevoid
setBoxCount
(int boxes) void
setHasChanged
(boolean hasChanged) void
setLastBox
(int lastBox) void
void
setPlayerName
(String playerName) void
setPlayerUUID
(UUID playerUUID) void
swap
(int box1, int slot1, int box2, int slot2) void
swap
(StoragePosition position1, StoragePosition position2) Swaps the pokemon at the given positions in the storageboolean
swapBoxes
(int box1, int box2) net.minecraft.nbt.CompoundTag
writeToNBT
(net.minecraft.nbt.CompoundTag nbt) Writes the storage to the given NBT tagMethods inherited from class com.pixelmonmod.pixelmon.api.storage.PokemonStorage
add, addAndGetPosition, canTransfer, clone, countAll, countEggs, countEmpty, countPokemon, find, findAll, findAll, findAllPositions, findAllPositions, findOne, findOne, getCurryData, getOwner, getStorageType, getUniqueId, hasSpace, initialize, isTracking, notifyListeners, retrieveAll, setNeedsSaving, shouldSendUpdates, shouldSendUpdates, toString, track, trackingPlayers, transfer, untrack, updateSingleCurryData, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
boxes
-
lastBox
protected int lastBox -
playerUUID
-
playerName
-
cachePosition
-
-
Constructor Details
-
PCStorage
-
PCStorage
-
-
Method Details
-
encode
public void encode(net.minecraft.network.FriendlyByteBuf buffer) Description copied from class:PokemonStorage
Writes the storage to the given buffer- Specified by:
encode
in classPokemonStorage
- Parameters:
buffer
- the buffer to write to
-
decode
public void decode(net.minecraft.network.FriendlyByteBuf buf) Description copied from class:PokemonStorage
Reads the storage from the given buffer- Specified by:
decode
in classPokemonStorage
- Parameters:
buf
- the buffer to read from
-
open
public void open(net.minecraft.server.level.ServerPlayer player) Description copied from class:PokemonStorage
Opens the storage for the given player- Overrides:
open
in classPokemonStorage
- Parameters:
player
- the player to open the storage for
-
setPlayer
-
setBoxCount
public void setBoxCount(int boxes) -
getLastBox
public int getLastBox() -
setLastBox
public void setLastBox(int lastBox) -
getBoxes
-
getBox
-
getBoxCount
public int getBoxCount() -
getAll
Description copied from class:PokemonStorage
Gets a array of all pokemon within this storage. May not be the implementations array (e.g it could be copy). So don't expect to be able to edit this. the size of the array should always match the maximum capacity and will obviously contain null elements for slots that are not full.- Specified by:
getAll
in classPokemonStorage
- Returns:
- An array of all pokemon within this storage. By convention this is not the implementation's array (thus this is a copy). This is preferred because it forces modifications to go through the relevant methods which fire events and flip hasChanged.
-
getAllPositions
Description copied from class:PokemonStorage
Same asPokemonStorage.getAll()
, but forStoragePosition
s. Note that this will return every position, regardless of whether or not it contains a Pokemon, for flexibility.- Specified by:
getAllPositions
in classPokemonStorage
-
maxSize
public int maxSize()- Specified by:
maxSize
in classPokemonStorage
- Returns:
- The maximum capacity of the Storage (or the individual containers, in cases like PCStorage)
-
writeToNBT
public net.minecraft.nbt.CompoundTag writeToNBT(net.minecraft.nbt.CompoundTag nbt) Description copied from class:PokemonStorage
Writes the storage to the given NBT tag- Specified by:
writeToNBT
in classPokemonStorage
- Parameters:
nbt
- the NBT tag to write to- Returns:
- the NBT tag with the storage written to it
-
readFromNBT
Description copied from class:PokemonStorage
Reads the storage from the given NBT tag- Specified by:
readFromNBT
in classPokemonStorage
- Parameters:
nbt
- the NBT tag to read from- Returns:
- a future that completes when the storage has been read from the NBT tag
-
getFirstEmptyPosition
Description copied from class:PokemonStorage
Gets the first position where there is no pokemon in the storage- Specified by:
getFirstEmptyPosition
in classPokemonStorage
- Returns:
- the first empty position in the storage
-
set
Description copied from class:PokemonStorage
Sets the given pokemon at the given position in the storage- Specified by:
set
in classPokemonStorage
- Parameters:
position
- the position to set the pokemonpokemon
- the pokemon to set
-
set
-
get
Description copied from class:PokemonStorage
Gets the pokemon at the given position in the storage
Will return null if there is no pokemon at the given position- Specified by:
get
in classPokemonStorage
- Parameters:
position
- the position to get the pokemon from- Returns:
- the pokemon at the given position
-
get
-
swap
Description copied from class:PokemonStorage
Swaps the pokemon at the given positions in the storage- Specified by:
swap
in classPokemonStorage
- Parameters:
position1
- the first position to swapposition2
- the second position to swap
-
swap
public void swap(int box1, int slot1, int box2, int slot2) -
swapBoxes
public boolean swapBoxes(int box1, int box2) -
getPosition
Description copied from class:PokemonStorage
Gets the position of the given pokemon in the storage
Will return null if the pokemon is not in the storage- Specified by:
getPosition
in classPokemonStorage
- Parameters:
pokemon
- the pokemon to get the position of- Returns:
- the position of the given pokemon in the storage
-
getShouldSave
public boolean getShouldSave()- Overrides:
getShouldSave
in classPokemonStorage
-
setHasChanged
public void setHasChanged(boolean hasChanged) - Overrides:
setHasChanged
in classPokemonStorage
-
sendContents
public void sendContents(net.minecraft.server.level.ServerPlayer player) -
iterator
-
clear
public void clear()Description copied from class:PokemonStorage
Clears all the pokemon from the storage- Specified by:
clear
in classPokemonStorage
-
getPlayerName
-
setPlayerName
-
getPlayerUUID
-
setPlayerUUID
-
getPlayer
public net.minecraft.server.level.ServerPlayer getPlayer()
-