Jump to content

[1.8] Crop texture problem


robmart

Recommended Posts

So i have this code for my crop base

package com.robmart.MoreMinecraft.block;

import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.EnumPlantType;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class Crops extends BlockCrops{

    @SideOnly(Side.CLIENT)
    public EnumWorldBlockLayer getBlockLayer()
    {
        return EnumWorldBlockLayer.CUTOUT;
    }

    public boolean isFullCube()
    {
        return false;
    }

    public boolean isOpaqueCube()
    {
        return false;
    }

    @Override
    protected boolean canPlaceBlockOn(Block ground)
    {
        return ground == Blocks.farmland;
    }

    public Crops()
    {
        this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));
        this.setTickRandomly(true);
        float f = 0.5F;
        this.setCreativeTab((CreativeTabs)null);
        this.setHardness(0.0F);
        this.setStepSound(soundTypeGrass);
        this.disableStats();
    }

    public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z)
    {
        return EnumPlantType.Plains;
    }
}

 

And this code for the crop itself

package com.robmart.MoreMinecraft.block;

import com.robmart.MoreMinecraft.init.InitItem;
import com.robmart.MoreMinecraft.reference.Reference;
import net.minecraft.init.Items;
import net.minecraft.item.Item;

public class BlockStrawberriesCrop extends Crops{
    private static String name = "StrawberriesCrop";

    public BlockStrawberriesCrop(){
        this.setUnlocalizedName(Reference.MOD_ID.toLowerCase() + ":" + name);
    }
    
    @Override
    protected Item getSeed()
    {
        //return InitItem.StrawberrySeed;
        return Items.wheat_seeds;
    }

    @Override
    protected Item getCrop()
    {
        return InitItem.Strawberry;
    }

    public  static  String getName(){
        return name;

    }
}

 

And this code for my blockstates

{
    "variants": {
        "age=0": { "model": "moreminecraft:strawberries_stage_0" },
        "age=1": { "model": "moreminecraft:strawberries_stage_1" },
        "age=2": { "model": "moreminecraft:strawberries_stage_2" },
        "age=3": { "model": "moreminecraft:strawberries_stage_3" },
        "age=4": { "model": "moreminecraft:strawberries_stage_4" },
        "age=5": { "model": "moreminecraft:strawberries_stage_5" },
        "age=6": { "model": "moreminecraft:strawberries_stage_6" },
        "age=7": { "model": "moreminecraft:strawberries_stage_7" }
    }
}

 

And I´m getting this error

[19:14:09] [Client thread/WARN]: Unable to load definition moreminecraft:StrawberryCrop#age=1
java.lang.RuntimeException: Encountered an exception when loading model definition of model moreminecraft:blockstates/StrawberryCrop.json
at net.minecraft.client.resources.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:177) ~[ModelBakery.class:?]
at net.minecraft.client.resources.model.ModelBakery.loadVariants(ModelBakery.java:118) [ModelBakery.class:?]
at net.minecraft.client.resources.model.ModelBakery.func_177577_b(ModelBakery.java:98) [ModelBakery.class:?]
at net.minecraft.client.resources.model.ModelBakery.setupModelRegistry(ModelBakery.java:88) [ModelBakery.class:?]
at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29) [ModelManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.notifyReloadListeners(SimpleReloadableResourceManager.java:134) [simpleReloadableResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.reloadResources(SimpleReloadableResourceManager.java:118) [simpleReloadableResourceManager.class:?]
at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:766) [Minecraft.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:306) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:520) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:355) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_25]
at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_25]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) [idea_rt.jar:?]
Caused by: java.io.FileNotFoundException: moreminecraft:blockstates/StrawberryCrop.json
at net.minecraft.client.resources.FallbackResourceManager.getAllResources(FallbackResourceManager.java:99) ~[FallbackResourceManager.class:?]
at net.minecraft.client.resources.SimpleReloadableResourceManager.getAllResources(SimpleReloadableResourceManager.java:81) ~[simpleReloadableResourceManager.class:?]
at net.minecraft.client.resources.model.ModelBakery.getModelBlockDefinition(ModelBakery.java:152) ~[ModelBakery.class:?]
... 24 more

 

And other errors like that one for age 1-7. What do i do?

Link to comment
Share on other sites

Hi

 

You probably haven't registered your variants properly or there is a subtle mismatch between the name of your files

 

You might find this link useful

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

(see the Block Rendering topics)

 

also this example project which has a working example of variants (example 3)

https://github.com/TheGreyGhost/MinecraftByExample

 

(Edit: brainfade suggestion removed - sorry)

 

You could try searching the vanilla code for the text message "Unable to load definition ", putting a breakpoint there, and inspecting the name and the registry to see what has been registered compared with what the code expects to find.

 

-TGG

 

Link to comment
Share on other sites

Hi

 

You probably haven't registered your variants properly or there is a subtle mismatch between the name of your files

 

You might find this link useful

http://greyminecraftcoder.blogspot.com.au/p/list-of-topics.html

(see the Block Rendering topics)

 

also this example project which has a working example of variants (example 3)

https://github.com/TheGreyGhost/MinecraftByExample

 

(Edit: brainfade suggestion removed - sorry)

 

You could try searching the vanilla code for the text message "Unable to load definition ", putting a breakpoint there, and inspecting the name and the registry to see what has been registered compared with what the code expects to find.

 

-TGG

 

So i did this

        ModelBakery.addVariantName(
                GameRegistry.findItem
                        ("MoreMinecraft",
                        "strawberries_stage"),
                "moreminecraft:strawberries_stage_0");

and i get a nullpointer at the first line... Help?

Link to comment
Share on other sites

Is ModelBakery a defined variable?

(Not declared, defined)

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

show your class(es) where you create your items & blocks and register them?

 

-TGG

 

package com.robmart.MoreMinecraft.init;

import com.robmart.MoreMinecraft.handler.ConfigurationHandler;
import com.robmart.MoreMinecraft.items.*;
import com.robmart.MoreMinecraft.reference.Reference;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraftforge.fml.common.registry.GameRegistry;

@GameRegistry.ObjectHolder(Reference.MOD_ID)
public class InitItem {

    public static final Item Ruby = new ItemRuby();
    public static final Item Flour = new ItemFlour();
    public static final Item Salt = new ItemSalt();
    public static final ItemFood Strawberry = new ItemStrawberry(1, 2F);
    //public static final ItemSeed StrawberrySeed = new ItemStrawberrySeed();
    public static final ItemFood Blueberry = new ItemBlueberry(1, 2F);
    //public static final ItemSeed BlueberrySeed = new ItemBlueberrySeed();
    public static final Item Vanilla = new ItemVanilla();
    //public static final ItemSeed VanillaSeed = new ItemVanillaSeed();
    public static final Item VanillaPowder = new ItemVanillaPowder();
    public static final ItemFood IceCreamCone = new ItemIceCreamCone(2, 4F);
    public static final ItemFood TastyCreamVanilla = new ItemTastyCreamVanilla(2, 4F, "Vanilla Edition");
    public static final ItemFood IceCreamVanilla = new ItemIceCreamVanilla(8, 12F, "Vanilla Edition");

    public static void Init()
    {
        GameRegistry.registerItem(Ruby, "Ruby");

        if(ConfigurationHandler.farmer) {
            GameRegistry.registerItem(Flour, "Flour");
            GameRegistry.registerItem(Salt, "Salt");
            GameRegistry.registerItem(Strawberry, "Strawberry");
            //GameRegistry.registerItem(StrawberrySeed, "StrawberrySeed");
            GameRegistry.registerItem(Blueberry, "Blueberry");
            //GameRegistry.registerItem(BlueberrySeed, "BlueberrySeed");
            GameRegistry.registerItem(Vanilla, "Vanilla");
            //GameRegistry.registerItem(VanillaSeed, "VanillaSeed");
            GameRegistry.registerItem(IceCreamCone, "IceCreamCone");
            GameRegistry.registerItem(VanillaPowder, "VanillaPowder");
            GameRegistry.registerItem(TastyCreamVanilla, "TastyCreamVanilla");
            GameRegistry.registerItem(IceCreamVanilla, "IceCreamVanilla");
        }
    }
}

that is items

 

package com.robmart.MoreMinecraft.init;

import com.robmart.MoreMinecraft.block.*;
import com.robmart.MoreMinecraft.handler.ConfigurationHandler;
import com.robmart.MoreMinecraft.reference.Reference;
import net.minecraft.block.Block;
import net.minecraftforge.fml.common.registry.GameRegistry;

@GameRegistry.ObjectHolder(Reference.MOD_ID)
public class InitBlock
{
    public static final Block RubyOre = new BlockRubyOre();
    public static final Block RubyBlock = new BlockRubyBlock();
    public static final Block SaltOre = new BlockSaltOre();
    public static final Crops StrawberryCrop = new BlockStrawberriesCrop();
    //public static final BlockCrops BlueberryCrop = new BlockBlueberryCrop();
    //public static final BlockCrops VanillaCrop = new BlockVanillaCrop();

    public static void Init()
    {
        GameRegistry.registerBlock(RubyOre, "RubyOre");
        GameRegistry.registerBlock(RubyBlock, "RubyBlock");

        if(ConfigurationHandler.farmer) {
            GameRegistry.registerBlock(SaltOre, "SaltOre");
            GameRegistry.registerBlock(StrawberryCrop, "StrawberryCrop");
            //GameRegistry.registerBlock(BlueberryCrop, "BlueberryCrop");
            //GameRegistry.registerBlock(VanillaCrop, "VanillaCrop");
        }
    }
}

this is blocks

Link to comment
Share on other sites

Uh huh.

 

And neither one of those code snippets is a class named "ModelBakery" nor a class that contains a field called ModelBakery.  Or even a reference to the other two.

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

Hi

 

Are you using Intellij 14 perhaps?

If so, see here about sourceSets

http://www.minecraftforge.net/forum/index.php/topic,21354.0.html

 

 

Otherwise, your file StrawberryCrop.json either doesn't exist or is in the wrong folder.

The folder structure should look like this

src/main/resources/assets/moreminecraft/blockstates

 

I also suggest you use lower case for all your filenames, it will probably save you pain later on.

 

-TGG

 

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.