Jump to content

Custom RecipeSerializer not working. [1.15.2]


CookieLukas

Recommended Posts

I have registered a custom recipe serilizer called BlastFurnaceRecipeSerializer,  which extends from my class  MasaRecipeSerializer. I copyed most of the the structure from ImmersiveEngineering.
Now I registered the method like this:
 

public static final RegistryObject<BlastFurnaceRecipeSerializer> BLAST_FURNACE_RECIPES = RECIPE_SERIALIZERS.register("blast_recipe", BlastFurnaceRecipeSerializer::new);
   
  //or
  
static {
    BlastFurnaceRecipe.SERIALIZER = RECIPE_SERIALIZERS.register(
			"blast_recipes", BlastFurnaceRecipeSerializer::new
	);
}

And put a debug message in the read function of the serilizer.  The message is not being printed. What could be the problem.
Heres my reciepy:
 

{
  "type": "masa:blast_recipe",
  "result": {
    "tag": "minecraft:glass"
  },
  "input": {
    "tag": "minecraft:diamond"
  },
  "time": 5
}

 

Edited by CookieLukas
version
Link to comment
Share on other sites

3 minutes ago, diesieben07 said:

Well, which one is it?

Please post the whole registration class.

Sorry, that was a bit unclear, I tried both. Heres the revevant stuff of the registration, I appreciate you help:

 

public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = new DeferredRegister<>(ForgeRegistries.RECIPE_SERIALIZERS, MODID);

public static void init() {
	RECIPE_SERIALIZERS.register(FMLJavaModLoadingContext.get().getModEventBus());
}

 

Link to comment
Share on other sites

4 minutes ago, diesieben07 said:

Snippets do not help, as the context is relevant.

Ok, here the whole class, everything else is working fine.
 

public class Registration {
	
	private static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID);
    private static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID);
    private static final DeferredRegister<TileEntityType<?>> TILES = new DeferredRegister<>(ForgeRegistries.TILE_ENTITIES, MODID);
    private static final DeferredRegister<ContainerType<?>> CONTAINERS = new DeferredRegister<>(ForgeRegistries.CONTAINERS, MODID);
    private static final DeferredRegister<EntityType<?>> ENTITIES = new DeferredRegister<>(ForgeRegistries.ENTITIES, MODID);
    private static final DeferredRegister<ModDimension> DIMENSIONS = new DeferredRegister<>(ForgeRegistries.MOD_DIMENSIONS, MODID);
    private static final DeferredRegister<Biome> BIOMES = new DeferredRegister<>(ForgeRegistries.BIOMES, MODID);
    private static final DeferredRegister<Fluid> FLUIDS = new DeferredRegister<>(ForgeRegistries.FLUIDS, MODID);
    //private static final DeferredRegister<SpecialRecipeSerializer<IRecipe<?>>> RECIPE_SERIALIZER = new DeferredRegister<>(ForgeRegistries.RECIPE_SERIALIZERS, MODID);
    public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = new DeferredRegister<>(ForgeRegistries.RECIPE_SERIALIZERS, MODID);

    public static void init() {
        BLOCKS.register(FMLJavaModLoadingContext.get().getModEventBus());
        ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
        TILES.register(FMLJavaModLoadingContext.get().getModEventBus());
        CONTAINERS.register(FMLJavaModLoadingContext.get().getModEventBus());
        ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus());
        DIMENSIONS.register(FMLJavaModLoadingContext.get().getModEventBus());
        BIOMES.register(FMLJavaModLoadingContext.get().getModEventBus());
        FLUIDS.register(FMLJavaModLoadingContext.get().getModEventBus());
        RECIPE_SERIALIZERS.register(FMLJavaModLoadingContext.get().getModEventBus());

    }
    
//----------------------------------------

    public static final RegistryObject<Biome> TESTBIOME = BIOMES.register("testbiome", TestBiome::new);
    public static final RegistryObject<VoidModDimension> DIMENSION = DIMENSIONS.register("dimension", VoidModDimension::new);  
    
    public static final RegistryObject<BlastFurnaceRecipeSerializer> BLAST_FURNACE_RECIPES = RECIPE_SERIALIZERS.register("blast_recipe", BlastFurnaceRecipeSerializer::new);
    
    public static final RegistryObject<BlockIronFurnace> IRON_FURNACE = BLOCKS.register(BlockIronFurnace.IRON_FURNACE, BlockIronFurnace::new);
    public static final RegistryObject<Item> IRON_FURNACE_ITEM = ITEMS.register(BlockIronFurnace.IRON_FURNACE, () -> new BlockItem(IRON_FURNACE.get(), new Item.Properties().group(ItemGroup.MISC)));
    public static final RegistryObject<TileEntityType<BlockIronFurnaceTile>> IRON_FURNACE_TILE = TILES.register(BlockIronFurnace.IRON_FURNACE, () -> TileEntityType.Builder.create(BlockIronFurnaceTile::new, IRON_FURNACE.get()).build(null));

    public static final RegistryObject<ContainerType<BlockIronFurnaceContainer>> IRON_FURNACE_CONTAINER = CONTAINERS.register(BlockIronFurnace.IRON_FURNACE, () -> IForgeContainerType.create((windowId, inv, data) -> {
        BlockPos pos = data.readBlockPos();
        return new BlockIronFurnaceContainer(windowId, Minecraft.getInstance().world, pos, inv, Minecraft.getInstance().player);
    }));
//--------------------------------------------------------------------
    
    
  //fluidtest
    public static final RegistryObject<Item> OIL_BUCKET = ITEMS.register("oil_bucket", () -> new BucketItem(() -> ModFluids.oil, new Item.Properties().group(ItemGroup.MISC).maxStackSize(1)));
    public static final RegistryObject<Block> OIL = BLOCKS.register("flowing_oil", ()-> new FlowingFluidBlock(() -> ModFluids.oil, Block.Properties.create(Material.WATER).doesNotBlockMovement().noDrops()));
    
    
    //test
    public static final RegistryObject<Item> TESTITEM = ITEMS.register("testitem", TestItem::new);
    public static final RegistryObject<Item> FIRSTITEM = ITEMS.register("firstitem", () -> new Item(new Item.Properties().group(ItemGroup.MISC).maxStackSize(4)));
    public static final RegistryObject<Item> SECONDITEM = ITEMS.register("seconditem", () -> new Item(new Item.Properties().group(ItemGroup.MISC).maxStackSize(64)));
}

 

Link to comment
Share on other sites

 

NEVERMIND, FOUND THE ISSUE, I HAD A MAP IN THE RECIPE CLASS WHICH WAS NOT INITALIZED CORRECTLY.

21 hours ago, diesieben07 said:

Does the JSON file get loaded if you change the type to a vanilla recipe? As in: Are you sure the JSON file is not the problem.

It was the json, I misspelled something, but now its still not loading, It crashes while it tries to load the advancements.
Ive found this anwser from you, but I dont think anything in my recipe could be invalid:
Heres all the relevant info:
Recipe:

{
  "type": "masa:blast_recipe",
  "result": {
    "item": "minecraft:diamond"
  },
  "input": {
    "item": "minecraft:coal"
  },
  "time": 10
}


Class:

	@Override
	public BlastFurnaceRecipe readFromJson(ResourceLocation recipeId, JsonObject json)
	{
		ItemStack output = readOutput(json.get("result"));
		Ingredient input = Ingredient.deserialize(json.get("input"));
		int time = JSONUtils.getInt(json, "time", 200);
		ItemStack slag = ItemStack.EMPTY;
		if(json.has("slag"))
			slag = readOutput(JSONUtils.getJsonObject(json, "slag"));
		System.out.println("recipemod");
		System.out.println(output.getDisplayName().getString());
		return new BlastFurnaceRecipe(recipeId, output, input, time, slag);
	}

	@Nullable
	@Override
	public BlastFurnaceRecipe read(ResourceLocation recipeId, PacketBuffer buffer)
	{
		ItemStack output = buffer.readItemStack();
		Ingredient input = Ingredient.read(buffer);
		int time = buffer.readInt();
		ItemStack slag = ItemStack.EMPTY;
		if(buffer.readBoolean())
			slag = buffer.readItemStack();
		System.out.println("recipemod");
		System.out.println(output.getDisplayName().getString());
		return new BlastFurnaceRecipe(recipeId, output, input, time, slag);
	}


 

[m[32m[10:05:04] [Server thread/INFO] [ne.mi.co.AdvancementLoadFix/]: Using new advancement loading for net.minecraft.advancements.PlayerAdvancements@65947359
[m[1;31m[10:05:04] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception
net.minecraft.crash.ReportedException: Ticking memory connection
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:158) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:903) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662) [?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151] {}
Caused by: java.lang.RuntimeException: Why did the advancements not load yet?!
	at net.minecraftforge.common.AdvancementLoadFix.loadVisibility(AdvancementLoadFix.java:51) ~[?:?] {re:classloading}
	at net.minecraft.advancements.PlayerAdvancements.load(PlayerAdvancements.java:157) ~[?:?] {re:classloading}
	at net.minecraft.advancements.PlayerAdvancements.<init>(PlayerAdvancements.java:65) ~[?:?] {re:classloading}
	at net.minecraft.server.management.PlayerList.getPlayerAdvancements(PlayerList.java:806) ~[?:?] {re:classloading}
	at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:167) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:395) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:120) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:64) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:246) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:152) ~[?:?] {re:classloading}

 

 

// Daisy, daisy...

Time: 11/03/21 10:05
Description: Ticking memory connection

java.lang.RuntimeException: Why did the advancements not load yet?!
	at net.minecraftforge.common.AdvancementLoadFix.loadVisibility(AdvancementLoadFix.java:51) ~[?:?] {re:classloading}
	at net.minecraft.advancements.PlayerAdvancements.load(PlayerAdvancements.java:157) ~[?:?] {re:classloading}
	at net.minecraft.advancements.PlayerAdvancements.<init>(PlayerAdvancements.java:65) ~[?:?] {re:classloading}
	at net.minecraft.server.management.PlayerList.getPlayerAdvancements(PlayerList.java:806) ~[?:?] {re:classloading}
	at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:167) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:395) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:120) ~[?:?] {re:classloading}
	at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:64) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:246) ~[?:?] {re:classloading}
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:152) ~[?:?] {re:classloading}
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:903) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662) ~[?:?] {re:classloading,pl:accesstransformer:B}
	at java.lang.Thread.run(Thread.java:748) ~[?:1.8.0_151] {}


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at net.minecraftforge.common.AdvancementLoadFix.loadVisibility(AdvancementLoadFix.java:51)
	at net.minecraft.advancements.PlayerAdvancements.load(PlayerAdvancements.java:157)
	at net.minecraft.advancements.PlayerAdvancements.<init>(PlayerAdvancements.java:65)
	at net.minecraft.server.management.PlayerList.getPlayerAdvancements(PlayerList.java:806)
	at net.minecraft.entity.player.ServerPlayerEntity.<init>(ServerPlayerEntity.java:167)
	at net.minecraft.server.management.PlayerList.createPlayerForUser(PlayerList.java:395)
	at net.minecraft.network.login.ServerLoginNetHandler.tryAcceptPlayer(ServerLoginNetHandler.java:120)
	at net.minecraft.network.login.ServerLoginNetHandler.tick(ServerLoginNetHandler.java:64)
	at net.minecraft.network.NetworkManager.tick(NetworkManager.java:246)

-- Ticking connection --
Details:
	Connection: net.minecraft.network.NetworkManager@d0ff70a
Stacktrace:
	at net.minecraft.network.NetworkSystem.tick(NetworkSystem.java:152)
	at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:903)
	at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:821)
	at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:120)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:662)
	at java.lang.Thread.run(Thread.java:748)

 

Edited by CookieLukas
Found the issue
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.