<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[BlockBBEvent in scripts?]]></title><description><![CDATA[<p dir="auto">title // aaa bbb</p>
]]></description><link>https://forum.liquidbounce.net/topic/3574/blockbbevent-in-scripts</link><generator>RSS for Node</generator><lastBuildDate>Thu, 11 Jun 2026 04:51:57 GMT</lastBuildDate><atom:link href="https://forum.liquidbounce.net/topic/3574.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 25 Jan 2022 19:51:23 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 18:38:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a><br />
What <code>Java.extend()</code> returns is something that behaves like a type (Forgot what it really is, probably a JSAdaptor or something).<br />
Similar to what you will get from using <code>Java.type()</code>.</p>
<pre><code>ArrayList = Java.type("java.util.ArrayList")
arrayList = new ArrayList()
</code></pre>
<pre><code>BBConsumer = Java.extend(Listenable, Consumer, {
    handleEvents: function() { return true},
    accept: function(e) {
        // onBlockBB here
        
    }
})

consumer = new BBConsumer()
registerListener(consumer)
// not registerListener(BBConsumer)
/* I am sure there would be a better name for BBConsumer
And if you want to use it like a anonymous class in Java you could just read the BlockAnimations.js or better,  nashorn document
https://github.com/CzechHek/Core/blob/879f36d7e41ccc7868285b0a808866b360f30822/Scripts/BlockAnimations.js#L35
*/  
</code></pre>
<p dir="auto">Not sure if the type from <code>Java.extend</code> would have other unexpected methods that only takes 1 parameters, you might want to check if the parameter's super class is <code>Event</code>.</p>
<p dir="auto">Or you could just explicitly specify the <code>accept</code> method in it.<br />
<code>method = consumer.class.getMethod("accept", java.lang.Object.class)</code></p>
<p dir="auto">Edit:<br />
Nvm, I forgot that this was scriptAPI, the <code>Consumer</code> here is a <code>Consumer&lt;?&gt;</code>, not <code>Consumer&lt;BlockBBEvent&gt;</code> which means the <code>accepct()</code> takes an <code>java.lang.Object</code>, and it will register a Listener that listens to any event that is an <code>java.lang.Object</code>, which probably means all events.'</p>
<p dir="auto">Here is what I did</p>
<pre><code>registry = getField(LiquidBounce.eventManager, "registry").get(LiquidBounce.eventManager)
BBs = registry.getOrDefault(BlockBBEvent.class, new ArrayList())
BBs.add(new EventHook(consumer, 
        consumer.class.getMethod("accept", java.lang.Object.class), 
        LiquidBounce.moduleManager.class
                .getDeclaredMethod("onKey", KeyEvent.class)
                .getAnnotation(EventTarget.class)))
registry[BlockBBEvent.class] = BBs
</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/28262</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28262</guid><dc:creator><![CDATA[commandblock2]]></dc:creator><pubDate>Thu, 27 Jan 2022 18:38:30 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Fri, 28 Jan 2022 11:16:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/czechhek" aria-label="Profile: czechhek">@<bdi>czechhek</bdi></a> said in <a href="/post/28268">BlockBBEvent in scripts?</a>:</p>
<blockquote>
<p dir="auto">I'll try to simplify it and automize it via Core.</p>
</blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> <a href="https://forums.ccbluex.net/topic/94/script-base-core-3-28-simple-yet-powerful-scriptapi-base/30" target="_blank" rel="noopener noreferrer nofollow ugc">https://forums.ccbluex.net/topic/94/script-base-core-3-28-simple-yet-powerful-scriptapi-base/30</a> and here it is</p>
<p dir="auto">You can use all events if you import Core base, no need to do any of this stuff.<br />
For more info, look at my comment on Core post.</p>
]]></description><link>https://forum.liquidbounce.net/post/28296</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28296</guid><dc:creator><![CDATA[CzechHek]]></dc:creator><pubDate>Fri, 28 Jan 2022 11:16:38 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Fri, 28 Jan 2022 05:23:15 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> same</p>
<p dir="auto">i rember <img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f633.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--flushed" style="height:23px;width:auto;vertical-align:middle" title="😳" alt="😳" /><img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f633.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--flushed" style="height:23px;width:auto;vertical-align:middle" title="😳" alt="😳" /><img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f633.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--flushed" style="height:23px;width:auto;vertical-align:middle" title="😳" alt="😳" /></p>
]]></description><link>https://forum.liquidbounce.net/post/28276</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28276</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 28 Jan 2022 05:23:15 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Fri, 28 Jan 2022 05:22:19 GMT]]></title><description><![CDATA[<p dir="auto">@fartcheese Wait... I rember<img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f600.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--grinning" style="height:23px;width:auto;vertical-align:middle" title=":grinning:" alt="😀" /></p>
]]></description><link>https://forum.liquidbounce.net/post/28275</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28275</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Fri, 28 Jan 2022 05:22:19 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Fri, 28 Jan 2022 05:18:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> we forgor <img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f480.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--skull" style="height:23px;width:auto;vertical-align:middle" title="💀" alt="💀" /></p>
]]></description><link>https://forum.liquidbounce.net/post/28273</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28273</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 28 Jan 2022 05:18:33 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Fri, 28 Jan 2022 05:17:38 GMT]]></title><description><![CDATA[<p dir="auto">@fartcheese i forgor <img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f480.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--skull" style="height:23px;width:auto;vertical-align:middle" title=":skull:" alt="💀" /></p>
]]></description><link>https://forum.liquidbounce.net/post/28272</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28272</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Fri, 28 Jan 2022 05:17:38 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Fri, 28 Jan 2022 05:17:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> you forgor <img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f480.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--skull" style="height:23px;width:auto;vertical-align:middle" title="💀" alt="💀" /></p>
]]></description><link>https://forum.liquidbounce.net/post/28271</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28271</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Fri, 28 Jan 2022 05:17:00 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Fri, 28 Jan 2022 05:16:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/czechhek" aria-label="Profile: czechhek">@<bdi>czechhek</bdi></a> my problem was too stupid: i forgot to create new instance of my listener (and i had some shitcode in listener prob)</p>
]]></description><link>https://forum.liquidbounce.net/post/28270</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28270</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Fri, 28 Jan 2022 05:16:52 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 23:44:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a></p>
<p dir="auto">This is what I came up with without seeing <a class="plugin-mentions-user plugin-mentions-a" href="/user/commandblock2" aria-label="Profile: commandblock2">@<bdi>commandblock2</bdi></a>'s solution.<br />
I had to reverse engineer a bunch of stuff and then put all together and it worked.</p>
<p dir="auto">I was wondering what the hell was annotation in Nashorn and it turns out that</p>
<p dir="auto"><code>print(annotation.class)</code></p>
<p dir="auto">literally returns<br />
<img src="/assets/uploads/files/1643323295286-d828c6df-270d-452a-8db2-b751195f7d54-image.png" alt="d828c6df-270d-452a-8db2-b751195f7d54-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I'll try to simplify it and automize it via Core.</p>
<pre><code>///api_version=2
(script = registerScript({
    name: "Test",
    authors: ["CzechHek"],
    version: "1.0"
})).import("Core.lib");

module = {
    onClickGuiLoaded: function () {
        listener = new (Java.extend(Listenable, Consumer, { 
            handleEvents: function() { return TestModule.state }, 
            accept: function(e) { 
                print(e)
            }
        }));

        method = getMethod(listener, "accept");
        annotation = getMethod(TestModule, "onUpdate").getDeclaredAnnotations()[0];
        
        AeventManager = new Reflector(LiquidBounce.eventManager)
        invocableEventTargets = AeventManager.registry.getOrDefault(BlockBBEvent.class, new ArrayList());
        invocableEventTargets.add(new EventHook(listener, method, annotation));
        AeventManager.registry[BlockBBEvent.class] = invocableEventTargets;
    }
}

Listenable = Java.type("net.ccbluex.liquidbounce.event.Listenable");
Consumer = Java.type("java.util.function.Consumer");
BlockBBEvent = Java.type("net.ccbluex.liquidbounce.event.BlockBBEvent");
EventHook = Java.type("net.ccbluex.liquidbounce.event.EventHook");
ArrayList = Java.type("java.util.ArrayList")
</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/28268</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28268</guid><dc:creator><![CDATA[CzechHek]]></dc:creator><pubDate>Thu, 27 Jan 2022 23:44:39 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 18:38:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/commandblock2" aria-label="Profile: commandblock2">@<bdi>commandblock2</bdi></a> Thank you</p>
]]></description><link>https://forum.liquidbounce.net/post/28264</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28264</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Thu, 27 Jan 2022 18:38:22 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 18:38:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a><br />
What <code>Java.extend()</code> returns is something that behaves like a type (Forgot what it really is, probably a JSAdaptor or something).<br />
Similar to what you will get from using <code>Java.type()</code>.</p>
<pre><code>ArrayList = Java.type("java.util.ArrayList")
arrayList = new ArrayList()
</code></pre>
<pre><code>BBConsumer = Java.extend(Listenable, Consumer, {
    handleEvents: function() { return true},
    accept: function(e) {
        // onBlockBB here
        
    }
})

consumer = new BBConsumer()
registerListener(consumer)
// not registerListener(BBConsumer)
/* I am sure there would be a better name for BBConsumer
And if you want to use it like a anonymous class in Java you could just read the BlockAnimations.js or better,  nashorn document
https://github.com/CzechHek/Core/blob/879f36d7e41ccc7868285b0a808866b360f30822/Scripts/BlockAnimations.js#L35
*/  
</code></pre>
<p dir="auto">Not sure if the type from <code>Java.extend</code> would have other unexpected methods that only takes 1 parameters, you might want to check if the parameter's super class is <code>Event</code>.</p>
<p dir="auto">Or you could just explicitly specify the <code>accept</code> method in it.<br />
<code>method = consumer.class.getMethod("accept", java.lang.Object.class)</code></p>
<p dir="auto">Edit:<br />
Nvm, I forgot that this was scriptAPI, the <code>Consumer</code> here is a <code>Consumer&lt;?&gt;</code>, not <code>Consumer&lt;BlockBBEvent&gt;</code> which means the <code>accepct()</code> takes an <code>java.lang.Object</code>, and it will register a Listener that listens to any event that is an <code>java.lang.Object</code>, which probably means all events.'</p>
<p dir="auto">Here is what I did</p>
<pre><code>registry = getField(LiquidBounce.eventManager, "registry").get(LiquidBounce.eventManager)
BBs = registry.getOrDefault(BlockBBEvent.class, new ArrayList())
BBs.add(new EventHook(consumer, 
        consumer.class.getMethod("accept", java.lang.Object.class), 
        LiquidBounce.moduleManager.class
                .getDeclaredMethod("onKey", KeyEvent.class)
                .getAnnotation(EventTarget.class)))
registry[BlockBBEvent.class] = BBs
</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/28262</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28262</guid><dc:creator><![CDATA[commandblock2]]></dc:creator><pubDate>Thu, 27 Jan 2022 18:38:30 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 17:35:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> <img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f480.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--skull" style="height:23px;width:auto;vertical-align:middle" title="💀" alt="💀" /><img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f480.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--skull" style="height:23px;width:auto;vertical-align:middle" title="💀" alt="💀" /><img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f480.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--skull" style="height:23px;width:auto;vertical-align:middle" title="💀" alt="💀" /><img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f480.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--skull" style="height:23px;width:auto;vertical-align:middle" title="💀" alt="💀" /></p>
]]></description><link>https://forum.liquidbounce.net/post/28259</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28259</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 27 Jan 2022 17:35:24 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 17:33:02 GMT]]></title><description><![CDATA[<p dir="auto">@fartcheese lmao</p>
]]></description><link>https://forum.liquidbounce.net/post/28257</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28257</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Thu, 27 Jan 2022 17:33:02 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 17:32:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> <strong>WHO</strong> asked</p>
<p dir="auto">the guy named <strong>WHO</strong> asked</p>
]]></description><link>https://forum.liquidbounce.net/post/28256</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28256</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 27 Jan 2022 17:32:10 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 17:30:16 GMT]]></title><description><![CDATA[<p dir="auto">@fartcheese wdym</p>
]]></description><link>https://forum.liquidbounce.net/post/28255</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28255</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Thu, 27 Jan 2022 17:30:16 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 17:29:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> who did</p>
]]></description><link>https://forum.liquidbounce.net/post/28254</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28254</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 27 Jan 2022 17:29:44 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 17:29:14 GMT]]></title><description><![CDATA[<p dir="auto">@fartcheese and? who asked?</p>
]]></description><link>https://forum.liquidbounce.net/post/28253</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28253</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Thu, 27 Jan 2022 17:29:14 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 17:24:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> said in <a href="/post/28250">BlockBBEvent in scripts?</a>:</p>
<blockquote>
<p dir="auto"><code>authors: ["xWhitey"],</code></p>
</blockquote>
]]></description><link>https://forum.liquidbounce.net/post/28252</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28252</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 27 Jan 2022 17:24:21 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 17:16:09 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/commandblock2" aria-label="Profile: commandblock2">@<bdi>commandblock2</bdi></a> I currently did this:</p>
<pre><code>///api_version=2
(script = registerScript({
    name: "BlockBBEvent",
    authors: ["xWhitey"],
    version: "1.337"
})).import("Core.lib");

module = {
    category: "Core",
    onLoad: function() {
        registerListener(Java.extend((Java.type('net.ccbluex.liquidbounce.event.Listenable')), (Java.type('java.util.function.Consumer')), {
            handleEvents: function() { return true },
            accept: function(e) {
                e instanceof BlockBBEvent &amp;&amp; print("Hello from BlockBBEvent!")
            }
        }))
    }
}

function registerListener(listener) {
    for each(method in listener.class.getDeclaredMethods()) {
        if (method.getParameterTypes().length == 1) {
            if (!method.isAccessible())
                method.setAccessible(true);
			
            var eventClass = method.getParameterTypes()[0];

            var adaptedEventManager = new Reflector(LiquidBounce.INSTANCE.eventManager);

            var invokableEventTargets = adaptedEventManager.registry.getOrDefault(eventClass, new ArrayList());
            var onTickMethod = (Java.type('net.ccbluex.liquidbounce.utils.RotationUtils')).class.getDeclaredMethod("onTick", TickEvent.class);
            var annotations = onTickMethod.getDeclaredAnnotations();
            var annotation = null;
            for each(a in annotations) {
                annotation = a;
            }
            invokableEventTargets.add(new EventHook(listener, method, annotation));
            adaptedEventManager.registry.put(eventClass, invokableEventTargets);
        }
    }
}

var TickEvent = Java.type('net.ccbluex.liquidbounce.event.TickEvent'), BlockBBEvent = Java.type('net.ccbluex.liquidbounce.event.BlockBBEvent'), EventHook = Java.type('net.ccbluex.liquidbounce.event.EventHook'), ArrayList = Java.type('java.util.ArrayList');
</code></pre>
<p dir="auto">but it throws an error:</p>
<pre><code>[23:01:10] [Client thread/ERROR] [LiquidBounce]: [ScriptAPI] Exception in script 'BlockBBEvent'!
java.lang.ClassCastException: Cannot cast jdk.internal.dynalink.beans.StaticClass to net.ccbluex.liquidbounce.event.Listenable
	at java.lang.invoke.MethodHandleImpl.newClassCastException(Unknown Source) ~[?:1.8.0_144]
	at java.lang.invoke.MethodHandleImpl.castReference(Unknown Source) ~[?:1.8.0_144]
	at jdk.nashorn.internal.scripts.Script$Recompilation$6736$598A$\^eval\_.registerListener(&lt;eval&gt;:37) ~[?:?]
	at jdk.nashorn.internal.scripts.Script$Recompilation$6733$207$\^eval\_.onLoad(&lt;eval&gt;:11) ~[?:?]
	at jdk.nashorn.internal.scripts.Script$Recompilation$6546$\^eval\_.L:611#L:629(&lt;eval&gt;:631) ~[?:?]
	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:628) ~[ScriptFunctionData.class:?]
	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494) ~[ScriptFunction.class:?]
	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393) ~[ScriptRuntime.class:?]
	at jdk.nashorn.api.scripting.ScriptObjectMirror.call(ScriptObjectMirror.java:117) ~[ScriptObjectMirror.class:?]
	at net.ccbluex.liquidbounce.script.Script.callEvent(Script.kt:203) [Script.class:?]
	at net.ccbluex.liquidbounce.script.Script.onEnable(Script.kt:171) [Script.class:?]
	at net.ccbluex.liquidbounce.script.ScriptManager.enableScripts(ScriptManager.kt:53) [ScriptManager.class:?]
	at net.ccbluex.liquidbounce.LiquidBounce.startClient(LiquidBounce.kt:130) [LiquidBounce.class:?]
	at net.minecraft.client.Minecraft.handler$zze000$startGame(Minecraft.java:3428) [bib.class:?]
	at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:536) [bib.class:?]
	at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:378) [bib.class:?]
	at net.minecraft.client.main.Main.main(SourceFile:123) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_144]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_144]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_144]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [game.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [game.jar:?]
</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/28250</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28250</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Thu, 27 Jan 2022 17:16:09 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Thu, 27 Jan 2022 03:31:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a><br />
Indeed something like that.</p>
<pre><code>val eventClass = method.parameterTypes[0] as Class&lt;out Event&gt;
val eventTarget = method.getAnnotation(EventTarget::class.java)
</code></pre>
<p dir="auto">Unfortunately, nashorn/reflection does not have any capability of adding annotations.<br />
<code>method.getAnnotation(EventTarget::class.java)</code><br />
and we will have to make our own <code>registerListener()</code>.</p>
<p dir="auto">The 3 lines actually does the work is here.</p>
<pre><code>val invokableEventTargets = registry.getOrDefault(eventClass, ArrayList())
invokableEventTargets.add(EventHook(listener, method, eventTarget))
registry[eventClass] = invokableEventTargets
</code></pre>
<p dir="auto">You only need to convert this 3 line to js and it would be fine.<br />
Note the second line<br />
<code>EventHook(listener, method, eventTarget)</code><br />
the <code>listener</code> is just the listener,<br />
the <code>method</code> is <code>accept</code> acquired using reflection<br />
but for the <code>eventTarget</code>, I borrowed it with reflection from a function in other class that <code>extends Listener</code> already presented in LB.</p>
<p dir="auto">As for the performance issue, it's true, in my case, putting a print every time it is called makes the frame rate goes from 80(limited) to less than 1.</p>
]]></description><link>https://forum.liquidbounce.net/post/28240</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28240</guid><dc:creator><![CDATA[commandblock2]]></dc:creator><pubDate>Thu, 27 Jan 2022 03:31:21 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Wed, 26 Jan 2022 22:26:53 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/idk-my-name" aria-label="Profile: idk-my-name">@<bdi>idk-my-name</bdi></a> you should probably register it on load, unregister it on unload and handle if it gets triggered in handleEvents method</p>
]]></description><link>https://forum.liquidbounce.net/post/28238</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28238</guid><dc:creator><![CDATA[CzechHek]]></dc:creator><pubDate>Wed, 26 Jan 2022 22:26:53 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Wed, 26 Jan 2022 21:12:04 GMT]]></title><description><![CDATA[<p dir="auto">He basically says that the event is not added due to its performance killing capability as it is called lots of times in the code.</p>
]]></description><link>https://forum.liquidbounce.net/post/28237</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28237</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Wed, 26 Jan 2022 21:12:04 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Wed, 26 Jan 2022 20:53:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/czechhek" aria-label="Profile: czechhek">@<bdi>czechhek</bdi></a> Marco says: the problem will be in optimization</p>
]]></description><link>https://forum.liquidbounce.net/post/28236</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28236</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Wed, 26 Jan 2022 20:53:20 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Wed, 26 Jan 2022 20:20:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/commandblock2" aria-label="Profile: commandblock2">@<bdi>commandblock2</bdi></a> waait that's cool never had that idea</p>
<p dir="auto">I might automatize that via Core.</p>
]]></description><link>https://forum.liquidbounce.net/post/28235</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28235</guid><dc:creator><![CDATA[CzechHek]]></dc:creator><pubDate>Wed, 26 Jan 2022 20:20:50 GMT</pubDate></item><item><title><![CDATA[Reply to BlockBBEvent in scripts? on Wed, 26 Jan 2022 19:41:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/commandblock2" aria-label="Profile: commandblock2">@<bdi>commandblock2</bdi></a><br />
I understood from your tutorial that I should somewhere use registerListener, prob like this:</p>
<pre><code class="language-javascript">onEnable: function() {
    LiquidBounce.INSTANCE.eventManager.registerListener(listener)
},
onDisable: function() {
    LiquidBounce.INSTANCE.eventManager.unregisterListener(listener)
}
listener = Java.extend(Listenable, Consumer, { 
    handleEvents: function() { return true}, 
    accept: function(e) { 
        e instanceof BlockBBEvent &amp;&amp; print("Hello from BlockBBEvent!")
    } 
})
</code></pre>
]]></description><link>https://forum.liquidbounce.net/post/28234</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/28234</guid><dc:creator><![CDATA[idk my name]]></dc:creator><pubDate>Wed, 26 Jan 2022 19:41:11 GMT</pubDate></item></channel></rss>