2022-07-02 16:50:16 +00:00
/ *
* Copyright ( c ) 2019 - 2022 GeyserMC . http : //geysermc.org
*
* Permission is hereby granted , free of charge , to any person obtaining a copy
* of this software and associated documentation files ( the " Software " ) , to deal
* in the Software without restriction , including without limitation the rights
* to use , copy , modify , merge , publish , distribute , sublicense , and / or sell
* copies of the Software , and to permit persons to whom the Software is
* furnished to do so , subject to the following conditions :
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software .
*
* THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND , EXPRESS OR
* IMPLIED , INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY ,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT . IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM , DAMAGES OR OTHER
* LIABILITY , WHETHER IN AN ACTION OF CONTRACT , TORT OR OTHERWISE , ARISING FROM ,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE .
*
* @author GeyserMC
* @link https : //github.com/GeyserMC/Geyser
* /
package org.geysermc.geyser.item.components ;
2022-12-31 01:57:38 +00:00
import com.google.common.base.Suppliers ;
import org.geysermc.geyser.item.Items ;
import org.geysermc.geyser.item.type.Item ;
2022-07-02 16:50:16 +00:00
2022-12-31 01:57:38 +00:00
import java.util.Collections ;
2022-07-02 16:50:16 +00:00
import java.util.Locale ;
2022-12-31 01:57:38 +00:00
import java.util.Set ;
import java.util.function.Supplier ;
2022-07-02 16:50:16 +00:00
public enum ToolTier {
2022-12-31 01:57:38 +00:00
WOODEN ( 2 , ( ) - > Set . of ( Items . OAK_PLANKS , Items . SPRUCE_PLANKS , Items . BIRCH_PLANKS , Items . JUNGLE_PLANKS , Items . ACACIA_PLANKS , Items . DARK_OAK_PLANKS , Items . CRIMSON_PLANKS , Items . WARPED_PLANKS , Items . MANGROVE_PLANKS ) ) , // PLANKS tag // TODO ?
STONE ( 4 , ( ) - > Set . of ( Items . COBBLESTONE , Items . BLACKSTONE , Items . COBBLED_DEEPSLATE ) ) , // STONE_TOOL_MATERIALS tag
IRON ( 6 , ( ) - > Collections . singleton ( Items . IRON_INGOT ) ) ,
GOLDEN ( 12 , ( ) - > Collections . singleton ( Items . GOLD_INGOT ) ) ,
DIAMOND ( 8 , ( ) - > Collections . singleton ( Items . DIAMOND ) ) ,
NETHERITE ( 9 , ( ) - > Collections . singleton ( Items . NETHERITE_INGOT ) ) ;
2022-07-02 16:50:16 +00:00
2023-02-15 05:17:14 +00:00
private static final ToolTier [ ] VALUES = values ( ) ;
2022-07-02 16:50:16 +00:00
private final int speed ;
2022-12-31 01:57:38 +00:00
private final Supplier < Set < Item > > repairIngredients ;
2022-07-02 16:50:16 +00:00
2022-12-31 01:57:38 +00:00
ToolTier ( int speed , Supplier < Set < Item > > repairIngredients ) {
2022-07-02 16:50:16 +00:00
this . speed = speed ;
2022-12-31 01:57:38 +00:00
// Lazily initialize as this will likely be called as items are loading
this . repairIngredients = Suppliers . memoize ( repairIngredients : : get ) ;
2022-07-02 16:50:16 +00:00
}
2022-12-31 01:57:38 +00:00
public Set < Item > getRepairIngredients ( ) {
return repairIngredients . get ( ) ;
}
2022-07-02 16:50:16 +00:00
@Override
public String toString ( ) {
return this . name ( ) . toLowerCase ( Locale . ROOT ) ;
}
}