Skip to content

Instantly share code, notes, and snippets.

@Twinklez
Created April 1, 2014 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Twinklez/9905161 to your computer and use it in GitHub Desktop.
Save Twinklez/9905161 to your computer and use it in GitHub Desktop.
10.12.0.997 Forge
public void teleport(World world, EntityPlayer player)
{
if (!world.isRemote)
{
System.out.println("IsRemote: false");
Vec3 vec3 = player.getPosition(1.0F);
++vec3.yCoord;
Vec3 lookVec = player.getLook(1.0F);
Vec3 addedVector = vec3.addVector(lookVec.xCoord * 50.0D, lookVec.yCoord * 50.0D, lookVec.zCoord * 50.0D);
MovingObjectPosition movingObjPos = world.clip(vec3, addedVector);
//world.func_147447_a(vec3, addedVector, true, true, false);
if (movingObjPos != null && movingObjPos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
System.out.println("made it");
int blockX = movingObjPos.blockX;
int blockY = movingObjPos.blockY;
int blockZ = movingObjPos.blockZ;
EntityPlayerMP playerMP = (EntityPlayerMP)player;
if (!playerMP.playerNetServerHandler.func_147362_b().func_150724_d())
{
System.out.println("made it 2");
playerMP.setPositionAndUpdate((double)blockX, (double)((float)blockY + 1.0F), (double)blockZ);
playerMP.fallDistance = 0.0F;
}
else if (playerMP.playerNetServerHandler.func_147362_b().func_150724_d())
{
System.out.println("made it elsewise 2");
playerMP.setPositionAndUpdate((double)blockX, (double)((float)blockY + 1.0F), (double)blockZ);
playerMP.fallDistance = 0.0F;
}
}
if (movingObjPos != null && movingObjPos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
System.out.println(movingObjPos.typeOfHit);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment