Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

  • Author

I know that the registration could be the problem, but since there is actually no metadata value saved how can i register it properly? Like a normal metadata block (so using a normal ItemBlock class and registering every variant with a different name?)

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • Author

Ok, so i've now this

block.setUnlocalizedName(name);
	GameRegistry.registerBlock(block, name);
	ModelBakery.addVariantName(Item.getItemFromBlock(coal_block), 
			BL.MODID + ":" + "coal_block_0", 
			BL.MODID + ":" + "coal_block_1",
			BL.MODID + ":" + "coal_block_2",
			BL.MODID + ":" + "coal_block_3",
			BL.MODID + ":" + "coal_block_4",
			BL.MODID + ":" + "coal_block_5",
			BL.MODID + ":" + "coal_block_6",
			BL.MODID + ":" + "coal_block_7",
			BL.MODID + ":" + "coal_block_8",
			BL.MODID + ":" + "coal_block_9",
			BL.MODID + ":" + "coal_block_10");
	for(int i = 0; i < 11; i++)
		renderItem.getItemModelMesher().register(Item.getItemFromBlock(block), i, new ModelResourceLocation(BL.MODID + ":" + name + "_" + i, "inventory"));

The model file are pretty the same as before (only the block high on each value is changed)

So now if i place a block down it place the last block model registered (the corresponding to the damage value of 10)

 

EDIT: printing this in the getActualState always return 10

System.out.println(state.getValue(DAMAGE));

 

so basically the damage value is never change, even doing this

newState = state.withProperty(DAMAGE, Integer.valueOf(progress.getPartialBlockDamage()));

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • Author

Alright, so now my block is registered as a normal block, and as i said in the previous edit i print the damage value when breaking the block but is always 10, event if i force it to 0

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • Author
:( Don't worry man, at least you tried to solve this problem ;) Thanks for all your support ;) Hope to find out a way to make this work

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • Author

Ok, quick discover. If i comment everything in my getActualState method and only do this

state.withProperty(DAMAGE, Integer.valueOf(3));

 

it return the block model for the damage value of 3, wich is correct. So i think that the problem could be in this method

@Override
@SideOnly(Side.CLIENT)
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
	IBlockState newState = null;

	RenderGlobal render = Minecraft.getMinecraft().renderGlobal;

	DestroyBlockProgress progress;

	if(damage != null)
	{
		Map mp;
		try {
			mp = (Map)damage.get(render);
			Iterator it = mp.entrySet().iterator();
			while (it.hasNext()) {
				Map.Entry pair = (Map.Entry)it.next();
				progress = (DestroyBlockProgress) pair.getValue();

				if(progress.getPosition().equals(pos))
				{
					newState =  state.withProperty(DAMAGE, Integer.valueOf(progress.getPartialBlockDamage()));
				}
			}
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
	}
	return newState;
}

Don't blame me if i always ask for your help. I just want to learn to be better :)

  • Author

Woops xD Ok, changed to this ;)

/**
 * Get the actual Block state of this Block at the given position. This applies properties not visible in the
 * metadata, such as fence connections.
 */
@Override
@SideOnly(Side.CLIENT)
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
	RenderGlobal render = Minecraft.getMinecraft().renderGlobal;

	DestroyBlockProgress progress;

	if(damage != null)
	{
		Map mp;
		try {
			mp = (Map)damage.get(render);
			Iterator it = mp.entrySet().iterator();
			while (it.hasNext()) {
				Map.Entry pair = (Map.Entry)it.next();
				progress = (DestroyBlockProgress) pair.getValue();

				if(progress.getPosition().equals(pos))
				{
					return state.withProperty(DAMAGE, Integer.valueOf(progress.getPartialBlockDamage()));
				}
			}
		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		}
	}
	return state;
}

Don't blame me if i always ask for your help. I just want to learn to be better :)

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.