Jump to content

on item rightclick


firstarchon

Recommended Posts

ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)

 

ItemStack: Is the stack of items the player right clicked with.

World: The world that the player is currently in.

EntityPlayer: The player that actually right clicked the ItemStack.

I require Java, both the coffee and the code :)

Link to comment
Share on other sites

so if I do

ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer)

do I have to call this method somehow and pass it these arguments or do I just throw this in my item class and code what I want to happen when it is rightclickd? also how would I get the item to interact with the block in question? like trigger a red stone pulse?

Link to comment
Share on other sites

No, you do not have to call it yourself simply implement your logic inside and it will be called on its own.

 

As for Redstone look at some of the Redstone code in any redstone enabled block in vanilla, it should get you started.

I require Java, both the coffee and the code :)

Link to comment
Share on other sites

I've tried that. the only problem is that vanilla code doesn't use descriptive names so you wind up with code that looks like

 public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
    {
        int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_);
        int j1 = i1 & 7;
        int k1 = 8 - (i1 & ;

        if (k1 == 0)
        {
            return true;
        }
        else
        {
            p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, j1 + k1, 3);
            p_149727_1_.markBlockRangeForRenderUpdate(p_149727_2_, p_149727_3_, p_149727_4_, p_149727_2_, p_149727_3_, p_149727_4_);
            p_149727_1_.playSoundEffect((double)p_149727_2_ + 0.5D, (double)p_149727_3_ + 0.5D, (double)p_149727_4_ + 0.5D, "random.click", 0.3F, 0.6F);
            this.func_150042_a(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, j1);
            p_149727_1_.scheduleBlockUpdate(p_149727_2_, p_149727_3_, p_149727_4_, this, this.tickRate(p_149727_1_));
            return true;
        }
    }

and to my brain there is very little difference between this and binary code xD

Link to comment
Share on other sites

Well Redstone is a huge part of Minecraft, when I say huge i mean HUGE and in order to explain everything it would take time.

 

I urge you to try and understand how the BlockButton works under "package net.minecraft.block;" I know it may be hard to read though the obfuscated code but it the variable types are not obfuscated and you can probably track them down and understand. It takes time but it will teach how to read other peoples code and understand programming better.

 

Here is a list of overrides you might want to focus on:

int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_);

int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_);

boolean canProvidePower();

updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_);

 

Also type redstone in the search field for these forums and see what people had asked for in the past, you might encounter something that solvea your problems :)

I require Java, both the coffee and the code :)

Link to comment
Share on other sites

I have a general idea of what the code should do.

 

on right click

 

then some kind of code to tell that returns the some sort of unique identifier for the block that was clicked on

 

some kind of code that instructs that block to emit redstone.

 

do you have any suggestions to where I should look for details on the part where I tell the code to interact with the specific block that was clicked on?

 

Link to comment
Share on other sites

if you have a button on a block and you right click it the button powers the block and the power propagates through the block to any redstone stuff behind it. my idea is to add a rightclick function to a tool so that when you rightclick a block with a tool it acts as if it is receiving a redstone signal from a button.

Link to comment
Share on other sites

if you have a button on a block and you right click it the button powers the block and the power propagates through the block to any redstone stuff behind it. my idea is to add a rightclick function to a tool so that when you rightclick a block with a tool it acts as if it is receiving a redstone signal from a button.

 

The block the button is on is not emitting a redstone signal itself, but rather that the next space over (where the wire or torch or whatever is) is being indirectly powered by the button.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

so could instead of powering an arbitrary block could it instead check adjacent blocks to see if they are powerable and if they are provide them with a redstone pulse? that again would take some way of interacting with blocks (I have to have some way to tell the blocks what block I'm looking to interact with and I'm not sure how to do that)

Link to comment
Share on other sites

so could instead of powering an arbitrary block could it instead check adjacent blocks to see if they are powerable and if they are provide them with a redstone pulse? that again would take some way of interacting with blocks (I have to have some way to tell the blocks what block I'm looking to interact with and I'm not sure how to do that)

No! Again, you can't power blocks with an item.

Maker of the Craft++ mod.

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.