teleport_arrow.txt 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. air_material = material.get("AIR");
  2. grass_block_mat = material.get("GRASS_BLOCK");
  3. mat_to_set = material.get("SLIME_BLOCK");
  4. event.load("projectile_hit");
  5. @wait
  6. wait();
  7. if(event == "projectile_hit") {
  8. if(shooter == null) {
  9. goto("wait");
  10. }
  11. if(!isPlayer(shooter)){
  12. goto("wait");
  13. }
  14. shooter_name = player.getName(shooter);
  15. if(shooter_name != "SirTerence7" && shooter_name != "fireeagle013" && shooter_name != "Mareeeen"){
  16. goto("wait");
  17. }
  18. hit_location = entity.getLocation(projectile);
  19. if(block.getType(block.get(hit_location)) == air_material && block.getType(block.get(loc.mod(hit_location, 0, 1, 0))) == air_material){
  20. entity.remove(projectile);
  21. shooter_look = entity.getLook(shooter);
  22. shooter_motion = entity.getMotion(shooter);
  23. entity.teleport(shooter, hit_location);
  24. entity.setMotion(shooter, shooter_motion[0], shooter_motion[2], shooter_motion[2]);
  25. entity.setLook(shooter, shooter_look[0], shooter_look[1], shooter_look[2]);
  26. block_under = block.get(loc.mod(hit_location, 0, -1, 0));
  27. if(block.getType(block_under) == grass_block_mat){
  28. block.setMaterial(block_under, mat_to_set, false);
  29. }
  30. }
  31. }
  32. goto("wait");