#Speed but below the player's block they're standing on
38 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
PlayerEvents.tick is an option
you use that, check the block below them (player.x - 2) if its the speed block, then add a potion effect or smth
just use the speedFactor(float) on the custom block, or existing block through block modification
that will give it the speed factor if they're directly on it, I need it to be if its one below
onEvent('block.modification', event => {
event.modify('minecraft:stone', block => {
block.speedFactor = 2.0
})
})```
For existing blocks
onEvent('block.registry', event => {
event.create('test_block')
.material('glass')
.hardness(0.5)
.displayName('Test Block')
.speedFactor(2.0)
})```
An this other for custom blocks
that is if they are standing on the block
they want it below the block they are standing on
aka
🚶
🟩 <-- not this block
🟦 <-- this block
how do I give speed to the player?
speed effect could work
there's probably some better way with attributes
but i dont know how those work at all lmao
how do I give a player a speed effect I meant
yeah, i could probalby learn attributes too for it
surely it could just be setting a flag for the player, checking hte flag and increasing the speed when the criteria is on and unchecking the flag and removing the speed when the criteria is off
player.potionEffects.add("minecraft:swiftness", 20, 1, false, false);
does anyone see an issue with? can't get it to work for some reason
why the boleans
that's what other people were doing from other posts I tried to find I'll remove them & see if that fixes it
oh
its not switftness
its speed
thanks
swiftness is just the name of the potion, not the effect
yea that's definitely the issue i think, let me test it then if it works ill close the ticket thanks
for those who need it in the future, the code:
onEvent("player.tick", (event) => {
const player = event.getPlayer();
if (event.level.getBlock(player.x, player.y - 2, player.z) == "kubejs:speed_block") {
player.potionEffects.add("minecraft:speed", 20, 0, false, false);
}
});
