Search in sources :

Example 6 with ValueCollection

use of org.lanternpowered.server.data.ValueCollection in project LanternServer by LanternPowered.

the class LanternItemStack method registerKeys.

private void registerKeys() {
    final ValueCollection c = getValueCollection();
    ((LanternItemType) this.itemType).getKeysProvider().accept(c);
    c.register(Keys.DISPLAY_NAME, null);
    c.register(Keys.ITEM_LORE, Collections.emptyList());
    c.register(Keys.BREAKABLE_BLOCK_TYPES, new HashSet<>());
    c.register(Keys.ITEM_ENCHANTMENTS, Collections.emptyList());
}
Also used : ValueCollection(org.lanternpowered.server.data.ValueCollection)

Example 7 with ValueCollection

use of org.lanternpowered.server.data.ValueCollection in project LanternServer by LanternPowered.

the class LanternFurnace method registerKeys.

@Override
public void registerKeys() {
    super.registerKeys();
    final ElementListener<Integer> clearProperty = (oldElement, newElement) -> this.inventory.resetCachedProgress();
    final ValueCollection c = getValueCollection();
    c.register(Keys.MAX_BURN_TIME, 0, 0, Integer.MAX_VALUE).addListener(clearProperty);
    c.register(Keys.PASSED_BURN_TIME, 0, 0, Keys.MAX_BURN_TIME).addListener(clearProperty);
    c.register(Keys.MAX_COOK_TIME, 0, 0, Integer.MAX_VALUE).addListener(clearProperty);
    c.register(Keys.PASSED_COOK_TIME, 0, 0, Keys.MAX_COOK_TIME).addListener(clearProperty);
}
Also used : Inventory(org.spongepowered.api.item.inventory.Inventory) SmeltingResult(org.spongepowered.api.item.recipe.smelting.SmeltingResult) Keys(org.spongepowered.api.data.key.Keys) LanternTileEntity(org.lanternpowered.server.block.tile.LanternTileEntity) IIngredient(org.lanternpowered.server.item.recipe.IIngredient) ItemStackSnapshot(org.spongepowered.api.item.inventory.ItemStackSnapshot) SmeltingRecipe(org.spongepowered.api.item.recipe.smelting.SmeltingRecipe) IFuel(org.lanternpowered.server.item.recipe.fuel.IFuel) OptionalInt(java.util.OptionalInt) ValueCollection(org.lanternpowered.server.data.ValueCollection) ISmeltingRecipe(org.lanternpowered.server.item.recipe.smelting.ISmeltingRecipe) ItemStack(org.spongepowered.api.item.inventory.ItemStack) VanillaInventoryArchetypes(org.lanternpowered.server.inventory.vanilla.VanillaInventoryArchetypes) ElementListener(org.lanternpowered.server.data.element.ElementListener) TileEntityInventory(org.spongepowered.api.item.inventory.type.TileEntityInventory) BlockTypes(org.spongepowered.api.block.BlockTypes) TileEntityCarrier(org.spongepowered.api.block.tileentity.carrier.TileEntityCarrier) LanternGame(org.lanternpowered.server.game.LanternGame) PeekedOfferTransactionResult(org.lanternpowered.server.inventory.PeekedOfferTransactionResult) BlockState(org.spongepowered.api.block.BlockState) Direction(org.spongepowered.api.util.Direction) FurnaceInventory(org.lanternpowered.server.inventory.vanilla.block.FurnaceInventory) Lantern(org.lanternpowered.server.game.Lantern) ITileEntityRefreshBehavior(org.lanternpowered.server.block.tile.ITileEntityRefreshBehavior) ITileEntityCarrier(org.lanternpowered.server.block.tile.ITileEntityCarrier) BlockType(org.spongepowered.api.block.BlockType) Optional(java.util.Optional) Furnace(org.spongepowered.api.block.tileentity.carrier.Furnace) LanternEnumTraits(org.lanternpowered.server.block.trait.LanternEnumTraits) ValueCollection(org.lanternpowered.server.data.ValueCollection)

Example 8 with ValueCollection

use of org.lanternpowered.server.data.ValueCollection 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

ValueCollection (org.lanternpowered.server.data.ValueCollection)8 Optional (java.util.Optional)3 Lantern (org.lanternpowered.server.game.Lantern)3 VanillaInventoryArchetypes (org.lanternpowered.server.inventory.vanilla.VanillaInventoryArchetypes)3 Keys (org.spongepowered.api.data.key.Keys)3 LanternKeys (org.lanternpowered.server.data.key.LanternKeys)2 ChestInventory (org.lanternpowered.server.inventory.vanilla.block.ChestInventory)2 BlockState (org.spongepowered.api.block.BlockState)2 BlockTypes (org.spongepowered.api.block.BlockTypes)2 DataTransactionResult (org.spongepowered.api.data.DataTransactionResult)2 Vector3d (com.flowpowered.math.vector.Vector3d)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 OptionalInt (java.util.OptionalInt)1 Random (java.util.Random)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1