Advertisement
Guest User

Untitled

a guest
Feb 19th, 2023
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.12 KB | None | 0 0
  1. public class PacketSyncTeleporterPosToClient {
  2.  
  3. private final int posX, posY, posZ;
  4. private final int d1posX, d1posY, d1posZ;
  5. private final int d2posX, d2posY, d2posZ;
  6. private final int d3posX, d3posY, d3posZ;
  7. private final int d4posX, d4posY, d4posZ;
  8. private final int d5posX, d5posY, d5posZ;
  9. private final int d6posX, d6posY, d6posZ;
  10. private final int d7posX, d7posY, d7posZ;
  11. private String dimName;
  12. private final BlockPos blockPos;
  13. private final int selected;
  14. private final String dest0name,dest1name,dest2name,dest3name,dest4name,dest5name,dest6name,dest7name;
  15. private final boolean dest0exists,dest1exists,dest2exists,dest3exists,dest4exists,dest5exists,dest6exists,dest7exists;
  16. private final String dest0dim,dest1dim,dest2dim,dest3dim,dest4dim,dest5dim,dest6dim,dest7dim;
  17.  
  18. public PacketSyncTeleporterPosToClient(String dest0dim,
  19. String dest1dim,
  20. String dest2dim,
  21. String dest3dim,
  22. String dest4dim,
  23. String dest5dim,
  24. String dest6dim,
  25. String dest7dim,
  26. boolean dest0exists,
  27. boolean dest1exists,
  28. boolean dest2exists,
  29. boolean dest3exists,
  30. boolean dest4exists,
  31. boolean dest5exists,
  32. boolean dest6exists,
  33. boolean dest7exists,
  34. String dest0name,
  35. String dest1name,
  36. String dest2name,
  37. String dest3name,
  38. String dest4name,
  39. String dest5name,
  40. String dest6name,
  41. String dest7name,
  42. int selected, int posX,int posY,int posZ,
  43. int d1posX,int d1posY,int d1posZ,
  44. int d2posX,int d2posY,int d2posZ,
  45. int d3posX,int d3posY,int d3posZ,
  46. int d4posX,int d4posY,int d4posZ,
  47. int d5posX,int d5posY,int d5posZ,
  48. int d6posX,int d6posY,int d6posZ,
  49. int d7posX,int d7posY,int d7posZ, String dimName, BlockPos pos) {
  50. this.posX = posX;this.posY = posY;this.posZ = posZ;
  51. this.d1posX = d1posX;this.d1posY = d1posY;this.d1posZ = d1posZ;
  52. this.d2posX = d2posX;this.d2posY = d2posY;this.d2posZ = d2posZ;
  53. this.d3posX = d3posX;this.d3posY = d3posY;this.d3posZ = d3posZ;
  54. this.d4posX = d4posX;this.d4posY = d4posY;this.d4posZ = d4posZ;
  55. this.d5posX = d5posX;this.d5posY = d5posY;this.d5posZ = d5posZ;
  56. this.d6posX = d6posX;this.d6posY = d6posY;this.d6posZ = d6posZ;
  57. this.d7posX = d7posX;this.d7posY = d7posY;this.d7posZ = d7posZ;
  58. this.dimName = dimName;
  59. this.blockPos = pos;
  60. this.selected = selected;
  61. this.dest0name = dest0name;
  62. this.dest1name = dest1name;
  63. this.dest2name = dest2name;
  64. this.dest3name = dest3name;
  65. this.dest4name = dest4name;
  66. this.dest5name = dest5name;
  67. this.dest6name = dest6name;
  68. this.dest7name = dest7name;
  69. this.dest0exists = dest0exists;
  70. this.dest1exists = dest1exists;
  71. this.dest2exists = dest2exists;
  72. this.dest3exists = dest3exists;
  73. this.dest4exists = dest4exists;
  74. this.dest5exists = dest5exists;
  75. this.dest6exists = dest6exists;
  76. this.dest7exists = dest7exists;
  77. this.dest0dim = dest0dim;
  78. this.dest1dim = dest1dim;
  79. this.dest2dim = dest2dim;
  80. this.dest3dim = dest3dim;
  81. this.dest4dim = dest4dim;
  82. this.dest5dim = dest5dim;
  83. this.dest6dim = dest6dim;
  84. this.dest7dim = dest7dim;
  85. }
  86.  
  87. public PacketSyncTeleporterPosToClient(FriendlyByteBuf buf) {
  88. this.posX = buf.readInt();this.posY = buf.readInt();this.posZ = buf.readInt();
  89. this.d1posX = buf.readInt();this.d1posY = buf.readInt();this.d1posZ = buf.readInt();
  90. this.d2posX = buf.readInt();this.d2posY = buf.readInt();this.d2posZ = buf.readInt();
  91. this.d3posX = buf.readInt();this.d3posY = buf.readInt();this.d3posZ = buf.readInt();
  92. this.d4posX = buf.readInt();this.d4posY = buf.readInt();this.d4posZ = buf.readInt();
  93. this.d5posX = buf.readInt();this.d5posY = buf.readInt();this.d5posZ = buf.readInt();
  94. this.d6posX = buf.readInt();this.d6posY = buf.readInt();this.d6posZ = buf.readInt();
  95. this.d7posX = buf.readInt();this.d7posY = buf.readInt();this.d7posZ = buf.readInt();
  96. this.blockPos = buf.readBlockPos();
  97. this.selected = buf.readInt();
  98. this.dest0name = buf.readUtf();
  99. this.dest1name = buf.readUtf();
  100. this.dest2name = buf.readUtf();
  101. this.dest3name = buf.readUtf();
  102. this.dest4name = buf.readUtf();
  103. this.dest5name = buf.readUtf();
  104. this.dest6name = buf.readUtf();
  105. this.dest7name = buf.readUtf();
  106. this.dest0exists = buf.readBoolean();
  107. this.dest1exists = buf.readBoolean();
  108. this.dest2exists = buf.readBoolean();
  109. this.dest3exists = buf.readBoolean();
  110. this.dest4exists = buf.readBoolean();
  111. this.dest5exists = buf.readBoolean();
  112. this.dest6exists = buf.readBoolean();
  113. this.dest7exists = buf.readBoolean();
  114. this.dest0dim = buf.readUtf();
  115. this.dest1dim = buf.readUtf();
  116. this.dest2dim = buf.readUtf();
  117. this.dest3dim = buf.readUtf();
  118. this.dest4dim = buf.readUtf();
  119. this.dest5dim = buf.readUtf();
  120. this.dest6dim = buf.readUtf();
  121. this.dest7dim = buf.readUtf();
  122. }
  123.  
  124. public void toBytes(FriendlyByteBuf buf) {
  125. buf.writeInt(posX);buf.writeInt(posY);buf.writeInt(posZ);
  126. buf.writeInt(d1posX);buf.writeInt(d1posY);buf.writeInt(d1posZ);
  127. buf.writeInt(d2posX);buf.writeInt(d2posY);buf.writeInt(d2posZ);
  128. buf.writeInt(d3posX);buf.writeInt(d3posY);buf.writeInt(d3posZ);
  129. buf.writeInt(d4posX);buf.writeInt(d4posY);buf.writeInt(d4posZ);
  130. buf.writeInt(d5posX);buf.writeInt(d5posY);buf.writeInt(d5posZ);
  131. buf.writeInt(d6posX);buf.writeInt(d6posY);buf.writeInt(d6posZ);
  132. buf.writeInt(d7posX);buf.writeInt(d7posY);buf.writeInt(d7posZ);
  133. buf.writeBlockPos(blockPos);
  134. buf.writeInt(selected);
  135. buf.writeUtf(dest0name);
  136. buf.writeUtf(dest1name);
  137. buf.writeUtf(dest2name);
  138. buf.writeUtf(dest3name);
  139. buf.writeUtf(dest4name);
  140. buf.writeUtf(dest5name);
  141. buf.writeUtf(dest6name);
  142. buf.writeUtf(dest7name);
  143. buf.writeBoolean(dest0exists);
  144. buf.writeBoolean(dest1exists);
  145. buf.writeBoolean(dest2exists);
  146. buf.writeBoolean(dest3exists);
  147. buf.writeBoolean(dest4exists);
  148. buf.writeBoolean(dest5exists);
  149. buf.writeBoolean(dest6exists);
  150. buf.writeBoolean(dest7exists);
  151. buf.writeUtf(dest0dim);
  152. buf.writeUtf(dest1dim);
  153. buf.writeUtf(dest2dim);
  154. buf.writeUtf(dest3dim);
  155. buf.writeUtf(dest4dim);
  156. buf.writeUtf(dest5dim);
  157. buf.writeUtf(dest6dim);
  158. buf.writeUtf(dest7dim);
  159. }
  160.  
  161. public boolean handle(Supplier<NetworkEvent.Context> ctx) {
  162. NetworkEvent.Context context = ctx.get();
  163. context.enqueueWork(() -> {
  164. // This is the client
  165. if(Minecraft.getInstance().level.getBlockEntity(blockPos) instanceof WarpPipeBlockEntity blockEntity) {
  166. blockEntity.dest0Posx = posX; blockEntity.dest0Posy=posY; blockEntity.dest0Posz=posZ;
  167. blockEntity.dest1Posx = d1posX;blockEntity.dest1Posy=d1posY;blockEntity.dest1Posz=d1posZ;
  168. blockEntity.dest2Posx = d2posX;blockEntity.dest2Posy=d2posY;blockEntity.dest2Posz=d2posZ;
  169. blockEntity.dest3Posx = d3posX;blockEntity.dest3Posy=d3posY;blockEntity.dest3Posz=d3posZ;
  170. blockEntity.dest4Posx = d4posX;blockEntity.dest4Posy=d4posY;blockEntity.dest4Posz=d4posZ;
  171. blockEntity.dest5Posx = d5posX;blockEntity.dest5Posy=d5posY;blockEntity.dest5Posz=d5posZ;
  172. blockEntity.dest6Posx = d6posX;blockEntity.dest6Posy=d6posY;blockEntity.dest6Posz=d6posZ;
  173. blockEntity.dest7Posx = d7posX;blockEntity.dest7Posy=d7posY;blockEntity.dest7Posz=d7posZ;
  174. blockEntity.setDimensionName(dimName);
  175. blockEntity.selectedWheelPart = this.selected;
  176. blockEntity.dest0name = this.dest0name;
  177. blockEntity.dest1name = this.dest1name;
  178. blockEntity.dest2name = this.dest2name;
  179. blockEntity.dest3name = this.dest3name;
  180. blockEntity.dest4name = this.dest4name;
  181. blockEntity.dest5name = this.dest5name;
  182. blockEntity.dest6name = this.dest6name;
  183. blockEntity.dest7name = this.dest7name;
  184.  
  185. blockEntity.dest0dim = dest0dim;
  186. blockEntity.dest1dim = dest1dim;
  187. blockEntity.dest2dim = dest2dim;
  188. blockEntity.dest3dim = dest3dim;
  189. blockEntity.dest4dim = dest4dim;
  190. blockEntity.dest5dim = dest5dim;
  191. blockEntity.dest6dim = dest6dim;
  192. blockEntity.dest7dim = dest7dim;
  193.  
  194. blockEntity.dest0exists = this.dest0exists;
  195. blockEntity.dest1exists = this.dest1exists;
  196. blockEntity.dest2exists = this.dest2exists;
  197. blockEntity.dest3exists = this.dest3exists;
  198. blockEntity.dest4exists = this.dest4exists;
  199. blockEntity.dest5exists = this.dest5exists;
  200. blockEntity.dest6exists = this.dest6exists;
  201. blockEntity.dest7exists = this.dest7exists;
  202. if(Minecraft.getInstance().player.containerMenu instanceof TeleporterMenu menu &&
  203. menu.blockEntity.getBlockPos().equals(blockPos)) {
  204. blockEntity.dest0Posx = posX; blockEntity.dest0Posy=posY; blockEntity.dest0Posz=posZ;
  205. blockEntity.dest1Posx = d1posX;blockEntity.dest1Posy=d1posY;blockEntity.dest1Posz=d1posZ;
  206. blockEntity.dest2Posx = d2posX;blockEntity.dest2Posy=d2posY;blockEntity.dest2Posz=d2posZ;
  207. blockEntity.dest3Posx = d3posX;blockEntity.dest3Posy=d3posY;blockEntity.dest3Posz=d3posZ;
  208. blockEntity.dest4Posx = d4posX;blockEntity.dest4Posy=d4posY;blockEntity.dest4Posz=d4posZ;
  209. blockEntity.dest5Posx = d5posX;blockEntity.dest5Posy=d5posY;blockEntity.dest5Posz=d5posZ;
  210. blockEntity.dest6Posx = d6posX;blockEntity.dest6Posy=d6posY;blockEntity.dest6Posz=d6posZ;
  211. blockEntity.dest7Posx = d7posX;blockEntity.dest7Posy=d7posY;blockEntity.dest7Posz=d7posZ;
  212. blockEntity.setDimensionName(dimName);
  213.  
  214. blockEntity.dest0dim = dest0dim;
  215. blockEntity.dest1dim = dest1dim;
  216. blockEntity.dest2dim = dest2dim;
  217. blockEntity.dest3dim = dest3dim;
  218. blockEntity.dest4dim = dest4dim;
  219. blockEntity.dest5dim = dest5dim;
  220. blockEntity.dest6dim = dest6dim;
  221. blockEntity.dest7dim = dest7dim;
  222.  
  223. blockEntity.selectedWheelPart = this.selected;
  224. blockEntity.dest0name = this.dest0name;
  225. blockEntity.dest1name = this.dest1name;
  226. blockEntity.dest2name = this.dest2name;
  227. blockEntity.dest3name = this.dest3name;
  228. blockEntity.dest4name = this.dest4name;
  229. blockEntity.dest5name = this.dest5name;
  230. blockEntity.dest6name = this.dest6name;
  231. blockEntity.dest7name = this.dest7name;
  232.  
  233. blockEntity.dest0exists = this.dest0exists;
  234. blockEntity.dest1exists = this.dest1exists;
  235. blockEntity.dest2exists = this.dest2exists;
  236. blockEntity.dest3exists = this.dest3exists;
  237. blockEntity.dest4exists = this.dest4exists;
  238. blockEntity.dest5exists = this.dest5exists;
  239. blockEntity.dest6exists = this.dest6exists;
  240. blockEntity.dest7exists = this.dest7exists;
  241. }
  242. }
  243. });
  244. return true;
  245. }
  246. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement