sitting.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. event.load("entity_dismount");
  2. event.load("block_click");
  3. event.load("server_pre_stop");
  4. sitting = map.new();
  5. stairs_tag = block.getTag("minecraft:stairs");
  6. msg.string("dev", "§bSitting §rloaded.");
  7. @wait
  8. wait();
  9. ignoreGoto(event);
  10. goto("wait");
  11. @entity_dismount
  12. if(isPlayer(entity)) {
  13. player = entity;
  14. player_uuid = player.getUuid(player);
  15. if(map.contains(sitting, player_uuid)) {
  16. entity.remove(map.get(sitting, player_uuid));
  17. map.remove(sitting, player_uuid);
  18. }
  19. entity.teleport(player, loc.mod(entity.getLocation(player), 0, 1, 0));
  20. }
  21. goto("wait");
  22. @server_pre_stop
  23. iter = map.iterator(sitting);
  24. while(hasNext(iter)) {
  25. element = next(iter);
  26. uuid = map.getKey(element);
  27. p = player.get(uuid);
  28. if(p != null) {
  29. entity.unmount(p);
  30. }
  31. }
  32. term();
  33. @block_click
  34. if(block == null) {
  35. goto("wait");
  36. }
  37. if(hand == read.slot("OFF_HAND")) {
  38. goto("wait");
  39. }
  40. if(block.hasTag(block, stairs_tag)) {
  41. if(action != "RIGHT_CLICK_BLOCK") {
  42. goto("wait");
  43. }
  44. if(block.getBisectedHalf(block) != "BOTTOM") {
  45. goto("wait");
  46. }
  47. if(item.getType(living.getHand(player)) != material.getAir()) {
  48. goto("wait");
  49. }
  50. if(!block.isAir(block.mod(block, 0, 1, 0))) {
  51. goto("wait");
  52. }
  53. player_uuid = player.getUuid(player);
  54. if(map.contains(sitting, player_uuid)) {
  55. goto("wait");
  56. }
  57. if(player.hasMinigame(player)) {
  58. goto("wait");
  59. }
  60. if(!player.hasSittingActivated(player)) {
  61. goto("wait");
  62. }
  63. loc = block.getLocation(block);
  64. entity = entity.spawnseat(loc);
  65. map.add(sitting, player_uuid, entity);
  66. entity.mount(player, entity);
  67. }
  68. goto("wait");