Jump to content

Failing to find model json file


SciHi

Recommended Posts

I have been working at this for hours now; following countless different tutorials but to no avail.
I am creating a new item like so:

public class Item_NewIngot extends Item
{
	public Item_NewIngot()
	{
		setUnlocalizedName("newingot");
		setRegistryName("newingot");
		
		setCreativeTab(Wire.tab);
	}
	public void registerModel()
	{
		ModelLoader.setCustomModelResourceLocation(this, 0, new ModelResourceLocation("wire:newingot", "inventory"));
	}
}

I register it in

public static void registerItems(RegistryEvent.Register<Item> event)

I call registerModel in

public static void registerItems(ModelRegistryEvent event) 

But this never actually works, I get an output like this when forge loads:

Quote

Caused by: java.io.FileNotFoundException: wire:models/item/newingot.json

So for some reason it doesn't find the json file.

I know it exists and I have it under that directory - attached an image

Here is the contents of that file:

{
	"parent": "item/generated",
	"textures": 
	{
		"layer0": "wire:items/newingot"
	}
}

And I also have the icon here - attached another image

Why isn't this working?

dir.png

dir2.png

Link to comment
Share on other sites

Your modding workspace is set up in your roaming AppData folder? So that's where your project file is? It seems like you're putting your JSON in your regular minecraft location not your project asset location...

 

Can you show screenshot of Eclipse's package explorer tree showing the resource package location?

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Just now, jabelar said:

Your modding workspace is set up in your roaming AppData folder? So that's where your project file is? It seems like you're putting your JSON in your regular minecraft location not your project asset location...

 

Can you show screenshot of Eclipse's package explorer tree showing the resource package location?

Oh I know how weird it looks, I created a modding folder in the .minecraft folder just so I didn't have to have everything dumped on the desktop.

Here is a screenshot of all the directories and stuff

dir3.png

Link to comment
Share on other sites

Quote from StackOverflow. " There are three cases where a FileNotFoundException may be thrown. The named file does not exist. The named file is actually a directory. The named file cannot be opened for reading for some reason. The first two cases are unlikely based on your description. I would test against the third case using file.canRead() . "

 

Link to comment
Share on other sites

Also try running

attrib -R -H /D /S C:\Users\Reece\AppData\Roaming\.minecraft

This will remove both the hidden and read-only attributes from .minecraft and all of its subfolders and files.

Link to comment
Share on other sites

11 minutes ago, hiotewdew said:

Quote from StackOverflow. " There are three cases where a FileNotFoundException may be thrown. The named file does not exist. The named file is actually a directory. The named file cannot be opened for reading for some reason. The first two cases are unlikely based on your description. I would test against the third case using file.canRead() . "

 

I was going to mention a similar thing -- I think AppData folder might have permissions issues in some cases.

 

The first two cases are still possible -- the smallest typo can cause a file to not be found. For example, I'm assuming your mod id is actually "wire" all lower cases and stuff. I usually try to avoid typos by only entering the text once -- for example, in your model registration instead of "wire:newingot.json" I would usually code it as ingotInstance.getRegistryName(). In my example of course you would replace  ingotInstance with the injected instance from your item registration.

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Ok so if I do a full build through the commands line then launch the game it works!

Then if I do the same thing through the IDE then it doesn't...

 

I assume it must be to do with the permissions now then

 

2 minutes ago, hiotewdew said:

Also try running


attrib -R -H /D /S C:\Users\Reece\AppData\Roaming\.minecraft

This will remove both the hidden and read-only attributes from .minecraft and all of its subfolders and files.

I ran this but nothing changed unfortunately.

Link to comment
Share on other sites

I would make a new project in a little better of a folder. Hidden appdata folders are not a good place to have configuration heavy IDE projects.

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



  • 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.