Jump to content

[1.8] [SOLVED] Crops are invisible


Ferrettomato

Recommended Posts

I'm having trouble getting the texture to appear on a crop block called

blightplant

. Any stage, when placed in the world, has no texture whatsoever (completely transparent). In Item form, the texture is missing (purple and black cube), unless I comment out the ModelBakery line, in which case the first stage renders in the inventory but is still invisible when placed down.

 

Files:

 

Relevant init lines:

Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(this.blightplant), 0, new ModelResourceLocation("ferret_myfirstmod:blightplant", "inventory"));
ModelBakery.addVariantName(Item.getItemFromBlock(this.blightplant), new String[]{"ferret_myfirstmod:blightplant1", "ferret_myfirstmod:blightplant2", "ferret_myfirstmod:blightplant3"});

 

BlockBlightPlant class:

package com.ferret.myfirstmod;

import java.util.List;
import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockBush;
import net.minecraft.block.IGrowable;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IStringSerializable;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockBlightPlant extends BlockBush implements IGrowable {

public static final PropertyEnum AGE = PropertyEnum.create("age", BlockBlightPlant.EnumType.class);

public BlockBlightPlant() {
	super(Material.plants);
	setUnlocalizedName(MyFirstMod.MODID + "_" + "blightplant");
	setCreativeTab(CreativeTabs.tabMisc);
	setHardness(0.0F);
	setBlockBounds(0F, 0.0F, 0F, 1F, 0.25F, 1F);
	setStepSound(soundTypeGrass);
}

@Override
public int getRenderType()
{
	return 6;
}

@SuppressWarnings({"unchecked", "rawtypes"})
@SideOnly(Side.CLIENT)
@Override
public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List)
{
	for (int i = 0; i < 3; i++)
	{
		par3List.add(new ItemStack(par1, 1, i));
	}
}

@Override
    public int damageDropped(IBlockState state)
    {
        return ((BlockBlightPlant.EnumType)state.getValue(AGE)).getMetadata();
    }

@Override
public IBlockState getStateFromMeta(int meta)
{
	return this.getDefaultState().withProperty(AGE, BlockBlightPlant.EnumType.byMetadata(meta));

}

@Override
public int getMetaFromState(IBlockState state)
{
	return ((BlockBlightPlant.EnumType)state.getValue(AGE)).getMetadata();
}

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

    public static enum EnumType implements IStringSerializable
    {
        AGE1(0, "0"),
        AGE2(1, "1"),
        AGE3(2, "2");
        private static final BlockBlightPlant.EnumType[] META_LOOKUP = new BlockBlightPlant.EnumType[values().length];
        private final int meta;
        private final String name;
        private final String 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;
        }

        public int getMetadata()
        {
            return this.meta;
        }

        public String toString()
        {
            return this.name;
        }

        public static BlockBlightPlant.EnumType byMetadata(int meta)
        {
            if (meta < 0 || meta >= META_LOOKUP.length)
            {
                meta = 0;
            }

            return META_LOOKUP[meta];
        }

        public String getName()
        {
            return this.name;
        }

        public String getUnlocalizedName()
        {
            return this.unlocalizedName;
        }

        static
        {
            BlockBlightPlant.EnumType[] var0 = values();
            int var1 = var0.length;

            for (int var2 = 0; var2 < var1; ++var2)
            {
                BlockBlightPlant.EnumType var3 = var0[var2];
                META_LOOKUP[var3.getMetadata()] = var3;
            }
        }
    }

@Override
public boolean canGrow(World worldIn, BlockPos pos, IBlockState state, boolean isClient) 
{
	return getMetaFromState(state) != 2;
}

@Override
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, IBlockState state) 
{
	return true;
}

@Override
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) 
{
	int next = getMetaFromState(state) + 1;

	if(next > 2)
	{
		next = 2;
	}

	worldIn.setBlockState(pos, getStateFromMeta(2));
}
}

 

blightplant.json (blockstate):

{
"variants": {
	"age=0": { "model": "ferret_myfirstmod:blightplant1" },
	"age=1": { "model": "ferret_myfirstmod:blightplant2" },
	"age=2": { "model": "ferret_myfirstmod:blightplant3" }
}
}

 

blightplant1.json (block) (one for each stage):

{
"parent": "block/crop",
"textures": {
	"crop": "ferret_myfirstmod:blocks/blightplant1"
}
}

 

blightplant1.json (item) (one for each stage):

{
"parent": "ferret_myfirstmod:block/blightplant1",
"display": {
	"thirdperson": {
		"rotation": [ 10, -45, 170 ],
		"translation": [ 0, 1.5, -2.75 ],
		"scale": [ 0.375, 0.375, 0.375 ]
	}
}
}

 

What can I change to get the textures to appear?

Link to comment
Share on other sites

In 1.7.10, the

int

returned from

getRenderType()

determines how to block is rendered. In 1.8, it determines if the block will be rendered as a fluid, a standard JSON model or does not get rendered.

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

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.