Jump to content

[1.8] [SOLVED] is effective on check


statphantom

Recommended Posts

I am wondering the best way to loop through a Item's isEffectiveOn() Block <set> in order to manually change the mining speed. Please help with your ideas? thanks.

 

I am currently doing....

if (isEffective(helditem, block)) {
		event.newSpeed = event.originalSpeed * 0.3f;
	}

private boolean isEffective(ItemStack helditem, Block block) {
	if (helditem.getItem() instanceof ItemTool) {
		Set tooltypes = helditem.getItem().getToolClasses(helditem);

		Iterator<String> i = tooltypes.iterator();

		while (i.hasNext()) {
			if (block.isToolEffective(i.next(), block.getDefaultState())) {
				return true;
			}
		}

	}
	return false;
}

Link to comment
Share on other sites

1. following tutorials it said to do this, and I have done this due to that my tool really is a tool and I take advantage of harvest levels, tool material etc. To me this seems simpler and more compatibly friendly

 

2. thanks fixed that

 

3. I had seen and fixed that but forgot to edit this post to show it

 

4. this is how I learnt to iterate through sets when learning java

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.