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

Hello i am getting an error when right clicking in game

 

[16:58:12] [server thread/FATAL]: Error executing task

java.util.concurrent.ExecutionException: java.lang.NullPointerException

at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_112]

at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_112]

at net.minecraft.util.Util.runTask(Util.java:26) [util.class:?]

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:742) [MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) [MinecraftServer.class:?]

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) [integratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]

at java.lang.Thread.run(Thread.java:745) [?:1.8.0_112]

Caused by: java.lang.NullPointerException

at com.drsteam1111.drbit.item.ItemNecklessOfDeath.onItemRightClick(ItemNecklessOfDeath.java:35) ~[itemNecklessOfDeath.class:?]

at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:176) ~[itemStack.class:?]

at net.minecraft.server.management.PlayerInteractionManager.processRightClick(PlayerInteractionManager.java:391) ~[PlayerInteractionManager.class:?]

at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:740) ~[NetHandlerPlayServer.class:?]

at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:43) ~[CPacketPlayerTryUseItem.class:?]

at net.minecraft.network.play.client.CPacketPlayerTryUseItem.processPacket(CPacketPlayerTryUseItem.java:9) ~[CPacketPlayerTryUseItem.class:?]

at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_112]

at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_112]

at net.minecraft.util.Util.runTask(Util.java:25) ~[util.class:?]

... 5 more

 

Heres my Code:

 

    @Override

    public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand) {

        if(!world.isRemote) {

            if(player.getHeldItemOffhand().getItem() == itemStack.getItem() && player.getHeldItemMainhand().getItem() == itemStack.getItem()) {

                } else if (player.getHeldItemOffhand().getItem() == itemStack.getItem() || player.getHeldItemMainhand().getItem() == itemStack.getItem()){

                    player.addPotionEffect(new PotionEffect(Potion.getPotionById(6), 1, 2, false, false));

                    player.addChatComponentMessage(new TextComponentString("You Drain Strength From The Dead"));

                    player.setHealth(player.getHealth() - 4f);

                    return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);

            }

        }

        return super.onItemRightClick(itemStack, world, player, hand);

    }

 

Does any one know what the problem is?

What if one of the hands contains nothing? Hint: it returns

null

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

What if one of the hands contains nothing? Hint: it returns

null

.

 

changed the code to

 

            if(player.getHeldItemOffhand().getItem() == ModItems.neckless_of_death && player.getHeldItemMainhand().getItem() == null || player.getHeldItemOffhand().getItem() == null && player.getHeldItemMainhand().getItem() == ModItems.neckless_of_death) {

                player.addPotionEffect(new PotionEffect(Potion.getPotionById(6), 1, 2, false, false));

                player.addChatComponentMessage(new TextComponentString("You Drain Strength From The Dead"));

                player.setHealth(player.getHealth() - 4f);

                return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);

            }

 

No.

getHeldItem*hand()

returns

null

, not

getItem()

. Check if

getHeldItem*hand()

is not equal to

null

, then try to get the

Item

from it.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

No.

getHeldItem*hand()

returns

null

, not

getItem()

. Check if

getHeldItem*hand()

is not equal to

null

, then try to get the

Item

from it.

 

got it working with

 

            if(player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() == itemStack.getItem() && player.getHeldItemOffhand() == null) {

                player.addPotionEffect(new PotionEffect(Potion.getPotionById(5), 1200, 2, false, false));

                player.addChatComponentMessage(new TextComponentString("You Drain Strength From The Dead"));

                player.setHealth(player.getHealth() - 4f);

                return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);

            } else if (player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() == itemStack.getItem() &&    player.getHeldItemMainhand() == null) {

                player.addPotionEffect(new PotionEffect(Potion.getPotionById(5), 1200, 2, false, false));

                player.addChatComponentMessage(new TextComponentString("You Drain Strength From The Dead"));

                player.setHealth(player.getHealth() - 4f);

                return ActionResult.newResult(EnumActionResult.SUCCESS, itemStack);

 

Thank You!

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.