Jump to content

Help with custom crops (1.12.2)


Blackviper108

Recommended Posts

I am trying to create a custom crop and i cant seem to get the textures to work i am just getting the pink and black box. please could you try to keep the explinations simple because im relatively new to modding.

 

please let me know if i forgot to include something

 

cropBear.java

Spoiler

package viper.mod.objects.blocks;

import net.minecraft.block.Block;
import net.minecraft.block.BlockCrops;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import viper.mod.init.BlockInit;
import viper.mod.init.ItemInit;

public class cropBear extends BlockCrops
{
    private static final AxisAlignedBB[] red_gummy_bear = new AxisAlignedBB[] {new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.125D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.25D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.375D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.625D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.75D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.875D, 1.0D), new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 1.0D, 1.0D)};
    
    public cropBear(String name)
    {
        setUnlocalizedName(name);
        setRegistryName(name);
        BlockInit.BLOCKS.add(this);
        ItemInit.ITEMS.add(new ItemBlock(this).setRegistryName(getRegistryName()));
    }
    
    @Override
    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
    {
        if(!worldIn.isRemote)
        {
            if(this.isMaxAge(state))
            {
                worldIn.spawnEntity(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ItemInit.RED_GUMMY_BEAR, 1)));
                worldIn.setBlockState(pos, this.withAge(0));
                return true;
            }
        }
        
        return false;
    }
    
    @Override
    protected Item getSeed()
    {
        return ItemInit.RED_GUMMY_SEED;
    }
    
    @Override
    protected Item getCrop()
    {
        return ItemInit.RED_GUMMY_BEAR;
    }
    
    @Override
    public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)
    {
        return red_gummy_bear[((Integer)state.getValue(this.getAgeProperty())).intValue()];
    }
}

 

Models/Block

Spoiler

{
    "parent": "block/crop",
    "textures": {
        "crop": "blocks/bear_plant0"
    }
}

 

rest are the same with the exception of the number 0

 

Blockstates

Spoiler

{
    "variants": {
        "age=0": { "model": "cropBear0" },
        "age=1": { "model": "cropBear1" },
        "age=2": { "model": "cropBear2" },
        "age=3": { "model": "cropBear3" },
        "age=4": { "model": "cropBear4" },
        "age=5": { "model": "cropBear5" },
        "age=6": { "model": "cropBear6" },
        "age=7": { "model": "cropBear7" }
    }
}

 

Capture.PNG

Edited by Blackviper108
Link to comment
Share on other sites

58 minutes ago, Blackviper108 said:

model": "cropBear0

You dont have your modid here so it will look under assets/minecraft/... to fix this do modid:fileName

Second problem is it needs to be all lowercase.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.