Jump to content

[1.12.2] onBlockActivated Not Working?


ssbbpeople

Recommended Posts

Hi,

 

I've recently finished the classes for my BlockGrinder, but onBlockActivated seems to not be firing when I right-click the block. When I right-click it, absolutely nothing happens.

Here's the code:
 

	//When right-clicked
	   @Override
	    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
	    {
		   if(worldIn.isRemote) {
			   return true;
		   }
	            final TileEntity tileentity = worldIn.getTileEntity(pos);

	            if (tileentity instanceof TileGrinder)
	            {
	            	playerIn.openGui(Main.instance, ModGuiHandler.MOD_GRINDER, worldIn, pos.getX(), pos.getY(), pos.getZ());
	                playerIn.addStat(StatList.FURNACE_INTERACTION);
	            }

	            return true;
	    }

 

I used the BlockFurnace class as reference for this method, but it doesn't open the GUI nor make the player right-click animation for the block

Link to comment
Share on other sites

45 minutes ago, ssbbpeople said:

Thank you! I got the onBlockActivated method functioning correctly. Now I just have two smelting bugs... it instantly smelts items, even when there's no fuel

Not sure if you are asking for help or not...but if you want help we need to see the code for your TE.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

21 minutes ago, ssbbpeople said:

Yes, sorry I forgot to link my GitHub. Here's the link:
https://github.com/SpookyBarca/Metallurgy

All my Grinder files are in the same package.

You never ever check if the time passed smelting is high enough and you also never check if the furnace has fuel in your trySmeltItem method.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

56 minutes ago, ssbbpeople said:

How can I check that in the trySmeltItem if there's no boolean? I thought I already checked that with boolean isItemValid method

if (this.smeltTime >= this.maxSmeltTime)

 

Edited by Animefan8888
Using the code block.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

12 minutes ago, ssbbpeople said:

Okay, I inserted the code:


	private void trySmeltItem(){
		
		if (this.smeltTime >= this.maxSmeltTime) {
			return;
		}
...

And the bug still remains ?

No that is not what I said. You need to actually smelt the item when that condition is true.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Just now, ssbbpeople said:

Oh okay. So I rearranged it like this:


        if (this.canSmeltItem())
        {
        	
    		if (this.smeltTime >= this.maxSmeltTime) {
    			return;
    		}

 

The bug occurs, but its under the if statement canSmeltItem

Do you know the Java language or is Minecraft Modding your first venture?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Look at the if-statement.

Consider likely values.

Compute the outcome in your head.

 

If that fails, use the debugger.

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

2 minutes ago, ssbbpeople said:

I'm starting to learn Java, I made the mistake of going to modding tutorials first

Yes, yes you have. You should probably get some programming experience first. Or if you are dead set on doing this you won't really get help here because we don't like to have to teach Java to people.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.