Farming for Blockheads

Farming for Blockheads

79M Downloads

IMC Handler non-functional

Tohricat opened this issue ยท 2 comments

commented

Minecraft Version

1.18.x

Mod Loader

Forge

Mod Loader Version

1.18.2

Mod Version

10.0.1

Describe the Issue

Hello! I'm writing a mod that adds seasonal categories to the market, however, no categories nor entries can be made. There are no errors. I've attached code below. Let me know if you require anything else - thanks!

@Mod.EventBusSubscriber(modid = "seasonal_seed_shop", bus = Mod.EventBusSubscriber.Bus.MOD)
public class Events {

	@SubscribeEvent
	public static void onIMCEvent(InterModEnqueueEvent event) {	
		
		final Logger LOGGER = LogManager.getLogger();
		
		CompoundTag winterData = new CompoundTag();
		winterData.putString("RegistryName", "seasonal_seed_shop:winter_crops");
		winterData.putString("Tooltip", "Winter");
		winterData.putString("Icon", "minecraft:snowball");
		winterData.putInt("SortIndex", 4);
		
		CompoundTag springData = new CompoundTag();
		springData.putString("RegistryName", "seasonal_seed_shop:spring_crops");
		springData.putString("Tooltip", "Spring");
		springData.putString("Icon", "minecraft:allium");
		springData.putInt("SortIndex", 1);
		
		CompoundTag summerData = new CompoundTag();
		summerData.putString("RegistryName", "seasonal_seed_shop:summer_crops");
		summerData.putString("Tooltip", "Summer");
		summerData.putString("Icon", "minecraft:melon_slice");
		summerData.putInt("SortIndex", 2);
		
		CompoundTag autumnData = new CompoundTag();
		autumnData.putString("RegistryName", "seasonal_seed_shop:autumn_crops");
		autumnData.putString("Tooltip", "Autumn");
		autumnData.putString("Icon", "minecraft:brown_dye");
		autumnData.putInt("SortIndex", 3);
		
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketCategory", () -> winterData );
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketCategory", () -> springData );
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketCategory", () -> summerData );
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketCategory", () -> autumnData );
		
		CompoundTag test = new CompoundTag();
		test.putString("OutputItem", "minecraft:diamond");
		test.putString("CostItem", "minecraft:emerald");
		test.putString("Category", "farmingforblockheads:seeds");
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketEntry", () -> { return test; });
		
		LOGGER.fatal("Hello from Seasonal Seeds Shop!");
	}
}

Logs

No response

Do you use any performance-enhancing mods (e.g. OptiFine)?

Radium, FerriteCore, Rubidium

commented

Thanks for your response on Discord, Blay. I've modified the "Icon" to now be a tag, but I'm still getting nothing - no categories, nor anything in the logs. Here's the code.



@Mod.EventBusSubscriber(modid = "seasonal_seed_shop", bus = Mod.EventBusSubscriber.Bus.MOD)
public class Events {

	@SubscribeEvent
	public static void onIMCEvent(InterModEnqueueEvent event) {	
		
		final Logger LOGGER = LogManager.getLogger();
		
		ItemStack autumnIcon = new ItemStack(Items.STONE_HOE);
		CompoundTag iconTag = new CompoundTag();
		autumnIcon.save(iconTag);
		
		LOGGER.fatal(ItemStack.of(iconTag).getItem().getRegistryName());
		
		CompoundTag winterData = new CompoundTag();
		winterData.putString("RegistryName", "seasonal_seed_shop:winter_crops");
		winterData.putString("Tooltip", "Winter");
		winterData.put("Icon", iconTag);
		winterData.putInt("SortIndex", 4);
		
		CompoundTag springData = new CompoundTag();
		springData.putString("RegistryName", "seasonal_seed_shop:spring_crops");
		springData.putString("Tooltip", "Spring");
		springData.put("Icon", iconTag);
		springData.putInt("SortIndex", 1);
		
		CompoundTag summerData = new CompoundTag();
		summerData.putString("RegistryName", "seasonal_seed_shop:summer_crops");
		summerData.putString("Tooltip", "Summer");
		summerData.put("Icon", iconTag);
		summerData.putInt("SortIndex", 2);
				
		CompoundTag autumnData = new CompoundTag();
		autumnData.putString("RegistryName", "seasonal_seed_shop:autumn_crops");
		autumnData.putString("Tooltip", "Autumn");
		autumnData.put("Icon", iconTag);
		autumnData.putInt("SortIndex", 3);
		
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketCategory", () -> winterData );
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketCategory", () -> springData );
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketCategory", () -> summerData );
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketCategory", () -> autumnData );
		
		ItemStack boat = new ItemStack(Items.ACACIA_BOAT);
		CompoundTag boatTag = new CompoundTag();
		boat.save(boatTag);
		
		CompoundTag test = new CompoundTag();
		test.put("OutputItem", boatTag);
		test.put("CostItem", boatTag);
		test.putString("Category", "seasonal_seed_shop:summer_crops");
		InterModComms.sendTo("farmingforblockheads", "RegisterMarketEntry", () -> { return test; });
		
		LOGGER.fatal("Hello from Seasonal Seeds Shop!");
	}
}

I also tested by adding a boat item to the category, but still nothing appears in the market.

commented

You are right, it seems the IMC API is currently non-functional because its registrations are reset when a world is loaded.

I recommend using the data pack API instead by placing json files like this in your mod's resources, since I probably won't be fixing IMC before 1.19:

https://github.com/ModdingForBlockheads/FarmingForBlockheads/tree/1.18.x/shared/src/main/resources/data/farmingforblockheads/farmingforblockheads_compat

Example file: https://gist.github.com/blay09/93a48d092d6dc570a64c81e1912dc4d0