// Path: src/main/java/com/cazsius/solcarrot/communication/FoodListMessage.java
// public final class FoodListMessage {
// 	private CompoundNBT capabilityNBT;
// 	
// 	public FoodListMessage(FoodList foodList) {
// 		this.capabilityNBT = foodList.serializeNBT();
// 	}
// 	
// 	public FoodListMessage(PacketBuffer buffer) {
// 		this.capabilityNBT = buffer.readCompoundTag();
// 	}
// 	
// 	public void write(PacketBuffer buffer) {
// 		buffer.writeCompoundTag(capabilityNBT);
// 	}
// 	
// 	public void handle(Supplier<NetworkEvent.Context> context) {
// 		DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> Handler.handle(this, context));
// 	}
// 	
// 	private static class Handler {
// 		static void handle(FoodListMessage message, Supplier<NetworkEvent.Context> context) {
// 			context.get().enqueueWork(() -> {
// 				PlayerEntity player = Minecraft.getInstance().player;
// 				FoodList.get(player).deserializeNBT(message.capabilityNBT);
// 			});
// 			context.get().setPacketHandled(true);
// 		}
// 	}
// }


import com.cazsius.solcarrot.communication.FoodListMessage;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import static net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD;
package com.cazsius.solcarrot;



@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) {
// Path: src/main/java/com/cazsius/solcarrot/communication/FoodListMessage.java
// public final class FoodListMessage {
// 	private CompoundNBT capabilityNBT;
// 	
// 	public FoodListMessage(FoodList foodList) {
// 		this.capabilityNBT = foodList.serializeNBT();
// 	}
// 	
// 	public FoodListMessage(PacketBuffer buffer) {
// 		this.capabilityNBT = buffer.readCompoundTag();
// 	}
// 	
// 	public void write(PacketBuffer buffer) {
// 		buffer.writeCompoundTag(capabilityNBT);
// 	}
// 	
// 	public void handle(Supplier<NetworkEvent.Context> context) {
// 		DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> Handler.handle(this, context));
// 	}
// 	
// 	private static class Handler {
// 		static void handle(FoodListMessage message, Supplier<NetworkEvent.Context> context) {
// 			context.get().enqueueWork(() -> {
// 				PlayerEntity player = Minecraft.getInstance().player;
// 				FoodList.get(player).deserializeNBT(message.capabilityNBT);
// 			});
// 			context.get().setPacketHandled(true);
// 		}
// 	}
// }


// Path: src/main/java/com/cazsius/solcarrot/SOLCarrot.java
import com.cazsius.solcarrot.communication.FoodListMessage;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLFingerprintViolationEvent;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import static net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD;

package com.cazsius.solcarrot;



@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)