<?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[[Help Needed] Get player slot]]></title><description><![CDATA[<pre><code>/// api_version=2
var script = registerScript({
    name: "BowDamage",
    version: "1.0.0",
    authors: ["PlumerMan"]
});

var RotationUtils = Java.type('net.ccbluex.liquidbounce.utils.RotationUtils');
var Rotation = Java.type('net.ccbluex.liquidbounce.utils.Rotation');
var LiquidBounce = Java.type("net.ccbluex.liquidbounce.LiquidBounce");
var ItemStack = Java.type("net.minecraft.item.ItemStack");
var ItemBow = Java.type("net.minecraft.item.ItemBow");
var ItemFishingRod = Java.type("net.minecraft.item.ItemFishingRod");
var waitingForDMG = false;
var ticksLeft = false;
var prevSlot = -1;
var sx, sz;

script.registerModule({
    name: "BowDamage",
    description: "Damages yourself",
    category: "Fun",
    settings: {
        mname: Setting.text({
            name: "Module",
            default: "Fly"
        }),
    }
}, function (module) {
    module.on("enable", function () {
        waitingForDMG = true;
        ticksLeft = 3;
        sx = mc.thePlayer.posX; sz = mc.thePlayer.posZ;
        
        for (x = 0; x &lt; 9; ++x) {
            stack = mc.thePlayer.inventory.getStackInSlot(x);
            
            if(stack != null &amp;&amp; stack.getItem() != null &amp;&amp; stack.getItem() == mc.thePlayer.getHeldItem()) {
                prevSlot = x;
                Chat.print("Set slot");
            }
        }
    });

    module.on("disable", function () {
        var module = moduleManager.getModule(this.settings.mname.get());
        module.state = this.state = false;
        prevSlot = -1;
    });

    module.on("update", function() {
        Chat.print(prevSlot + " slot | " + mc.thePlayer.getHeldItem());
        if(waitingForDMG) {
            mc.thePlayer.setPosition(sx, mc.thePlayer.posY, sz);
            mc.thePlayer.motionX = mc.thePlayer.motionZ = 0;
        }

        if(ticksLeft &gt; 0) {
            for (x = 0; x &lt; 9; ++x) {
				stack = mc.thePlayer.inventory.getStackInSlot(x);
				
				if(stack != null &amp;&amp; stack.getItem() != null &amp;&amp; (stack.getItem() instanceof ItemBow || stack.getItem() instanceof ItemFishingRod)) {
                    mc.thePlayer.inventory.currentItem = x;
                }
            }

            mc.gameSettings.keyBindUseItem.pressed = true;

            RotationUtils.setTargetRotation(new Rotation(mc.thePlayer.rotationYaw, -90))
            ticksLeft--;
        } else {
            RotationUtils.setTargetRotation(new Rotation(mc.thePlayer.rotationYaw, -90))
            mc.gameSettings.keyBindUseItem.pressed = false;
        }

        if(waitingForDMG &amp;&amp; mc.thePlayer.hurtTime == 9) {
            var module = moduleManager.getModule(this.settings.mname.get());
            module.state = true; waitingForDMG = false;
            mc.thePlayer.currentItem = prevSlot;
        }
    });
});
</code></pre>
<p dir="auto">I tried getting the slot by using 'player.currentItem' but it returned null and the code on the onEnable event wasnt working either.</p>
<p dir="auto"><a href="https://emalm.com/?v=kdTa7" target="_blank" rel="noopener noreferrer nofollow ugc">https://emalm.com/?v=kdTa7</a></p>
]]></description><link>https://forum.liquidbounce.net/topic/4183/help-needed-get-player-slot</link><generator>RSS for Node</generator><lastBuildDate>Tue, 16 Jun 2026 20:56:57 GMT</lastBuildDate><atom:link href="https://forum.liquidbounce.net/topic/4183.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 Jul 2022 23:44:35 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Help Needed] Get player slot on Mon, 11 Jul 2022 22:14:03 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>uh, this was a small brain moment. I found the issue.</strong></em></p>
<pre><code>mc.thePlayer.currentItem = prevSlot;
</code></pre>
<p dir="auto">this is what i did</p>
<pre><code>mc.thePlayer.inventory.currentItem = prevSlot;
</code></pre>
<p dir="auto">this is what it was meant to be</p>
]]></description><link>https://forum.liquidbounce.net/post/32010</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/32010</guid><dc:creator><![CDATA[Plumer Man]]></dc:creator><pubDate>Mon, 11 Jul 2022 22:14:03 GMT</pubDate></item><item><title><![CDATA[Reply to [Help Needed] Get player slot on Mon, 11 Jul 2022 22:14:03 GMT]]></title><description><![CDATA[<p dir="auto"><em><strong>uh, this was a small brain moment. I found the issue.</strong></em></p>
<pre><code>mc.thePlayer.currentItem = prevSlot;
</code></pre>
<p dir="auto">this is what i did</p>
<pre><code>mc.thePlayer.inventory.currentItem = prevSlot;
</code></pre>
<p dir="auto">this is what it was meant to be</p>
]]></description><link>https://forum.liquidbounce.net/post/32010</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/32010</guid><dc:creator><![CDATA[Plumer Man]]></dc:creator><pubDate>Mon, 11 Jul 2022 22:14:03 GMT</pubDate></item><item><title><![CDATA[Reply to [Help Needed] Get player slot on Mon, 11 Jul 2022 21:34:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/plumer-man" aria-label="Profile: plumer-man">@<bdi>plumer-man</bdi></a> Does the script show up?</p>
]]></description><link>https://forum.liquidbounce.net/post/32009</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/32009</guid><dc:creator><![CDATA[Ali00035]]></dc:creator><pubDate>Mon, 11 Jul 2022 21:34:32 GMT</pubDate></item><item><title><![CDATA[Reply to [Help Needed] Get player slot on Mon, 11 Jul 2022 16:39:01 GMT]]></title><description><![CDATA[<p dir="auto">please help <img src="https://forum.liquidbounce.net/assets/plugins/nodebb-plugin-emoji/emoji/android/1f62d.png?v=866ab33d74c" class="not-responsive emoji emoji-android emoji--sob" style="height:23px;width:auto;vertical-align:middle" title=":sob:" alt="😭" /></p>
]]></description><link>https://forum.liquidbounce.net/post/32004</link><guid isPermaLink="true">https://forum.liquidbounce.net/post/32004</guid><dc:creator><![CDATA[Plumer Man]]></dc:creator><pubDate>Mon, 11 Jul 2022 16:39:01 GMT</pubDate></item></channel></rss>