Search in sources :

Example 1 with InventorySnapshot

use of org.lanternpowered.server.inventory.InventorySnapshot in project LanternServer by LanternPowered.

the class LanternShulkerBox method registerKeys.

@Override
public void registerKeys() {
    super.registerKeys();
    final ValueCollection c = getValueCollection();
    c.register(Keys.DISPLAY_NAME, null);
    c.registerProcessor(LanternKeys.INVENTORY_SNAPSHOT).add(builder -> builder.offerHandler(((key, valueContainer, inventorySnapshot) -> {
        this.inventory.clear();
        inventorySnapshot.offerTo(this.inventory);
        return DataTransactionResult.successNoData();
    })).failAlwaysRemoveHandler().retrieveHandler((key, valueContainer) -> Optional.of(InventorySnapshot.ofInventory(this.inventory))));
}
Also used : InventorySnapshot(org.lanternpowered.server.inventory.InventorySnapshot) LanternKeys(org.lanternpowered.server.data.key.LanternKeys) Location(org.spongepowered.api.world.Location) Keys(org.spongepowered.api.data.key.Keys) BlockTypes(org.spongepowered.api.block.BlockTypes) Random(java.util.Random) DataTransactionResult(org.spongepowered.api.data.DataTransactionResult) ValueCollection(org.lanternpowered.server.data.ValueCollection) BlockState(org.spongepowered.api.block.BlockState) ChestInventory(org.lanternpowered.server.inventory.vanilla.block.ChestInventory) SoundCategories(org.spongepowered.api.effect.sound.SoundCategories) Lantern(org.lanternpowered.server.game.Lantern) SoundTypes(org.spongepowered.api.effect.sound.SoundTypes) World(org.spongepowered.api.world.World) VanillaInventoryArchetypes(org.lanternpowered.server.inventory.vanilla.VanillaInventoryArchetypes) Optional(java.util.Optional) ValueCollection(org.lanternpowered.server.data.ValueCollection)

Aggregations

Optional (java.util.Optional)1 Random (java.util.Random)1 ValueCollection (org.lanternpowered.server.data.ValueCollection)1 LanternKeys (org.lanternpowered.server.data.key.LanternKeys)1 Lantern (org.lanternpowered.server.game.Lantern)1 InventorySnapshot (org.lanternpowered.server.inventory.InventorySnapshot)1 VanillaInventoryArchetypes (org.lanternpowered.server.inventory.vanilla.VanillaInventoryArchetypes)1 ChestInventory (org.lanternpowered.server.inventory.vanilla.block.ChestInventory)1 BlockState (org.spongepowered.api.block.BlockState)1 BlockTypes (org.spongepowered.api.block.BlockTypes)1 DataTransactionResult (org.spongepowered.api.data.DataTransactionResult)1 Keys (org.spongepowered.api.data.key.Keys)1 SoundCategories (org.spongepowered.api.effect.sound.SoundCategories)1 SoundTypes (org.spongepowered.api.effect.sound.SoundTypes)1 Location (org.spongepowered.api.world.Location)1 World (org.spongepowered.api.world.World)1