#Speed but below the player's block they're standing on

38 messages · Page 1 of 1 (latest)

strange bison
#

I want to have a block, that gives the player a speed boost, but it's below the block they're standing on. So it would be like:

Player
Normal Ground block
Speed block

Kinda like how soul sand with ice below it slows the player more. Any suggestions?

rancid ermineBOT
#

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

plush merlin
#

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

wary summit
#

just use the speedFactor(float) on the custom block, or existing block through block modification

strange bison
#

that will give it the speed factor if they're directly on it, I need it to be if its one below

wary summit
#
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

plush merlin
#

they want it below the block they are standing on

#

aka
🚶
🟩 <-- not this block
🟦 <-- this block

wary summit
#

OH

#

Ok then Player tick should do

#

Sorry for that

#

Im blind as hell sometimes

plush merlin
#

ITS FINE

#

sorry capslock

strange bison
#

how do I give speed to the player?

plush merlin
#

there's probably some better way with attributes

#

but i dont know how those work at all lmao

strange bison
#

how do I give a player a speed effect I meant

cold quartz
#

player.effects.add("effect", level, time)

#

probably

plush merlin
#

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

strange bison
#

player.potionEffects.add("minecraft:swiftness", 20, 1, false, false);

does anyone see an issue with? can't get it to work for some reason

strange bison
#

that's what other people were doing from other posts I tried to find I'll remove them & see if that fixes it

plush merlin
#

its not switftness

#

its speed

strange bison
#

thanks

plush merlin
#

swiftness is just the name of the potion, not the effect

strange bison
#

yea that's definitely the issue i think, let me test it then if it works ill close the ticket thanks

strange bison
#

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);
    }
});