Jump to content

[1.12.2; Solved] Modelling ItemBlocks with metadata


Aarilight

Recommended Posts

I have a block, "SummonerEmpty" which has variants. They all render correctly in the world, and the ItemBlocks for them seem to function correctly (eg: they place the correct blocks)

However, all the ItemBlocks, when in inventory slots, are the "missing texture", while held they are the "missing texture" block.

This is my currrent block class:

public class SummonerEmpty extends ModBlock {

	public static final IProperty<EndersteelType> VARIANT = PropertyEnum.create("variant", EndersteelType.class);

	public SummonerEmpty() {
		super("summoner_empty", new Material(MapColor.STONE).setTransparent());
		setHasItem();
		setHardness(5F);
		setResistance(30F);
		setHarvestLevel("pickaxe", 1);
		setSoundType(SoundType.METAL);
		setDefaultState(getDefaultState().withProperty(VARIANT, EndersteelType.NORMAL));
	}

	@Override
	protected BlockStateContainer createBlockState() {
		List<IProperty<?>> props = new ArrayList<>(super.createBlockState().getProperties());
		props.add(VARIANT);
		return new BlockStateContainer(this, props.toArray(new IProperty<?>[0]));
	}

	@Override
	public IBlockState getStateFromMeta(int meta) {
		return getDefaultState().withProperty(VARIANT, EndersteelType.byMetadata(meta));
	}

	@Override
	public int getMetaFromState(IBlockState state) {
		return state.getValue(VARIANT).getMeta();
	}

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

	@Override
	public void getSubBlocks(CreativeTab tab, NonNullList<ItemStack> list) {
		for (EndersteelType enumType : EndersteelType.values()) {
			Logger.info("" + enumType.getMeta());
			list.add(new ItemStack(this, 1, enumType.getMeta()));
		}
	}

	@Override
	public ItemBlock getItemBlock() {
		ItemBlock result = new ItemBlock(this) {
			@Override
			public int getMetadata(int damage) {
				return damage;
			}
		};

		result.setRegistryName(getRegistryName());

		return result;
	}
}


And then models/item/summoner_empty.json:

{
	"parent": "soulus:block/summoner"
}


Which inherits models/block/summoner.json:

{
	"parent": "minecraft:block/cube_all",
	"textures": {
		"all": "soulus:blocks/summoner_normal"
	}
}


I know this wouldn't work for the variants, because it only specifies the normal texture, but I would have expected this to show that texture for all of them, instead of texture erroring... I'm assuming I'm missing something pretty basic for the variants to work?

[solved, this was like 10 billion different issues all rolled into one]

Edited by Aarilight
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.