Jump to content

Recommended Posts

Posted

so i have a bank item i created with the xact code:

package tuskiomi.common;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;


public class PaintbrushGray extends Item {
public PaintbrushGray(int id){
	super(id);
	setCreativeTab(CreativeTabs.tabAllSearch);

}
public String getTextureFile() {
        return "/tuskiomi/moditemsheet.png";
}

 public boolean onItemUse(ItemStack tool,
		   EntityPlayer player, World world, int x, int y,
		   int z, int par7, float xFloat, float yFloat, float zFloat)
		 {
	 System.out.println("access start");
		  if (!player.canPlayerEdit(x, y, z, par7, tool))//can the player edit this block? if he cant then dont do anything
		  {
			  System.out.println("access denied");
		   return false;
		   
		  }
		  System.out.println("access granted");

		  return true;
		}

	public void updateIcons(IconRegister iconRegister)
	{
	         iconIndex = iconRegister.registerIcon(tuskiomi.modid + ":" + this.getUnlocalizedName());
	}
}

when the item is right clicked or left clicked, the console doesn't do anything.

the texture is correct.

anybody know how to fix this?

Also, I should have you know that you are reading my signature.

Posted

so i have a bank item i created with the xact code:

package tuskiomi.common;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;


public class PaintbrushGray extends Item {
public PaintbrushGray(int id){
	super(id);
	setCreativeTab(CreativeTabs.tabAllSearch);

}
public String getTextureFile() {
        return "/tuskiomi/moditemsheet.png";
}

 public boolean onItemUse(ItemStack tool,
		   EntityPlayer player, World world, int x, int y,
		   int z, int par7, float xFloat, float yFloat, float zFloat)
		 {
	 System.out.print("access start");
		  if (!player.canPlayerEdit(x, y, z, par7, tool))//can the player edit this block? if he cant then dont do anything
		  {
			  System.out.print("access denied");
		   return false;
		   
		  }
		  System.out.print("access granted");

		  return true;
		}

	public void updateIcons(IconRegister iconRegister)
	{
	         iconIndex = iconRegister.registerIcon(tuskiomi.modid + ":" + this.getUnlocalizedName());
	}
}

when the item is right clicked or left clicked, the console doesn't do anything.

the texture is correct.

anybody know how to fix this?

 

Add @Override to your onItemUse method. If there is an error appearing, you're using the wrong method.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

Its not a bug its called when it needs to be called.

See the many other things that could be stopping it from being called.

Ctrl+Alt+H is your friend in eclipse.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Its not a bug its called when it needs to be called.

See the many other things that could be stopping it from being called.

Ctrl+Alt+H is your friend in eclipse.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Its not a bug its called when it needs to be called.

See the many other things that could be stopping it from being called.

Ctrl+Alt+H is your friend in eclipse.

Thanks, Lex!

I have done some searches and  found that the 'PlayerControllerMP' has a direct link to calling this method.

i went ahead for debuging pourposes put in a println statement after line 348 to print some thing out whe nthe method was called. The Item did something very pecuilar when i right clicked with it.

the lines printed out like so fore every one click:

2013-04-18 16:28:34 [iNFO] [sTDOUT] access granted //one print statement in my item code

2013-04-18 16:28:46 [iNFO] [sTDOUT] Debug RightClick //debug print

2013-04-18 16:28:46 [iNFO] [sTDOUT] access start //another print in my item code

2013-04-18 16:28:46 [iNFO] [sTDOUT] access granted //repeat?????

2013-04-18 16:28:46 [iNFO] [sTDOUT] access start // it started again but didn't end???

 

i'm very confsed and would be happy if someone could explian why this happens!! :D

 

 

Also, I should have you know that you are reading my signature.

Posted

Its not a bug its called when it needs to be called.

See the many other things that could be stopping it from being called.

Ctrl+Alt+H is your friend in eclipse.

Thanks, Lex!

I have done some searches and  found that the 'PlayerControllerMP' has a direct link to calling this method.

i went ahead for debuging pourposes put in a println statement after line 348 to print some thing out whe nthe method was called. The Item did something very pecuilar when i right clicked with it.

the lines printed out like so fore every one click:

2013-04-18 16:28:34 [iNFO] [sTDOUT] access granted //one print statement in my item code

2013-04-18 16:28:46 [iNFO] [sTDOUT] Debug RightClick //debug print

2013-04-18 16:28:46 [iNFO] [sTDOUT] access start //another print in my item code

2013-04-18 16:28:46 [iNFO] [sTDOUT] access granted //repeat?????

2013-04-18 16:28:46 [iNFO] [sTDOUT] access start // it started again but didn't end???

 

i'm very confsed and would be happy if someone could explian why this happens!! :D

 

 

Also, I should have you know that you are reading my signature.

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.