Search in sources :

Example 1 with ToolTypeProperty

use of org.spongepowered.api.data.property.item.ToolTypeProperty in project SpongeCommon by SpongePowered.

the class ToolTypePropertyStore method getFor.

@Override
protected Optional<ToolTypeProperty> getFor(ItemStack itemStack) {
    if (itemStack.getItem() instanceof ItemTool) {
        final ItemTool tool = (ItemTool) itemStack.getItem();
        final Item.ToolMaterial toolMaterial = tool.toolMaterial;
        return Optional.of(new ToolTypeProperty((ToolType) (Object) toolMaterial));
    } else if (itemStack.getItem() instanceof ItemSword) {
        final ItemSword itemSword = (ItemSword) itemStack.getItem();
        final Item.ToolMaterial swordMaterial = itemSword.material;
        return Optional.of(new ToolTypeProperty((ToolType) (Object) swordMaterial));
    } else if (itemStack.getItem() instanceof ItemHoe) {
        final ItemHoe itemHoe = (ItemHoe) itemStack.getItem();
        final Item.ToolMaterial hoeMaterial = itemHoe.toolMaterial;
        return Optional.of(new ToolTypeProperty((ToolType) (Object) hoeMaterial));
    }
    return Optional.empty();
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) ItemHoe(net.minecraft.item.ItemHoe) ItemTool(net.minecraft.item.ItemTool) ToolType(org.spongepowered.api.data.type.ToolType) ToolTypeProperty(org.spongepowered.api.data.property.item.ToolTypeProperty)

Aggregations

Item (net.minecraft.item.Item)1 ItemHoe (net.minecraft.item.ItemHoe)1 ItemSword (net.minecraft.item.ItemSword)1 ItemTool (net.minecraft.item.ItemTool)1 ToolTypeProperty (org.spongepowered.api.data.property.item.ToolTypeProperty)1 ToolType (org.spongepowered.api.data.type.ToolType)1