Search in sources :

Example 1 with ElementListener

use of org.lanternpowered.server.data.element.ElementListener 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)

Aggregations

Optional (java.util.Optional)1 OptionalInt (java.util.OptionalInt)1 ITileEntityCarrier (org.lanternpowered.server.block.tile.ITileEntityCarrier)1 ITileEntityRefreshBehavior (org.lanternpowered.server.block.tile.ITileEntityRefreshBehavior)1 LanternTileEntity (org.lanternpowered.server.block.tile.LanternTileEntity)1 LanternEnumTraits (org.lanternpowered.server.block.trait.LanternEnumTraits)1 ValueCollection (org.lanternpowered.server.data.ValueCollection)1 ElementListener (org.lanternpowered.server.data.element.ElementListener)1 Lantern (org.lanternpowered.server.game.Lantern)1 LanternGame (org.lanternpowered.server.game.LanternGame)1 PeekedOfferTransactionResult (org.lanternpowered.server.inventory.PeekedOfferTransactionResult)1 VanillaInventoryArchetypes (org.lanternpowered.server.inventory.vanilla.VanillaInventoryArchetypes)1 FurnaceInventory (org.lanternpowered.server.inventory.vanilla.block.FurnaceInventory)1 IIngredient (org.lanternpowered.server.item.recipe.IIngredient)1 IFuel (org.lanternpowered.server.item.recipe.fuel.IFuel)1 ISmeltingRecipe (org.lanternpowered.server.item.recipe.smelting.ISmeltingRecipe)1 BlockState (org.spongepowered.api.block.BlockState)1 BlockType (org.spongepowered.api.block.BlockType)1 BlockTypes (org.spongepowered.api.block.BlockTypes)1 Furnace (org.spongepowered.api.block.tileentity.carrier.Furnace)1