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

Posted

goods

 

i been doing somethings whith blocks but alredy dont get how properties work

 

i make some hot item and want to cool them rigth clickin and filled cauldrun

in this case a wanna get if the cauldrun has water but has not realize how to get the value of a properti from a block here

im doing

 

// ########################################################################3
@Override
public ItemStack onItemUseFinish(ItemStack lingote, World worldIn, EntityPlayer playerIn) {

	if (!worldIn.isRemote) {

		MovingObjectPosition mov = Minecraft.getMinecraft().objectMouseOver;
		BlockPos pos = mov.getBlockPos();
		EnumFacing sid=	mov.sideHit;

		IBlockState blkst = worldIn.getBlockState(pos);
		Block blk = blkst.getBlock();

		chat.chatm(playerIn, "Block="+blk.getUnlocalizedName());
		chat.chatm(playerIn, "BlockState="+blkst.getPropertyNames() );

		//level = blkst.getValue(property);
		//Block caldero = Blocks.cauldron;
                        //if (blk == caldero)


	}// is ! remote
	return lingote;
}


// ########################################################################3

this return

 

[11:09:58] [Client thread/INFO]: [CHAT] Block=tile.cauldron

[11:09:58] [Client thread/INFO]: [CHAT] BlockState=[PropertyInteger{name=level, clazz=class java.lang.Integer, values=[0, 1, 2, 3]}]

 

i need to now the value of "name=level"

how i do thath

 

  • Author

 

 

well

 

how do you instantiate that the get the value as a int

thaths the part i dont get

 

int level = blkst.LEVEL.getValue();  //wrong

int level = blkst.getValue(blkst.LEVEL); //wrong

 

  • Author

this blocks in 1.8 has become a little anfractuous (complicadito) to get it work 
but its done 

// ######################################################################################3

@Override

public ItemStack onItemRightClick(ItemStack lingote, World worldIn,EntityPlayer playerIn) {

 

 

if (!worldIn.isRemote) {

 

MovingObjectPosition mov = Minecraft.getMinecraft().objectMouseOver;

BlockPos pos = mov.getBlockPos();

EnumFacing sid= mov.sideHit;

 

IBlockState blkst = worldIn.getBlockState(pos);

Block blk = blkst.getBlock();

 

Block caldero = Blocks.cauldron;

IBlockState calderost=caldero.getDefaultState();

 

if (blk == caldero )

{

 

PropertyInteger LEVEL = PropertyInteger.create("level", 0, 3);

 

int levelInt = (Integer) blkst.getValue(BlockCauldron.LEVEL) ;

 

if ( levelInt > 0 )

{

 

worldIn.spawnEntityInWorld(new EntityItem(worldIn, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(MercenaryModItems.aceroMercenario, 1, 0)));

 

worldIn.playSoundAtEntity(playerIn, "modmercenario:extingir", 1.0F, 1.0F );

 

playerIn.inventory.consumeInventoryItem(MercenaryModItems.hierroAlrojo);

 

}

 

 

levelInt--;

 

if (levelInt < 0)

{

levelInt=0;

}

 

worldIn.setBlockState(pos, calderost.withProperty(LEVEL, Integer.valueOf(levelInt)) );

 

 

}

 

}// is ! remote

 

playerIn.setItemInUse(lingote, this.getMaxItemUseDuration(lingote));

return lingote;

}

 

// ####################################################################################3

[/code]

 

 

 

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.