Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

I'm making a mod where if I right click with an empty hand on sand, it gives me a item. I use the onPlayerInteract(PlayerInteractEvent.RightClickBlock event) to do this, but when I try to get the block which is right clicked it returns the wrong type.

 

Block block = event.getWorld().getBlockState(event.getPos()).getBlock();

 

It says incompatible types:

required: jdk.nashorn.internal.ir.Block

found: net.minecraft.block.Block

 

The whole class:

@SubscribeEvent
    public static void onPlayerInteract(PlayerInteractEvent.RightClickBlock event) {
        ItemStack hand = event.getItemStack();
        Block block = event.getWorld().getBlockState(event.getPos()).getBlock();
        if (hand.isEmpty() && event.getEntityPlayer().isSneaking()) {
            if (ImmutableSet.of(Blocks.SAND).contains(block)) {
                if (event.getWorld().isRemote) {
                    event.getEntityPlayer().swingArm(event.getHand());
                } else {
                    if (Math.random() < 0.8)
                        event.getEntityPlayer().dropItem(new ItemStack(Items.STICK), false);
                }
                event.setCanceled(true);
                event.setCancellationResult(EnumActionResult.SUCCESS);
            }
        }
    }

 

How do I solve this problem?

 

This is in 1.12.2 btw.

Edited by Tieso2001
added version

Which Block did you import?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

2 minutes ago, Tieso2001 said:

if (ImmutableSet.of(Blocks.SAND).contains(block)) {

just do if(block==Blocks.SAND)

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Which Block class did you import?

Which class called “Block” (from one of the external libraries) did you import into the class that you are writing? If it’s not “net.minecraft.block” that’s your problem.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

You need to know basic Java before you make a mod. Even spending 1-2 hours reading or watching a good tutorial helps immeasurably. Sorry to be blunt with you, but this is an absolute pre-requisite.

On the upside you now know one of the causes of this error, and know how to fix it.

Usually googling an error you got should get you an decent explanation. This problem deals with such basic Java that no one appears to have asked this question on google (the error is pretty self explanatory to someone with basic Java knowledge), so this advice doesn’t apply in this specific case, but it is good advice in general!

Happy Modding!

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

  • Author

Thanks for the advice, I know basic java and I have made mods before, but this was something that I just didn't realise and thought that it was some other mistakes than importing the wrong class. Also I tried googling but that didn't really got me anywhere so I decided to see if someone could help me here. Anyways thanks for your help.

19 hours ago, Tieso2001 said:

It says incompatible types:

required: jdk.nashorn.internal.ir.Block

found: net.minecraft.block.Block

If you don't recognize a thing, you probably did something wrong. In this case, figure out why "jdk.nashorn" is being referenced.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.