Sleazy Fork is available in English.

CheatNite

CraftNite cheat client. Credits to 🄱u𝕥c🅷e𝕣_B𝙤🅈 for icon.

  1. // ==UserScript==
  2. // @name CheatNite
  3. // @namespace cheatnite
  4. // @icon https://cdn.discordapp.com/icons/1134569036043276439/2664d328e7ccce265d3a473e05adc96c.webp
  5. // @version 2.2
  6. // @description CraftNite cheat client. Credits to 🄱u𝕥c🅷e𝕣_B𝙤🅈 for icon.
  7. // @author towelgreen
  8. // @match https://craftnite.io/*
  9. // @run-at document-start
  10. // @license GPL-3.0
  11. // @grant GM_addStyle
  12. // @require https://greasyfork.org/scripts/475779-readschem/code/readschem.js?version=1253860
  13. // ==/UserScript==
  14. //credits to 🄱u𝕥c🅷e𝕣_B𝙤🅈 for icon
  15. const yoClasses = ['RPCMatchRemainingTime', 'RPCa822erScore', 'CMDChunkBuffered', 'a201', 'a202', 'a199', 'a200', 'a169', 'a130', 'a119', 'a129', 'a128', 'a186', 'a222ingSoon', 'a124', 'a125', 'a126', 'RPCEndMatch', 'a188', 'a236', 'a189', 'a190', 'a191', 'a192', 'a193', 'a175', 'a194', 'a234', 'a171', 'a121', 'a172', 'a173', 'a174', 'a195', 'a180', 'a225', 'a226', 'a227', 'a228', 'a117', 'a118', 'a222']
  16. const blocks = {"random": "random", "air":0,"stone":256,"stone_granite":257,"stone_granite_smooth":258,"stone_diorite":259,"stone_diorite_smooth":260,"stone_andesite":261,"stone_andesite_smooth":262,"grass":512,"dirt":770,"coarse_dirt":769,"cobblestone":1024,"planks_oak":1280,"planks_spruce":1281,"planks_birch":1282,"planks_jungle":1283,"planks_acacia":1284,"planks_big_oak":1285,"sapling_oak":1536,"sapling_spruce":1537,"sapling_birch":1538,"sapling_jungle":1539,"sapling_acacia":1540,"sapling_roofed_oak":1541,"bedrock":1792,"flowing_water":2048,"water":2304,"flowing_lava":2560,"lava":2816,"sand":3072,"red_sand":3073,"gravel":3328,"gold_ore":3584,"iron_ore":3840,"coal_ore":4096,"log_oak":4352,"log_spruce":4353,"log_birch":4354,"log_jungle":4355,"leaves_oak":4608,"leaves_spruce":4609,"leaves_birch":4610,"leaves_jungle":4611,"sponge":4864,"sponge_wet":4865,"glass":5120,"lapis_ore":5376,"lapis_block":5632,"dispenser":5888,"sandstone_normal":6144,"sandstone_carved":6145,"sandstone_smooth":6146,"noteblock":6400,"bed":6656,"golden_rail":6912,"detector_rail":7168,"sticky_piston":7424,"web":7680,"double_plant_grass":7936,"fern":7938,"deadbush":8192,"piston":8448,"piston_head":8704,"wool_colored_white":8960,"wool_colored_orange":8961,"wool_colored_magenta":8962,"wool_colored_light_blue":8963,"wool_colored_yellow":8964,"wool_colored_lime":8965,"wool_colored_pink":8966,"wool_colored_gray":8967,"wool_colored_silver":8968,"wool_colored_cyan":8969,"wool_colored_purple":8970,"wool_colored_blue":8971,"wool_colored_brown":8972,"wool_colored_green":8973,"wool_colored_red":8974,"wool_colored_black":8975,"piston_extension":9216,"yellow_flower":9472,"flower_rose":9728,"flower_blue_orchid":9729,"flower_allium":9730,"flower_houstonia":9731,"flower_tulip_red":9732,"flower_tulip_orange":9733,"flower_tulip_white":9734,"flower_tulip_pink":9735,"flower_oxeye_daisy":9736,"brown_mushroom":9984,"red_mushroom":10240,"gold_block":10496,"iron_block":10752,"double_stone_slab":11008,"brick":11012,"stonebrick":11013,"nether_brick":11014,"quartz_block":39681,"stone_slab":11278,"quartz_block_chiseled":11023,"sandstone_top":11273,"quartz_block_top":11279,"brick_block":11520,"tnt":11777,"bookshelf":12032,"mossy_cobblestone":12288,"obsidian":12544,"torch":12804,"fire":13056,"mob_spawner":13312,"oak_stairs":13568,"chest":13824,"redstone_wire":14080,"diamond_ore":14336,"diamond_block":14592,"crafting_table":14848,"wheat":15104,"farmland":15360,"furnace":15616,"lit_furnace":15872,"standing_sign":16128,"wooden_door":16384,"ladder":16640,"rail":16896,"stone_stairs":17152,"wall_sign":17408,"lever":17664,"stone_pressure_plate":17920,"iron_door":18176,"wooden_pressure_plate":18432,"redstone_ore":18688,"lit_redstone_ore":18944,"unlit_redstone_torch":19204,"redstone_torch":19460,"stone_button":19712,"snow_layer":19968,"ice":20224,"snow":20480,"cactus":20736,"clay":20992,"reeds":21248,"jukebox":21505,"fence":21760,"pumpkin":22016,"netherrack":22272,"soul_sand":22528,"glowstone":22784,"portal":23040,"lit_pumpkin":23296,"cake":23552,"unpowered_repeater":23808,"powered_repeater":24064,"glass_white":24320,"glass_orange":24321,"glass_magenta":24322,"glass_light_blue":24323,"glass_yellow":24324,"glass_lime":24325,"glass_pink":24326,"glass_gray":24327,"stained_glass":24328,"glass_cyan":24329,"glass_purple":24330,"glass_blue":24331,"glass_brown":24332,"glass_green":24333,"glass_red":24334,"glass_black":24335,"trapdoor":24576,"monster_egg":24837,"stonebrick_mossy":25089,"stonebrick_cracked":25090,"stonebrick_carved":25091,"brown_mushroom_block":25344,"red_mushroom_block":25600,"iron_bars":25856,"glass_pane":26112,"melon_block":26368,"pumpkin_stem":26624,"melon_stem":26880,"vine":27136,"fence_gate":27392,"brick_stairs":27648,"stone_brick_stairs":27904,"mycelium":28160,"waterlily":28416,"nether_brick_fence":28928,"nether_brick_stairs":29184,"nether_wart":29440,"enchanting_table":29696,"brewing_stand":29952,"cauldron":30208,"end_portal":30464,"end_portal_frame":30720,"end_stone":30976,"dragon_egg":31232,"redstone_lamp":31488,"lit_redstone_lamp":31744,"double_wooden_slab":32000,"wooden_slab":32256,"cocoa":32512,"sandstone_stairs":32768,"emerald_ore":33024,"ender_chest":33280,"tripwire_hook":33536,"tripwire":33792,"emerald_block":34048,"spruce_stairs":34304,"birch_stairs":34560,"jungle_stairs":34816,"command_block":35072,"beacon":35328,"cobblestone_wall":35584,"cobblestone_mossy":35585,"flower_pot":35840,"carrots":36096,"potatoes":36352,"wooden_button":36608,"skull":36864,"anvil":37120,"trapped_chest":37376,"light_weighted_pressure_plate":37632,"heavy_weighted_pressure_plate":37888,"unpowered_comparator":38144,"powered_comparator":38400,"daylight_detector":38656,"redstone_block":38912,"quartz_ore":39168,"hopper":39424,"quartz_block_lines":39682,"quartz_stairs":39936,"activator_rail":40192,"dropper":40448,"hardened_clay_stained_white":40704,"hardened_clay_stained_orange":40705,"hardened_clay_stained_magenta":40706,"hardened_clay_stained_light_blue":40707,"hardened_clay_stained_yellow":40708,"hardened_clay_stained_lime":40709,"hardened_clay_stained_pink":40710,"hardened_clay_stained_gray":40711,"hardened_clay_stained_silver":40712,"hardened_clay_stained_cyan":40713,"hardened_clay_stained_purple":40714,"hardened_clay_stained_blue":40715,"hardened_clay_stained_brown":40716,"hardened_clay_stained_green":40717,"hardened_clay_stained_red":40718,"hardened_clay_stained_black":40719,"stained_glass_pane":40960,"leaves_acacia":41216,"leaves_big_oak":41217,"log2":41473,"acacia_stairs":41728,"dark_oak_stairs":41984,"slime":42240,"barrier":42496,"iron_trapdoor":42752,"prismarine_rough":43008,"prismarine_bricks":43009,"prismarine_dark":43010,"sea_lantern":43264,"hay_block":43520,"carpet":43791,"hardened_clay":44032,"coal_block":44288,"packed_ice":44544,"double_plant":44800,"double_plant_syringa_top":44801,"double_plant_paeonia_top":44805,"standing_banner":45056,"wall_banner":45312,"daylight_detector_inverted":45568,"red_sandstone_normal":45824,"red_sandstone_carved":45825,"red_sandstone_smooth":45826,"red_sandstone_stairs":46080,"double_stone_slab2":46336,"stone_slab2":46592,"spruce_fence_gate":46848,"birch_fence_gate":47104,"jungle_fence_gate":47360,"dark_oak_fence_gate":47616,"acacia_fence_gate":47872,"spruce_fence":48128,"birch_fence":48384,"jungle_fence":48640,"dark_oak_fence":48896,"acacia_fence":49152,"spruce_door":49408,"birch_door":49664,"jungle_door":49920,"acacia_door":50176,"dark_oak_door":50432,"end_rod":50688,"chorus_plant":50944,"chorus_flower":51200,"purpur_block":51456,"purpur_pillar":51712,"purpur_stairs":51968,"purpur_double_slab":52224,"purpur_slab":52480,"end_bricks":52736,"beetroots":52992,"grass_path":53248,"end_gateway":53504,"repeating_command_block":53760,"chain_command_block":54016,"frosted_ice":54272,"magma":54528,"nether_wart_block":54784,"red_nether_brick":55040,"bone_block":55296,"item-snowball-blue":55781,"item-tnt-yellow":55782,"item-woodplank-grey":55783,"item-stoneball-grey":55784,"item-stairs-grey":55785,"item-pistol-grey":55786,"item-pickaxe-grey":55787,"item-uri-yellow":55788,"item-uri-purple":55789,"item-uri-blue":55790,"item-uri-green":55791,"item-uri-grey":55792,"item-ak47-yellow":55793,"item-ak47-purple":55794,"item-ak47-blue":55795,"item-ak47-green":55796,"item-ak47-grey":55797,"item-shotgun-yellow":55798,"item-shotgun-purple":55799,"item-shotgun-blue":55800,"item-shotgun-green":55801,"item-shotgun-grey":55802,"item-sniper-yellow":55803,"item-sniper-purple":55804,"item-sniper-blue":55805,"item-sniper-green":55806,"item-sniper-grey":55807,"observer":55808,"white_shulker_box":56064,"orange_shulker_box":56320,"magenta_shulker_box":56576,"light_blue_shulker_box":56832,"yellow_shulker_box":57088,"lime_shulker_box":57344,"pink_shulker_box":57600,"gray_shulker_box":57856,"light_gray_shulker_box":58112,"cyan_shulker_box":58368,"purple_shulker_box":58624,"blue_shulker_box":58880,"brown_shulker_box":59136,"green_shulker_box":59392,"red_shulker_box":59648,"black_shulker_box":59904,"white_glazed_terracotta":60160,"orange_glazed_terracotta":60416,"magenta_glazed_terracotta":60672,"light_blue_glazed_terracotta":60928,"yellow_glazed_terracotta":61184,"lime_glazed_terracotta":61440,"pink_glazed_terracotta":61696,"gray_glazed_terracotta":61952,"light_gray_glazed_terracotta":62208,"cyan_glazed_terracotta":62464,"purple_glazed_terracotta":62720,"blue_glazed_terracotta":62976,"brown_glazed_terracotta":63232,"green_glazed_terracotta":63488,"red_glazed_terracotta":63744,"black_glazed_terracotta":64000,"concrete_white":64256,"concrete_orange":64257,"concrete_magenta":64258,"concrete_light_blue":64259,"concrete_yellow":64260,"concrete_lime":64261,"concrete_pink":64262,"concrete_gray":64263,"concrete_silver":64264,"concrete_cyan":64265,"concrete_purple":64266,"concrete_blue":64267,"concrete_brown":64268,"concrete_green":64269,"concrete_red":64270,"concrete_black":64271,"concrete_powder_white":64512,"concrete_powder_orange":64513,"concrete_powder_magenta":64514,"concrete_powder_light_blue":64515,"concrete_powder_yellow":64516,"concrete_powder_lime":64517,"concrete_powder_pink":64518,"concrete_powder_gray":64519,"concrete_powder_silver":64520,"concrete_powder_cyan":64521,"concrete_powder_blue":64522,"concrete_powder_brown":64523,"concrete_powder_green":64524,"concrete_powder_red":64525,"concrete_powder_black":64527,"structure_block":65280}
  17. const blockStrings = Object.keys(blocks).slice(1);
  18. let blockCommands = ['item', '/set', '/box', '/replace', '/sphere', '/hsphere'];
  19. let commands = ['truecoords', 'ignore', 'unignore', 'unstuck', 'drain', 'item', 'invsize', 'tp', 'time', 'bg', '/p1', '/p2', '/pos1', '/pos2', '/stop', '/positions', '/set', '/box', '/replace', '/sphere', '/hsphere', '/copy', '/paste', '/clearclipboard', '/load', '/save', '/build', '/builds', '/new'];
  20. let espGeometry, lineMaterial, red, espMaterial, textCanvas;
  21. function addGlobal(name, value) {
  22. var script = document.createElement('script');
  23. script.textContent = `window.${name} = ${value};`;
  24. (document.head||document.documentElement).appendChild(script);
  25. script.remove();
  26. }
  27. function start() {
  28. addGlobal('cheatnite', '{}');
  29. cheatnite.auto = true;
  30. cheatnite.coords = {x:0, y:0, z:0};
  31. cheatnite.worldedit = {
  32. clipboard: [null, null, {}],
  33. builds: {}
  34. };
  35. cheatnite.ignored = [];
  36. cheatnite.customBlockId = 256;
  37. cheatnite.server = {};
  38. cheatnite.fly = false;
  39. cheatnite.chatspam = null;
  40. cheatnite.chatspam_count = 0;
  41. cheatnite.bulletspam = null;
  42. cheatnite.tntspam = null;
  43. cheatnite.bedrock = false;
  44. cheatnite.drain = false;
  45. cheatnite.esp = true;
  46. cheatnite.noclip = false;
  47. cheatnite.invisible = false;
  48. cheatnite.darkMode = true;
  49. cheatnite.shiftKeyPressed = false;
  50. document.getElementById("leftwrap").innerHTML = "";
  51. //cheat display code inspired by https://greasyfork.org/en/scripts/474923-craftnite-io-hacked-client-fly-triggerbot-esp-rapidfire-speedhacks-and-more
  52. cheatnite.cheatDisp = document.createElement("h1");
  53. cheatnite.cheatDisp.style.position = "fixed";
  54. cheatnite.cheatDisp.style.fontSize = "156.25%";
  55. cheatnite.cheatDisp.style.right = 0;
  56. cheatnite.cheatDisp.style.marginRight = "10px";
  57. cheatnite.cheatDisp.style.backgroundColor = "rgba(0, 0, 0, 0)";
  58. cheatnite.cheatDisp.style.textAlign = "right";
  59. cheatnite.cheatDisp.style.fontFamily = "'Lucida Console', Monaco, monospace";
  60. cheatnite.cheatDisp.style.fontWeight = "bold";
  61. document.body.appendChild(cheatnite.cheatDisp);
  62. cheatnite.activatedCheats = ['ESP'];
  63. cheatnite.updateCheatDisp = true;
  64. }
  65. window.addEventListener('load', start);
  66.  
  67. GM_addStyle(`
  68. input#customServer {
  69. height: 63px;
  70. width: 100%;
  71. text-align: center;
  72. font-size: 22px;
  73. font-family: Madera;
  74. color: #000 !important;
  75. border: 0px solid #000000;
  76. background: #ffffff;
  77. border-radius: 2px;
  78. }
  79. `);
  80.  
  81. function addInputAbovePlayButton() {
  82. const playBtn = document.getElementById('playbtn');
  83. const customServer = document.createElement('input');
  84. customServer.id = 'customServer';
  85. customServer.type = 'text';
  86. customServer.placeholder = 'Random server';
  87. customServer.value = localStorage.getItem('lastServer') ? localStorage.getItem('lastServer') : '';
  88. playBtn.parentNode.insertBefore(customServer, playBtn);
  89. const lineBreak = document.createElement('br');
  90. customServer.parentNode.insertBefore(lineBreak, customServer);
  91. }
  92. window.addEventListener('load', addInputAbovePlayButton);
  93.  
  94. var a914 = "[joined with towelgreen's advanced CheatNite client (on Greasyfork)]";
  95. function customStartBtn () {
  96. let nameValue = document.getElementById ('name').value;
  97. addGlobal('playerName', nameValue ? JSON.stringify(nameValue) : JSON.stringify('unnamed'))
  98. setCookie ("name", playerName, 365);
  99. setCookie ("skin", playerSkin, 365);
  100. var inputValue = (document.getElementById('customServer').value || '').trim();
  101. var localStorageValue = localStorage.getItem('lastServer');
  102. if (inputValue === 'Random server' || !inputValue) {
  103. requestServerName();
  104. } else if (localStorageValue && inputValue === 'Last server') {
  105. localStorage.setItem('lastServer', localStorageValue);
  106. G.gameServerAddress = localStorageValue;
  107. playGame();
  108. } else {
  109. localStorage.setItem('lastServer', inputValue);
  110. G.gameServerAddress = inputValue;
  111. playGame();
  112. }
  113. }
  114. var originalSend = window.XMLHttpRequest.prototype.send;
  115. var originalOpen = window.XMLHttpRequest.prototype.open;
  116. window.XMLHttpRequest.prototype.open = function(method, url) {
  117. this._url = url;
  118. return originalOpen.apply(this, arguments);
  119. };
  120. window.XMLHttpRequest.prototype.send = function() {
  121. if (this._url && this._url.startsWith('https://craftnite.io/gs/requestServer.php')){
  122. this.addEventListener('readystatechange', function() {
  123. if (this.readyState === 4) {
  124. var inputValue = (document.getElementById('customServer')?.value || '').trim();
  125. var localStorageValue = localStorage.getItem('lastServer');
  126. if (inputValue === 'Random server' || !inputValue) {
  127. localStorage.setItem('lastServer', this.responseText);
  128. return this.responseText
  129. }
  130. }
  131. }, false);
  132. }
  133. if (this._url.startsWith('https://craftnite.io') || this._url === 'a.zip') {
  134. return originalSend.apply(this, arguments);c
  135. }
  136. };
  137.  
  138. let selectedIndex = -1;
  139. let suggestions = [];
  140. function chatCmdSuggestions(event) {
  141. let keyCode = event.keyCode;
  142. if (keyCode !== 40 && keyCode !== 38 && keyCode !== 13) {
  143. let filter = GAME.chatInput.value.toLowerCase();
  144. suggestions = [];
  145. if (filter.includes('/')) {
  146. let command = blockCommands.find(command => filter.startsWith('/' + command.toLowerCase() + ' '));
  147. if (command) {
  148. filter = filter.slice(command.length + 1).trim();
  149. Object.keys(blocks).forEach(item => {
  150. if (item.toLowerCase().includes(filter)) {
  151. suggestions.push('/' + command + ' ' + item);
  152. }
  153. });
  154. } else {
  155. commands.forEach(command => {
  156. if (command.toLowerCase().startsWith(filter.slice(1))) {
  157. suggestions.push('/' + command);
  158. }
  159. });
  160. }
  161. }
  162. }
  163. if (keyCode === 40 || keyCode === 38 || keyCode === 13) {
  164. if (selectedIndex >= 0) {
  165. if (keyCode === 13) {
  166. GAME.chatInput.value = suggestions[selectedIndex] || GAME.chatInput.value;
  167. selectedIndex = -1;
  168. GAME.chatInput.focus();
  169. return;
  170. }
  171. }
  172. if (keyCode === 40) {
  173. selectedIndex++;
  174. if (selectedIndex >= suggestions.length) {
  175. selectedIndex = 0;
  176. }
  177. } else if (keyCode === 38) {
  178. selectedIndex--;
  179. if (selectedIndex < 0) {
  180. selectedIndex = suggestions.length - 1;
  181. }
  182. }
  183. GAME.chatInput.value = suggestions[selectedIndex] || GAME.chatInput.value;
  184. }
  185. }
  186.  
  187. function shuffle(array) {
  188. for (let i = array.length - 1; i > 0; i--) {
  189. const j = Math.floor(Math.random() * (i + 1));
  190. [array[i], array[j]] = [array[j], array[i]];
  191. }
  192. }
  193. async function a637(positions, blockIds, errorCallback=null) {
  194. const indices = Array.from({length: positions.length}, (_, n) => n);
  195. shuffle(indices);
  196. var index, chunkCoords, chunk, innerPos, pkt;
  197. for (var r = 0; r < indices.length; r++) {
  198. if (!cheatnite.worldedit.inprogress) {
  199. if (errorCallback)
  200. errorCallback();
  201. return;
  202. }
  203. index = indices[r];
  204. chunkCoords = GAME.a865.getChunkFromPos(positions[index]);
  205. innerPos = coordsToInsidePos(positions[index], chunkCoords);
  206. pkt = new a234();
  207. pkt.i = chunkCoords[0];
  208. pkt.e = chunkCoords[1];
  209. pkt.o = chunkCoords[2];
  210. pkt.v = innerPos;
  211. pkt.u = blockIds[index];
  212. G.socket.send(pkt.a614());
  213. if (r % 100 === 99) {
  214. await sleep(cheatnite.server.r*200);
  215. }
  216. }
  217. }
  218. async function rawa637(iArr, eArr, oArr, vArr, uArr, errorCallback=null) {
  219. const indices = Array.from({length: iArr.length}, (_, n) => n);
  220. shuffle(indices);
  221. var index, pkt;
  222. for (var r = 0; r < indices.length; r++) {
  223. if (!cheatnite.worldedit.inprogress) {
  224. if (errorCallback)
  225. errorCallback();
  226. return;
  227. }
  228. index = indices[r];
  229. pkt = new a234();
  230. pkt.i = iArr[index];
  231. pkt.e = eArr[index];
  232. pkt.o = oArr[index];
  233. pkt.v = vArr[index];
  234. pkt.u = uArr[index];
  235. G.socket.send(pkt.a614());
  236. if (r % 100 === 99) {
  237. await sleep(cheatnite.server.r*200);
  238. }
  239. }
  240. }
  241. function tp(pos, updateVisual = true) {
  242. let me = GAME.a865.player;
  243. var pkt = new a175();
  244. pkt.time = parseFloat(("" + Date.now() / 1e3).slice(4));
  245. pkt.x = pos.x;
  246. pkt.y = pos.y;
  247. pkt.z = pos.z;
  248. pkt.a751 = me.a751;
  249. if (updateVisual) {
  250. me.controls.moveCameraTo(pos);
  251. me.position.copy(pos);
  252. }
  253. if (me.camera != null) {
  254. me.camera.rotation.order = "YXZ";
  255. pkt.a748 = me.camera.rotation.y;
  256. pkt.a749 = me.camera.rotation.x;
  257. }
  258. G.socket.send(pkt.a614())
  259. }
  260. function getColor(index, total) {
  261. let hue = 360 * (index / (total * 2));
  262. let saturation = 100;
  263. let lightness = 75;
  264. return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
  265. }
  266. function randomIP() {
  267. const octets = [];
  268. for (let i = 0; i < 4; i++) {
  269. const octet = Math.floor(Math.random() * 256);
  270. octets.push(octet);
  271. }
  272. return octets.join('.');
  273. }
  274. function isURL(str) {
  275. try {
  276. new URL(str);
  277. return true;
  278. } catch (e) {
  279. return false;
  280. }
  281. }
  282. function getBuildName(filename) {
  283. if (filename === '') {
  284. filename = '';
  285. }
  286. filename = filename.replaceAll(' ', '_');
  287. while (Object.keys(cheatnite.worldedit.builds).includes(filename)) {
  288. if (/\d+$/.test(filename)) {
  289. filename = filename.replace(/(\d+)$/, (match) => parseInt(match) + 1);
  290. } else {
  291. filename = filename + '1';
  292. }
  293. }
  294. return filename;
  295. }
  296. function shoot(gun) {
  297. var e = new THREE.Vector3;
  298. var a = 8;
  299. var b = 9;
  300. switch (gun) {
  301. case "pistol":
  302. a = 8;
  303. b = 9;
  304. break;
  305. case "shotgun":
  306. a = 12;
  307. b = 13;
  308. var spread = 0.06; //spread goes from 0.03 - 0.06
  309. for (var i = 0; i < 8; i++) {
  310. e.x = G.randFloat(-spread, spread, 2);
  311. e.y = G.randFloat(-spread, spread, 2);
  312. e.z = G.randFloat(-spread, spread, 2);
  313. GAME.a865.player.a609(a, b, {
  314. headshotMsg: ["boom ", "headshot"],
  315. headshotColor: ["rgba(255,0,0,{opacity})", "rgba(255,255,255,{opacity})"]
  316. }, false, false, e)
  317. }
  318. return;
  319. case "sniper":
  320. a = 16;
  321. b = 17;
  322. e.x *= 100;
  323. e.y = G.randFloat(20 * -GAME.a865.player.a92.y, 20 * GAME.a865.player.a92.y, 2);
  324. e.z *= 100;
  325. break;
  326. case "ak47":
  327. a = 14;
  328. b = 15;
  329. e.x *= 100;
  330. e.y = G.randFloat(-GAME.a865.player.a92.y / 2, GAME.a865.player.a92.y / 2, 2);
  331. e.z *= 100;
  332. break;
  333. }
  334. GAME.a865.player.a609(a, b, {
  335. headshotMsg: ["boom ", "headshot"],
  336. headshotColor: ["rgba(255,0,0,{opacity})", "rgba(255,255,255,{opacity})"]
  337. }, false, false, e)
  338. }
  339. function throwItem(item) {
  340. var e = new THREE.Vector3;
  341. var spread = 0.2
  342. e.x = G.randFloat(-spread, spread, 2);
  343. e.y = G.randFloat(-spread, spread, 2);
  344. e.z = G.randFloat(-spread, spread, 2);
  345. switch(item) {
  346. case "stone":
  347. GAME.a865.player.a609(2, 2, {
  348. me: true
  349. });
  350. break;
  351. case "wood":
  352. GAME.a865.player.a609(3, 3, {
  353. me: true
  354. });
  355. break;
  356. case "tnt":
  357. GAME.a865.player.a609(4, 4, {
  358. me: true
  359. }, false, false, e);
  360. break;
  361. case "stairs":
  362. GAME.a865.player.a609(6, 6, {
  363. me: true
  364. })
  365. }
  366. }
  367. function onDeath(dv) {
  368. let c = new a191();
  369. c.a615(dv);
  370. GAME.a865.player.a539();
  371. GAME.addKillfeed(G.othera822ers[c.a163].name, "killed", GAME.a865.player.name);
  372. GAME.myKillerId = c.a163;
  373. G.othera822ers[c.a163] && G.othera822ers[c.a163].a472.add(GAME.camera);
  374. GAME.drawLeaderboard();
  375. $(document).off("mousedown.pointerLock");
  376. GAME.respawnIn = 0;
  377. $(document).on("mousedown.respawn", (function(t) {
  378. if(!$(t.target).is("#bottomright")) {
  379. GAME.a865.player.respawn();
  380. GAME.a865.player.controls.lock();
  381. $(document).off("mousedown.respawn");
  382. }
  383. }))
  384. GAME.uiManager.inventory.close();
  385. GAME.deadPopup = true;
  386. cheatnite.customBlockId = 256;
  387. if (cheatnite.tntspam) {
  388. cheatnite.tntspam = null;
  389. clearInterval(cheatnite.tntspam);
  390. modifyCheatDisp("tntspam");
  391. }
  392. if (cheatnite.bulletspam) {
  393. clearInterval(cheatnite.bulletspam);
  394. cheatnite.bulletspam = null;
  395. modifyCheatDisp("bulletspam");
  396. }
  397. cheatnite.updateCheatDisp = true;
  398. }
  399. function parseOutgoingChat(dv) {
  400. let msg = "";
  401. for (let i = 1; i < dv.byteLength; i += 2) {
  402. const charCode = dv.getUint16(i, true);
  403. msg += String.fromCharCode(charCode);
  404. }
  405. return msg;
  406. }
  407. function drawLeaderboard() {
  408. GAME.leaderboard = [];
  409. for (var t = [], e = 0; e < 120; e++)
  410. if (G.othera822ers[e]) {
  411. var i = G.othera822ers[e];
  412. t.push([i.a649, i.id, i.name])
  413. }
  414. t.sort((function(t, e) {
  415. return t[0] - e[0]
  416. }
  417. ));
  418. for (var o = -1, n = 0, s = !1, r = !1, a = !1, h = (e = 0,
  419. 0), l = t.length - 1; l >= 0; l--)
  420. a = t[l][1] == GAME.a865.player.id,
  421. t[l][0] != o && (o = t[l][0],
  422. n++),
  423. r = !1,
  424. e < 10 ? (a && (s = !0),
  425. r = !0) : s ? 10 == e && (r = !0) : a && (r = !0),
  426. r && (GAME.leaderboard[h] = {
  427. me: a,
  428. rank: n,
  429. name: `(${t[l][1]}) ${t[l][2]}`,
  430. a649: t[l][0],
  431. id: t[l][1]
  432. },
  433. h++),
  434. e++
  435. }
  436. function addCustomChat(name, msg) {
  437. if ("" != (msg = msg.trim())) {
  438. GAME.chat.push({
  439. name: name,
  440. msg: msg
  441. });
  442. if (GAME.chat.length > 5)
  443. GAME.chat = GAME.chat.slice(GAME.chat.length - 5, GAME.chat.length);
  444. GAME.newChatMessage = true;
  445. }
  446. }
  447. function addChat(t, e) {
  448. if ("" != (e = e.trim())) {
  449. if (cheatnite.ignored.includes(G.othera822ers[t].id)) {
  450. return;
  451. }
  452. if (e === a914) {
  453. return;
  454. }
  455. var i = "server";
  456. 255 != t && (i = G.othera822ers[t].name);
  457. if (i > 20) {
  458. i = i.substring(0, 17) + '...';
  459. }
  460. var name = `(${G.othera822ers[t].id}) ` + i;
  461. GAME.chat.push({
  462. name: name,
  463. msg: e
  464. });
  465. if (GAME.chat.length > 5)
  466. GAME.chat = GAME.chat.slice(GAME.chat.length - 5, GAME.chat.length);
  467. GAME.newChatMessage = true;
  468. }
  469. }
  470. function sleep(milliseconds) {
  471. return new Promise(resolve => setTimeout(resolve, milliseconds));
  472. }
  473. function checkInt(num) {
  474. return !isNaN(parseInt(num));
  475. }
  476. function checkNumsInArr(arr, len) {
  477. var nums = [];
  478. for (let i in arr) {
  479. if (!isNaN(Number(arr[i]))) {
  480. nums.push(Number(arr[i]));
  481. }
  482. }
  483. if (nums.length === len) {
  484. return nums;
  485. }
  486. return false;
  487. }
  488. function convertCoords(coords, type) {
  489. if (!coords) {
  490. return false;
  491. }
  492. var convertedCoords = new THREE.Vector3();
  493. if(type === "adjusted") {
  494. convertedCoords.x = coords.x / 5 - 740;
  495. convertedCoords.y = coords.y / 5 - 53;
  496. convertedCoords.z = coords.z / 5 - 550;
  497. } else if(type === "true") {
  498. convertedCoords.x = (coords.x + 740) * 5;
  499. convertedCoords.y = (coords.y + 53) * 5;
  500. convertedCoords.z = (coords.z + 550) * 5;
  501. } else {
  502. throw new Error('convertCoords type must be "true" or "adjusted".');
  503. }
  504. return convertedCoords;
  505. }
  506. function showKillFeed() {
  507. GAME.killfeedCanvas.cvs.clear();
  508. const num = (GAME.killfeed.length < 5) ? 0 : (GAME.killfeed.length - 5);
  509. for (let i = 0, index = num; index < GAME.killfeed.length; index++) {
  510. const entry = GAME.killfeed[index];
  511. if (entry) {
  512. const killer = (entry.killer.length < 10) ? entry.killer : (entry.killer.substring(0, 10) + "..");
  513. const victim = (entry.victim.length < 10) ? entry.victim : (entry.victim.substring(0, 10) + "..");
  514. const killFeedText = `${killer} ${entry.action} ${victim}`;
  515. GAME.killfeedCanvas.text(
  516. [10, 4 + 24 * i],
  517. [0, 0],
  518. killFeedText,
  519. "rgba(255, 255, 255, .9)",
  520. 20,
  521. "top",
  522. "left",
  523. G.a816
  524. );
  525. i++;
  526. }
  527. }
  528. GAME.killfeedCanvas.cvs.flip();
  529. GAME.killfeedCanvas.cvs.show();
  530. }
  531. function modifyCheatDisp(text) {
  532. const index = cheatnite.activatedCheats.indexOf(text);
  533. if (index !== -1) {
  534. cheatnite.activatedCheats.splice(index, 1);
  535. } else {
  536. cheatnite.activatedCheats.push(text);
  537. }
  538. cheatnite.updateCheatDisp = true;
  539. }
  540. function customPosToV(t, buildP) {
  541. for (var e = -1, i = 0; i < 32; i++)
  542. if (t.x >= buildP.x + 5*i && t.x <= buildP.x + 5*(i + 1)) {
  543. e = i;
  544. break
  545. }
  546. var o = -1;
  547. for (i = 0; i < 32; i++)
  548. if (t.y >= buildP.y + 5*i && t.y <= buildP.y + 5*(i + 1)) {
  549. o = i;
  550. break
  551. }
  552. var n = -1;
  553. for (i = 0; i < 32; i++)
  554. if (t.z >= buildP.z + 5*i && t.z <= buildP.z + 5*(i + 1)) {
  555. n = i;
  556. break
  557. }
  558. return -1 != e && -1 != o && -1 != n && G.a650.prototype.a720(e, o, n)
  559. }
  560. function posTochunk(pos, buildP = null) {
  561. const chunkCoords = GAME.a865.getChunkFromPos(pos);
  562. const [i, e, o] = chunkCoords;
  563. let insidePos;
  564. if (buildP) {
  565. insidePos = customPosToV(pos, GAME.a865.a643s[i][e][o].buildP.clone());
  566. } else {
  567. insidePos = GAME.a865.a643s[i][e][o]?.posToV(pos);
  568. }
  569. return [chunkCoords, insidePos];
  570. }
  571. function getBlockIdAtPos(pos, buildP = null) {
  572. const chunkCoords = GAME.a865.getChunkFromPos(pos);
  573. const [i, e, o] = chunkCoords;
  574. if (i>160 || e>160 || o>160)
  575. return null;
  576. const chunk = GAME.a865.a643s?.[i]?.[e]?.[o];
  577. if (!chunk) {
  578. return 0;
  579. }
  580. try {
  581. let insidePos;
  582. if (buildP) {
  583. insidePos = customPosToV(pos, chunk.buildP.clone());
  584. } else {
  585. insidePos = chunk.posToV(pos);
  586. }
  587. const blockId = chunk.volume[insidePos];
  588. return blockId;
  589. } catch {
  590. return null;
  591. }
  592. }
  593. function getLookAtBlockId() {
  594. let blockId = null;
  595. var position = GAME.a865.player.position;
  596. position.y += 2.5;
  597. var rotation = GAME.a865.player.direction;
  598. const lookDirection = new THREE.Vector3();
  599. lookDirection.setFromSphericalCoords(rotation.x, rotation.y, rotation.z);
  600. const maxDistance = 1000;
  601. const stepSize = 0.1;
  602. const lookPosition = new THREE.Vector3();
  603. for (let distance = 0; distance <= maxDistance; distance += stepSize) {
  604. lookPosition.copy(position).addScaledVector(rotation, distance);
  605. blockId = getBlockIdAtPos(lookPosition);
  606. if (blockId) {
  607. break;
  608. }
  609. }
  610. return blockId;
  611. }
  612. function wasThrown() {
  613. try {
  614. throw new Error();
  615. } catch (e) {
  616. const stackLines = e.stack.split('\n');
  617. const callerLine = stackLines[3];
  618. const functionName = callerLine.match(/\ba853\b/);
  619. return !!functionName;
  620. }
  621. }
  622. function countItemInInv(target) {
  623. let count = 0;
  624. for (const item of GAME.a865.player.items) {
  625. if (item !== -1 && item.a474Id === target && item.total) {
  626. count += item.total;
  627. }
  628. }
  629. return count;
  630. }
  631. function getFormattedDateString() {
  632. const date = new Date();
  633. const year = date.getFullYear();
  634. const month = String(date.getMonth() + 1).padStart(2, '0');
  635. const day = String(date.getDate()).padStart(2, '0');
  636. const hours = String(date.getHours()).padStart(2, '0');
  637. const minutes = String(date.getMinutes()).padStart(2, '0');
  638. const seconds = String(date.getSeconds()).padStart(2, '0');
  639. return `${year}-${month}-${day}-${hours}-${minutes}-${seconds}`;
  640. }
  641. function saveScene() {
  642. var renderer = GAME.renderer;
  643. var camera = GAME.a865.player.camera;
  644. renderer.render(GAME.scene, camera);
  645. var link = document.createElement('a');
  646. link.href = renderer.domElement.toDataURL('image/png');
  647. link.download = 'craftnite-io-'+getFormattedDateString()+'.png';
  648. link.style.display = 'none';
  649. document.body.appendChild(link);
  650. link.click();
  651. document.body.removeChild(link);
  652. }
  653. function hidePlayerBoxes() {
  654. const players = [];
  655. for (const p of G.othera822ers)
  656. if (p && p.id !== GAME.a865.player.id)
  657. players.push(p);
  658. for (let i = 0; i < players.length; i++) {
  659. const player = players[i];
  660. if (player.a472.box) {
  661. player.a472.box.visible = false;
  662. }
  663. }
  664. }
  665. function showPlayerBoxes() {
  666. const players = [];
  667. for (const p of G.othera822ers)
  668. if (p && p.id !== GAME.a865.player.id)
  669. players.push(p);
  670. for (let i = 0; i < players.length; i++) {
  671. const player = players[i];
  672. if (player.a472.box) {
  673. player.a472.box.visible = true;
  674. }
  675. }
  676. }
  677. function flipObjectUpsideDown(points) {
  678. let flippedPoints = [];
  679. let minY = points[0].y;
  680. let maxY = points[0].y;
  681. for (let i = 1; i < points.length; i++) {
  682. minY = Math.min(minY, points[i].y);
  683. maxY = Math.max(maxY, points[i].y);
  684. }
  685. const yRange = maxY - minY;
  686. for (let i = 0; i < points.length; i++) {
  687. let point = points[i];
  688. let newY = minY + (yRange - (point.y - minY));
  689. flippedPoints.push(new THREE.Vector3(point.x, newY, point.z));
  690. }
  691. return flippedPoints;
  692. }
  693. const cbReplacer = (key, value) => {
  694. if (value && value.isVector3) {
  695. return [value.x, value.y, value.z];
  696. } else if (value instanceof Uint16Array) {
  697. return Array.from(value);
  698. }
  699. return value;
  700. };
  701. const cbReviver = (key, value) => {
  702. if (Array.isArray(value)) {
  703. if (value.length === 3 && value.every(i => typeof i === 'number')) {
  704. return new THREE.Vector3(value[0], value[1], value[2]);
  705. }
  706. }
  707. return value;
  708. };
  709. function readChunksFromLocal(file) {
  710. return new Promise((resolve, reject) => {
  711. const reader = new FileReader();
  712. reader.onload = async (event) => {
  713. if (file.name.endsWith('.json')) {
  714. try {
  715. const jsonData = JSON.parse(event.target.result, cbReviver);
  716. if (jsonData.length !== 3) {
  717. throw new Error('Incorrect length for chunks loaded from file. Expected 3, got '+jsonData.length.toString()+'.');
  718. }
  719. if (!jsonData[0].isVector3 || !jsonData[1].isVector3) {
  720. throw new Error('First 2 items were expected to be arrays of length 3.');
  721. }
  722. if (Object.keys(jsonData[2]).some(key => typeof key !== 'string')) {
  723. throw new Error('Expected all keys in 3rd item to be strings.');
  724. }
  725. resolve(jsonData);
  726. } catch (error) {
  727. reject(`Error parsing JSON file: ${error.message}`);
  728. }
  729. }
  730. };
  731. reader.onerror = (event) => {
  732. reject(event.target.error);
  733. };
  734. reader.readAsText(file);
  735. });
  736. }
  737. function readBuildFromLocal(file) {
  738. return new Promise((resolve, reject) => {
  739. const reader = new FileReader();
  740. reader.onload = async (event) => {
  741. const buffer = new Uint8Array(event.target.result);
  742. const blks = await readBuildFile(file.name, buffer, blockStrings);
  743. resolve(blks);
  744. };
  745. reader.onerror = (event) => {
  746. reject(event.target.error);
  747. };
  748. reader.readAsArrayBuffer(file);
  749. });
  750. }
  751. async function readBuildFromURL(url) {
  752. const response = await fetch(url);
  753. const buffer = new Uint8Array(await response.arrayBuffer());
  754. const blks = await readBuildFile(url, buffer, blockStrings);
  755. return blks;
  756. }
  757. function chunkToCoords(chunkCoords, insidePos) {
  758. const [chunkX, chunkY, chunkZ] = chunkCoords;
  759. const x = insidePos % 32;
  760. const y = Math.floor(insidePos / 32) % 32;
  761. const z = Math.floor(insidePos / (32 * 32));
  762. const worldX = chunkX * 32 + x;
  763. const worldY = chunkY * 32 + y;
  764. const worldZ = chunkZ * 32 + z;
  765. return new THREE.Vector3(5*worldX, 5*worldY, 5*worldZ);
  766. }
  767. function coordsToInsidePos(worldCoords, chunkCoords) {
  768. const [chunkX, chunkY, chunkZ] = chunkCoords;
  769. const x = Math.floor(worldCoords.x/5) - chunkX * 32;
  770. const y = Math.floor(worldCoords.y/5) - chunkY * 32;
  771. const z = Math.floor(worldCoords.z/5) - chunkZ * 32;
  772. const insidePos = x + y * 32 + z * 32 * 32;
  773. return insidePos;
  774. }
  775.  
  776. let WorldEdit = {};
  777.  
  778. WorldEdit.pos1 = function(args) {
  779. let me = GAME.a865.player;
  780. if (args.length === 0) {
  781. cheatnite.worldedit.pos1 = me.position.clone();
  782. addCustomChat('WorldEdit', `pos1 set to ${convertCoords(cheatnite.worldedit.pos1, "adjusted")}`)
  783. } else if (args.length === 3) {
  784. let nums = checkNumsInArr(args, 3)
  785. if (!nums) {
  786. this.error('Numbers expected as arguments.');
  787. return;
  788. }
  789. let unadjusted = new THREE.Vector3(nums[0], nums[1], nums[2]);
  790. cheatnite.worldedit.pos1 = convertCoords(unadjusted, "true");
  791. addCustomChat('WorldEdit', `pos1 set to ${convertCoords(cheatnite.worldedit.pos1, "adjusted")}`)
  792. } else {
  793. this.error(`Expected 0 or 3 arguments, got ${args.length}.`);
  794. }
  795. return;
  796. }
  797. WorldEdit.pos2 = function(args) {
  798. let me = GAME.a865.player;
  799. if (args.length === 0) {
  800. cheatnite.worldedit.pos2 = me.position.clone();
  801. addCustomChat('WorldEdit', `pos2 set to ${convertCoords(cheatnite.worldedit.pos2, "adjusted")}`)
  802. } else if (args.length === 3) {
  803. let nums = checkNumsInArr(args, 3)
  804. if (!nums) {
  805. this.error('Numbers expected as arguments.');
  806. }
  807. let unadjusted = new THREE.Vector3(nums[0], nums[1], nums[2]);
  808. cheatnite.worldedit.pos2 = convertCoords(unadjusted, "true");
  809. addCustomChat('WorldEdit', `pos2 set to ${convertCoords(cheatnite.worldedit.pos2, "adjusted")}`)
  810. } else {
  811. this.error(`Expected 0 or 3 arguments, got ${args.length}.`);
  812. }
  813. return;
  814. }
  815. WorldEdit.generatePointsNotOf = async function*(pointA, pointB, chunkSize, blockId) {
  816. let start = new THREE.Vector3(Math.floor(pointA.x/5), Math.floor(pointA.y/5), Math.floor(pointA.z/5));
  817. let end = new THREE.Vector3(Math.floor(pointB.x/5), Math.floor(pointB.y/5), Math.floor(pointB.z/5));
  818. let tempPos;
  819. let points = [];
  820. for (let x = Math.min(start.x, end.x); x <= Math.max(start.x, end.x); x++) {
  821. for (let y = Math.min(start.y, end.y); y <= Math.max(start.y, end.y); y++) {
  822. for (let z = Math.min(start.z, end.z); z <= Math.max(start.z, end.z); z++) {
  823. tempPos = new THREE.Vector3(x*5+2.5, y*5+2.5, z*5+2.5);
  824. if (getBlockIdAtPos(tempPos) !== blockId) {
  825. points.push(new THREE.Vector3(x*5+2.5, y*5+2.5, z*5+2.5));
  826. if (points.length >= chunkSize) {
  827. yield points;
  828. points = [];
  829. }
  830. }
  831. }
  832. }
  833. await sleep(10);
  834. if (!cheatnite.worldedit.inprogress) {
  835. yield points;
  836. points = [];
  837. }
  838. }
  839. if (points.length > 0) {
  840. yield points;
  841. }
  842. }
  843. WorldEdit.generateBoxPoints = async function*(pointA, pointB, chunkSize) {
  844. let start = new THREE.Vector3(Math.floor(pointA.x / 5), Math.floor(pointA.y / 5), Math.floor(pointA.z / 5));
  845. let end = new THREE.Vector3(Math.floor(pointB.x / 5), Math.floor(pointB.y / 5), Math.floor(pointB.z / 5));
  846. let tempPos;
  847. let points = [];
  848. for (let x = Math.min(start.x, end.x); x <= Math.max(start.x, end.x); x++) {
  849. for (let y = Math.min(start.y, end.y); y <= Math.max(start.y, end.y); y++) {
  850. for (let z = Math.min(start.z, end.z); z <= Math.max(start.z, end.z); z++) {
  851. if (x === start.x || x === end.x || y === start.y || y === end.y || z === start.z || z === end.z) {
  852. tempPos = new THREE.Vector3(x * 5 + 2.5, y * 5 + 2.5, z * 5 + 2.5);
  853. points.push(tempPos);
  854. if (points.length >= chunkSize) {
  855. yield points;
  856. points = [];
  857. }
  858. }
  859. }
  860. }
  861. await sleep(10);
  862. if (!cheatnite.worldedit.inprogress) {
  863. yield points;
  864. points = [];
  865. }
  866. }
  867. if (points.length > 0) {
  868. yield points;
  869. }
  870. }
  871. WorldEdit.generatePointsOf = async function*(pointA, pointB, blockId, chunkSize) {
  872. let start = new THREE.Vector3(Math.floor(pointA.x/5), Math.floor(pointA.y/5), Math.floor(pointA.z/5));
  873. let end = new THREE.Vector3(Math.floor(pointB.x/5), Math.floor(pointB.y/5), Math.floor(pointB.z/5));
  874. let tempPos;
  875. let points = [];
  876. for (let x = Math.min(start.x, end.x); x <= Math.max(start.x, end.x); x++) {
  877. for (let y = Math.min(start.y, end.y); y <= Math.max(start.y, end.y); y++) {
  878. for (let z = Math.min(start.z, end.z); z <= Math.max(start.z, end.z); z++) {
  879. tempPos = new THREE.Vector3(x*5+2.5, y*5+2.5, z*5+2.5);
  880. if (getBlockIdAtPos(tempPos) == blockId) {
  881. points.push(new THREE.Vector3(x*5+2.5, y*5+2.5, z*5+2.5));
  882. if (points.length >= chunkSize) {
  883. yield points;
  884. points = [];
  885. }
  886. }
  887. }
  888. }
  889. await sleep(10);
  890. if (!cheatnite.worldedit.inprogress) {
  891. yield points;
  892. points = [];
  893. }
  894. }
  895. if (points.length > 0) {
  896. yield points;
  897. }
  898. }
  899. WorldEdit.generateSpherePoints = async function*(centerPoint, radius, chunkSize, blockId) {
  900. let points = [];
  901. let radiusSquared = radius * radius;
  902. let minX = Math.floor((centerPoint.x - radius) / 5);
  903. let maxX = Math.floor((centerPoint.x + radius) / 5);
  904. let minY = Math.floor((centerPoint.y - radius) / 5);
  905. let maxY = Math.floor((centerPoint.y + radius) / 5);
  906. let minZ = Math.floor((centerPoint.z - radius) / 5);
  907. let maxZ = Math.floor((centerPoint.z + radius) / 5);
  908. let tempPos;
  909. for (let x = minX; x <= maxX; x++) {
  910. for (let y = minY; y <= maxY; y++) {
  911. for (let z = minZ; z <= maxZ; z++) {
  912. tempPos = new THREE.Vector3(x * 5 + 2.5, y * 5 + 2.5, z * 5 + 2.5);
  913. let distanceSquared = tempPos.distanceToSquared(centerPoint);
  914. if (distanceSquared <= radiusSquared && getBlockIdAtPos(tempPos) !== blockId) {
  915. points.push(tempPos);
  916. if (points.length >= chunkSize) {
  917. yield points;
  918. points = [];
  919. }
  920. }
  921. }
  922. }
  923. await sleep(10);
  924. if (!cheatnite.worldedit.inprogress) {
  925. yield points;
  926. points = [];
  927. }
  928. }
  929. if (points.length > 0) {
  930. yield points;
  931. }
  932. }
  933. WorldEdit.generateHollowSpherePoints = async function*(centerPoint, radius, chunkSize, blockId) {
  934. let points = [];
  935. let radiusSquared = radius * radius;
  936. let innerRadiusSquared = (radius - 1) * (radius - 1);
  937. let minX = Math.floor((centerPoint.x - radius) / 5);
  938. let maxX = Math.floor((centerPoint.x + radius) / 5);
  939. let minY = Math.floor((centerPoint.y - radius) / 5);
  940. let maxY = Math.floor((centerPoint.y + radius) / 5);
  941. let minZ = Math.floor((centerPoint.z - radius) / 5);
  942. let maxZ = Math.floor((centerPoint.z + radius) / 5);
  943. let tempPos;
  944. for (let x = minX; x <= maxX; x++) {
  945. for (let y = minY; y <= maxY; y++) {
  946. for (let z = minZ; z <= maxZ; z++) {
  947. tempPos = new THREE.Vector3(x * 5 + 2.5, y * 5 + 2.5, z * 5 + 2.5);
  948. let distanceSquared = tempPos.distanceToSquared(centerPoint);
  949. if (distanceSquared <= radiusSquared && getBlockIdAtPos(tempPos) !== blockId) {
  950. let isOnSurface = false;
  951. for (let dx = -1; dx <= 1; dx++) {
  952. for (let dy = -1; dy <= 1; dy++) {
  953. for (let dz = -1; dz <= 1; dz++) {
  954. let neighborPos = new THREE.Vector3(tempPos.x + dx * 5, tempPos.y + dy * 5, tempPos.z + dz * 5);
  955. let neighborDistanceSquared = neighborPos.distanceToSquared(centerPoint);
  956. if (neighborDistanceSquared >= innerRadiusSquared) {
  957. isOnSurface = true;
  958. break;
  959. }
  960. }
  961. if (isOnSurface) break;
  962. }
  963. if (isOnSurface) break;
  964. }
  965. if (isOnSurface) {
  966. points.push(tempPos);
  967. if (points.length >= chunkSize) {
  968. yield points;
  969. points = [];
  970. }
  971. }
  972. }
  973. }
  974. }
  975. await sleep(10);
  976. if (!cheatnite.worldedit.inprogress) {
  977. yield points;
  978. points = [];
  979. }
  980. }
  981. if (points.length > 0) {
  982. yield points;
  983. }
  984. }
  985. WorldEdit.copyChunks = async function(pointA, pointB) {
  986. let start = new THREE.Vector3(Math.floor(pointA.x/5), Math.floor(pointA.y/5), Math.floor(pointA.z/5));
  987. let end = new THREE.Vector3(Math.floor(pointB.x/5), Math.floor(pointB.y/5), Math.floor(pointB.z/5));
  988. let tempPos, tempBlock;
  989. let i, e, o;
  990. let chunk, volume;
  991. let key;
  992. let volumes = {};
  993. let minX = Math.min(start.x, end.x);
  994. let minY = Math.min(start.y, end.y);
  995. let minZ = Math.min(start.z, end.z);
  996. let maxX = Math.max(start.x, end.x);
  997. let maxY = Math.max(start.y, end.y);
  998. let maxZ = Math.max(start.z, end.z);
  999. for (let x = minX; x <= maxX; x++) {
  1000. if (x % 32 !== 0 && x !== minX && x !== maxX) continue;
  1001. for (let y = minY; y <= maxY; y++) {
  1002. if (y % 32 !== 0 && y !== minY && y !== maxY) continue;
  1003. for (let z = minZ; z <= maxZ; z++) {
  1004. if (z % 32 !== 0 && z !== minZ && z !== maxZ) continue;
  1005. tempPos = new THREE.Vector3(x*5+2.5, y*5+2.5, z*5+2.5);
  1006. [i, e, o] = GAME.a865.getChunkFromPos(tempPos);
  1007. if (i>160 || e>160 || o>160)
  1008. continue;
  1009. chunk = GAME.a865.a643s[i][e][o];
  1010. volume = chunk?.volume;
  1011. key = [i, e, o].join(',');
  1012. if (volume) {
  1013. volumes[key] = [chunk.buildP.clone(), volume];
  1014. } else {
  1015. volumes[key] = [new THREE.Vector3(i*32*5, e*32*5, o*32*5), new Uint8Array(32768)]
  1016. }
  1017. }
  1018. }
  1019. await sleep(1);
  1020. }
  1021. return [
  1022. new THREE.Vector3(minX, minY, minZ),
  1023. new THREE.Vector3(maxX, maxY, maxZ),
  1024. volumes,
  1025. ];
  1026. };
  1027. WorldEdit.generatePointsFromClipboard = async function*(chunkSize = 100, newStart = null) {
  1028. let [start, end, cbVolumes] = cheatnite.worldedit.clipboard;
  1029. const diff = newStart ? new THREE.Vector3(Math.floor(newStart.x/5), Math.floor(newStart.y/5), Math.floor(newStart.z/5)).sub(start) : new THREE.Vector3(0,0,0);
  1030. let count = 0;
  1031. let chunkXList = [];
  1032. let chunkYList = [];
  1033. let chunkZList = [];
  1034. let insidePositionsList = [];
  1035. let blockIdsList = [];
  1036. for (let x = start.x; x <= end.x; x++) {
  1037. for (let y = start.y; y <= end.y; y++) {
  1038. for (let z = start.z; z <= end.z; z++) {
  1039. const oldPos = new THREE.Vector3(x*5+2.5, y*5+2.5, z*5+2.5);
  1040. const chunkCoords = GAME.a865.getChunkFromPos(oldPos);
  1041. const chunkData = cbVolumes[chunkCoords.join(',')];
  1042. if (!chunkData)
  1043. continue;
  1044. const insidePos = customPosToV(oldPos, chunkData[0]);
  1045. const blockId = chunkData[1][insidePos];
  1046. const [newChunkCoords, newInsidePos] = posTochunk(oldPos.clone().add(diff.clone().multiplyScalar(5)));
  1047. const [newCx, newCy, newCz] = newChunkCoords;
  1048. const currentBlock = GAME.a865.a643s[newCx][newCy][newCz]?.volume?.[newInsidePos];
  1049. if (blockId === currentBlock)
  1050. continue;
  1051. chunkXList.push(newCx);
  1052. chunkYList.push(newCy);
  1053. chunkZList.push(newCz);
  1054. insidePositionsList.push(newInsidePos);
  1055. blockIdsList.push(blockId);
  1056. count++;
  1057. if (count >= chunkSize) {
  1058. yield [chunkXList, chunkYList, chunkZList, insidePositionsList, blockIdsList];
  1059. chunkXList = [];
  1060. chunkYList = [];
  1061. chunkZList = [];
  1062. insidePositionsList = [];
  1063. blockIdsList = [];
  1064. count = 0;
  1065. }
  1066. }
  1067. }
  1068. await sleep(10);
  1069. }
  1070. if (count) {
  1071. yield [chunkXList, chunkYList, chunkZList, insidePositionsList, blockIdsList];
  1072. }
  1073. };
  1074. WorldEdit.generatePointsFromBuild = async function*(buildName, start, chunkSize) {
  1075. let tempPos;
  1076. let shiftedPoints = [];
  1077. let buildBlockIds = [];
  1078. const buildBlocks = cheatnite.worldedit.builds[buildName];
  1079. for (let i = 0; i < buildBlocks.length; i++) {
  1080. tempPos = new THREE.Vector3(
  1081. buildBlocks[i].pos[0] * 5 + start.x,
  1082. buildBlocks[i].pos[1] * 5 + start.y,
  1083. buildBlocks[i].pos[2] * 5 + start.z
  1084. )
  1085. const blockId = blocks[buildBlocks[i].name];
  1086. if (getBlockIdAtPos(tempPos) !== blockId) {
  1087. shiftedPoints.push(tempPos.clone())
  1088. buildBlockIds.push(blockId);
  1089. if (shiftedPoints.length >= chunkSize) {
  1090. yield [shiftedPoints, buildBlockIds];
  1091. shiftedPoints = [];
  1092. buildBlockIds = [];
  1093. }
  1094. }
  1095. }
  1096. if (shiftedPoints.length) {
  1097. yield [shiftedPoints, buildBlockIds];
  1098. }
  1099. }
  1100. WorldEdit.set = async function(start, end, blockName) {
  1101. cheatnite.worldedit.inprogress = "set";
  1102. cheatnite.updateCheatDisp = true;
  1103. addCustomChat('WorldEdit', `Setting ${convertCoords(start, "adjusted")} - ${convertCoords(end, "adjusted")} to ${blockName} blocks...`);
  1104. let blockId = blocks[blockName];
  1105. let chunkSize = 30000;
  1106. let generator = this.generatePointsNotOf(start, end, chunkSize, blockId);
  1107. for await (let chunk of generator) {
  1108. await a637(chunk, this.createBlockArr(chunk.length, blockId), ()=>{
  1109. addCustomChat('WorldEdit', 'Stopped //set command.');
  1110. });
  1111. if (!cheatnite.worldedit.inprogress)
  1112. return;
  1113. }
  1114. cheatnite.worldedit.inprogress = false;
  1115. cheatnite.updateCheatDisp = true;
  1116. addCustomChat('WorldEdit', 'Completed //set command.');
  1117. }
  1118. WorldEdit.box = async function(start, end, blockName) {
  1119. cheatnite.worldedit.inprogress = "box";
  1120. cheatnite.updateCheatDisp = true;
  1121. addCustomChat('WorldEdit', `Generating a box from ${convertCoords(start, "adjusted")} to ${convertCoords(end, "adjusted")} using ${blockName} blocks...`);
  1122. let blockId = blocks[blockName];
  1123. let chunkSize = 30000;
  1124. let generator = this.generateBoxPoints(start, end, chunkSize, blockId);
  1125. for await (let chunk of generator) {
  1126. await a637(chunk, this.createBlockArr(chunk.length, blockId), ()=>{
  1127. addCustomChat('WorldEdit', 'Stopped //box command.');
  1128. });
  1129. if (!cheatnite.worldedit.inprogress)
  1130. return;
  1131. }
  1132. cheatnite.worldedit.inprogress = false;
  1133. cheatnite.updateCheatDisp = true;
  1134. addCustomChat('WorldEdit', 'Completed //box command.');
  1135. }
  1136. WorldEdit.replace = async function(start, end, blockIdStart, blockNameEnd) {
  1137. cheatnite.worldedit.inprogress = "replace";
  1138. cheatnite.updateCheatDisp = true;
  1139. addCustomChat('WorldEdit', `Replacing ${BLOCK_CONFIG[blockIdStart].name} with ${blockNameEnd} in ${convertCoords(start, "adjusted")} - ${convertCoords(end, "adjusted")}...`);
  1140. let blockIdEnd = blocks[blockNameEnd];
  1141. if (blockIdStart === blockIdEnd) {
  1142. cheatnite.worldedit.inprogress = false;
  1143. cheatnite.updateCheatDisp = true;
  1144. addCustomChat('WorldEdit', 'Completed //replace command.');
  1145. return;
  1146. }
  1147. let chunkSize = 30000;
  1148. let generator = this.generatePointsOf(start, end, blockIdStart, chunkSize);
  1149. for await (let chunk of generator) {
  1150. await a637(chunk, this.createBlockArr(chunk.length, blockIdEnd), ()=>{
  1151. addCustomChat('WorldEdit', 'Stopped //replace command.');
  1152. });
  1153. if (!cheatnite.worldedit.inprogress)
  1154. return;
  1155. }
  1156. cheatnite.worldedit.inprogress = false;
  1157. cheatnite.updateCheatDisp = true;
  1158. addCustomChat('WorldEdit', 'Completed //replace command.');
  1159. }
  1160. WorldEdit.sphere = async function(centerPoint, blockName, radius) {
  1161. cheatnite.worldedit.inprogress = "sphere";
  1162. cheatnite.updateCheatDisp = true;
  1163. addCustomChat('WorldEdit', `Creating a ${blockName} sphere with center ${convertCoords(centerPoint, "adjusted")} and radius ${radius}...`);
  1164. let blockId = blocks[blockName];
  1165. let chunkSize = 30000;
  1166. let generator = this.generateSpherePoints(centerPoint, radius, chunkSize, blockId);
  1167. for await (let chunk of generator) {
  1168. await a637(chunk, this.createBlockArr(chunk.length, blockId), ()=>{
  1169. addCustomChat('WorldEdit', 'Stopped //sphere command.');
  1170. });
  1171. if (!cheatnite.worldedit.inprogress)
  1172. return;
  1173. }
  1174. cheatnite.worldedit.inprogress = false;
  1175. cheatnite.updateCheatDisp = true;
  1176. addCustomChat('WorldEdit', 'Completed //sphere command.');
  1177. }
  1178. WorldEdit.hollowSphere = async function(centerPoint, blockName, radius) {
  1179. cheatnite.worldedit.inprogress = "hollow sphere";
  1180. cheatnite.updateCheatDisp = true;
  1181. addCustomChat('WorldEdit', `Creating a ${blockName} hollow sphere with center ${convertCoords(centerPoint, "adjusted")} and radius ${radius}...`);
  1182. let blockId = blocks[blockName];
  1183. let chunkSize = 30000;
  1184. let generator = this.generateHollowSpherePoints(centerPoint, radius, chunkSize, blockId);
  1185. for await (let chunk of generator) {
  1186. await a637(chunk, this.createBlockArr(chunk.length, blockId), ()=>{
  1187. addCustomChat('WorldEdit', 'Stopped //hsphere command.');
  1188. });
  1189. if (!cheatnite.worldedit.inprogress)
  1190. return;
  1191. }
  1192. cheatnite.worldedit.inprogress = false;
  1193. cheatnite.updateCheatDisp = true;
  1194. addCustomChat('WorldEdit', 'Completed //hsphere command.');
  1195. }
  1196. WorldEdit.copy = async function(start, end) {
  1197. addCustomChat('WorldEdit', `Saving volume ${convertCoords(start, "adjusted")} - ${convertCoords(end, "adjusted")} to clipboard...`);
  1198. cheatnite.worldedit.clipboard = await this.copyChunks(start, end);
  1199. addCustomChat('WorldEdit', 'Saved volume to clipboard.');
  1200. }
  1201. WorldEdit.paste = async function(start) {
  1202. cheatnite.worldedit.inprogress = "paste";
  1203. cheatnite.updateCheatDisp = true;
  1204. addCustomChat('WorldEdit', `Pasting clipboard at ${convertCoords(start || cheatnite.worldedit.clipboard[0], "adjusted")}...`);
  1205. let chunkSize = 30000;
  1206. let generator = this.generatePointsFromClipboard(chunkSize, start);
  1207. for await (const [x, y, z, insidePos, blockIds] of generator) {
  1208. await rawa637(x, y, z, insidePos, blockIds, ()=>{
  1209. addCustomChat('WorldEdit', 'Stopped //paste command.');
  1210. })
  1211. if (!cheatnite.worldedit.inprogress)
  1212. return;
  1213. }
  1214. cheatnite.worldedit.inprogress = false;
  1215. cheatnite.updateCheatDisp = true;
  1216. addCustomChat('WorldEdit', 'Pasted volume.');
  1217. }
  1218. WorldEdit.build = async function(buildName, start) {
  1219. cheatnite.worldedit.inprogress = "build";
  1220. cheatnite.updateCheatDisp = true;
  1221. addCustomChat('WorldEdit', `Building ${buildName} at ${convertCoords(start, "adjusted")}...`);
  1222. let chunkSize = 30000;
  1223. let generator = this.generatePointsFromBuild(buildName, start, chunkSize);
  1224. for await (let chunk of generator) {
  1225. await a637(chunk[0], chunk[1], ()=>{
  1226. addCustomChat('WorldEdit', 'Stopped //build command.');
  1227. });
  1228. if (!cheatnite.worldedit.inprogress)
  1229. return;
  1230. }
  1231. cheatnite.worldedit.inprogress = false;
  1232. cheatnite.updateCheatDisp = true;
  1233. addCustomChat('WorldEdit', 'Finished building '+buildName+'.');
  1234. }
  1235. WorldEdit.error = function(msg) {
  1236. addCustomChat('WorldEdit.Error', msg);
  1237. }
  1238. WorldEdit.createBlockArr = function(len, blockId) {
  1239. if (typeof(blockId) === 'number') {
  1240. return Array(len).fill(blockId);
  1241. } else {
  1242. const filteredKeys = Object.keys(BLOCK_CONFIG).filter(key => parseInt(key) !== 0);
  1243. const arr = Array.from({ length: len }, () => {
  1244. return parseInt(filteredKeys[Math.floor(Math.random() * filteredKeys.length)]);
  1245. })
  1246. return arr;
  1247. }
  1248. }
  1249.  
  1250. setInterval(() => {
  1251. if (typeof(GAME) !== 'undefined' && GAME?.a865?.player?.position && GAME?.loadingUI.hidden == true) {
  1252. let me = GAME.a865.player;
  1253. let bottomright = document.getElementById('bottomright');
  1254. bottomright.style.display = 'block';
  1255. if (!me.dead) {
  1256. cheatnite.coords = convertCoords(me.position, "adjusted");
  1257. bottomright.textContent = `(${cheatnite.coords.x.toFixed(1)}, ${cheatnite.coords.y.toFixed(1)}, ${cheatnite.coords.z.toFixed(1)})`;
  1258. if (GAME?.oceanHeightTo) {
  1259. cheatnite.drain = cheatnite.coords.y < 10;
  1260. GAME.oceanHeightTo = cheatnite.drain ? -10000 : 317;
  1261. }
  1262. if (GAME.myKillerId && !G.othera822ers.some((p) => p?.ID === GAME.myKillerId))
  1263. GAME.myKillerId = null;
  1264. } else {
  1265. var newPos = G.othera822ers?.[GAME.myKillerId]?.position || me.position;
  1266. let coords = convertCoords(newPos, "adjusted");
  1267. bottomright.textContent = `(${coords.x.toFixed(1)}, ${coords.y.toFixed(1)}, ${coords.z.toFixed(1)})`;
  1268. }
  1269. if (cheatnite.updateCheatDisp) {
  1270. //cheat display code inspired by https://greasyfork.org/en/scripts/474923-craftnite-io-hacked-client-fly-triggerbot-esp-rapidfire-speedhacks-and-more
  1271. var textArr = cheatnite.activatedCheats;
  1272. textArr.sort((a, b) => a.length - b.length);
  1273. textArr = textArr.slice(0);
  1274. if (cheatnite.customBlockId !== 256)
  1275. textArr.push(`Item: ${BLOCK_CONFIG[cheatnite.customBlockId]?.name || cheatnite.customBlockId}`);
  1276. if (cheatnite.worldedit.inprogress)
  1277. textArr.push(`WorldEdit: ${cheatnite.worldedit.inprogress}`);
  1278. var coloredTextArr = textArr.map(function(text, index) {
  1279. return '<span style="color: ' + getColor(index, textArr.length) + '">' + text.toUpperCase() + '</span>';
  1280. });
  1281. cheatnite.cheatDisp.innerHTML = coloredTextArr.join('<br>');
  1282. cheatnite.updateCheatDisp = false;
  1283. cheatnite.cheatDisp.style.top = (document.documentElement.clientHeight + bottomright.clientHeight*0.5 - (26*textArr.length)) + "px";
  1284. }
  1285. }
  1286. var extra = document.getElementsByClassName('truepush_optin_notifications');
  1287. if (extra.length)
  1288. extra[0].remove();
  1289. }, 50);
  1290.  
  1291. function initEsp() {
  1292. espGeometry = new THREE.EdgesGeometry(new THREE.BoxGeometry(5, 10, 5).translate(0, -3, 0));
  1293. lineMaterial = new THREE.LineBasicMaterial({ color: 0xff0000 });
  1294. red = `
  1295. void main() {
  1296. gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
  1297. }
  1298. `;
  1299. espMaterial = new THREE.RawShaderMaterial({
  1300. vertexShader: `
  1301. attribute vec3 position;
  1302. uniform mat4 projectionMatrix;
  1303. uniform mat4 modelViewMatrix;
  1304. void main() {
  1305. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  1306. gl_Position.z = 1.0;
  1307. }
  1308. `,
  1309. fragmentShader: red
  1310. });
  1311. textCanvas = new G.Canvas2d();
  1312. textCanvas.alpha = 0;
  1313. textCanvas.init();
  1314. }
  1315. function animate() {
  1316. window.requestAnimationFrame(animate);
  1317. const players = [];
  1318. for (const p of G.othera822ers)
  1319. if (p && p.id && p.id !== GAME.a865.player.id)
  1320. players.push(p);
  1321. textCanvas.clear();
  1322. const drawnTextPositions = [];
  1323. const minSpacing = 4;
  1324. const textOffset = 24;
  1325. for (let i = 0; i < players.length; i++) {
  1326. const player = players[i];
  1327. if (!player.a472.box) {
  1328. const box = new THREE.LineSegments(espGeometry, espMaterial);
  1329. box.frustumCulled = false;
  1330. player.a472.add(box);
  1331. player.a472.box = box;
  1332. }
  1333. player.a472.box.visible = cheatnite.esp;
  1334. if (player.a472.visible && cheatnite.esp) {
  1335. const worldPos = new THREE.Vector3();
  1336. player.a472.box.getWorldPosition(worldPos);
  1337. let screenPos = G.worldPosToScreenCoords(worldPos, GAME.camera, window.innerWidth, window.innerHeight);
  1338. if (screenPos.orientation !== 'center')
  1339. continue;
  1340. let playerName = `(${player.id}) ` + (player.name.length > 20 ? player.name.substring(0, 17) + '...' : player.name);
  1341. let color = "#FFFFFF";
  1342. if (player.ID === GAME.myKillerId) {
  1343. playerName = '(killer) '+playerName;
  1344. color = "#FF8080";
  1345. }
  1346. const textSize = 16;
  1347. let yPos = screenPos.coords.y - 10;
  1348. for (const drawnPos of drawnTextPositions) {
  1349. if (Math.abs(drawnPos.x - screenPos.coords.x) < textSize && Math.abs(drawnPos.y - yPos) < textSize) {
  1350. yPos = drawnPos.y - textSize - minSpacing;
  1351. }
  1352. }
  1353. drawnTextPositions.push({ x: screenPos.coords.x, y: yPos });
  1354. textCanvas.text(
  1355. [screenPos.coords.x, yPos],
  1356. playerName,
  1357. color,
  1358. textSize,
  1359. "middle",
  1360. "center"
  1361. );
  1362. }
  1363. }
  1364. textCanvas.flip();
  1365. }
  1366.  
  1367. let checkInterval = setInterval(() => {
  1368. if (typeof(G) !== 'undefined' && typeof(G.socket) !== 'undefined' && G.socket !== null && G.socket.binaryType == "arraybuffer") {
  1369. clearInterval(checkInterval);
  1370. G.socket.onmessage = new Proxy(G.socket.onmessage || function(){}, {
  1371. apply: function (target, scope, args) {
  1372. var i = new DataView(args[0].data);
  1373. let opcode = i.getUint8(0);
  1374. if (opcode === 19) {
  1375. onDeath(i);
  1376. } else if (opcode === G.a823.RPCMatchRemainingTime) {
  1377. var c, ratio;
  1378. (c = new RPCMatchRemainingTime).a615(i);
  1379. if (!cheatnite.server.time) {
  1380. cheatnite.server.r = 3;
  1381. var e = new a201();
  1382. e.msg = a914;
  1383. G.socket.send(e.a614());
  1384. } else {
  1385. ratio = (Date.now() - cheatnite.server.time)/1000;
  1386. if (ratio >= 1)
  1387. cheatnite.server.r = ratio;
  1388. }
  1389. cheatnite.server.time = Date.now();;
  1390. }
  1391. let data = target.apply(scope, args);
  1392. return data;
  1393. }
  1394. });
  1395. }
  1396. }, 1000);
  1397. WebSocket.prototype.send = new Proxy(WebSocket.prototype.send, {
  1398. apply: function (target, scope, args) {
  1399. var dataView = new DataView(args[0]);
  1400. let opcode = dataView.getUint8(0);
  1401. if (opcode == 27) {
  1402. let blockName, thickess, radius, pID, pkt, player;
  1403. let adjustedCoords = `(${cheatnite.coords.x.toFixed(0)}, ${cheatnite.coords.y.toFixed(0)}, ${cheatnite.coords.z.toFixed(0)})`
  1404. let msg = parseOutgoingChat(dataView);
  1405. if (msg.startsWith('/')) {
  1406. addCustomChat('$', msg)
  1407. let splitMsg = msg.split(' ').filter(word => word !== '');
  1408. let cmd = splitMsg[0].substr(1).toLowerCase();
  1409. let args = splitMsg.slice(1);
  1410. switch(cmd) {
  1411. case 'truecoords':
  1412. addCustomChat('<', `(${(me.position.x).toFixed(1)}, ${(me.position.y).toFixed(1)}, ${(me.position.z).toFixed(1)})`)
  1413. break;
  1414. case 'ignore':
  1415. pID = parseInt(args[0]);
  1416. if (!isNaN(pID)) {
  1417. if (!cheatnite.ignored.includes(pID)) {
  1418. cheatnite.ignored.push(pID);
  1419. addCustomChat('<', `Ignored player with ID ${pID}`);
  1420. } else {
  1421. addCustomChat('Error', `Player ID ${pID} is already ignored.`);
  1422. }
  1423. } else {
  1424. addCustomChat('Error', 'A number is expected as an argument (the player\'s ID).');
  1425. }
  1426. break;
  1427. case 'unignore':
  1428. pID = parseInt(args[0]);
  1429. if (!isNaN(pID)) {
  1430. if (cheatnite.ignored.includes(pID)) {
  1431. cheatnite.ignored = cheatnite.ignored.filter(item => item !== pID);
  1432. addCustomChat('<', `Unignored player with ID ${pID}`);
  1433. } else {
  1434. addCustomChat('Error', `Player ID ${pID} is not in ignored list.`);
  1435. }
  1436. } else {
  1437. addCustomChat('Error', 'A number is expected as an argument (the player\'s ID).');
  1438. }
  1439. break;
  1440. case 'unstuck':
  1441. G.a597.rebound.enabled = true;
  1442. addCustomChat('<', 'Unstuck.');
  1443. break
  1444. case 'drain':
  1445. cheatnite.drain = !cheatnite.drain;
  1446. GAME.oceanHeightTo = cheatnite.drain ? -10000 : 317;
  1447. addCustomChat('<', cheatnite.drain ? 'Ocean gone (for client).' : 'Ocean is back.');
  1448. break;
  1449. case 'item':
  1450. if (args.length === 0) {
  1451. cheatnite.customBlockId = getLookAtBlockId();
  1452. } else if (checkInt(args[0]) && Object.keys(BLOCK_CONFIG).includes(args[0])) {
  1453. cheatnite.customBlockId = parseInt(args[0]);
  1454. } else if (Object.keys(blocks).includes(args[0].toLowerCase())) {
  1455. cheatnite.customBlockId = blocks[args[0].toLowerCase()];
  1456. } else {
  1457. addCustomChat('Error', `Block ${args[0]} does not exist.`);
  1458. return;
  1459. }
  1460. if (!cheatnite.customBlockId) {
  1461. addCustomChat('<', 'Reset stone items.');
  1462. return;
  1463. }
  1464. var stoneNeeded = 1000 - countItemInInv("stone");
  1465. if (stoneNeeded > 0) {
  1466. GAME.a865.player.a458("stone", stoneNeeded);
  1467. }
  1468. addCustomChat('<', `Thrown stone set to ${BLOCK_CONFIG[cheatnite.customBlockId]?.name || cheatnite.customBlockId}.`);
  1469. break;
  1470. case 'invsize':
  1471. if (args.length === 0) {
  1472. GAME.a865.player.totalShorta843 = 4;
  1473. addCustomChat('<', 'Inventory size reset.')
  1474. } else if (checkInt(args[0]) && parseInt(args[0])>=0 && parseInt(args[0])<=35) {
  1475. GAME.a865.player.totalShorta843 = parseInt(args[0]);
  1476. addCustomChat('<', 'Inventory size set to '+args[0]+'.')
  1477. } else {
  1478. addCustomChat('Error', 'Invalid input. Expected an integer between 0 and 35, inclusive.')
  1479. }
  1480. break;
  1481. case 'tp':
  1482. pID = parseInt(args[0]);
  1483. if (!isNaN(pID)) {
  1484. player = G.othera822ers.find(p => p?.id === pID);
  1485. if (!player) {
  1486. addCustomChat('Error', `Player with ID ${pID} not found.`);
  1487. return
  1488. }
  1489. tp(player.position);
  1490. addCustomChat('>', `Teleported to ${player.id}.`)
  1491. } else {
  1492. addCustomChat('Error', 'A number is expected as an argument (the player\'s ID).');
  1493. }
  1494. break;
  1495. case 'time':
  1496. if (args.length < 2 || args[0].toLowerCase() !== 'set') {
  1497. addCustomChat('Error', 'Expected at 2 args: set and (day/night).')
  1498. return;
  1499. }
  1500. if (args[1].toLowerCase() === 'night') {
  1501. cheatnite.darkMode = true;
  1502. G.CONFIG.a133 = new THREE.Color("rgb(30, 30, 30)");
  1503. } else {
  1504. cheatnite.darkMode = false;
  1505. G.CONFIG.a133 = G.CONFIG.a134;
  1506. }
  1507. GAME.updatea668(false);
  1508. addCustomChat('<', `Time set to ${cheatnite.darkMode ? 'night' : 'day'}.`);
  1509. break;
  1510. case 'bg':
  1511. if (args.length) {
  1512. if (isURL(args[0])) {
  1513. addCustomChat('<', 'Loading background image from url...');
  1514. const textureLoader = new THREE.TextureLoader();
  1515. textureLoader.load(args[0], (texture) => {
  1516. const sphereGeometry = new THREE.SphereBufferGeometry(16e3, 32, 15);
  1517. const texturedMaterial = new THREE.MeshBasicMaterial({
  1518. map: texture,
  1519. side: THREE.BackSide,
  1520. });
  1521. const skybox = new THREE.Mesh(sphereGeometry, texturedMaterial);
  1522. GAME.scene.add(skybox);
  1523. addCustomChat('<', 'Background image set!');
  1524. });
  1525. }
  1526. return;
  1527. }
  1528. var input = document.createElement('input');
  1529. input.type = 'file';
  1530. input.onchange = (event) => {
  1531. addCustomChat('<', 'Loading background image from file...');
  1532. const file = event.target.files[0];
  1533. const reader = new FileReader();
  1534. reader.onload = (event) => {
  1535. const textureLoader = new THREE.TextureLoader();
  1536. textureLoader.load(event.target.result, (texture) => {
  1537. const sphereGeometry = new THREE.SphereBufferGeometry(16e3, 32, 15);
  1538. const texturedMaterial = new THREE.MeshBasicMaterial({
  1539. map: texture,
  1540. side: THREE.BackSide,
  1541. });
  1542. const skybox = new THREE.Mesh(sphereGeometry, texturedMaterial);
  1543. GAME.scene.add(skybox);
  1544. addCustomChat('<', 'Background image set!');
  1545. });
  1546. };
  1547. reader.readAsDataURL(file);
  1548. };
  1549. input.click();
  1550. break;
  1551. case '/p1':
  1552. WorldEdit.pos1(args);
  1553. break;
  1554. case '/p2':
  1555. WorldEdit.pos2(args);
  1556. break;
  1557. case '/pos1':
  1558. WorldEdit.pos1(args);
  1559. break;
  1560. case '/pos2':
  1561. WorldEdit.pos2(args);
  1562. break;
  1563. case '/set':
  1564. if (cheatnite.worldedit.inprogress) {
  1565. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  1566. return;
  1567. }
  1568. if (!cheatnite.worldedit.pos1 || !cheatnite.worldedit.pos2) {
  1569. WorldEdit.error('You must set //pos1 and //pos2 before running this worldedit command.');
  1570. return;
  1571. }
  1572. if (args.length === 0) {
  1573. WorldEdit.error('Expected 1 argument, got 0.');
  1574. return;
  1575. }
  1576. blockName = args[0].toLowerCase();
  1577. if (!Object.keys(blocks).includes(blockName)) {
  1578. WorldEdit.error(`Block ${blockName} does not exist.`);
  1579. return;
  1580. }
  1581. WorldEdit.set(cheatnite.worldedit.pos1.clone(), cheatnite.worldedit.pos2.clone(), blockName)
  1582. break;
  1583. case '/box':
  1584. if (cheatnite.worldedit.inprogress) {
  1585. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  1586. return;
  1587. }
  1588. if (!cheatnite.worldedit.pos1 || !cheatnite.worldedit.pos2) {
  1589. WorldEdit.error('You must set //pos1 and //pos2 before running this worldedit command.');
  1590. return;
  1591. }
  1592. if (args.length === 0) {
  1593. WorldEdit.error('Expected 1 argument, got 0.');
  1594. return;
  1595. }
  1596. blockName = args[0].toLowerCase();
  1597. if (!Object.keys(blocks).includes(blockName)) {
  1598. WorldEdit.error(`Block ${blockName} does not exist.`);
  1599. return;
  1600. }
  1601. WorldEdit.box(cheatnite.worldedit.pos1.clone(), cheatnite.worldedit.pos2.clone(), blockName);
  1602. break;
  1603. case '/replace':
  1604. if (cheatnite.worldedit.inprogress) {
  1605. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  1606. return;
  1607. }
  1608. if (!cheatnite.worldedit.pos1 || !cheatnite.worldedit.pos2) {
  1609. WorldEdit.error('You must set //pos1 and //pos2 before running this worldedit command.');
  1610. return;
  1611. }
  1612. if (args.length == 0) {
  1613. WorldEdit.error('Expected at least 1 argument, got 0.');
  1614. return;
  1615. }
  1616. var blockIdStart = getLookAtBlockId();
  1617. if (!blockIdStart) {
  1618. blockIdStart = 0;
  1619. }
  1620. var blockNameEnd = args[0].toLowerCase();
  1621. if (!Object.keys(blocks).includes(blockNameEnd)) {
  1622. WorldEdit.error(`Block ${blockNameEnd} does not exist.`);
  1623. return;
  1624. }
  1625. WorldEdit.replace(cheatnite.worldedit.pos1.clone(), cheatnite.worldedit.pos2.clone(), blockIdStart, blockNameEnd);
  1626. break;
  1627. case '/sphere':
  1628. if (cheatnite.worldedit.inprogress) {
  1629. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  1630. return;
  1631. }
  1632. if (!cheatnite.worldedit.pos1 && !cheatnite.worldedit.pos2) {
  1633. WorldEdit.error('You must set //pos1 or //pos2 before running this worldedit command.');
  1634. return;
  1635. }
  1636. if (args.length === 0) {
  1637. WorldEdit.error('Expected at 2 arguments, got 0.');
  1638. return;
  1639. }
  1640. blockName = args[0].toLowerCase();
  1641. if (!Object.keys(blocks).includes(blockName)) {
  1642. WorldEdit.error(`Block ${blockName} does not exist.`);
  1643. return;
  1644. }
  1645. radius = parseInt(args[1]);
  1646. if (!radius) {
  1647. WorldEdit.error(`Invalid radius ${radius}`);
  1648. return;
  1649. }
  1650. WorldEdit.sphere((cheatnite.worldedit.pos1 || cheatnite.worldedit.pos2).clone(), blockName, radius);
  1651. break;
  1652. case '/hsphere':
  1653. if (cheatnite.worldedit.inprogress) {
  1654. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  1655. return;
  1656. }
  1657. if (!cheatnite.worldedit.pos1 && !cheatnite.worldedit.pos2) {
  1658. WorldEdit.error('You must set //pos1 or //pos2 before running this worldedit command.');
  1659. return;
  1660. }
  1661. if (args.length === 0) {
  1662. WorldEdit.error('Expected at 2 arguments, got 0.');
  1663. return;
  1664. }
  1665. blockName = args[0].toLowerCase();
  1666. if (!Object.keys(blocks).includes(blockName)) {
  1667. WorldEdit.error(`Block ${blockName} does not exist.`);
  1668. return;
  1669. }
  1670. radius = parseInt(args[1]);
  1671. if (!radius) {
  1672. WorldEdit.error(`Invalid radius ${radius}`);
  1673. return;
  1674. }
  1675. WorldEdit.hollowSphere((cheatnite.worldedit.pos1 || cheatnite.worldedit.pos2).clone(), blockName, radius);
  1676. break;
  1677. case '/copy':
  1678. if (cheatnite.worldedit.inprogress) {
  1679. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  1680. return;
  1681. }
  1682. if (!cheatnite.worldedit.pos1 || !cheatnite.worldedit.pos2) {
  1683. WorldEdit.error('You must set //pos1 and //pos2 before running this worldedit command.');
  1684. return;
  1685. }
  1686. WorldEdit.copy(cheatnite.worldedit.pos1.clone(), cheatnite.worldedit.pos2.clone());
  1687. break;
  1688. case '/paste':
  1689. if (cheatnite.worldedit.inprogress) {
  1690. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  1691. return;
  1692. }
  1693. if (!cheatnite.worldedit.clipboard[0]) {
  1694. WorldEdit.error('Nothing is copied to clipboard.');
  1695. return;
  1696. }
  1697. if (args.length && args[0].toLowerCase() === 'original') {
  1698. WorldEdit.paste(null);
  1699. } else {
  1700. WorldEdit.paste(GAME.a865.player.position.clone());
  1701. }
  1702. break;
  1703. case '/clearclipboard':
  1704. cheatnite.worldedit.clipboard = [null, null, {}];
  1705. addCustomChat('WorldEdit', 'Cleared clipboard.');
  1706. break;
  1707. case '/stop':
  1708. if (!cheatnite.worldedit.inprogress) {
  1709. WorldEdit.error("No WorldEdit commands are currently running.");
  1710. return;
  1711. }
  1712. cheatnite.worldedit.inprogress = false;
  1713. cheatnite.updateCheatDisp = true;
  1714. break;
  1715. case '/positions':
  1716. addCustomChat('WorldEdit', `pos1: ${convertCoords(cheatnite.worldedit.pos1, "adjusted") || 'not set'}; pos2: ${convertCoords(cheatnite.worldedit.pos2, "adjusted") || 'not set'}`);
  1717. break;
  1718. case '/load':
  1719. if (args.length) {
  1720. if (isURL(args[0])) {
  1721. const buildName = getBuildName(args[0].split('/').pop().split('#')[0].split('?')[0])
  1722. cheatnite.worldedit.builds[buildName] = readBuildFromURL(args[0]);
  1723. }
  1724. return;
  1725. }
  1726. var input = document.createElement('input');
  1727. input.type = 'file';
  1728. input.onchange = async (event) => {
  1729. try {
  1730. const file = event.target.files[0];
  1731. const fnWithExt = file.name || '';
  1732. const fn = fnWithExt.split(".").slice(0, -1).join(".");
  1733. const buildName = getBuildName(fn || '');
  1734. let loadedBuild;
  1735. if (fnWithExt.endsWith('.json')) {
  1736. loadedBuild = await readChunksFromLocal(file);
  1737. } else if (fnWithExt.endsWith('.schem') || fnWithExt.endsWith('.schematic') || fnWithExt.endsWith('.nbt')) {
  1738. loadedBuild = await readBuildFromLocal(file)
  1739. } else {
  1740. throw new Error('Unsupported file extension.')
  1741. }
  1742. if (loadedBuild) {
  1743. cheatnite.worldedit.builds[buildName] = loadedBuild;
  1744. addCustomChat('WorldEdit', 'Loaded build '+buildName+' from file.');
  1745. }
  1746. } catch (errorString) {
  1747. WorldEdit.error(errorString.toString());
  1748. } finally {
  1749. input.remove();
  1750. }
  1751. };
  1752. input.click();
  1753. break;
  1754. case '/new':
  1755. //not implemented
  1756. break;
  1757. case '/build':
  1758. if (cheatnite.worldedit.inprogress) {
  1759. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  1760. return;
  1761. }
  1762. var keys = Object.keys(cheatnite.worldedit.builds);
  1763. if (keys.length === 0) {
  1764. WorldEdit.error('You do not have any builds.')
  1765. return;
  1766. }
  1767. if (args.length === 0) {
  1768. WorldEdit.build(Object.keys(cheatnite.worldedit.builds)[Object.keys(cheatnite.worldedit.builds).length - 1], GAME.a865.player.position.clone());
  1769. return;
  1770. }
  1771. if (!cheatnite.worldedit.builds[args[0]]) {
  1772. WorldEdit.error('Build '+args[0]+' not found. Your saved builds are: '+Object.keys(cheatnite.worldedit.builds).join(', '));
  1773. break;
  1774. }
  1775. WorldEdit.build(args[0], GAME.a865.player.position.clone());
  1776. break;
  1777. case '/builds':
  1778. addCustomChat('WorldEdit', 'Your builds are: '+Object.keys(cheatnite.worldedit.builds).join(', '));
  1779. break
  1780. case '/save':
  1781. //not implemented
  1782. break;
  1783. default:
  1784. if (cmd.startsWith('/')) {
  1785. WorldEdit.error(`Command /${cmd} not found.`);
  1786. } else {
  1787. addCustomChat('Error', `Command /${cmd} not found in CheatNite.`);
  1788. }
  1789. break;
  1790. }
  1791. return;
  1792. }
  1793. }
  1794. if (G?.socket?.readyState === WebSocket.OPEN) {
  1795. let data = target.apply(scope, args);
  1796. return data;
  1797. }
  1798. }
  1799. })
  1800.  
  1801. var checkFuncInterval = setInterval(function() {
  1802. if (typeof(wwShowVideoAd) !== 'undefined' && typeof(wwShowDedAd) !== 'undefined') {
  1803. addGlobal('wwShowVideoAd', '() => {}');
  1804. addGlobal('wwShowDedAd', '() => {}')
  1805. clearInterval(checkFuncInterval);
  1806. }
  1807. }, 500);
  1808. var checkGInterval = setInterval(function() {
  1809. if (typeof(G) !== 'undefined' && G.a822er && G.Game && G.a823) {
  1810. G.a822er.prototype.a612 = (function(_super) {
  1811. return function() {
  1812. arguments[2] = 255;
  1813. return _super.apply(this, arguments);
  1814. };
  1815. })(G.a822er.prototype.a612);
  1816. G.Game.prototype.updatea668 = (function(_super) {
  1817. return function() {
  1818. G.CONFIG.a135Color = G.CONFIG.a139 = 0xFFFFFF;
  1819. G.CONFIG.a135Near = G.CONFIG.a135Far = G.CONFIG.a140 = G.CONFIG.a141 = 1000000;
  1820. return _super.apply(this, arguments);
  1821. };
  1822. })(G.Game.prototype.updatea668);
  1823. G.Grid.prototype.a637 = (function(_super) {
  1824. return function() {
  1825. if (wasThrown() && arguments[1].length === 1 && arguments[1][0] == 256 && cheatnite.customBlockId !== 256) {
  1826. arguments[1] = WorldEdit.createBlockArr(1, cheatnite.customBlockId);
  1827. }
  1828. return _super.apply(this, arguments);
  1829. };
  1830. })(G.Grid.prototype.a637);
  1831. G.Game.prototype.addChat = addChat;
  1832. G.a823.a191 = 119;
  1833. G.a867[2].a676 = 100;
  1834. G.a867[18].range = 2250;
  1835. a173.prototype.a614 = (function(_super) {
  1836. return function() {
  1837. this.name = this.name.split("§").slice(0, -1).join("§") + "§" + randomIP();
  1838. return _super.apply(this, arguments);
  1839. };
  1840. })(a173.prototype.a614);
  1841. G.a325.prototype.a71a668 = (function(_super) {
  1842. return function() {
  1843. var tryPos = arguments[2];
  1844. if (arguments.length === 7) {
  1845. if (cheatnite.fly && !cheatnite.shiftKeyPressed && GAME.a865.player.vY < 0) {
  1846. tryPos.y = arguments[1].y;
  1847. }
  1848. if (cheatnite.noclip) {
  1849. return {
  1850. pos: tryPos,
  1851. a289: false,
  1852. a693: [],
  1853. a825: false,
  1854. normal: new THREE.Vector3(0, 0, 0),
  1855. };
  1856. }
  1857. }
  1858. return _super.apply(this, arguments);
  1859. };
  1860. })(G.a325.prototype.a71a668);
  1861. G.a822er.prototype.update = (function(_super) {
  1862. return function() {
  1863. if (cheatnite.fly)
  1864. G.Keybinds.moveUpward.a730 ? this.jump = true : this.jump = false;
  1865. return _super.apply(this, arguments);
  1866. };
  1867. })(G.a822er.prototype.update);
  1868. G.a822er.prototype.a727 = (function(_super) {
  1869. return function() {
  1870. _super.apply(this, arguments);
  1871. this.ammoAnimations = null;
  1872. };
  1873. })(G.a822er.prototype.a727);
  1874. G.Grid.prototype.a610 = (function(_super) {
  1875. return function() {
  1876. let t = arguments[0];
  1877. for (var r = 0; r < t.length; r++) {
  1878. var a = this.getChunkFromPos(t[r]);
  1879. var chunk = this.a643s[a[0]][a[1]][a[2]];
  1880. chunk.delV(chunk.posToV(t[r]));
  1881. }
  1882. };
  1883. })(G.Grid.prototype.a610);
  1884. a175.prototype.a614 = (function(_super) {
  1885. return function() {
  1886. if (cheatnite.invisible) {
  1887. let me = GAME.a865.player;
  1888. this.x = me.position.x + G.randInt(-100, 100);
  1889. this.y = me.position.y + G.randInt(1000, 10000);
  1890. this.z = me.position.z + G.randInt(-100, 100);
  1891. }
  1892. this.a748 += G.randFloat(-0.02, 0.02, 10);
  1893. this.a749 += G.randFloat(-0.02, 0.02, 10);
  1894. return _super.apply(this, arguments);
  1895. };
  1896. })(a175.prototype.a614);
  1897. G.Game.prototype.drawLeaderboard = drawLeaderboard;
  1898. a130.prototype.a615 = (function(_super) {
  1899. return function() {
  1900. _super.apply(this, arguments);
  1901. if (cheatnite.darkMode) {
  1902. this.a133 = new THREE.Color("rgb(30, 30, 30)");
  1903. }
  1904. };
  1905. })(a130.prototype.a615);
  1906. clearInterval(checkGInterval);
  1907. }
  1908. }, 500);
  1909. var checkGAMEInterval = setInterval(function() {
  1910. if (typeof(GAME) !== 'undefined' && GAME.a865?.player && GAME.a865?.player?.shoutOutAnimations?.a759s) {
  1911. if (!textCanvas) {
  1912. initEsp();
  1913. animate();
  1914. }
  1915. GAME.chatInput.onkeyup = function(event) {
  1916. chatCmdSuggestions(event);
  1917. }
  1918. GAME.chatInput.setAttribute("autocomplete", "off");
  1919. GAME.a865.player.updatea809Total = () => {};
  1920. GAME.a865.player.shoutOutAnimations.a759s.deadEnd.a843[0.48].a853 = (t, e)=>{
  1921. var i = 0;
  1922. GAME.bottleneckCanvas.cvs.bufferCanvas.width < 1024 && (i = 100),
  1923. GAME.bottleneckCanvas.a449([-150 + i, -200], [.5, .5], [300, 420], !0, 0, "rgba(0, 0, 0, 0.35)"),
  1924. GAME.bottleneckCanvas.a449([-150 + i, 120], [.5, .5], [300, 100], !0, 0, "rgba(0, 0, 0, 0.5)"),
  1925. GAME.bottleneckCanvas.a449([-2500 + i, -1500], [.5, .5], [5e3, 3e3], !0, 0, "rgba(5, 0, 0, " + (.5 - .1 * a97(3, t.a852)) + ")"),
  1926. GAME.bottleneckCanvas.text([0 + i, -90], [.5, .5], e.title, "rgba(" + e.red + ", " + e.green + ", " + e.blue + ", 1)", 48 - 0 * a97(3, t.a852), "middle", "center", G.a816),
  1927. GAME.bottleneckCanvas.text([0 + i, 20], [.5, .5], `(${G.othera822ers[GAME.myKillerId].id}) ${G.othera822ers[GAME.myKillerId].name}` + " killed you", "#ffffff", 20 - 0 * a97(3, t.a852), "middle", "center", G.a816),
  1928. GAME.bottleneckCanvas.text([0 + i, 170], [.5, .5], GAME.respawnIn > 0 ? "Respawn in " + GAME.respawnIn + "..." : "Click to respawn", "rgba(255, 255, 255, 1)", 26 + 4 * a97(3, t.a852), "middle", "center", G.a816)
  1929. }
  1930. GAME.a865.player.shoutOutAnimations.a759s.deadEnd.a843[0.52].a853 = (t, e)=>{
  1931. var i = 0;
  1932. GAME.bottleneckCanvas.cvs.bufferCanvas.width < 1024 && (i = 100),
  1933. GAME.bottleneckCanvas.a449([-150 + i, -200], [.5, .5], [300, 420], !0, 0, "rgba(0, 0, 0, 0.35)"),
  1934. GAME.bottleneckCanvas.a449([-150 + i, 120], [.5, .5], [300, 100], !0, 0, "rgba(0, 0, 0, 0.5)"),
  1935. GAME.bottleneckCanvas.a449([-2500 + i, -1500], [.5, .5], [5e3, 3e3], !0, 0, "rgba(5, 0, 0, " + (.4 + .1 * a97(3, t.a852)) + ")"),
  1936. GAME.bottleneckCanvas.text([0 + i, -90], [.5, .5], e.title, "rgba(" + e.red + ", " + e.green + ", " + e.blue + ", 1)", 48 + 0 * a97(3, t.a852), "middle", "center", G.a816),
  1937. GAME.bottleneckCanvas.text([0 + i, 20], [.5, .5], `(${G.othera822ers[GAME.myKillerId].id}) ${G.othera822ers[GAME.myKillerId].name}` + " killed you", "#ffffff", 20 + 0 * a97(3, t.a852), "middle", "center", G.a816),
  1938. GAME.bottleneckCanvas.text([0 + i, 170], [.5, .5], GAME.respawnIn > 0 ? "Respawn in " + GAME.respawnIn + "..." : "Click to respawn", "rgba(255, 255, 255, 1)", 30 - 4 * a97(3, t.a852), "middle", "center", G.a816)
  1939. }
  1940. GAME.a865.player.shoutOutAnimations.a759s.leaderboard.a843[1].start = (t, e)=>{
  1941. GAME.leaderboardCanvas.cvs.clear(),
  1942. GAME.leaderboardCanvas.a449([-230, 10], [1, 0], [220, 280], !0, 1, "rgba(0, 0, 0, 0.6)");
  1943. for (var e = 0; e < GAME.leaderboard.length; e++)
  1944. GAME.leaderboard[e] && (GAME.leaderboard[e].me ? (GAME.leaderboardCanvas.text([-220, 18 + 24 * e], [1, 0], GAME.leaderboard[e].rank + ". " + (GAME.leaderboard[e].name.length < 14 ? GAME.leaderboard[e].name : GAME.leaderboard[e].name.substring(0, 14) + ".."), "rgba(255, 255, 255, 1)", 20, "top", "left", G.a816),
  1945. GAME.leaderboardCanvas.text([-24, 18 + 24 * e], [1, 0], GAME.leaderboard[e].a649, "rgba(255, 255, 255, 1)", 23, "top", "center", G.a816)) : (GAME.leaderboardCanvas.text([-220, 18 + 24 * e], [1, 0], GAME.leaderboard[e].rank + ". " + (GAME.leaderboard[e].name.length < 14 ? GAME.leaderboard[e].name : GAME.leaderboard[e].name.substring(0, 14) + ".."), "rgba(255, 50, 0, 1)", 20, "top", "left", G.a816),
  1946. GAME.leaderboardCanvas.text([-24, 18 + 24 * e], [1, 0], GAME.leaderboard[e].a649, "rgba(255, 255, 255, 1)", 23, "top", "center", G.a816)));
  1947. GAME.leaderboardCanvas.cvs.flip(),
  1948. GAME.leaderboardCanvas.cvs.show()
  1949. }
  1950. clearInterval(checkGAMEInterval);
  1951. }
  1952. }, 500);
  1953. var checkElementsInterval = setInterval(function() {
  1954. var el = document.getElementById('cross-promo')
  1955. var discord = document.getElementById("discord");
  1956. var topleft = document.getElementById("topleft");
  1957. var playBtn = document.getElementById("playbtn");
  1958. if (el && discord && topleft && !playBtn.disabled) {
  1959. el.remove();
  1960. var newEl = document.createElement("div");
  1961. newEl.id = "CheatNite";
  1962. var anchor = document.createElement("a");
  1963. anchor.textContent = "CheatNite loaded!";
  1964. anchor.href = "https://discord.gg/ye3bXsm6Qx";
  1965. anchor.style.fontSize = "2em";
  1966. newEl.appendChild(anchor);
  1967. topleft.appendChild(newEl);
  1968. console.log('CheatNite loaded!');
  1969. discord.href = "https://discord.gg/ye3bXsm6Qx";
  1970. playBtn.removeAttribute("onclick");
  1971. playBtn.onclick = customStartBtn;
  1972. clearInterval(checkElementsInterval);
  1973. }
  1974. }, 500);
  1975.  
  1976. document.addEventListener("keydown", function(event) {
  1977. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === "f") {
  1978. if (typeof(G) !== 'undefined' && typeof(G.CONFIG) !== 'undefined' && typeof(G.CONFIG.a143) !== 'undefined') {
  1979. G.CONFIG.a143 = !G.CONFIG.a143;
  1980. if (!G.CONFIG.a143) {
  1981. G.CONFIG.a155 = 0.1;
  1982. G.CONFIG.a156 = 0.3
  1983. cheatnite.fly = false;
  1984. } else {
  1985. G.CONFIG.a155 = 100;
  1986. G.CONFIG.a156 = 2;
  1987. cheatnite.fly = true;
  1988. }
  1989. modifyCheatDisp("fly");
  1990. }
  1991. }
  1992. });
  1993. let isMouseDown = false;
  1994. document.addEventListener('mousedown', (event) => {
  1995. if (event.button === 0) {
  1996. isMouseDown = true;
  1997. }
  1998. });
  1999. document.addEventListener('mouseup', () => {
  2000. isMouseDown = false;
  2001. });
  2002. //chatspam. Also a good example of keybinded-spam
  2003. document.addEventListener('keydown', (event) => {
  2004. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT') {
  2005. if (event.key === 'q') {
  2006. if (cheatnite.chatspam) {
  2007. clearInterval(cheatnite.chatspam);
  2008. cheatnite.chatspam = null;
  2009. cheatnite.chatspam_count = 0;
  2010. }
  2011. else {
  2012. cheatnite.chatspam = setInterval(() => {
  2013. if (cheatnite.auto || isMouseDown) {
  2014. var e = new a201();
  2015. e.msg = 'CheatNite ' + cheatnite.chatspam_count.toString();
  2016. cheatnite.chatspam_count++;
  2017. if (cheatnite.chatspam_count >= 1000)
  2018. cheatnite.chatspam_count = 0;
  2019. G.socket.send(e.a614());
  2020. }
  2021. }, 60);
  2022. }
  2023. modifyCheatDisp("chatspam");
  2024. }
  2025. }
  2026. });
  2027. document.addEventListener('keydown', (event) => {
  2028. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT') {
  2029. if (event.key === 'r' && !event.metaKey && !event.ctrlKey) {
  2030. if (cheatnite.bulletspam) {
  2031. clearInterval(cheatnite.bulletspam);
  2032. cheatnite.bulletspam = null;
  2033. }
  2034. else {
  2035. cheatnite.bulletspam = setInterval(() => {
  2036. if (typeof(GAME) === 'undefined' || !GAME?.a865?.player || GAME.a865.player.dead) {
  2037. clearInterval(cheatnite.bulletspam);
  2038. cheatnite.bulletspam = null;
  2039. }
  2040. if (cheatnite.auto || isMouseDown) {
  2041. shoot("shotgun")
  2042. }
  2043. }, 50);
  2044. }
  2045. modifyCheatDisp("bulletspam");
  2046. }
  2047. }
  2048. });
  2049. document.addEventListener('keydown', (event) => {
  2050. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT') {
  2051. if (event.key === 't' && !event.metaKey && !event.ctrlKey) {
  2052. if (cheatnite.tntspam) {
  2053. clearInterval(cheatnite.tntspam);
  2054. cheatnite.tntspam = null;
  2055. }
  2056. else {
  2057. cheatnite.tntspam = setInterval(() => {
  2058. if (typeof(GAME) === 'undefined' || !GAME?.a865?.player || GAME.a865.player.dead) {
  2059. clearInterval(cheatnite.tntspam);
  2060. cheatnite.tntspam = null;
  2061. }
  2062. if (cheatnite.auto || isMouseDown) {
  2063. throwItem("tnt")
  2064. }
  2065. }, 100);
  2066. }
  2067. modifyCheatDisp("tntspam");
  2068. }
  2069. }
  2070. });
  2071. let isZoomedIn = false;
  2072. document.addEventListener('keydown', function(event) {
  2073. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'z' && !isZoomedIn) {
  2074. GAME.updateZoom(4);
  2075. isZoomedIn = true;
  2076. modifyCheatDisp("zoom (4x)");
  2077. }
  2078. });
  2079. document.addEventListener('keyup', function(event) {
  2080. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'z' && isZoomedIn) {
  2081. GAME.updateZoom(1);
  2082. isZoomedIn = false;
  2083. modifyCheatDisp("zoom (4x)");
  2084. }
  2085. });
  2086. //credits: https://greasyfork.org/en/scripts/462757-craftnite-io-cheat
  2087. document.addEventListener('keydown', function(event) {
  2088. if (document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'Shift') {
  2089. cheatnite.shiftKeyPressed = true;
  2090. G.CONFIG.environmentOceanFloorHeight = -10000;
  2091. }
  2092. });
  2093. document.addEventListener('keyup', function(event) {
  2094. if (document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'Shift') {
  2095. cheatnite.shiftKeyPressed = false;
  2096. G.CONFIG.environmentOceanFloorHeight = 260;
  2097. }
  2098. });
  2099. document.addEventListener('keydown', (event) => {
  2100. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'e') {
  2101. cheatnite.esp = !cheatnite.esp;
  2102. modifyCheatDisp('ESP');
  2103. }
  2104. });
  2105. document.addEventListener('keydown', (event) => {
  2106. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'c' && !event.metaKey && !event.ctrlKey) {
  2107. cheatnite.customBlockId = getLookAtBlockId();
  2108. cheatnite.updateCheatDisp = true;
  2109. if (!cheatnite.customBlockId) {
  2110. addCustomChat('<', 'Reset stone items.');
  2111. return;
  2112. }
  2113. var stoneNeeded = 1000 - countItemInInv("stone");
  2114. if (stoneNeeded > 0) {
  2115. GAME.a865.player.a458("stone", stoneNeeded);
  2116. }
  2117. addCustomChat('<', `Thrown stone set to ${BLOCK_CONFIG[cheatnite.customBlockId]?.name || cheatnite.customBlockId}.`);
  2118. }
  2119. });
  2120. document.addEventListener('keydown', (event) => {
  2121. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'p' && typeof(GAME) !== 'undefined' && GAME?.renderer) {
  2122. if (cheatnite.esp)
  2123. hidePlayerBoxes();
  2124. saveScene();
  2125. if (cheatnite.esp)
  2126. showPlayerBoxes();
  2127. }
  2128. });
  2129. document.addEventListener('keydown', (event) => {
  2130. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'n') {
  2131. cheatnite.noclip = !cheatnite.noclip;
  2132. modifyCheatDisp("noclip");
  2133. }
  2134. });
  2135. document.addEventListener('keydown', (event) => {
  2136. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT') {
  2137. if ((event.ctrlKey || event.metaKey) && !cheatnite.shiftKeyPressed) {
  2138. if (event.key === 'c') {
  2139. if (cheatnite.worldedit.inprogress) {
  2140. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  2141. return;
  2142. }
  2143. if (!cheatnite.worldedit.pos1 || !cheatnite.worldedit.pos2) {
  2144. WorldEdit.error('You must set //pos1 and //pos2 before running this worldedit command.');
  2145. return;
  2146. }
  2147. WorldEdit.copy(cheatnite.worldedit.pos1.clone(), cheatnite.worldedit.pos2.clone());
  2148. }
  2149. else if (event.key === 'v') {
  2150. if (cheatnite.worldedit.inprogress) {
  2151. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  2152. return;
  2153. }
  2154. if (!cheatnite.worldedit.clipboard[0]) {
  2155. WorldEdit.error('Nothing is copied to clipboard.');
  2156. return;
  2157. }
  2158. WorldEdit.paste(GAME.a865.player.position.clone());
  2159. } else if (event.key === 'b') {
  2160. if (cheatnite.worldedit.inprogress) {
  2161. WorldEdit.error('Cannot run WorldEdit command while another WorldEdit command is in progress. Run //stop to stop current running WorldEdit command.');
  2162. return;
  2163. }
  2164. const keys = Object.keys(cheatnite.worldedit.builds);
  2165. if (keys.length === 0) {
  2166. WorldEdit.error('You do not have any builds.')
  2167. return;
  2168. }
  2169. WorldEdit.build(keys[keys.length - 1], GAME.a865.player.position.clone());
  2170. }
  2171. }
  2172. }
  2173. });
  2174. document.addEventListener('keydown', (event) => {
  2175. if (typeof(cheatnite) !== 'undefined' && document.activeElement && document.activeElement.tagName !== 'INPUT' && event.key === 'i') {
  2176. cheatnite.invisible = !cheatnite.invisible;
  2177. tp(GAME.a865.player.position, false);
  2178. modifyCheatDisp("invisible");
  2179. }
  2180. });