// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
//     @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
//     @CapabilityInject(CrusherStats.class)
//     Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
// 
//     @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
//     @CapabilityInject(ItemStackColorable.class)
//     Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
// 
//     @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
//     @CapabilityInject(Silkworm.class)
//     Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }


import cn.mccraft.chinacraft.init.CCCapabilities;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
package cn.mccraft.chinacraft.capability;



public class CapabilitySilkworm {
    public static class Storage implements Capability.IStorage<Silkworm> {
        @Nullable
        @Override
        public NBTBase writeNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side) {
            return new NBTTagInt(instance.getState().ordinal());
        }

        @Override
        public void readNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side, NBTBase nbt) {
            instance.setState(SilkwormState.values()[((NBTTagInt) nbt).getInt()]);
        }
    }

    public static class Implementation implements Silkworm {
        private SilkwormState state;

        @Override
        public SilkwormState getState() {
            return state;
        }

        @Override
        public void setState(SilkwormState state) {
            this.state = state;
        }
    }

    public static class Serializable implements ICapabilitySerializable<NBTTagCompound> {
        private Silkworm silkworm = new Implementation();

        @Override
        public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
// Path: src/main/java/cn/mccraft/chinacraft/init/CCCapabilities.java
// public interface CCCapabilities {
//     @RegCapability(storageClass = CapabilityCrusherStats.Storage.class, implClass = CapabilityCrusherStats.Implementation.class)
//     @CapabilityInject(CrusherStats.class)
//     Capability<CrusherStats> CRUSHER_STATS_CAPABILITY = null;
// 
//     @RegCapability(storageClass = CapabilityColor.Storage.class, implClass = CapabilityColor.Implementation.class)
//     @CapabilityInject(ItemStackColorable.class)
//     Capability<ItemStackColorable> ITEM_STACK_COLORABLE_CAPABILITY = null;
// 
//     @RegCapability(storageClass = CapabilitySilkworm.Storage.class, implClass = CapabilitySilkworm.Implementation.class)
//     @CapabilityInject(Silkworm.class)
//     Capability<Silkworm> SILKWORM_CAPABILITY = null;
// }


// Path: src/main/java/cn/mccraft/chinacraft/capability/CapabilitySilkworm.java
import cn.mccraft.chinacraft.init.CCCapabilities;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagInt;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilitySerializable;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

package cn.mccraft.chinacraft.capability;



public class CapabilitySilkworm {
    public static class Storage implements Capability.IStorage<Silkworm> {
        @Nullable
        @Override
        public NBTBase writeNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side) {
            return new NBTTagInt(instance.getState().ordinal());
        }

        @Override
        public void readNBT(Capability<Silkworm> capability, Silkworm instance, EnumFacing side, NBTBase nbt) {
            instance.setState(SilkwormState.values()[((NBTTagInt) nbt).getInt()]);
        }
    }

    public static class Implementation implements Silkworm {
        private SilkwormState state;

        @Override
        public SilkwormState getState() {
            return state;
        }

        @Override
        public void setState(SilkwormState state) {
            this.state = state;
        }
    }

    public static class Serializable implements ICapabilitySerializable<NBTTagCompound> {
        private Silkworm silkworm = new Implementation();

        @Override
        public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
            return capability.equals(CCCapabilities.SILKWORM_CAPABILITY);