Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] Block Model not Found for Metadata Block


americanman
 Share

Recommended Posts

I've managed to get my metadata block into the game's creative tabs and it will go into the world with the game crashing. However, the game keeps giving me this message about my block model not being found. I've looked at some tutorials and tried troubleshooting the issue but I can't seem to get it to render in the game without the purple and black texture. I'm only trying to make the "undamaged" variant of the block right now and will work on the other variants once that one works. Here's the code:

 

Error message:

 

[12:13:34] [Client thread/ERROR] [FML]: Model definition for location xcom:alien_alloy_wall#damage_level=undamaged not found

 

Block Class

package com.littlepup.xcom.blocks;

import java.util.List;

import com.littlepup.xcom.XcomMain;
import net.minecraft.block.Block;
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.entity.EntityLivingBase;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;

public class AlienAlloyWall extends Block implements IMetaBlockName
{
public AlienAlloyWall(Material material) 
{
	super(material);
	this.setUnlocalizedName("alien_alloy_wall");
	this.setCreativeTab(XcomMain.xcomTab);
	this.setHardness(2.0F);
	this.setResistance(250.0F);
	this.setDefaultState(this.blockState.getBaseState().withProperty(DAMAGE_LEVEL, AlienAlloyWallTypes.UNDAMAGED));
}

public static final PropertyEnum DAMAGE_LEVEL = PropertyEnum.create("damage_level", AlienAlloyWall.AlienAlloyWallTypes.class);

//Contains different types of alien alloy blocks
public enum AlienAlloyWallTypes implements IStringSerializable
{
	UNDAMAGED(0, "undamaged"),
	SLIGHTLY_DAMAGED(1, "slightly_damaged"),
	SOMEWHAT_DAMAGED(2, "somewhat_damaged"),
	MODERATELY_DAMAGED(3, "moderately_damaged"),
	VERY_DAMAGED(4, "very_damaged");

	private int ID;
	private String name;

	private AlienAlloyWallTypes(int ID, String name)
	{
		this.ID = ID;
		this.name = name;
	}

	@Override
	public String getName() 
	{
		return name;
	}

	@Override
	public String toString() 
	{
		return getName();
	}

	public int getID()
	{
		return ID;
	}			
}

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

@Override
public IBlockState getStateFromMeta(int meta)
{
	AlienAlloyWallTypes type;

	switch(meta)
	{
		case 0: type = AlienAlloyWallTypes.UNDAMAGED;
			break;
		case 1: type = AlienAlloyWallTypes.SLIGHTLY_DAMAGED;
			break;
		case 2: type = AlienAlloyWallTypes.SOMEWHAT_DAMAGED;
			break;
		case 3: type = AlienAlloyWallTypes.MODERATELY_DAMAGED;
			break;
		case 4: type = AlienAlloyWallTypes.VERY_DAMAGED;
			break;
		default: type = null;
			System.out.println("AlienAlloyWall.getStateFromMeta() is having trouble.");
			break;
	}

	return getDefaultState().withProperty(DAMAGE_LEVEL, type);
}

@Override
public int getMetaFromState(IBlockState state)
{
	AlienAlloyWallTypes type = (AlienAlloyWallTypes) state.getValue(DAMAGE_LEVEL);
	return type.getID();
}

@Override
public int damageDropped(IBlockState state)
{
	return getMetaFromState(state);
}

public void getSubBlocks(Item item, CreativeTabs tab, List list)
{
	for(int i = 0; i < 5; i++ )
	{
		list.add(new ItemStack(item, 1, i));
	}
}

@Override
public String getSpecialName(ItemStack stack) 
{
	int meta = stack.getItemDamage();
	String type;

	switch(meta)
	{
		case 0: type = AlienAlloyWall.AlienAlloyWallTypes.UNDAMAGED.toString();
			break;
		case 1: type = AlienAlloyWall.AlienAlloyWallTypes.SLIGHTLY_DAMAGED.toString();
			break;
		case 2: type = AlienAlloyWall.AlienAlloyWallTypes.SOMEWHAT_DAMAGED.toString();
			break;
		case 3: type = AlienAlloyWall.AlienAlloyWallTypes.MODERATELY_DAMAGED.toString();
			break;
		case 4: type = AlienAlloyWall.AlienAlloyWallTypes.VERY_DAMAGED.toString();
			break;
		default: 
			type = null;
			System.out.println("Error in AlienAlloyWall enum types.");
		break;
	}

	return type;
}

@Override
public boolean isOpaqueCube()
{
	return false;
}

@Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
	EnumFacing direction = placer.getHorizontalFacing().rotateY();
	AlienAlloyWallTypes type = (AlienAlloyWallTypes) getStateFromMeta(meta).getValue(DAMAGE_LEVEL);

	return super.onBlockPlaced(world, pos, direction, hitX, hitY, hitZ, meta, placer).withProperty(DAMAGE_LEVEL, type);
}

@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos)
{
	return new ItemStack(Item.getItemFromBlock(this), 1, this.getMetaFromState(world.getBlockState(pos)));
}

@Override
public void onBlockDestroyedByExplosion(World world, BlockPos pos, Explosion explosion)

{
	IBlockState state = world.getBlockState(pos);
	int meta = getMetaFromState(state);
	IBlockState newType = state.cycleProperty(DAMAGE_LEVEL);

	if(meta <= 3)
	{
		world.setBlockState(pos, newType);
	}
	else
	{
		world.setBlockToAir(pos);
	}
}	
}

 

Blockstates json file

 

{
    "variants": 
    {
        "damage_level=undamaged,facing=up": { "model": "xcom:alien_alloy_wall_undamaged" },
        "damage_level=undamaged,facing=down": { "model": "xcom:alien_alloy_wall_undamaged", "x": 180},
        "damage_level=undamaged,facing=east": { "model": "xcom:alien_alloy_wall_undamaged", "x": 90 },
        "damage_level=undamaged,facing=west": { "model": "xcom:alien_alloy_wall_undamaged", "x": 270 },
        "damage_level=undamaged,facing=north": { "model": "xcom:alien_alloy_wall_undamaged", "y": 90 },
        "damage_level=undamaged,facing=south": { "model": "xcom:alien_alloy_wall_undamaged", "y": 270 }
    }
}

 

Registration

 

public final class BlocksMain 
{
public static Block alien_alloy_wall = new AlienAlloyWall(Material.iron);

public static void addMetadataBlocks()
{
	GameRegistry.registerBlock(alien_alloy_wall, MetaBlocks.class, "alien_alloy_wall");
}

public static void addMetadataBlockRenderers()
{
	//Meta-data-block model name variations
	ModelBakery.addVariantName(Item.getItemFromBlock(BlocksMain.alien_alloy_wall), "xcom:alien_alloy_wall_undamaged");

	//Registers the block renderer(s)
	Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(alien_alloy_wall), 0, new ModelResourceLocation(XcomMain.MODID + ":" +	"alien_ally_wall_undamaged", "inventory"));


}
}

 

Thanks to anyone who helps.

Link to comment
Share on other sites

How are you encoding 30 stays in only 16 values of metadata? You have 5 damage states and 6 facing states.

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

Sorry, I'm kind of new to this. If it's not possible to get more than 16 different states in a block, I'll try fixing that first. I'm really only trying to get a different texture to show based off of the meta data and it will form a different shape based off of the blocks around it. Should I be just using the metadata for the texture only and changing the shape based off of the blocks around it maybe?

 

Honestly, I'm really new to this.

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
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.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.