Class DeathChest
- java.lang.Object
-
- com.therandomlabs.vanilladeathchest.deathchest.DeathChest
-
public final class DeathChest extends Object
Represents a death chest.
-
-
Constructor Summary
Constructors Constructor Description DeathChest(UUID identifier, net.minecraft.server.world.ServerWorld world, UUID playerUUID, List<net.minecraft.entity.ItemEntity> items, net.minecraft.entity.player.PlayerInventory inventory, long creationTime, net.minecraft.util.math.BlockPos pos, boolean isDoubleChest, boolean locked)Constructs aDeathChestwith the specified properties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<net.minecraft.entity.ItemEntity>cloneItems()Returns a cloned mutable list containing this death chest's items.booleanexists()Returns whether this death chest exists in the world.static DeathChestfromTag(net.minecraft.server.world.ServerWorld world, net.minecraft.nbt.CompoundTag tag)Deserializes a death chest from aCompoundTag.longgetCreationTime()Returns this death chest's creation time.UUIDgetIdentifier()Returns this death chest's identifier.net.minecraft.entity.player.PlayerInventorygetInventory()Returns the player inventory at the time of death.List<net.minecraft.entity.ItemEntity>getItems()Returns a mutable list containing this death chest's items.UUIDgetPlayerUUID()Returns this death chest's player UUID.net.minecraft.util.math.BlockPosgetPos()Returns this death chest's position.net.minecraft.server.world.ServerWorldgetWorld()Returns this death chest's world.booleanisDoubleChest()Returns whether this death chest is a double chest.booleanisLocked()Returns whether this death chest is locked.booleanisProtectedFrom(net.minecraft.entity.player.PlayerEntity player)Returns whether death chest protection prevents the specified player from opening this death chest.voidsetLocked(boolean flag)Sets whether this death chest is locked.net.minecraft.nbt.CompoundTagtoTag(net.minecraft.nbt.CompoundTag tag)Serializes this death chest to aCompoundTag.
-
-
-
Constructor Detail
-
DeathChest
public DeathChest(UUID identifier, net.minecraft.server.world.ServerWorld world, UUID playerUUID, List<net.minecraft.entity.ItemEntity> items, net.minecraft.entity.player.PlayerInventory inventory, long creationTime, net.minecraft.util.math.BlockPos pos, boolean isDoubleChest, boolean locked)
Constructs aDeathChestwith the specified properties.- Parameters:
identifier- aUUID.world- aServerWorld.playerUUID- a player UUID.items- the items.inventory- the player inventory at the time of death.creationTime- a creation time.pos- a position. If this is a double chest, this is the position of the west block.isDoubleChest- whether the chest is a double chest.locked- whether the chest is locked.
-
-
Method Detail
-
getWorld
public net.minecraft.server.world.ServerWorld getWorld()
Returns this death chest's world.- Returns:
- this death chest's world.
-
getPlayerUUID
public UUID getPlayerUUID()
Returns this death chest's player UUID.- Returns:
- this death chest's player UUID.
-
getItems
public List<net.minecraft.entity.ItemEntity> getItems()
Returns a mutable list containing this death chest's items.- Returns:
- a mutable list containing this death chest's items.
-
cloneItems
public List<net.minecraft.entity.ItemEntity> cloneItems()
Returns a cloned mutable list containing this death chest's items.- Returns:
- a cloned mutable list containing this death chest's items.
-
getInventory
public net.minecraft.entity.player.PlayerInventory getInventory()
Returns the player inventory at the time of death.- Returns:
- the
PlayerInventoryat the time of death.
-
getCreationTime
public long getCreationTime()
Returns this death chest's creation time.- Returns:
- this death chest's creation time.
-
getPos
public net.minecraft.util.math.BlockPos getPos()
Returns this death chest's position. If this is a double chest, this is the position of the west block.- Returns:
- this death chest's position.
-
isDoubleChest
public boolean isDoubleChest()
Returns whether this death chest is a double chest. This may betrueeven if one half of the double chest has been destroyed.- Returns:
trueif this death chest is a double chest, or otherwisefalse.
-
isLocked
public boolean isLocked()
Returns whether this death chest is locked.- Returns:
trueif this death chest is locked, or otherwisefalse.
-
setLocked
public void setLocked(boolean flag)
Sets whether this death chest is locked.- Parameters:
flag-trueif this death chest should be locked, orfalseif this death chest should be unlocked.
-
exists
public boolean exists()
Returns whether this death chest exists in the world.- Returns:
trueif this death chest exists, or otherwisefalse.
-
isProtectedFrom
public boolean isProtectedFrom(net.minecraft.entity.player.PlayerEntity player)
Returns whether death chest protection prevents the specified player from opening this death chest.- Parameters:
player- a player.- Returns:
trueif this death chest is protected from the specified player, or otherwisefalse.
-
toTag
public net.minecraft.nbt.CompoundTag toTag(net.minecraft.nbt.CompoundTag tag)
Serializes this death chest to aCompoundTag.- Parameters:
tag- aCompoundTag.- Returns:
- the
CompoundTag.
-
fromTag
public static DeathChest fromTag(net.minecraft.server.world.ServerWorld world, net.minecraft.nbt.CompoundTag tag)
Deserializes a death chest from aCompoundTag.- Parameters:
world- aServerWorld.tag- aCompoundTag.- Returns:
- the deserialized
DeathChest.
-
-