Jump to content

registry override prevent json parse error


DutchM

Recommended Posts

In my mod I am trying to do a registry override, which works fine, but since the vanilla item didn't have any variants and my override item does, it causes a jsonparseerror on every single recipe that uses the item. I was wondering if there was any way to prevent this (it's caused by the fact that the json recipes don't have a data value as the original item doesn't have one, but since the override does have variants it requires a data value in the json). I looked through the stacktrace of the json error and could not find any place where a mod might hook into the process of loading recipe jsons. I condifered a few possible options to resolve this, but none of them are particularly helpful:

  • before the recipes are parsed, find every json recipe that would cause a jsonerror as a direct result of my override and fix the issue in the json file. This is not a solution since my mod may not always have the permissions to write, and may also cause issues in modloaders that do some form of version-checking or whatever.
  • use some method to catch exceptions from another thread. Not possible since the exception is already caught by the thread itself.
  • look for all recipes that would cause a jsonerror as a direct result of my override, parse them myself, then register the result. While definetely possible this would be a rather inefficient way to do it, and would also not prevent the json errors from occuring.

while the third option is possible, it would be nice to know if there is any point in which a mod can interrupt the recipe loading process (for instance if there's a hook i missed that let's you acess the json object or the loader or something)

Some things of note:

Vanilla recipes seem to be handled by a different loader which is perfectly capable of ignoring wheter or not an item has variants.
I can't fix the recipe registry entries after the fact, since the json error prevents the recipes from entering the registry in the first place.

Edited by DutchM
clarify
Link to comment
Share on other sites

Does having your own correct recipes in assets/minecraft/recipes work?

Edited by Cadiboo

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Yes, recipes aren't broken in general, it's just that recipes that use string that don't set a data tag are broken, and I have no control over what other modders do with their recipes, so I would like to make it so my mod fixes those recipes (that is, other mod's json recipes that use vanilla string).

Link to comment
Share on other sites

I think you could probably make your own IRecipe implementation and wrap the vanilla one to fix those conflicts. Just an idea tho

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

"the vanilla item didn't have any variants and my override item does"

That is your problem.

When replacing a registry item, do not add variants. You must replace the item exactly as is. if you need more then add an extra registry entry and translate them as needed.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

7 minutes ago, LexManos said:

"the vanilla item didn't have any variants and my override item does"

That is your problem.

When replacing a registry item, do not add variants. You must replace the item exactly as is. if you need more then add an extra registry entry and translate them as needed.

I'm fully aware that that is the cause of the issue. I'm looking for a way to circumvent the issue without changing that. As far as I can tell using some reference searches in Eclipse, recipes are the only thing that break by doing this. 

Link to comment
Share on other sites

Variants should be separate items in 1.13 anyway, so I think you should have the vanilla one as your default variant. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Just now, Cadiboo said:

Variants should be separate items in 1.13 anyway, so I think you should have the vanilla one as your default variant. 

I can definitely do that, and I probably will if there's really no circumventing this, but I'd really prefer seeing if there's a way to circumvent it since that wouls save alot of work rn, and also be clearer to the player imo. 

Link to comment
Share on other sites

16 minutes ago, DutchM said:

I can definitely do that, and I probably will if there's really no circumventing this, but I'd really prefer seeing if there's a way to circumvent it since that wouls save alot of work rn, and also be clearer to the player imo. 

You can still change the texture and the name of the object, there should be no difference to the end user

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Link to comment
Share on other sites

Just now, Cadiboo said:

You can still change the texture and the name of the object, there should be no difference to the end user

There is when using commands etc. Shouldn't be too big of a deal but eh there's no way to circumvent the error anyway so I suppose I'll have to redo my colored string. 

Link to comment
Share on other sites

"You shouldn't do that as that is now what the system is designed for"

"I still wanna do the thing even tho you just told me that it is the wrong way to do it because... I'm special..."

Seriously? No. Don't 'circumvent it' just use the system the way it was designed.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

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