Jump to content

[1.8] Setting Textures for Crops, and other crop related issues.


Recommended Posts

Posted

I created a custom parent class to suit the needs for my mod, the parent class is the basis for all of my crops. So far I just have one crop but 4 more are planned. I'm also trying to change certain things such as were the crops can be planted, I want them to be planted on grass block but so far that doesn't work either. I also have no clue if the other crop properties are working because, the growth stages aren't rendering due to I can't find a way to set the textures/models/blockstates.

 

For the record, I have other working functional blocks that aren't crops, so the problem lies with the crops some where.

 

Crop Parent Class

 

import net.minecraft.block.Block;

import net.minecraft.block.BlockCrops;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.init.Blocks;

import net.minecraft.util.BlockPos;

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;

import powerman913717.powerpotions.init.BlocksInit;

 

public class CropClass 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.grass;

    }

 

public CropClass()

    {

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

        this.setTickRandomly(true);

        float f = 0.5F;

        this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);

        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;

    }

}

 

 

This is the actual crop block file and the block is create with the others in my BlocksInit file, its added onto here.

 

import net.minecraft.init.Items;

import net.minecraft.item.Item;

import powerman913717.powerpotions.blockClasses.CropClass;

import powerman913717.powerpotions.init.ItemsInit;

 

public class wolfsbane_crop extends CropClass{

 

@Override

protected Item getSeed()

    {

        return ItemsInit.wolfsbane_seeds;

    }

 

@Override

    protected Item getCrop()

    {

        return ItemsInit.wolfsbane_leaves;

    }

}

 

Posted

First: For rendering you need to have a json would recommend looking in the vanilla assets for wheat as that has what you need for blockstates and models and such. Just follow that layout and you should get rendering working.

Second: If your seeds are extending ItemSeeds your need to change what they can plant on as it has a property in onItemUse called canSustainPlant and crops default to farmland so hence your problem being unable to plant on grass to fix that you need to override onItemUse and change canSustainPlant to ==Blocks.grass or something like that

Edit:Would also recommend a better naming sceme such as for CropsClass renaming it to BlockCropsBase

And items beginning with Item so that it is easy for other modders looking at your code to understand, so basically just follow how Minecraft does it and other modders do it with how they name things

Did you really need to know?

Posted

I understand how the json files work, the problem more so is the naming. In vanilla the only block that I see being created is just "wheat" however the files for the wheat are understood by minecraft even though they are named as wheat_stage0. So I'm trying to find a way to name my textures and other files in a way like that and have it read by Minecraft.

Posted

What you do first is add a render method like so:

 

    	registerRender(vitoidPlant, 0, Constants.modid + ":" + "vitoid_plant", "inventory");

   public static void registerRender(Block block, int metadata, String blockString, String location){
	   Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), metadata, new ModelResourceLocation(blockString, location));
   }

Then you must make a blockstate json file like this:

 

{
    "variants": {
        "age=0": { "model": "zero_quest:vitoid_plant_stage_0" },
        "age=1": { "model": "zero_quest:vitoid_plant_stage_1" },
        "age=2": { "model": "zero_quest:vitoid_plant_stage_2" },
        "age=3": { "model": "zero_quest:vitoid_plant_stage_3" },
        "age=4": { "model": "zero_quest:vitoid_plant_stage_4" },
        "age=5": { "model": "zero_quest:vitoid_plant_stage_5" },
        "age=6": { "model": "zero_quest:vitoid_plant_stage_6" },
        "age=7": { "model": "zero_quest:vitoid_plant_stage_7" }
    }
}

 

Then make model json files like each of the models you specify in the blockstate json file, then make the item model, I used the wheat's item model json file

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Minecraft understands the stage_0 variations because of the default block state. Your block state json file tells which model is used by each state. To enable the usage of this you need to make sure you use something like PropertyInteger and override the create default block state and the methods pertaining to the meta data. If you look inside any of the crop java files you will see this being done for each one.

Posted

Minecraft understands the stage_0 variations because of the default block state. Your block state json file tells which model is used by each state. To enable the usage of this you need to make sure you use something like PropertyInteger and override the create default block state and the methods pertaining to the meta data. If you look inside any of the crop java files you will see this being done for each one.

Not necessarily, I didn't use that and it still worked for me. All I did was register the render mesh and used the wheat's json files and just renamed them and changed what texture to use

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

Posted

Ok, I have all of my .json files set up correctly now...and the crop is rendering the model shape correctly...however the texture isn't displaying I know this is due to the textures not being registered to it. I tried NovaViper's code and I was getting errors, I'm assumed it went in to my blocks class where I register their renders. However that seems to not be working, were does it need to go exactly?

 

P.S.Thanks to all of those trying to help me, :D

Posted

Np and also, make sure you put your modid right before the texture name inside the json with the block model, like this:

 

{
    "parent": "block/cube_all",
    "textures": {
        "all": "zero_quest:blocks/looseBedrock" //Notice my modid
    }
}

Main Developer and Owner of Zero Quest

Visit the Wiki for more information

If I helped anyone, please give me a applaud and a thank you!

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.