Jump to content

Block JSON problems


scaper12123

Recommended Posts

I can't for the life of me find my issue with these ore blocks I'm trying to texture. Everything is in place, but something is missing to make the blocks render when placed in the world. For my copper ore block, as an example, the item renders fine in the inventory but when placed it gives me the default purple and black with the phrase: "rm:copper_ore#variant=copper" Fiddling around with my JSON seems to have done nothing.

 

This is what my JSON looks like, and if there is other information that needs knowing I'll happily provide it. I just want to understand what my issue here is.

For the blockstates, all of my ores are kept in a JSON file I call overworld_ores, a placeholder for when I diversify the locations of this ore. The ores were originally in their own json files named after the blocks, but I tried consolidating them after my attempts to do otherwise failed similarly. I suspect my issue is in this file, since only the block itself is having problems.

Quote

{
    "variants":
    {
        "variant=copper": { "model:": "rm:copper_ore"},
        "variant=tin": { "model:": "rm:tin_ore"},
        "variant=mithril": { "model:": "rm:mithril_ore"},
        "variant=luminite": { "model:": "rm:luminite_ore"},
        "variant=adamantite": { "model:": "rm:adamantite_ore"},
        "variant=runite": { "model:": "rm:runite_ore"}
    }
}

 

Then for the block model (of copper ore, for sake of example), I have the following

Quote

{
   "parent": "block/cube_all",
   "textures": {
       "all": "rm:blocks/copper_ore"
   }
}

 

And finally for the item model, I have this:

Quote

{
   "parent": "rm:block/copper_ore"
}

 

I am absolutely sure that the name "copper_ore" corresponds to the ore block as I intend, since it's showing up as an item correctly. I'm guessing my problem is an issue with blockstate, but any help understanding this would be appreciated.

Link to comment
Share on other sites

Post the error you get in the log. The whole thing. 

If you feel like it you can read them too and find a "Caused By" that actually tells you something. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

2 hours ago, scaper12123 said:

It doesn't generate an error log though.

Yes it is. It's a file called fml-client-latest.log in the logs folder of your run directory. There has to be an error in the log if you're getting a missing model.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

4 hours ago, larsgerrits said:

Yes it is. It's a file called fml-client-latest.log in the logs folder of your run directory. There has to be an error in the log if you're getting a missing model.

OK so as it turns out you're absolutely right and I had not realized that log was there until now. I think I have an idea of what my problem is, but it sadly means I'm going to be rewriting the entire code block that creates my ores. Whelp. Here's the log, if you're curious.

 

What I believe the problem is is how I've coded it or, rather, how the tutorial I follow coded it. The tutorial encourages using variants by using an Enum. However, this originally created problems for me because each type of ore I had created a variant of ore for each of the ores. I.E. For copper ore, I had copper#copper, copper#tin, copper#mithril, etc etc. This turned 6 ores into 36. I eventually fixed this by removing the code that spawns in the extra variants, meaning only one variant would spawn in. I even fixed the issue where the ores had no textures (except for the placed block). However, according to this log the extra variants still exist; the game is just not able to add them cause the code to add them in is commented out. So the code still relies on variants, and it's still getting messed up.

 

So instead of all this debauchery, I'll just code up each of the variants individually. It's more work and more code but, until I can figure out these variant issues, I'll have to go with that.

fml-client-latest.log

Link to comment
Share on other sites

5 minutes ago, scaper12123 said:

OK so as it turns out you're absolutely right and I had not realized that log was there until now. I think I have an idea of what my problem is, but it sadly means I'm going to be rewriting the entire code block that creates my ores. Whelp. Here's the log, if you're curious.

 

What I believe the problem is is how I've coded it or, rather, how the tutorial I follow coded it. The tutorial encourages using variants by using an Enum. However, this originally created problems for me because each type of ore I had created a variant of ore for each of the ores. I.E. For copper ore, I had copper#copper, copper#tin, copper#mithril, etc etc. This turned 6 ores into 36. I eventually fixed this by removing the code that spawns in the extra variants, meaning only one variant would spawn in. I even fixed the issue where the ores had no textures (except for the placed block). However, according to this log the extra variants still exist; the game is just not able to add them cause the code to add them in is commented out. So the code still relies on variants, and it's still getting messed up.

 

So instead of all this debauchery, I'll just code up each of the variants individually. It's more work and more code but, until I can figure out these variant issues, I'll have to go with that.

fml-client-latest.log

 

How many models do you have in your models folder ? What are they ?

 

From the fml-client-latest.log file, your main error seems to be :

 

Quote

[13:34:41] [main/ERROR] [FML/]: Exception loading model for variant rm:copper_ore#variant=tin for blockstate "rm:copper_ore[variant=tin]"

 

I suppose that either there is no such model file or there is a problem from registering block models.

Edited by Major Squirrel

Squirrel ! Squirrel ! Squirrel !

Link to comment
Share on other sites

1 minute ago, Major Squirrel said:

How many models do you have in your models folder ? What are they ?

3

Probably in the realm of 30 for blocks and 60 for items. I'm sure there's a way to consolidate these things but I'm not experienced enough with modding to understand how to do that safely. My format right now, except for that one blockstates file, is for each item to have its own item JSON and for each block to have its own item, block, and blockstate JSON. It's gotten quite cramped in that folder. So for another ore I have that I haven't implemented in my mod atm, Drakolith Ore, I have the following files:

Quote

// blockstate

{
    "variants": {
        "normal": { "model": "rm:drakolith_block" }
    }
}

 
Quote

// block

{
   "parent": "block/cube_all",
   "textures": {
       "all": "rm:blocks/drakolith_ore"
   }
}

 
Quote

// item

{
   "parent": "rm:block/drakolith_ore"
}

 

I should probably do something to consolidate them into fewer files, but my inexperience and lack of reliable tutorials on how to format mod JSON properly is making this difficult

 

 

11 minutes ago, Major Squirrel said:

they ?he fml-client-latest.log file, your main error seems to be :

 

I suppose that either there is no such model file or there is a problem from registering block models.

1

It's possibly both in the case of copper_ore#variant=tin_ore, since I removed the code that allows that to exist. In the case of ores I actually want to exist, i.e. the copper ore that isn't a variant of any kind and just exists like a good little ore block, is likely just missing the model because I have no clue how to format its json correctly to give it an actual model.

Link to comment
Share on other sites

Do your blocks have variants?

Because the issue is that the blockstate file doens't have the variant (or there's an issue with the data inside that variant).

Post your block code for your copper ore.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I may as well get an answer to this mystery. Here is what my copper ore looks like:

Quote

public class CopperOre extends ModOres{

    public CopperOre(String name, String dimension) {
        super(name, dimension);
        setSoundType(SoundType.STONE);
        setHardness(3.0F);
        setResistance(15.0F);
        setHarvestLevel("pickaxe", 0);
        setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, EnumHandler.EnumType.COPPER));
        
    }
}

 
Quote

public class ModOres extends Block implements IHasModel, IMetaName{
    public static final PropertyEnum<EnumHandler.EnumType> VARIANT = 
            PropertyEnum.<EnumHandler.EnumType>create("variant", EnumHandler.EnumType.class);
    
    private String name, dimension;
    
    public ModOres(String name, String dimension) {
        super(Material.ROCK);
        setUnlocalizedName(name);
        setRegistryName(name);
        setCreativeTab(Main.tabRunecraftMod);
        
        this.name = name;
        this.dimension = dimension;
        
        ModBlocks.BLOCKS.add(this);
        ModItems.ITEMS.add(new ItemBlockVariants(this).setRegistryName(this.getRegistryName()));
    }
    
    @Override
    public int damageDropped(IBlockState state) {
        return ((EnumHandler.EnumType)state.getValue(VARIANT)).getMeta();
    }
    
    @Override
    public int getMetaFromState(IBlockState state) {
        return ((EnumHandler.EnumType)state.getValue(VARIANT)).getMeta();
    }
    
    @Override
    public IBlockState getStateFromMeta(int meta) {
        return this.getDefaultState().withProperty(VARIANT, EnumHandler.EnumType.byMetadata(meta));
    }
    
    @Override
    public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos,
            EntityPlayer player) {
        return new ItemStack(Item.getItemFromBlock(this), 1, getMetaFromState(world.getBlockState(pos)));
    }
    
    /*
    @Override
    public void getSubBlocks(CreativeTabs itemIn, NonNullList<ItemStack> items) {
        for(EnumHandler.EnumType variant : EnumHandler.EnumType.values()) {
            items.add(new ItemStack(this, 1, variant.getMeta()));
        }
    }
    */
    
    @Override
    protected BlockStateContainer createBlockState() {
        return new BlockStateContainer(this, new IProperty[] {VARIANT});
    }
    
    @Override
    public String getSpecialName(ItemStack stack) {
        return EnumHandler.EnumType.values()[stack.getItemDamage()].getName();
    }

    @Override
    public void registerModels() {
        Main.proxy.registerItemRenderer(Item.getItemFromBlock(this), 0, "inventory");
        /*
        for(int i=0; i<EnumHandler.EnumType.values().length; i++) {
            Main.proxy.registerVariantRenderer(Item.getItemFromBlock(this), 
                    i, 
                    "ore_" + this.dimension + "_" + EnumHandler.EnumType.values().getName(), 
                    "inventory");
        }
        */
    }

}

1
Quote

public class EnumHandler {
    
    public static enum EnumType implements IStringSerializable{
        COPPER(0, "copper"),
        TIN(1, "tin"),
        MITHRIL(2, "mithril"),
        LUMINITE(3, "luminite"),
        ADAMANTITE(4, "adamantite"),
        RUNITE(5, "runite")
        ;
        
        private static final EnumType[] META_LOOKUP = new EnumType[values().length];
        private final int meta;
        private final String name, unlocalizedName;
        
        private EnumType(int meta, String name) {
            this(meta, name, name);
        }
        
        private EnumType(int meta, String name, String unlocalizedName) {
            this.meta = meta;
            this.name= name;
            this.unlocalizedName = unlocalizedName;
        }
        
        @Override
        public String getName() {
            return this.name;
        }
        
        public int getMeta() {
            return this.meta;
        }
        
        public String getUnlocalizedName() {
            return this.unlocalizedName;
        }
        
        @Override
        public String toString() {
            return this.name;
        }
        
        public static EnumType byMetadata(int meta) {
            return META_LOOKUP[meta];
        }
        
        static {
            for(EnumType enumtype : values()) {
                META_LOOKUP[enumtype.getMeta()] = enumtype;
            }
        }
    }
}

 

If anyone is curious why I've done it this way, I was following this modding tutorial.

Link to comment
Share on other sites

22 minutes ago, scaper12123 said:

CopperOre extends ModOres

22 minutes ago, scaper12123 said:

    @Override
    protected BlockStateContainer createBlockState() {
        return new BlockStateContainer(this, new IProperty[] {VARIANT});
    }

 

All of your ore blocks declare a variant which is not present in your blockstate.json

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 hour ago, Draco18s said:

 

All of your ore blocks declare a variant which is not present in your blockstate.json

Huh, well I'll have to do a bit of experimenting to figure out how to get that to work but until I do, I'm ditching variants. Thanks for your help though! At least I know what was causing the problem now, and I can probably avoid that later with some more experience.

Link to comment
Share on other sites

If you want to use variants for your ore types you need to use a single block (BlockModOres) with a variant property, then distinguish your different ores by variant, including in the blockstate file.

 

Here's the best example I have:

 

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/flowers/block/BlockOreFlower1.java

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/api/blockproperties/flowers/EnumOreFlower1.java

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/resources/assets/oreflowers/blockstates/oreflowers1.json

 

You'll have to pretend that some of the block properties (Props.FLOWER_STALK,Props.HAS_2D_ITEM) don't actually exist, as they're handled magically* elsewhere (and not relevant here). Additionally, the enum field for ore type is just a convenience mapping for my useage. A flat enum like you already have is fine.

*I use a custom statemapper.

Edited by Draco18s
  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

4 minutes ago, Draco18s said:

If you want to use variants for your ore types you need to use a single block (BlockModOres) with a variant property, then distinguish your different ores by variant, including in the blockstate file.

 

Here's the best example I have:

 

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/flowers/block/BlockOreFlower1.java

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/api/blockproperties/flowers/EnumOreFlower1.java

https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/resources/assets/oreflowers/blockstates/oreflowers1.json

 

You'll have to pretend that some of the block properties (Props.FLOWER_STALK,Props.HAS_2D_ITEM) don't actually exist, as they're handled magically* elsewhere (and not relevant here). Additionally, the enum field for ore type is just a convenience mapping for my useage. A flat enum like you already have is fine.

*I use a custom statemapper.

Good to know! Thanks. This'll definitely help as this mod I'm building gets more advanced. I'm only planning on a few ore blocks right now, only a few of which will be shared between dimensions, but as I add more worlds I'll definitely need to get into variants.

Link to comment
Share on other sites

54 minutes ago, scaper12123 said:

but as I add more worlds I'll definitely need to get into variants.

Just remember to group them by functionality. "This ore appears in the nether" isn't really important. If you've only got 12 ores across all dimensions, you can still squeeze that into one block + metadata.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.