Jump to content

Recommended Posts

Posted

I'm having trouble loading my crop textures in Minecraft 1.8.

 

Here's my hierarchy.

qWzXAYj.png

I copied pretty much everything wheat does.

The crop grows and harvests correctly but it shows the purple and black block textures.

 

Block Class & Crop Class

 

 

Mod_Block.java Class

 

package com.iC4Mods.ExtremeFood.init;

 

import com.iC4Mods.ExtremeFood.Ref;

import com.iC4Mods.ExtremeFood.crops.cropTomato;

 

import net.minecraft.block.Block;

import net.minecraft.client.Minecraft;

import net.minecraft.client.resources.model.ModelResourceLocation;

import net.minecraft.item.Item;

import net.minecraftforge.fml.common.registry.GameRegistry;

 

public class Mod_Blocks {

 

public static Block cropTomato;

 

public static void init(){

cropTomato = new cropTomato();

}

public static void register(){

GameRegistry.registerBlock(cropTomato, "cropTomato");

}

public static void registerRenders(){

registerRender(cropTomato);

}

public static void registerRender(Block block){

Item item = Item.getItemFromBlock(block);

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Ref.MODID + ":" + item.getUnlocalizedName().substring(5), "inventory"));

}

}

 

cropTomato.java Class

 

 

package com.iC4Mods.ExtremeFood.crops;

 

import com.iC4Mods.ExtremeFood.Main;

import com.iC4Mods.ExtremeFood.init.Mod_Items;

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockCrops;

import net.minecraft.init.Items;

import net.minecraft.item.Item;

 

public class cropTomato extends BlockCrops {

@Override

protected Item getSeed()

    {

        return Mod_Items.seedTomato;

    }

@Override

    protected Item getCrop()

    {

        return Mod_Items.ingredientTomato;

    }

public cropTomato(){

this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0)));

this.setUnlocalizedName("cropTomato");

}

}

 

 

 

 

 

Json Files

 

 

>blockstate>tomato.json

 

{

    "variants": {

        "age=0": { "model": "tomato_stage0" },

        "age=1": { "model": "tomato_stage1" },

        "age=2": { "model": "tomato_stage2" },

        "age=3": { "model": "tomato_stage3" },

        "age=4": { "model": "tomato_stage4" },

        "age=5": { "model": "tomato_stage5" },

        "age=6": { "model": "tomato_stage6" },

        "age=7": { "model": "tomato_stage7" }

    }

}

 

>models>block>tomato_stage0.json

 

{

    "parent": "block/crop",

    "textures": {

        "crop": "blocks/tomato_stage_0"

    }

}

 

 

>models>block>tomato_stage1.json

 

{

    "parent": "block/crop",

    "textures": {

        "crop": "blocks/tomato_stage_1"

    }

}

 

 

>models>block>tomato_stage2.json

 

{

    "parent": "block/crop",

    "textures": {

        "crop": "blocks/tomato_stage_2"

    }

}

 

 

>models>block>tomato_stage3.json

 

{

    "parent": "block/crop",

    "textures": {

        "crop": "blocks/tomato_stage_3"

    }

}

 

 

>models>block>tomato_stage4.json

 

{

    "parent": "block/crop",

    "textures": {

        "crop": "blocks/tomato_stage_4"

    }

}

 

 

>models>block>tomato_stage5.json

 

{

    "parent": "block/crop",

    "textures": {

        "crop": "blocks/tomato_stage_5"

    }

}

 

 

>models>block>tomato_stage6.json

 

{

    "parent": "block/crop",

    "textures": {

        "crop": "blocks/tomato_stage_6"

    }

}

 

 

>models>block>tomato_stage7.json

 

{

    "parent": "block/crop",

    "textures": {

        "crop": "blocks/tomato_stage_7"

    }

}

 

 

Texture names, you can see them in the picture.

 

 

If there's any information I missed that I needed to add to this.

Posted

it looks like your json file are wrong the model and texture paths should have you mod id in it like this "modid:tomato_stage0" and your texture path should be like this "modid:blocks/tomato_stage0"

Posted

in which .json file? I changed the tomato.json to this and Im still getting the purple/black block.

 

{

    "variants": {

        "age=0": { "model": "extremefoodmod:tomato_stage0" },

        "age=1": { "model": "extremefoodmod:tomato_stage1" },

        "age=2": { "model": "extremefoodmod:tomato_stage2" },

        "age=3": { "model": "extremefoodmod:tomato_stage3" },

        "age=4": { "model": "extremefoodmod:tomato_stage4" },

        "age=5": { "model": "extremefoodmod:tomato_stage5" },

        "age=6": { "model": "extremefoodmod:tomato_stage6" },

        "age=7": { "model": "extremefoodmod:tomato_stage7" }

    }

}

 

 

Posted

Your blockstate json file is misnamed.

It should be "cropTomato.json"

 

Also:

  • Don't use GameRegistry.registerBlock, use GameRegistry.register
  • Don't use getUnlocalizedName().substring(5), use .setRegistryName and .getRegistryName
  • Don't use Minecraft.getMinecraft().getRenderItem().getItemModelMesher(), use ModelLoader.setCustomModelResourceLocation
  • Don't use any client side code (the entire ModelMesher, ModelLoader system) in common code, use a proxy or you'll crash the dedicated server
  • Do setUnlocalizedName(getRegistryName), then your block has your modID prefixed to the unlocalized name, preventing conflicts
  • Make sure:
    • That either ModItems either runs after ModBlocks or that your tomato seed doesn't take your tomato crop block as a parameter
    • ModBlocks (and ModItems) have their init() method called during FMLPreInitialization (preInit) not FMLInitialization (init) or nothing will work right (models and such must be registered during preInit)

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.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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