Jump to content

Solved [1.8]Get blocks metadata (or equivalent)


Hamster_Furtif

Recommended Posts

Hey !

I'm trying to make it so when you right click on a block with an empty hand, it goes in your inventory. The problem is that when I right click on a blue flower, it gives me a red flower.

I know there are no more metadatas, but some properties. I would like to know how to get the color of the block I'm rightclicking on, and then convert it into an int so I can give it to my player. Here is my code:

 

public void clickEnderman(BlockPos pos, EntityPlayer player, Block block, PlayerInteractEvent event){
	if (isBlockEditable(block) == true && player.getCurrentEquippedItem() == null && (player.experienceLevel >= 1 || player.capabilities.isCreativeMode)){
		player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(block, 1));
		event.world.setBlockToAir(pos);
		player.addExperienceLevel(-1);

	}
}

 

Any help will be welcome !

Link to comment
Share on other sites

getPickBlock requires a moving object position, and it can only be accessed from an item. I want all this stuff to work when the player doesn't have an item.

Plus, I think it would be usefull to know how to get the damn colors from the block, I may need it some day.

Anyway, if you know how to get a moving object position without an Item, it would be usefull too !

Link to comment
Share on other sites

Doors aren't BlockContainers, and they don't have an associated ItemBlock. So you'd have to rethink your logic (Hint:

getPickBlock

. Please use that, it is your only way to do it properly..

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

I'm aware of that, there's a whole list of blocks I don't want the player to pick up (such a buttons, levers, and everything you need to right click on):

 

public boolean isBlockEditable(Block block){

	@SuppressWarnings("rawtypes")
	Class[] forbidden = {BlockDoor.class, BlockButton.class, BlockContainer.class, BlockCrops.class, BlockFenceGate.class, BlockPortal.class, BlockLiquid.class, BlockFire.class, BlockLever.class, BlockRedstoneDiode.class, BlockTrapDoor.class, BlockPistonExtension.class, BlockPistonBase.class, BlockDragonEgg.class, BlockWorkbench.class, BlockAnvil.class};
	Boolean isblockeditable = true;

	for (int i=0; i<forbidden.length; i++){
		if (forbidden[i].isInstance(block) || block == Blocks.obsidian || block == Blocks.bedrock || block == Blocks.bed)
			isblockeditable = false;
	}

	return isblockeditable;

}

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • It all began with a chance encounter with a testimonial shared by Olivia, a fellow traveler on the winding road of cryptocurrency. Her words spoke of a miraculous recovery orchestrated by Wizard Web Recovery, a beacon of hope in the murky waters of online fraud. Intrigued by her story, I reached out to Wizard Web Recovery, hoping they could work their magic on my blocked crypto recovery. With bated breath, I shared my plight, providing evidence of my dilemma and praying for a solution. To my astonishment, a prompt response came, swift and reassuring. Wizard Web Recovery wasted no time in assessing my situation, guiding me through the process with patience and expertise. and then like a ray of sunshine breaking through the clouds, came the news I had longed for – a new private key had been generated, restoring my precious bitcoins. It was a moment of jubilation, a triumph over adversity that filled me with newfound hope. At that moment, I realized the true power of Wizard Web Recovery, not just as skilled technicians, but as guardians of trust in the digital realm. With their assistance, I reclaimed what was rightfully mine, turning despair into determination and paving the way for a brighter future. But their capabilities did not end there. Delving deeper into their expertise, I discovered that Wizard Web Recovery possessed a wealth of knowledge in reclaiming lost stolen cryptocurrency, and even exposing fraudulent investment schemes. So to all those who find themselves entangled in the web of online fraud, take heart. With the guidance of Wizard Web Recovery, there is a path to redemption.     Write Mail; ( Wizard webrecovery AT  vprogrammer. net ) 
    • It all began with a chance encounter with a testimonial shared by Olivia, a fellow traveler on the winding road of cryptocurrency. Her words spoke of a miraculous recovery orchestrated by Wizard Web Recovery, a beacon of hope in the murky waters of online fraud. Intrigued by her story, I reached out to Wizard Web Recovery, hoping they could work their magic on my blocked crypto recovery. With bated breath, I shared my plight, providing evidence of my dilemma and praying for a solution. To my astonishment, a prompt response came, swift and reassuring. Wizard Web Recovery wasted no time in assessing my situation, guiding me through the process with patience and expertise. and then like a ray of sunshine breaking through the clouds, came the news I had longed for – a new private key had been generated, restoring my precious bitcoins. It was a moment of jubilation, a triumph over adversity that filled me with newfound hope. At that moment, I realized the true power of Wizard Web Recovery, not just as skilled technicians, but as guardians of trust in the digital realm. With their assistance, I reclaimed what was rightfully mine, turning despair into determination and paving the way for a brighter future. But their capabilities did not end there. Delving deeper into their expertise, I discovered that Wizard Web Recovery possessed a wealth of knowledge in reclaiming lost stolen cryptocurrency, and even exposing fraudulent investment schemes. So to all those who find themselves entangled in the web of online fraud, take heart. With the guidance of Wizard Web Recovery, there is a path to redemption.    
    • How can I add drops when killing an entity? Now there are no drops. How can I add an @override to change the attack speed to 1.6 and show "when in main hand...attack damage,...attack speed"? also, how can I make the item enchantable? 
    • Ok. Thanks. by the way, will this crash in any circumstances? public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) { if (entity instanceof LivingEntity){ LivingEntity victim = (LivingEntity) entity; if(!victim.isDeadOrDying() && victim.getHealth()>0){ victim.setHealth(0); return true; } } return false; }  
    • You shouldn't be extracting the mod .jar, just place it in your mods folder.
  • Topics

×
×
  • Create New...

Important Information

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