#Right Click Apply on Block with Item in Hand to change its form. Help.
32 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
(Ment to change the block with the item, if i sounded confusing (block transform)
The item (and the hand used) to interact with the block is already provided by the event
const {block, item, player} = event //shortcut for declaring multiple variables that already exist in X
if (item == 'kubejs:end_portal_frame_top'){ //no need to use ID, KubeJS provides easy equals check
block.set('minecraft:end_portal_frame')
if(!player.isCreative())
item.count--
player.swing() //makes the hand swing as if an item was used
}
const {block, item, player} = event
if (item == 'kubejs:end_portal_frame_top') {
event.block.set('minecraft:end_portal_frame')
if(!player.isCreative())
item.count--
player.swing()
}
})```
and.. still wont work..
BlockEvents.rightClicked('minecraft:endstone', event => {
const {block, item, player} = event
player.tell(`Right-clicked ${block} with ${item}`)
if (item == 'kubejs:end_portal_frame_top') {
event.block.set('minecraft:end_portal_frame')
if(!player.isCreative())
item.count--
player.swing()
}
})
also check logs to see if there's any issues
Oh and this is in a server_scripts file yes?
its server_scripts, yes
still nothing..
Paste version of server.log from @jaunty flare
ah
Don't have minecraft running atm, but check the mod:id of end stone
It should likely be minecraft:end_stone, not minecraft:endstone
yeah... makes sense
works!
just.... one problem..
when i create the portal, the portal FRAMES are not in the right direction, so the portal wont activate when i place in the eyes
/kjs hand will output into chat the held item's ID, and any and all possible tags etc into chat
All of them can be clicked to copy that string to clipboard, so you can easily ctrl+v into your script
block.set('minecraft:end_portal_frame[facing=north]')
You'll have to do some maths and calculate which facing (north/south/west/east) you need to place them, oooor, you can add a tooltip to the item, stating that players must use the frame top on a cardinal side (N/S/W/E), which allows you to reference that direction from the rightClicked event through event.facing
From that, you can either set the end stone with the same facing, or if needed use the opposite facing using event.facing.opposite
You may also want to disable using the frame top if the right-clicked side is Up/Down
Easy way to implement the facing without 4 separate if-statements et similar, is to use template literals, eg backticks, like I did in that player.tell snippet earlier
block.set(`minecraft:end_portal_frame[facing=${event.facing}]`)
This will place the block facing the player
If you need the opposite, the event.facing.opposite will have the block be placed facing away from you
so, like this?
const {block, item, player} = event
if (item == 'kubejs:end_portal_frame_top') {
event.block.set(`minecraft:end_portal_frame[facing=${event.facing}]`)
if(!player.isCreative())
item.count--
player.swing()
}
})
oh... wait
sec..
edited
yeah, that should alter the portal frame block's facing based on which side you clicked
ill try that in a sec
now it wont let me place them anymore, at all
ok, ok... me beeing me, means stupid... "endstone"
instead of end_stone
yeah no, still wont
they are ALL facing north... yea
gives me an error
oh wait no... nothing, it stopped
and i cannot right click it