Posted March 8, 20196 yr 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 March 8, 20196 yr by Tieso2001 added version
March 8, 20196 yr Which Block did you import? About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
March 8, 20196 yr 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 Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
March 8, 20196 yr Author Okay I will use if(block == Blocks.SAND) but I still have the error that the types are incompatible
March 8, 20196 yr 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 Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
March 8, 20196 yr Author Thanks! I accidentally imported the jdk.nashorn class instead of the minecaft one.
March 8, 20196 yr 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 Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.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)
March 8, 20196 yr 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.
March 9, 20196 yr 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.