package top.r3944realms.lib39.example.content.item;

import net.minecraft.world.entity.Entity;
import org.jetbrains.annotations.Nullable;
import top.r3944realms.lib39.Lib39;
import top.r3944realms.lib39.example.content.data.AbstractedTestSyncData;
import top.r3944realms.lib39.example.content.data.ExCapabilityHandler;
import top.r3944realms.lib39.example.content.data.TestSyncData;

/**
 * The type Forge neo forge item.
 */
public class NeoForgeNeoForgeItem extends AbstractNeoForgeItem{

    /**
     * Instantiates a new Forge neo forge item.
     *
     * @param properties the properties
     */
    public NeoForgeNeoForgeItem(Properties properties) {
        super(properties);
    }

    @Override
    protected AbstractedTestSyncData getData(Entity entity) {
        return getStaticData(entity);
    }

    /**
     * Gets static data.
     *
     * @param target the target
     * @return the static data
     */
    @SuppressWarnings("JavaExistingMethodCanBeUsed")
    public static @Nullable AbstractedTestSyncData getStaticData(Entity target) {
        try {
            AbstractedTestSyncData abstractData = target.getCapability(ExCapabilityHandler.TEST_CAP);
            if (abstractData instanceof TestSyncData) {
                return abstractData;
            }
        } catch (Exception e) {
            Lib39.LOGGER.error("[FabricItem] 获取服务器端数据失败", e);
        }
        return null;
    }
}
