Advertisement
Guest User

Mcreator Generated

a guest
Sep 11th, 2023
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. package net.coderandom.etheriacraft.procedures;
  2.  
  3. import net.minecraft.world.level.Level;
  4. import net.minecraft.world.item.ItemStack;
  5. import net.minecraft.world.entity.LivingEntity;
  6. import net.minecraft.world.entity.Entity;
  7. import net.minecraft.world.effect.MobEffectInstance;
  8. import net.minecraft.util.RandomSource;
  9. import net.minecraft.server.level.ServerPlayer;
  10. import net.minecraft.server.level.ServerLevel;
  11. import net.minecraft.resources.ResourceKey;
  12. import net.minecraft.network.protocol.game.ClientboundUpdateMobEffectPacket;
  13. import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket;
  14. import net.minecraft.network.protocol.game.ClientboundLevelEventPacket;
  15. import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
  16. import net.minecraft.core.BlockPos;
  17.  
  18. import net.coderandom.etheriacraft.EtheriaCraftMod;
  19.  
  20. public class FocusedEyeOfEnderRightclickedProcedure {
  21. public static double execute(Entity entity, ItemStack itemstack) {
  22. if (entity == null)
  23. return 0;
  24. if (entity.isShiftKeyDown()) {
  25. itemstack.getOrCreateTag().putString("dimension", ("" + entity.level().dimension()));
  26. EtheriaCraftMod.LOGGER.debug(("" + entity.level().dimension()));
  27. itemstack.getOrCreateTag().putDouble("teleportX", (entity.getX()));
  28. itemstack.getOrCreateTag().putDouble("teleportY", (entity.getY()));
  29. itemstack.getOrCreateTag().putDouble("teleportZ", (entity.getZ()));
  30. itemstack.getOrCreateTag().putDouble("yaw", (entity.getYRot()));
  31. itemstack.getOrCreateTag().putDouble("pitch", (entity.getXRot()));
  32. itemstack.getOrCreateTag().putBoolean("canTeleport", true);
  33. return 1;
  34. }
  35. if (itemstack.getOrCreateTag().getBoolean("canTeleport")) {
  36. if (!(itemstack.getOrCreateTag().getString("dimension")).equals("" + entity.level().dimension())) {
  37. EtheriaCraftMod.LOGGER.debug(("" + entity.level().dimension()));
  38. if ((itemstack.getOrCreateTag().getString("dimension")).contains("minecraft:overworld")) {
  39. if (entity instanceof ServerPlayer _player && !_player.level().isClientSide()) {
  40. ResourceKey<Level> destinationType = Level.OVERWORLD;
  41. if (_player.level().dimension() == destinationType)
  42. return;
  43. ServerLevel nextLevel = _player.server.getLevel(destinationType);
  44. if (nextLevel != null) {
  45. _player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.WIN_GAME, 0));
  46. _player.teleportTo(nextLevel, _player.getX(), _player.getY(), _player.getZ(), _player.getYRot(), _player.getXRot());
  47. _player.connection.send(new ClientboundPlayerAbilitiesPacket(_player.getAbilities()));
  48. for (MobEffectInstance _effectinstance : _player.getActiveEffects())
  49. _player.connection.send(new ClientboundUpdateMobEffectPacket(_player.getId(), _effectinstance));
  50. _player.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
  51. }
  52. }
  53. } else if ((itemstack.getOrCreateTag().getString("dimension")).contains("minecraft:the_nether")) {
  54. if (entity instanceof ServerPlayer _player && !_player.level().isClientSide()) {
  55. ResourceKey<Level> destinationType = Level.NETHER;
  56. if (_player.level().dimension() == destinationType)
  57. return;
  58. ServerLevel nextLevel = _player.server.getLevel(destinationType);
  59. if (nextLevel != null) {
  60. _player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.WIN_GAME, 0));
  61. _player.teleportTo(nextLevel, _player.getX(), _player.getY(), _player.getZ(), _player.getYRot(), _player.getXRot());
  62. _player.connection.send(new ClientboundPlayerAbilitiesPacket(_player.getAbilities()));
  63. for (MobEffectInstance _effectinstance : _player.getActiveEffects())
  64. _player.connection.send(new ClientboundUpdateMobEffectPacket(_player.getId(), _effectinstance));
  65. _player.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
  66. }
  67. }
  68. } else if ((itemstack.getOrCreateTag().getString("dimension")).contains("minecraft:the_end")) {
  69. if (entity instanceof ServerPlayer _player && !_player.level().isClientSide()) {
  70. ResourceKey<Level> destinationType = Level.END;
  71. if (_player.level().dimension() == destinationType)
  72. return;
  73. ServerLevel nextLevel = _player.server.getLevel(destinationType);
  74. if (nextLevel != null) {
  75. _player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.WIN_GAME, 0));
  76. _player.teleportTo(nextLevel, _player.getX(), _player.getY(), _player.getZ(), _player.getYRot(), _player.getXRot());
  77. _player.connection.send(new ClientboundPlayerAbilitiesPacket(_player.getAbilities()));
  78. for (MobEffectInstance _effectinstance : _player.getActiveEffects())
  79. _player.connection.send(new ClientboundUpdateMobEffectPacket(_player.getId(), _effectinstance));
  80. _player.connection.send(new ClientboundLevelEventPacket(1032, BlockPos.ZERO, 0, false));
  81. }
  82. }
  83. }
  84. }
  85. {
  86. Entity _ent = entity;
  87. _ent.setYRot((float) itemstack.getOrCreateTag().getDouble("yaw"));
  88. _ent.setXRot((float) itemstack.getOrCreateTag().getDouble("pitch"));
  89. _ent.setYBodyRot(_ent.getYRot());
  90. _ent.setYHeadRot(_ent.getYRot());
  91. _ent.yRotO = _ent.getYRot();
  92. _ent.xRotO = _ent.getXRot();
  93. if (_ent instanceof LivingEntity _entity) {
  94. _entity.yBodyRotO = _entity.getYRot();
  95. _entity.yHeadRotO = _entity.getYRot();
  96. }
  97. }
  98. {
  99. Entity _ent = entity;
  100. _ent.teleportTo((itemstack.getOrCreateTag().getDouble("teleportX")), (itemstack.getOrCreateTag().getDouble("teleportY")), (itemstack.getOrCreateTag().getDouble("teleportZ")));
  101. if (_ent instanceof ServerPlayer _serverPlayer)
  102. _serverPlayer.connection.teleport((itemstack.getOrCreateTag().getDouble("teleportX")), (itemstack.getOrCreateTag().getDouble("teleportY")), (itemstack.getOrCreateTag().getDouble("teleportZ")), _ent.getYRot(), _ent.getXRot());
  103. }
  104. {
  105. ItemStack _ist = itemstack;
  106. if (_ist.hurt(1, RandomSource.create(), null)) {
  107. _ist.shrink(1);
  108. _ist.setDamageValue(0);
  109. }
  110. }
  111. }
  112. return 0;
  113. }
  114. }
  115.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement