Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.10.2] ArrowNockEvent can't cancel
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 0
SirWindfield

[1.10.2] ArrowNockEvent can't cancel

By SirWindfield, May 9, 2017 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

SirWindfield    0

SirWindfield

SirWindfield    0

  • Tree Puncher
  • SirWindfield
  • Members
  • 0
  • 10 posts
Posted May 9, 2017

I am fairly new to Minecraft Modding (I have around 5 years Java experience).
I want to prevent vanilla bows from firing. Looking into the docs for Forge I came across the ArrowNockEvent which should allow me to cancel any bow actions.
But even thought the event is marked as @Cancelable, Forge still throws an IllegalArgumentException when I try to cancel the event.
Here is the code if I am doing something wrong:

 

@SubscribeEvent(priority = EventPriority.HIGHEST)
    public void onHit(ArrowNockEvent event) {
        // not sure if machines can trigger this event
        if (event.getEntityPlayer() != null) {
            ItemStack bow = event.getBow();
            System.out.println(bow);
            System.out.println("Empty? " + ItemStackTools.isEmpty(bow));
            if (!ItemStackTools.isEmpty(bow)) {
                if(bow.getItem() instanceof ItemBow) {
                    event.setCanceled(true);
                }
            }
        }
    }

 

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7687

diesieben07

diesieben07    7687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7687
  • 56228 posts
Posted May 9, 2017

ArrowNockEvent is not @Cancelable: https://github.com/MinecraftForge/MinecraftForge/blob/1.11.x/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java#L39

  • Quote

Share this post


Link to post
Share on other sites

SirWindfield    0

SirWindfield

SirWindfield    0

  • Tree Puncher
  • SirWindfield
  • Members
  • 0
  • 10 posts
Posted May 9, 2017 (edited)
4 minutes ago, diesieben07 said:

ArrowNockEvent is not @Cancelable: https://github.com/MinecraftForge/MinecraftForge/blob/1.11.x/src/main/java/net/minecraftforge/event/entity/player/ArrowNockEvent.java#L39

Looks like I had some older docs open. Is there any other practically disable vanilla bows without removing the recipe? 

Edited May 9, 2017 by SirWindfield
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    7687

diesieben07

diesieben07    7687

  • Reality Controller
  • diesieben07
  • Forum Team
  • 7687
  • 56228 posts
Posted May 9, 2017

If you set the ActionResult in the event it will override the vanilla mechanics and result.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • CyberNation
      Forge 1.7.10 Server Failed to write Transciever Channels

      By CyberNation · Posted 10 minutes ago

      i made a custom 1.7.10 modpack for my friends and I to play on decided to move it over to my own server host and now im getting an error when starting ive spent several hours trying to look for a solution and cant seem to find one im not sure if im in the right place for this but i hope someone can help me     17:44:27 Can't revert to frozen GameData state without freezing first. Server thread/INFO 17:44:27 Applying holder lookups Holder lookups applied Server thread/WARN 17:44:27 Failed to write Transciever Channels on exit: java.util.concurrent.ExecutionException: java.lang.NullPointerException Server thread/INFO 17:44:27 The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED. Errors may have been discarded. The state engine was in incorrect state ERRORED and forced into state AVAILABLE. Errors may have been discarded.     full Crash Log Report: Paste Bin https://pastebin.com/cxgY3t6q
    • DrCowiber
      Failed To Start Minecraft Server

      By DrCowiber · Posted 31 minutes ago

      Im wondering if changing the launch options for the main server jar will fix that? I saw some threads where some peoples launch files had "-o" as a launch option, is there a way I can change the launch options for when the vanilla server is launched?
    • DrCowiber
      Failed To Start Minecraft Server

      By DrCowiber · Posted 41 minutes ago

      When I run my forge Server it goes fine, but when I try to host off my Raspberry Pi 4 Model B 8GB RAM, using the 32-bit raspbian and 64-bit raspbian, I get this error at the end of log.   jpotsimple.UnrecognizedOptionException: o is not a recognized option     The full log file: https://pastebin.com/n4GpC53Q
    • KBomb
      Forge 1.12.2 Server Crashing On Start-up

      By KBomb · Posted 45 minutes ago

      I have been able to run the server in vanilla, but after adding the mods the server is crashing during the start-up. I will attach the crash report. I also have screenshots of what the server console was displaying if that may be necessary. crash-2021-02-24_18.58.56-server.txt
    • milkman69
      My game keeps crashing and I haven't even added any mods on yet

      By milkman69 · Posted 2 hours ago

      here's the crash report or whatever:  Failed to download file. Name: 1.16.4-forge-35.1.37.jar URL: https://s3.amazonaws.com/Minecraft.Download/versions/1.16.4-forge-35.1.37/1.16.4-forge-35.1.37.jar Filename on disk: 1.16.4-forge-35.1.37.jar Path: C:\Users\donov\AppData\Roaming\.minecraft\versions\1.16.4-forge-35.1.37\1.16.4-forge-35.1.37.jar Exists: File
  • Topics

    • CyberNation
      0
      Forge 1.7.10 Server Failed to write Transciever Channels

      By CyberNation
      Started 10 minutes ago

    • DrCowiber
      1
      Failed To Start Minecraft Server

      By DrCowiber
      Started 41 minutes ago

    • KBomb
      0
      Forge 1.12.2 Server Crashing On Start-up

      By KBomb
      Started 45 minutes ago

    • milkman69
      0
      My game keeps crashing and I haven't even added any mods on yet

      By milkman69
      Started 2 hours ago

    • Skyriis
      0
      [1.16.5] Adding a Button to KeyBindings

      By Skyriis
      Started 3 hours ago

  • Who's Online (See full list)

    • William59
    • Taknax
    • DrCowiber
    • mcnuggies
    • Draco18s
    • Jeldrik
    • PyRoTheLifeLess
    • CyberNation
    • Babelincoln1809
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.10.2] ArrowNockEvent can't cancel
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community