Hello, I am a beginner minecraft modder and i have some problems with a bit of code that would teleport the player in the direction he's facing.can anyone tell me How to merge these lines together:
player.getLookVec().scale(2.0F).add(player.getPositionVec());
TeleportCommand;
P.S: i need this to work in minecraft 1.16.5-36.0.15
@diesieben07 Can you please help me?
Small update!! I found the way to scale and add the lookvec to positionvec, but i still dont know how to teleport the player to that location.it would be very helpful if you could tell me which teleportation method i should use
Thanks in advance
public static void OnSwordClick (PlayerInteractEvent.RightClickItem event){
LivingEntity player = event.getEntityLiving();
if (player.getHeldItemMainhand().getItem() == myItem){
player.getLookVec().scale(2.0F).add(player.getPositionVec());
}
}
can you tell me if it is correct @diesieben07
Hello I am a beginner minecraft modder i have some issues when trying to add a right click functionality to my sword. The problem is that no matter what i have tried i cannot get my minecraft character to move in the direction he was facing. Here is the part of my code that is causing me trouble. Please help! Thank you in advance.
@SubscribeEvent
public static void OnSwordClick (PlayerInteractEvent.RightClickItem event){
LivingEntity player = event.getEntityLiving();
if (player.getHeldItemMainhand().getItem() ==myitem){
// teleport the player x blocks in the direction that he is facing
}
}
P.S:my forge mdk version is 1.16.5 - 36.0.45