JowoJo

Untitled

Mar 31st, 2023
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.26 KB | None | 0 0
  1. package net.mcreator.ocmd.procedures;
  2.  
  3. import net.minecraftforge.eventbus.api.SubscribeEvent;
  4. import net.minecraftforge.event.TickEvent;
  5. import net.minecraftforge.common.MinecraftForge;
  6.  
  7. import net.minecraft.world.IWorld;
  8. import net.minecraft.util.text.StringTextComponent;
  9. import net.minecraft.item.ItemStack;
  10. import net.minecraft.entity.player.ServerPlayerEntity;
  11. import net.minecraft.entity.player.PlayerEntity;
  12. import net.minecraft.entity.Entity;
  13.  
  14. import net.mcreator.ocmd.OcmMod;
  15.  
  16. import java.util.Map;
  17. import java.util.Collections;
  18.  
  19. public class TeleportationcrystalEvenementAuClicDroitDansLairProcedure {
  20.  
  21. public static void executeProcedure(Map<String, Object> dependencies) {
  22. if (dependencies.get("world") == null) {
  23. if (!dependencies.containsKey("world"))
  24. OcmMod.LOGGER.warn("Failed to load dependency world for procedure TeleportationcrystalEvenementAuClicDroitDansLair!");
  25. return;
  26. }
  27. if (dependencies.get("x") == null) {
  28. if (!dependencies.containsKey("x"))
  29. OcmMod.LOGGER.warn("Failed to load dependency x for procedure TeleportationcrystalEvenementAuClicDroitDansLair!");
  30. return;
  31. }
  32. if (dependencies.get("y") == null) {
  33. if (!dependencies.containsKey("y"))
  34. OcmMod.LOGGER.warn("Failed to load dependency y for procedure TeleportationcrystalEvenementAuClicDroitDansLair!");
  35. return;
  36. }
  37. if (dependencies.get("z") == null) {
  38. if (!dependencies.containsKey("z"))
  39. OcmMod.LOGGER.warn("Failed to load dependency z for procedure TeleportationcrystalEvenementAuClicDroitDansLair!");
  40. return;
  41. }
  42. if (dependencies.get("entity") == null) {
  43. if (!dependencies.containsKey("entity"))
  44. OcmMod.LOGGER.warn("Failed to load dependency entity for procedure TeleportationcrystalEvenementAuClicDroitDansLair!");
  45. return;
  46. }
  47. if (dependencies.get("itemstack") == null) {
  48. if (!dependencies.containsKey("itemstack"))
  49. OcmMod.LOGGER.warn("Failed to load dependency itemstack for procedure TeleportationcrystalEvenementAuClicDroitDansLair!");
  50. return;
  51. }
  52. IWorld world = (IWorld) dependencies.get("world");
  53. double x = dependencies.get("x") instanceof Integer ? (int) dependencies.get("x") : (double) dependencies.get("x");
  54. double y = dependencies.get("y") instanceof Integer ? (int) dependencies.get("y") : (double) dependencies.get("y");
  55. double z = dependencies.get("z") instanceof Integer ? (int) dependencies.get("z") : (double) dependencies.get("z");
  56. Entity entity = (Entity) dependencies.get("entity");
  57. ItemStack itemstack = (ItemStack) dependencies.get("itemstack");
  58. if (entity.isSneaking()) {
  59. itemstack.getOrCreateTag().putDouble("posx", x);
  60. itemstack.getOrCreateTag().putDouble("posy", y);
  61. itemstack.getOrCreateTag().putDouble("posz", z);
  62. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  63. ((PlayerEntity) entity).sendStatusMessage(new StringTextComponent("Position sauvegard\u00E9"), (false));
  64. }
  65. } else {
  66. itemstack.getOrCreateTag().putDouble("playertpposx", x);
  67. itemstack.getOrCreateTag().putDouble("playertpposy", y);
  68. itemstack.getOrCreateTag().putDouble("playertpposz", z);
  69. new Object() {
  70. private int ticks = 0;
  71. private float waitTicks;
  72. private IWorld world;
  73.  
  74. public void start(IWorld world, int waitTicks) {
  75. this.waitTicks = waitTicks;
  76. MinecraftForge.EVENT_BUS.register(this);
  77. this.world = world;
  78. }
  79.  
  80. @SubscribeEvent
  81. public void tick(TickEvent.ServerTickEvent event) {
  82. if (event.phase == TickEvent.Phase.END) {
  83. this.ticks += 1;
  84. if (this.ticks >= this.waitTicks)
  85. run();
  86. }
  87. }
  88.  
  89. private void run() {
  90. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  91. ((PlayerEntity) entity).sendStatusMessage(new StringTextComponent("T\u00E9l\u00E9portation dans 5 secondes..."), (false));
  92. }
  93. if (itemstack.getOrCreateTag().getDouble("playeractualposz") != itemstack.getOrCreateTag().getDouble("playertpposx")) {
  94. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  95. ((PlayerEntity) entity).sendStatusMessage(new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"), (false));
  96. }
  97. } else {
  98. if (itemstack.getOrCreateTag().getDouble("playeractualposy") != itemstack.getOrCreateTag().getDouble("playertpposy")) {
  99. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  100. ((PlayerEntity) entity).sendStatusMessage(new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"), (false));
  101. }
  102. } else {
  103. if (itemstack.getOrCreateTag().getDouble("playeractualposx") != itemstack.getOrCreateTag().getDouble("playertpposz")) {
  104. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  105. ((PlayerEntity) entity).sendStatusMessage(new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"),
  106. (false));
  107. }
  108. } else {
  109. itemstack.getOrCreateTag().putDouble("playeractualposz", z);
  110. itemstack.getOrCreateTag().putDouble("playeractualposy", y);
  111. itemstack.getOrCreateTag().putDouble("playeractualposx", x);
  112. itemstack.getOrCreateTag().putDouble("playeractualposz", z);
  113. itemstack.getOrCreateTag().putDouble("playeractualposy", y);
  114. itemstack.getOrCreateTag().putDouble("playeractualposx", x);
  115. new Object() {
  116. private int ticks = 0;
  117. private float waitTicks;
  118. private IWorld world;
  119.  
  120. public void start(IWorld world, int waitTicks) {
  121. this.waitTicks = waitTicks;
  122. MinecraftForge.EVENT_BUS.register(this);
  123. this.world = world;
  124. }
  125.  
  126. @SubscribeEvent
  127. public void tick(TickEvent.ServerTickEvent event) {
  128. if (event.phase == TickEvent.Phase.END) {
  129. this.ticks += 1;
  130. if (this.ticks >= this.waitTicks)
  131. run();
  132. }
  133. }
  134.  
  135. private void run() {
  136. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  137. ((PlayerEntity) entity).sendStatusMessage(
  138. new StringTextComponent("T\u00E9l\u00E9portation dans 4 secondes..."), (false));
  139. }
  140. if (itemstack.getOrCreateTag().getDouble("playeractualposz") != itemstack.getOrCreateTag()
  141. .getDouble("playertpposx")) {
  142. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  143. ((PlayerEntity) entity)
  144. .sendStatusMessage(new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"), (false));
  145. }
  146. } else {
  147. if (itemstack.getOrCreateTag().getDouble("playeractualposy") != itemstack.getOrCreateTag()
  148. .getDouble("playertpposy")) {
  149. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  150. ((PlayerEntity) entity).sendStatusMessage(
  151. new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"), (false));
  152. }
  153. } else {
  154. if (itemstack.getOrCreateTag().getDouble("playeractualposx") != itemstack.getOrCreateTag()
  155. .getDouble("playertpposz")) {
  156. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  157. ((PlayerEntity) entity).sendStatusMessage(
  158. new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"), (false));
  159. }
  160. } else {
  161. itemstack.getOrCreateTag().putDouble("playeractualposz", z);
  162. itemstack.getOrCreateTag().putDouble("playeractualposy", y);
  163. itemstack.getOrCreateTag().putDouble("playeractualposx", x);
  164. new Object() {
  165. private int ticks = 0;
  166. private float waitTicks;
  167. private IWorld world;
  168.  
  169. public void start(IWorld world, int waitTicks) {
  170. this.waitTicks = waitTicks;
  171. MinecraftForge.EVENT_BUS.register(this);
  172. this.world = world;
  173. }
  174.  
  175. @SubscribeEvent
  176. public void tick(TickEvent.ServerTickEvent event) {
  177. if (event.phase == TickEvent.Phase.END) {
  178. this.ticks += 1;
  179. if (this.ticks >= this.waitTicks)
  180. run();
  181. }
  182. }
  183.  
  184. private void run() {
  185. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  186. ((PlayerEntity) entity).sendStatusMessage(
  187. new StringTextComponent("T\u00E9l\u00E9portation dans 3 secondes..."),
  188. (false));
  189. }
  190. if (itemstack.getOrCreateTag().getDouble("playeractualposz") != itemstack.getOrCreateTag()
  191. .getDouble("playertpposx")) {
  192. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  193. ((PlayerEntity) entity).sendStatusMessage(
  194. new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"),
  195. (false));
  196. }
  197. } else {
  198. if (itemstack.getOrCreateTag().getDouble("playeractualposy") != itemstack
  199. .getOrCreateTag().getDouble("playertpposy")) {
  200. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  201. ((PlayerEntity) entity).sendStatusMessage(
  202. new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"),
  203. (false));
  204. }
  205. } else {
  206. if (itemstack.getOrCreateTag().getDouble("playeractualposx") != itemstack
  207. .getOrCreateTag().getDouble("playertpposz")) {
  208. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  209. ((PlayerEntity) entity).sendStatusMessage(
  210. new StringTextComponent("T\u00E9l\u00E9portation annul\u00E9 !"),
  211. (false));
  212. }
  213. } else {
  214. itemstack.getOrCreateTag().putDouble("playeractualposz", z);
  215. itemstack.getOrCreateTag().putDouble("playeractualposy", y);
  216. itemstack.getOrCreateTag().putDouble("playeractualposx", x);
  217. new Object() {
  218. private int ticks = 0;
  219. private float waitTicks;
  220. private IWorld world;
  221.  
  222. public void start(IWorld world, int waitTicks) {
  223. this.waitTicks = waitTicks;
  224. MinecraftForge.EVENT_BUS.register(this);
  225. this.world = world;
  226. }
  227.  
  228. @SubscribeEvent
  229. public void tick(TickEvent.ServerTickEvent event) {
  230. if (event.phase == TickEvent.Phase.END) {
  231. this.ticks += 1;
  232. if (this.ticks >= this.waitTicks)
  233. run();
  234. }
  235. }
  236.  
  237. private void run() {
  238. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  239. ((PlayerEntity) entity).sendStatusMessage(
  240. new StringTextComponent(
  241. "T\u00E9l\u00E9portation dans 2 secondes..."),
  242. (false));
  243. }
  244. if (itemstack.getOrCreateTag()
  245. .getDouble("playeractualposz") != itemstack.getOrCreateTag()
  246. .getDouble("playertpposx")) {
  247. if (entity instanceof PlayerEntity && !entity.world.isRemote()) {
  248. ((PlayerEntity) entity).sendStatusMessage(
  249. new StringTextComponent(
  250. "T\u00E9l\u00E9portation annul\u00E9 !"),
  251. (false));
  252. }
  253. } else {
  254. if (itemstack.getOrCreateTag()
  255. .getDouble("playeractualposy") != itemstack
  256. .getOrCreateTag().getDouble("playertpposy")) {
  257. if (entity instanceof PlayerEntity
  258. && !entity.world.isRemote()) {
  259. ((PlayerEntity) entity).sendStatusMessage(
  260. new StringTextComponent(
  261. "T\u00E9l\u00E9portation annul\u00E9 !"),
  262. (false));
  263. }
  264. } else {
  265. if (itemstack.getOrCreateTag()
  266. .getDouble("playeractualposx") != itemstack
  267. .getOrCreateTag().getDouble("playertpposz")) {
  268. if (entity instanceof PlayerEntity
  269. && !entity.world.isRemote()) {
  270. ((PlayerEntity) entity).sendStatusMessage(
  271. new StringTextComponent(
  272. "T\u00E9l\u00E9portation annul\u00E9 !"),
  273. (false));
  274. }
  275. } else {
  276. itemstack.getOrCreateTag().putDouble("playeractualposz",
  277. z);
  278. itemstack.getOrCreateTag().putDouble("playeractualposy",
  279. y);
  280. itemstack.getOrCreateTag().putDouble("playeractualposx",
  281. x);
  282. new Object() {
  283. private int ticks = 0;
  284. private float waitTicks;
  285. private IWorld world;
  286.  
  287. public void start(IWorld world, int waitTicks) {
  288. this.waitTicks = waitTicks;
  289. MinecraftForge.EVENT_BUS.register(this);
  290. this.world = world;
  291. }
  292.  
  293. @SubscribeEvent
  294. public void tick(TickEvent.ServerTickEvent event) {
  295. if (event.phase == TickEvent.Phase.END) {
  296. this.ticks += 1;
  297. if (this.ticks >= this.waitTicks)
  298. run();
  299. }
  300. }
  301.  
  302. private void run() {
  303. if (entity instanceof PlayerEntity
  304. && !entity.world.isRemote()) {
  305. ((PlayerEntity) entity).sendStatusMessage(
  306. new StringTextComponent(
  307. "T\u00E9l\u00E9portation dans 1 secondes..."),
  308. (false));
  309. }
  310. if (itemstack.getOrCreateTag().getDouble(
  311. "playeractualposz") != itemstack
  312. .getOrCreateTag()
  313. .getDouble("playertpposx")) {
  314. if (entity instanceof PlayerEntity
  315. && !entity.world.isRemote()) {
  316. ((PlayerEntity) entity).sendStatusMessage(
  317. new StringTextComponent(
  318. "T\u00E9l\u00E9portation annul\u00E9 !"),
  319. (false));
  320. }
  321. } else {
  322. if (itemstack.getOrCreateTag().getDouble(
  323. "playeractualposy") != itemstack
  324. .getOrCreateTag()
  325. .getDouble("playertpposy")) {
  326. if (entity instanceof PlayerEntity
  327. && !entity.world.isRemote()) {
  328. ((PlayerEntity) entity)
  329. .sendStatusMessage(
  330. new StringTextComponent(
  331. "T\u00E9l\u00E9portation annul\u00E9 !"),
  332. (false));
  333. }
  334. } else {
  335. if (itemstack.getOrCreateTag().getDouble(
  336. "playeractualposx") != itemstack
  337. .getOrCreateTag()
  338. .getDouble(
  339. "playertpposz")) {
  340. if (entity instanceof PlayerEntity
  341. && !entity.world.isRemote()) {
  342. ((PlayerEntity) entity)
  343. .sendStatusMessage(
  344. new StringTextComponent(
  345. "T\u00E9l\u00E9portation annul\u00E9 !"),
  346. (false));
  347. }
  348. } else {
  349. itemstack.getOrCreateTag().putDouble(
  350. "playeractualposz", z);
  351. itemstack.getOrCreateTag().putDouble(
  352. "playeractualposy", y);
  353. itemstack.getOrCreateTag().putDouble(
  354. "playeractualposx", x);
  355. new Object() {
  356. private int ticks = 0;
  357. private float waitTicks;
  358. private IWorld world;
  359.  
  360. public void start(IWorld world,
  361. int waitTicks) {
  362. this.waitTicks = waitTicks;
  363. MinecraftForge.EVENT_BUS
  364. .register(this);
  365. this.world = world;
  366. }
  367.  
  368. @SubscribeEvent
  369. public void tick(
  370. TickEvent.ServerTickEvent event) {
  371. if (event.phase == TickEvent.Phase.END) {
  372. this.ticks += 1;
  373. if (this.ticks >= this.waitTicks)
  374. run();
  375. }
  376. }
  377.  
  378. private void run() {
  379. if (entity instanceof PlayerEntity
  380. && !entity.world
  381. .isRemote()) {
  382. ((PlayerEntity) entity)
  383. .sendStatusMessage(
  384. new StringTextComponent(
  385. "T\u00E9l\u00E9portation !"),
  386. (false));
  387. }
  388. {
  389. Entity _ent = entity;
  390. _ent.setPositionAndUpdate(
  391. (itemstack
  392. .getOrCreateTag()
  393. .getDouble(
  394. "posx")),
  395. (itemstack
  396. .getOrCreateTag()
  397. .getDouble(
  398. "posy")),
  399. (itemstack
  400. .getOrCreateTag()
  401. .getDouble(
  402. "posz")));
  403. if (_ent instanceof ServerPlayerEntity) {
  404. ((ServerPlayerEntity) _ent).connection
  405. .setPlayerLocation(
  406. (itemstack
  407. .getOrCreateTag()
  408. .getDouble(
  409. "posx")),
  410. (itemstack
  411. .getOrCreateTag()
  412. .getDouble(
  413. "posy")),
  414. (itemstack
  415. .getOrCreateTag()
  416. .getDouble(
  417. "posz")),
  418. _ent.rotationYaw,
  419. _ent.rotationPitch,
  420. Collections
  421. .emptySet());
  422. }
  423. }
  424. MinecraftForge.EVENT_BUS
  425. .unregister(this);
  426. }
  427. }.start(world, (int) 20);
  428. }
  429. }
  430. }
  431. MinecraftForge.EVENT_BUS.unregister(this);
  432. }
  433. }.start(world, (int) 20);
  434. }
  435. }
  436. }
  437. MinecraftForge.EVENT_BUS.unregister(this);
  438. }
  439. }.start(world, (int) 20);
  440. }
  441. }
  442. }
  443. MinecraftForge.EVENT_BUS.unregister(this);
  444. }
  445. }.start(world, (int) 20);
  446. }
  447. }
  448. }
  449. MinecraftForge.EVENT_BUS.unregister(this);
  450. }
  451. }.start(world, (int) 20);
  452. }
  453. }
  454. }
  455. MinecraftForge.EVENT_BUS.unregister(this);
  456. }
  457. }.start(world, (int) 20);
  458. }
  459. }
  460. }
  461.  
Advertisement
Add Comment
Please, Sign In to add comment