Trying to make a sword that teleports the player where theyre looking but without getting stuck in blocks

Started by sqweems on

Topic category: Help with Minecraft modding (Java Edition)

Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Trying to make a sword that teleports the player where theyre looking but without getting stuck in blocks

hi, i'm trying to make a sword that lets you teleport 8 in the direction you are looking blocks but not through blocks. i already have the code to teleport but i can't make it stop if you hit blocks. 

pleas tell me how ty<3

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I assume you're using the…
Tue, 01/16/2024 - 22:16

I assume you're using the player's look angle vectors and multiplying by eight. You could simply check if the block at that position, and the block directly above it aren't solid, (and cancel the teleport if it is). You could also change the amount your multiplying the vectors by to smaller numbers each time there's a solid collision, in order to make the teleport stop before it hits a wall instead of straight up canceling it.

Joined Dec 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
tysm <3 thats rlly helpful 
Wed, 01/17/2024 - 00:13

tysm <3 thats rlly helpful