#How can I simulate bonemeal usage on a block?

64 messages · Page 1 of 1 (latest)

crystal bluff
#

I have some code here:

onEvent('block.right_click', event => {
    var item = event.item.id;
    var player = event.player;

    var helmetId = 'ssrp:farmer_hat';
    var chestplateId = 'ssrp:farmer_chestplate';
    var leggingsId = 'ssrp:farmer_leggings';
    var bootsId = 'ssrp:farmer_boots';

    var hasHelmet = player.headArmorItem && player.headArmorItem.id === helmetId;
    var hasChestplate = player.chestArmorItem && player.chestArmorItem.id === chestplateId;
    var hasLeggings = player.legsArmorItem && player.legsArmorItem.id === leggingsId;
    var hasBoots = player.feetArmorItem && player.feetArmorItem.id === bootsId;

    if ((hasHelmet && hasChestplate && hasLeggings && hasBoots) && item === 'minecraft:bone_meal') {
        console.info('Bone meal not consumed because player has specific armor.');
        //simulate the bonemeal usage on the block here
        event.cancel();
    }
});
cinder cipherBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

fathom rampart
#

you want exact behavior?

#

and cancel/allow accordingly

#

this is onForgeEvent

#

at startup

crystal bluff
#

hmm I prefer having it on server side

#

cuz startup needs to be on both client and server

fathom rampart
#

I see, anyway, you can just allow the event to go on if you pass those checks

#

and cancel when your criteria does not match

#

hmm but you want to not consume bonemeal

crystal bluff
#

right now event.cancel() works buuut it cancels event the usage

fathom rampart
#

can't you just add 1, so it will give 1 and later consume 1, maybe it will blink but may work as you want

crystal bluff
#

So I want to somehow force the event block to grow

crystal bluff
fathom rampart
#

bonemeal is more than that

crystal bluff
#

and it is consumed, then the added bonemeal will be in a different spot in the inv

fathom rampart
#

goes to 2 and to 1, you edit the same itemstack, it won't change places

crystal bluff
#

ohh, smart ahhaha

#

will try yes

#

will player.give and player.removeItem work?

fathom rampart
#

hmm you might have problem when you try to use where it doesn't apply

crystal bluff
#

I don't knwo the functions names

crystal bluff
#

let me first give and remove

fathom rampart
#

event.item.count++

crystal bluff
#

aha it can be like this

#

ok

fathom rampart
#

remove will remove automatically no?

crystal bluff
#

yep will

fathom rampart
#

did you install ProbeJS or not?

crystal bluff
#

I did while ago

#

need to update it

fathom rampart
#

did you run /probejs dump

#

?

crystal bluff
#

mmm I'm on a server

#

doesn't dump work only on single?

fathom rampart
#

yes single

crystal bluff
#

mhm will do it later

#

I need to run this skript as fast as I can

fathom rampart
crystal bluff
#

java.lang.IllegalArgumentException: count

#

hmm Rhino fails

untold gorge
#

??code

sacred totemBOT
# untold gorge ??code

🗒️**Send the code!**🗒️
You may have an issue with a KubeJS script and you explain it to the best of your ability yet without the actual code in question we have very little to go off of in trying to assist you.

untold gorge
#

??neversay

sacred totemBOT
# untold gorge ??neversay

Never say 'it crashed', 'it errored', or 'it didn't work' without providing the full crash report, log, and scripts!

crystal bluff
sacred totemBOT
#

Paste version of message.txt from @crystal bluff

untold gorge
crystal bluff
#

too long and Gnome pasted it

untold gorge
#

im talking about the actual script

#

we need both the code and the error log

crystal bluff
#
onEvent('block.right_click', event => {
    var item = event.item.id;
    var player = event.player;

    var helmetId = 'ssrp:farmer_hat';
    var chestplateId = 'ssrp:farmer_chestplate';
    var leggingsId = 'ssrp:farmer_leggings';
    var bootsId = 'ssrp:farmer_boots';

    var hasHelmet = player.headArmorItem && player.headArmorItem.id === helmetId;
    var hasChestplate = player.chestArmorItem && player.chestArmorItem.id === chestplateId;
    var hasLeggings = player.legsArmorItem && player.legsArmorItem.id === leggingsId;
    var hasBoots = player.feetArmorItem && player.feetArmorItem.id === bootsId;

    if (hasHelmet && hasChestplate && hasLeggings && hasBoots && item === 'minecraft:bone_meal') {
        item.count++;
    }
});
untold gorge
#

you need event.item.count not event.item.id.count

crystal bluff
#

uhhh

#

you're totally right

untold gorge
#

ye

crystal bluff
#

Worked, now I need to check if the block can grow

#

cuz it gives infinite bonemeals

#

but I cannot do this until my ProbeJS is fixed

#

I have another ticket "Checking the equipped armor", there the ProbeJS issue is documented