// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java
// @Mod(SOLCarrot.MOD_ID)
// @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD)
// public final class SOLCarrot {
// 	public static final String MOD_ID = "solcarrot";
// 	
// 	public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
// 	
// 	private static final String PROTOCOL_VERSION = "1.0";
// 	public static SimpleChannel channel = NetworkRegistry.ChannelBuilder
// 		.named(resourceLocation("main"))
// 		.clientAcceptedVersions(PROTOCOL_VERSION::equals)
// 		.serverAcceptedVersions(PROTOCOL_VERSION::equals)
// 		.networkProtocolVersion(() -> PROTOCOL_VERSION)
// 		.simpleChannel();
// 	
// 	public static ResourceLocation resourceLocation(String path) {
// 		return new ResourceLocation(MOD_ID, path);
// 	}
// 	
// 	// TODO: not sure if this is even implemented anymore
// 	@SubscribeEvent
// 	public static void onFingerprintViolation(FMLFingerprintViolationEvent event) {
// 		// This complains if jar not signed, even if certificateFingerprint is blank
// 		LOGGER.warn("Invalid Fingerprint!");
// 	}
// 	
// 	@SubscribeEvent
// 	public static void setUp(FMLCommonSetupEvent event) {
// 		channel.messageBuilder(FoodListMessage.class, 0)
// 			.encoder(FoodListMessage::write)
// 			.decoder(FoodListMessage::new)
// 			.consumer(FoodListMessage::handle)
// 			.add();
// 	}
// 	
// 	public SOLCarrot() {
// 		SOLCarrotConfig.setUp();
// 	}
// }


import com.cazsius.solcarrot.SOLCarrot;
import net.minecraft.item.*;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nullable;
import java.util.Objects;
import java.util.Optional;
package com.cazsius.solcarrot.tracking;



public final class FoodInstance {
	public final Item item;
	
	public FoodInstance(Item item) {
		this.item = item;
		if (!item.isFood()) throw new RuntimeException("Attempting to construct FoodInstance from non-food item.");
	}
	
	@Nullable
	public static FoodInstance decode(String encoded) {
		ResourceLocation name = new ResourceLocation(encoded);
		
		// TODO it'd be nice to store (and maybe even count) references to missing items, in case the mod is added back in later
		Item item = ForgeRegistries.ITEMS.getValue(name);
		if (item == null) {
// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java
// @Mod(SOLCarrot.MOD_ID)
// @Mod.EventBusSubscriber(modid = SOLCarrot.MOD_ID, bus = MOD)
// public final class SOLCarrot {
// 	public static final String MOD_ID = "solcarrot";
// 	
// 	public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
// 	
// 	private static final String PROTOCOL_VERSION = "1.0";
// 	public static SimpleChannel channel = NetworkRegistry.ChannelBuilder
// 		.named(resourceLocation("main"))
// 		.clientAcceptedVersions(PROTOCOL_VERSION::equals)
// 		.serverAcceptedVersions(PROTOCOL_VERSION::equals)
// 		.networkProtocolVersion(() -> PROTOCOL_VERSION)
// 		.simpleChannel();
// 	
// 	public static ResourceLocation resourceLocation(String path) {
// 		return new ResourceLocation(MOD_ID, path);
// 	}
// 	
// 	// TODO: not sure if this is even implemented anymore
// 	@SubscribeEvent
// 	public static void onFingerprintViolation(FMLFingerprintViolationEvent event) {
// 		// This complains if jar not signed, even if certificateFingerprint is blank
// 		LOGGER.warn("Invalid Fingerprint!");
// 	}
// 	
// 	@SubscribeEvent
// 	public static void setUp(FMLCommonSetupEvent event) {
// 		channel.messageBuilder(FoodListMessage.class, 0)
// 			.encoder(FoodListMessage::write)
// 			.decoder(FoodListMessage::new)
// 			.consumer(FoodListMessage::handle)
// 			.add();
// 	}
// 	
// 	public SOLCarrot() {
// 		SOLCarrotConfig.setUp();
// 	}
// }


// Path: src/main/java/com/cazsius/solcarrot/tracking/FoodInstance.java
import com.cazsius.solcarrot.SOLCarrot;
import net.minecraft.item.*;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nullable;
import java.util.Objects;
import java.util.Optional;

package com.cazsius.solcarrot.tracking;



public final class FoodInstance {
	public final Item item;
	
	public FoodInstance(Item item) {
		this.item = item;
		if (!item.isFood()) throw new RuntimeException("Attempting to construct FoodInstance from non-food item.");
	}
	
	@Nullable
	public static FoodInstance decode(String encoded) {
		ResourceLocation name = new ResourceLocation(encoded);
		
		// TODO it'd be nice to store (and maybe even count) references to missing items, in case the mod is added back in later
		Item item = ForgeRegistries.ITEMS.getValue(name);
		if (item == null) {
			SOLCarrot.LOGGER.warn("attempting to load item into food list that is no longer registered: " + encoded + " (removing from list)");