diff --git a/build.gradle b/build.gradle index 990f9db34..51c8b2226 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,8 @@ dependencies { includedLibrary "com.seedfinding:mc_core:${project.seedfinding_core_version}" includedLibrary "com.seedfinding:mc_seed:${project.seedfinding_seed_version}" + includedLibrary files('libs/LattiCG-1.06-rt.jar') + compileOnly 'com.demonwav.mcdev:annotations:2.0.0' modRuntimeOnly('me.djtheredstoner:DevAuth-fabric:1.1.0') { diff --git a/libs/LattiCG-1.06-rt.jar b/libs/LattiCG-1.06-rt.jar new file mode 100644 index 000000000..a8303a0cb Binary files /dev/null and b/libs/LattiCG-1.06-rt.jar differ diff --git a/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java b/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java deleted file mode 100644 index f69df4615..000000000 --- a/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java +++ /dev/null @@ -1,256 +0,0 @@ -package net.cortex.clientAddon.cracker; - -import net.earthcomputer.clientcommands.features.EnchantmentCracker; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -public class Lattice_cracker -{ - static long[][] aLLL={{-1448260238L, -12778033679726L, -46671229957710L, 22119786771154L, 27708029636082L, -22438238668014L, -34239632860622L, -4382943687854L, 8584312843890L, -4127871589486L, 8400903310002L, -11734527753262L, 27623303114482L, -16857517642734L, 5491174120242L, 18668149070930L, -1330558201998L, 1101586846866L, 23911899122610L, -11978722732846L}, - {2456726561834L, -3261629580086L, -29057456210070L, -7883513836534L, 31945299444394L, -5904400710838L, -24028330086934L, -8636803292534L, 6821737120042L, -34305302959670L, -31018921034646L, 7060520311050L, 14765354278826L, -8758653587382L, -20175659537686L, 8317473550218L, -10921060491734L, -2987718797622L, 5900808190314L, 6352173884938L}, - {8042575855974L, 813702672838L, 21581825640486L, 8883610035334L, -26255500269850L, 1036335804230L, 23567418219942L, -59603824122L, 25940808379494L, 4627497995462L, -25095571369178L, -7790883610746L, -1444450725402L, 722857134662L, -18908505102170L, -23894342415098L, -15177942083738L, -12318375958586L, 12756255809062L, 15774489680518L}, - {-49926751308L, 22840726110964L, -3448514642380L, 6728711122292L, 50694484168884L, 11896772388852L, -17420761795788L, -21289175223692L, 10636143502772L, -12584063447820L, 10571621705780L, 33447933867892L, 16024538905268L, -21277299740172L, 2190719327540L, -16944424797068L, 6434888028084L, 17819255953140L, 8234121155124L, 6241722843508L}, - {8043754892887L, -38916266631993L, 23882357015095L, 2619077463719L, -20615629409769L, 19068392119431L, 63315709066743L, 2837792392807L, 14856374199767L, 411971439687L, -23683213006409L, -14139599229401L, -13615773431401L, 10242565925895L, 5574772802935L, 2355273254375L, -1682386002601L, 11336528427975L, 8415441228087L, -34697163633241L}, - {-5494973979516L, -3768771516220L, 7235101896964L, -19515695350460L, 23438541016452L, 57947009982916L, 3234283125252L, 5251495302724L, -25447099812220L, 6873097837252L, -12648694512892L, -933295214780L, -14975211774076L, 50371998929860L, 20863835786244L, 9710816168004L, -14836142880636L, -35171132322620L, -16681195776764L, 32376126316868L}, - {-5483787940079L, -14637515878623L, 17850398343217L, 8949933093441L, 9702913766737L, 26217836632417L, 32304808029809L, 5980854830209L, -16772670002287L, -6669745261663L, 8075973487793L, -579480295743L, 16430785130961L, 39330324946401L, 3935927565041L, 55523837974785L, 17014677604369L, -6696604575711L, -12431751833295L, 14269142784833L}, - {-8032964665055L, 21247545045553L, 30929614226497L, 38962464794449L, 4709664238433L, 46931283075185L, 5116035389057L, 25432913878417L, 13768716371361L, -8484093305167L, -5787236730687L, -5382118136879L, -12479184539679L, 8488349265137L, -33497656644863L, -19141840389615L, 13977842297377L, 4331186424625L, -15699184980671L, 27715581108305L}, - {4988218521118L, 12616703326718L, -21204778378274L, -729956697154L, -24269072369250L, -33943758228098L, -41702548156578L, 5942270699326L, -10232590131938L, -1083939647234L, -45758359739682L, -12708051193154L, 12552936562846L, -10046183846786L, -8702244465058L, 11381428035134L, 16650379494430L, 13944071383038L, 22893499623902L, -28409737139778L}, - {10859897282794L, -16009052371574L, -28077257042902L, 21097912872138L, -206584942742L, 3730747636746L, 25181579293354L, -20380089126070L, 27191160511978L, -7834730081654L, -18843310182102L, 8168779438538L, 8388211764330L, -14474887821046L, -9054197428310L, -8396358786998L, 1437819853546L, 12575312994186L, -11470762766806L, 19726741079754L}, - {-7785498351601L, 31356985997823L, 9909996108527L, -2817590650145L, -35685247940145L, 5288384100287L, 3640951362735L, 7298985169055L, -7100594185329L, 3894496912767L, 18834937831023L, -3750473468321L, 4118829931855L, 3561000485695L, -34042906421201L, 5619317918751L, 7859936104207L, 20120144351487L, 29419781112303L, -4450764058145L}, - {-15649636543501L, -1908413202397L, -1804244975789L, 26155764302211L, -7805507340621L, 15748335521507L, -34485888812525L, 12610082285635L, -2321680889485L, 7215291256227L, 44027603297491L, 23636070121219L, -7236256904141L, -25012997587869L, -2849669480557L, -17631285738045L, 26616579342067L, -7244259402973L, -6060271105453L, -2521340642173L}, - {-18491400876168L, -4900215517448L, -6830241347976L, 21163840042488L, 16159978118520L, 8593158356216L, -21634197842824L, -4431664618504L, -4381551121544L, 2043191225080L, 38341802238584L, -15917443100168L, -16154482083464L, 13179037980920L, 12206922936440L, 35960063377400L, 28251901052792L, -31724682033416L, 20311095066232L, 24433634684408L}, - {-4844884945495L, -16727797029063L, 3490148401609L, 9661359584601L, 10717868544489L, 13348777617273L, 28592339043849L, 10588371811737L, -2765442277847L, 8602169554873L, -27136636757431L, 7588778513881L, -12754114872727L, 26999493236729L, -25823672861047L, -28601553011175L, -7734381844823L, -12048436164551L, -1942349172023L, 24752019699289L}, - {-14937328018869L, 18082834551803L, -2403011299157L, 23070439929947L, 17344700465931L, -8725186803525L, -943262729877L, 12838792545563L, 7655689591755L, 13889301818747L, 7894717573675L, 20345079906779L, -879696337781L, 657627611707L, 25750462860011L, 7218811563675L, 28387117718859L, -6335132727557L, 40341554437035L, -18369247458469L}, - {6141026202367L, -19291564456977L, -18640159820833L, 6565390987983L, 32484313936063L, 1745196162479L, -13911857960545L, 22895682815119L, 13490667904639L, 1187363088239L, 12794002902879L, -16489025321393L, 9461976038463L, -30568369643217L, 35815397664031L, -10446584481777L, -10587809773057L, -3274582897937L, 4365799500511L, 2437771762127L}, - {-17541499701901L, -18091677238877L, 777749549267L, 36973368814339L, 12312441813043L, 5024920823907L, 10647975635859L, -28706250657341L, 3974671559411L, -2041065388253L, 15379662124627L, -11309664147325L, 26276636102067L, -6915167758877L, -4707210596077L, 7443560238915L, 269939794035L, -14698604981085L, 8977530018771L, 362272646659L}, - {-1386259850433L, 3423168589871L, -16619435989985L, 12373450925839L, 11511687981311L, -4577750951441L, -44635762644513L, 5932736678095L, -3126138837313L, -13089806339153L, 30467539820447L, 1498640112271L, -75452509057L, 10924282772847L, 1194982802783L, -29116057183153L, -32751811546561L, 13522518193967L, -18623108310241L, 6054998756879L}, - {10711311805721L, 1077561689513L, 36740932605753L, 23665386205641L, -8342605339303L, 19521111802345L, 12323744175993L, 10898789119497L, -31652527936103L, 1054227271209L, -17122992478279L, 17802438232649L, -10829462534695L, 35502810688105L, 10721860192249L, 30043314908809L, -4902738940391L, -26106192275799L, -5734346459079L, 10406576366281L}, - {-18091677238877L, 777749549267L, 36973368814339L, 12312441813043L, 5024920823907L, 10647975635859L, -28706250657341L, 3974671559411L, -2041065388253L, 15379662124627L, -11309664147325L, 26276636102067L, -6915167758877L, -4707210596077L, 7443560238915L, 269939794035L, -14698604981085L, 8977530018771L, 362272646659L, 36478988018483L}}; - - static double[][] aLLLinv={{2.13162820728e-14, -1.7763568394e-14, 1.7763568394e-14, 2.48689957516e-14, 3.5527136788e-15, -3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15, -3.5527136788e-15, 3.5527136788e-15, 7.1054273576e-15, 3.5527136788e-15, -2.13162820728e-14, 0.0, -2.13162820728e-14, -3.5527136788e-15, 1.42108547152e-14, -1.06581410364e-14}, - {0.0, 0.0, -7.1054273576e-15, -7.1054273576e-15, -1.06581410364e-14, 3.5527136788e-15, -1.06581410364e-14, 1.06581410364e-14, -7.1054273576e-15, 3.5527136788e-15, 3.5527136788e-15, -1.06581410364e-14, -7.1054273576e-15, -1.06581410364e-14, 1.06581410364e-14, -3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15}, - {-3.5527136788e-15, -3.5527136788e-15, 1.06581410364e-14, 1.06581410364e-14, 3.5527136788e-15, -7.1054273576e-15, 7.1054273576e-15, 0.0, 3.5527136788e-15, -1.42108547152e-14, -7.1054273576e-15, 0.0, 3.5527136788e-15, 0.0, -7.1054273576e-15, 0.0, 0.0, 0.0, 0.0, 3.5527136788e-15}, - {3.5527136788e-15, -3.5527136788e-15, -7.1054273576e-15, -3.5527136788e-15, 0.0, -3.5527136788e-15, -7.1054273576e-15, 7.1054273576e-15, 0.0, 7.1054273576e-15, 0.0, -3.5527136788e-15, 0.0, 0.0, 3.5527136788e-15, 0.0, 7.1054273576e-15, 3.5527136788e-15, 1.06581410364e-14, 0.0}, - {1.42108547152e-14, -3.5527136788e-15, -7.1054273576e-15, 7.1054273576e-15, 0.0, -3.5527136788e-15, -3.5527136788e-15, 7.1054273576e-15, -7.1054273576e-15, -1.06581410364e-14, -7.1054273576e-15, -7.1054273576e-15, 0.0, 7.1054273576e-15, -3.5527136788e-15, -3.5527136788e-15, -3.5527136788e-15, -7.1054273576e-15, 0.0, 0.0}, - {7.1054273576e-15, 0.0, 0.0, 3.5527136788e-15, 7.1054273576e-15, 1.42108547152e-14, -3.5527136788e-15, 3.5527136788e-15, 0.0, 3.5527136788e-15, 7.1054273576e-15, 7.1054273576e-15, -3.5527136788e-15, -7.1054273576e-15, -3.5527136788e-15, 0.0, 0.0, -3.5527136788e-15, 0.0, 0.0}, - {-1.06581410364e-14, 3.5527136788e-15, -1.06581410364e-14, -7.1054273576e-15, -3.5527136788e-15, -3.5527136788e-15, -3.5527136788e-15, 0.0, -7.1054273576e-15, 7.1054273576e-15, 7.1054273576e-15, -7.1054273576e-15, -3.5527136788e-15, 3.5527136788e-15, 7.1054273576e-15, 7.1054273576e-15, 7.1054273576e-15, -3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15}, - {0.0, 7.1054273576e-15, 0.0, -1.06581410364e-14, -3.5527136788e-15, -3.5527136788e-15, 7.1054273576e-15, 3.5527136788e-15, -3.5527136788e-15, -3.5527136788e-15, 3.5527136788e-15, 3.5527136788e-15, -7.1054273576e-15, 3.5527136788e-15, 7.1054273576e-15, 1.06581410364e-14, -7.1054273576e-15, 0.0, 0.0, 0.0}, - {2.13162820728e-14, 0.0, 2.13162820728e-14, -3.5527136788e-15, 3.5527136788e-15, 3.5527136788e-15, 7.1054273576e-15, 7.1054273576e-15, -1.06581410364e-14, -3.5527136788e-15, -1.42108547152e-14, 3.5527136788e-15, -3.5527136788e-15, -1.42108547152e-14, 7.1054273576e-15, -1.7763568394e-14, -1.42108547152e-14, 0.0, -1.42108547152e-14, 3.5527136788e-15}, - {4.26325641456e-14, -2.48689957516e-14, 0.0, 0.0, -3.5527136788e-15, 7.1054273576e-15, -7.1054273576e-15, 7.1054273576e-15, -1.06581410364e-14, -7.1054273576e-15, -7.1054273576e-15, 0.0, -1.06581410364e-14, 3.5527136788e-15, -7.1054273576e-15, -1.7763568394e-14, -1.06581410364e-14, -1.7763568394e-14, -3.5527136788e-15, 7.1054273576e-15}, - {3.5527136788e-15, -3.5527136788e-15, 3.5527136788e-15, 3.5527136788e-15, 0.0, -3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15, -7.1054273576e-15, -3.5527136788e-15, 3.5527136788e-15, 3.5527136788e-15, 3.5527136788e-15, 0.0, -3.5527136788e-15, 0.0, -3.5527136788e-15, 3.5527136788e-15, 0.0, -3.5527136788e-15}, - {3.5527136788e-15, 7.1054273576e-15, 3.5527136788e-15, 0.0, 0.0, 0.0, 3.5527136788e-15, -7.1054273576e-15, -7.1054273576e-15, 3.5527136788e-15, 0.0, 1.06581410364e-14, -7.1054273576e-15, 0.0, 7.1054273576e-15, -7.1054273576e-15, -7.1054273576e-15, 0.0, 3.5527136788e-15, 3.5527136788e-15}, - {-3.5527136788e-15, -3.5527136788e-15, 1.7763568394e-14, 7.1054273576e-15, -7.1054273576e-15, 3.5527136788e-15, 2.13162820728e-14, -7.1054273576e-15, 1.06581410364e-14, -3.5527136788e-15, 0.0, 7.1054273576e-15, -1.06581410364e-14, 0.0, 0.0, 7.1054273576e-15, 7.1054273576e-15, 3.5527136788e-15, -7.1054273576e-15, -3.5527136788e-15}, - {3.5527136788e-15, -7.1054273576e-15, 1.42108547152e-14, 7.1054273576e-15, 3.5527136788e-15, 3.5527136788e-15, 1.42108547152e-14, -3.5527136788e-15, 7.1054273576e-15, -3.5527136788e-15, -7.1054273576e-15, 0.0, 3.5527136788e-15, 3.5527136788e-15, 3.5527136788e-15, -1.06581410364e-14, -7.1054273576e-15, 1.42108547152e-14, -7.1054273576e-15, -3.5527136788e-15}, - {-2.48689957516e-14, 0.0, 0.0, 0.0, 0.0, 3.5527136788e-15, 3.5527136788e-15, -7.1054273576e-15, 1.06581410364e-14, 1.06581410364e-14, 0.0, -3.5527136788e-15, 3.5527136788e-15, -7.1054273576e-15, 1.06581410364e-14, 1.42108547152e-14, 7.1054273576e-15, 1.06581410364e-14, 0.0, 0.0}, - {2.13162820728e-14, 3.5527136788e-15, -7.1054273576e-15, -1.06581410364e-14, 0.0, 0.0, -3.5527136788e-15, 7.1054273576e-15, -1.42108547152e-14, 0.0, 0.0, -3.5527136788e-15, -3.5527136788e-15, -1.06581410364e-14, 0.0, -1.06581410364e-14, -7.1054273576e-15, -1.06581410364e-14, 3.5527136788e-15, 7.1054273576e-15}, - {-1.42108547152e-14, -7.1054273576e-15, 7.1054273576e-15, 1.42108547152e-14, 0.0, -3.5527136788e-15, 1.42108547152e-14, -3.5527136788e-15, 1.7763568394e-14, 0.0, -7.1054273576e-15, 7.1054273576e-15, 1.06581410364e-14, 7.1054273576e-15, -3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15, 0.0, -7.1054273576e-15, -7.1054273576e-15}, - {-3.5527136788e-15, -7.1054273576e-15, -1.06581410364e-14, 7.1054273576e-15, 7.1054273576e-15, -3.5527136788e-15, 3.5527136788e-15, 0.0, 7.1054273576e-15, 7.1054273576e-15, 7.1054273576e-15, -7.1054273576e-15, 3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15, 3.5527136788e-15, -3.5527136788e-15, 7.1054273576e-15, -3.5527136788e-15, 7.1054273576e-15}, - {-7.1054273576e-15, 3.5527136788e-15, 7.1054273576e-15, 1.06581410364e-14, 7.1054273576e-15, 0.0, 0.0, -1.06581410364e-14, 7.1054273576e-15, 0.0, 1.42108547152e-14, 0.0, 1.06581410364e-14, 7.1054273576e-15, 0.0, 1.06581410364e-14, 0.0, 3.5527136788e-15, 3.5527136788e-15, 0.0}, - {-1.7763568394e-14, 0.0, 3.5527136788e-15, 3.5527136788e-15, -7.1054273576e-15, -3.5527136788e-15, 7.1054273576e-15, -7.1054273576e-15, 7.1054273576e-15, 1.06581410364e-14, 7.1054273576e-15, -3.5527136788e-15, 1.06581410364e-14, 7.1054273576e-15, -3.5527136788e-15, 1.42108547152e-14, 0.0, 3.5527136788e-15, 0.0, 3.5527136788e-15}}; - - - static long[] P={0L, 49720483695876L, 137139456763464L, 233987836661708L, 14307911880080L, 83935042429844L, 145080971318744L, 160613567801436L, 33313044635424L, 71300602445348L, 191662796360040L, 35596010767596L, 139814728398000L, 103370737179828L, 120424722284792L, 233843537749372L, 272110203194944L, 20902998949700L, 160211348143240L, 245358588709388L}; - - private static long[] multiply(long[][] matrix, long[] vector) { - int rows = matrix.length; - int columns = matrix[0].length; - - long[] result = new long[rows]; - - for (int row = 0; row < rows; row++) { - long sum = 0; - for (int column = 0; column < columns; column++) { - sum += matrix[column][row]* vector[column]; - } - result[row] = sum; - } - return result; - } - - - private static double[] multiply(double[][] matrix, double[] vector) { - int rows = matrix.length; - int columns = matrix[0].length; - - double[] result = new double[rows]; - - for (int row = 0; row < rows; row++) { - double sum = 0; - for (int column = 0; column < columns; column++) { - sum += matrix[column][row]* vector[column]; - } - result[row] = sum; - } - return result; - } - - - private static long[] multiply(long[] vector, long scalar) { - long[] result = new long[vector.length]; - - for (int i = 0; i < vector.length; i++) { - result[i]=vector[i]*scalar; - } - return result; - } - - - private static long[] add(long[] vectorA,long[] vectorB) - { - long[] result = new long[vectorA.length]; - for(int i=0;imax[i]) - return false; - return true; - } - private static boolean getNextPoint(long[] components,long[] v, long[][] A,long[] mins,long[] maxs)//mutates components and v - { - long[] v_ref=v; - for(int index=0;index maxs[index]) - { - components[index] = mins[index]; - v=sub(v,multiply(A[index],maxs[index]-mins[index]+1)); - } - else - { - for(int i=0;i dumbiterate(long[] mins, long[] maxs, long[][] A/*aLLL matrix*/, long[] P/*arbitary lattice point*/, long[] LowerBounds, long[] UpperBounds) - { - long[] temp = mins.clone(); - long[] v=add(multiply(A,temp),P); - List results=new ArrayList<>(); - while(true) - { - if(isInRegion(v,LowerBounds,UpperBounds)) - { - EnchantmentCracker.LOGGER.info("Found possible seed: " + Arrays.toString(v)); - results.add(v.clone()); - } - if(!getNextPoint(temp, v, A, mins, maxs)) - return results; - } - } - - private static List findAllSeedTuplesInBB(long[] UpperBounds,long[] LowerBounds) - { - int N=UpperBounds.length; - double[] min = new double[N]; - double[] max = new double[N]; - for(int x=0;x a=findAllSeedTuplesInBB(UpperBounds,LowerBounds); - if(a.size()==0) - return 0; - return lcg(a.get(0)[bits.length-1]);//returns the seed after - } -} - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/net/cortex/clientAddon/cracker/SeedCrackTask.java b/src/main/java/net/cortex/clientAddon/cracker/SeedCrackTask.java deleted file mode 100644 index 1607d68dc..000000000 --- a/src/main/java/net/cortex/clientAddon/cracker/SeedCrackTask.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.cortex.clientAddon.cracker; - -import net.earthcomputer.clientcommands.Configs; -import net.earthcomputer.clientcommands.features.PlayerRandCracker; -import net.earthcomputer.clientcommands.task.SimpleTask; - -public class SeedCrackTask extends SimpleTask { - @Override - public boolean condition() { - return Configs.playerCrackState == PlayerRandCracker.CrackState.CRACKING; - } - - @Override - protected void onTick() { - } - - @Override - public void onCompleted() { - if (condition()) { - Configs.playerCrackState = PlayerRandCracker.CrackState.UNCRACKED; - } - SeedCracker.currentTask = null; - } -} diff --git a/src/main/java/net/earthcomputer/clientcommands/command/CrackRNGCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/CrackRNGCommand.java index 16e4fbcab..1cee65a9e 100644 --- a/src/main/java/net/earthcomputer/clientcommands/command/CrackRNGCommand.java +++ b/src/main/java/net/earthcomputer/clientcommands/command/CrackRNGCommand.java @@ -2,9 +2,9 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.CommandDispatcher; -import net.cortex.clientAddon.cracker.SeedCracker; import net.earthcomputer.clientcommands.Configs; import net.earthcomputer.clientcommands.ServerBrandManager; +import net.earthcomputer.clientcommands.features.CCrackRng; import net.earthcomputer.clientcommands.features.PlayerRandCracker; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.network.chat.Component; @@ -20,7 +20,7 @@ public static void register(CommandDispatcher dispatc private static int crackPlayerRNG(FabricClientCommandSource source) { ServerBrandManager.rngWarning(); - SeedCracker.crack(seed -> { + CCrackRng.crack(seed -> { source.sendFeedback(Component.translatable("commands.ccrackrng.success", Long.toHexString(seed))); PlayerRandCracker.setSeed(seed); Configs.playerCrackState = PlayerRandCracker.CrackState.CRACKED; diff --git a/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/CCrackRng.java similarity index 57% rename from src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java rename to src/main/java/net/earthcomputer/clientcommands/features/CCrackRng.java index 13e858b05..d49b6e871 100644 --- a/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/CCrackRng.java @@ -1,12 +1,8 @@ -package net.cortex.clientAddon.cracker; +package net.earthcomputer.clientcommands.features; import net.earthcomputer.clientcommands.Configs; import net.earthcomputer.clientcommands.command.ClientCommandHelper; -import net.earthcomputer.clientcommands.features.EnchantmentCracker; -import net.earthcomputer.clientcommands.features.PlayerRandCracker; -import net.earthcomputer.clientcommands.mixin.LegacyRandomSourceAccessor; import net.earthcomputer.clientcommands.task.ItemThrowTask; -import net.earthcomputer.clientcommands.task.LongTask; import net.earthcomputer.clientcommands.task.TaskManager; import net.minecraft.ChatFormatting; import net.minecraft.client.Minecraft; @@ -14,29 +10,32 @@ import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; -import net.minecraft.util.RandomSource; -public class SeedCracker { - public interface OnCrack {void callback(long seed); } +public class CCrackRng { + private static final float MAX_ERROR = 0.00883889f; + + @FunctionalInterface + public interface OnCrack { + void callback(long seed); + } public static OnCrack callback; - public static long[] bits=new long[20]; + public static float[] nextFloats = new float[10]; public static int expectedItems=0; - public static LongTask currentTask; private static int attemptCount = 0; - private static final int MAX_ATTEMPTS = 10; + private static final int MAX_ATTEMPTS = 5; private static String currentTaskName = null; - private static String throwItems() - { + private static String throwItems() { LocalPlayer player = Minecraft.getInstance().player; + assert player != null; player.moveTo(player.getX(), player.getY(), player.getZ(), 0, 90); - Minecraft.getInstance().getConnection().send(new ServerboundMovePlayerPacket.Rot(0, 90, true)); // point to correct location - ItemThrowTask task = new ItemThrowTask(20) { + player.connection.send(new ServerboundMovePlayerPacket.Rot(0, 90, true)); // point to correct location + ItemThrowTask task = new ItemThrowTask(10) { @Override protected void onSuccess() { - SeedCracker.attemptCrack(); + CCrackRng.attemptCrack(); } @Override @@ -62,10 +61,20 @@ protected void onItemSpawn(ClientboundAddEntityPacket packet) { public static void attemptCrack() { - long seed= Lattice_cracker.crack(SeedCracker.bits); - - if(seed==0)//Basicaly if seed is zero it means it failed to try to crack again - { + long[] seeds = CCrackRngGen.getSeeds( + Math.max(0, nextFloats[0] - MAX_ERROR), Math.min(1, nextFloats[0] + MAX_ERROR), + Math.max(0, nextFloats[1] - MAX_ERROR), Math.min(1, nextFloats[1] + MAX_ERROR), + Math.max(0, nextFloats[2] - MAX_ERROR), Math.min(1, nextFloats[2] + MAX_ERROR), + Math.max(0, nextFloats[3] - MAX_ERROR), Math.min(1, nextFloats[3] + MAX_ERROR), + Math.max(0, nextFloats[4] - MAX_ERROR), Math.min(1, nextFloats[4] + MAX_ERROR), + Math.max(0, nextFloats[5] - MAX_ERROR), Math.min(1, nextFloats[5] + MAX_ERROR), + Math.max(0, nextFloats[6] - MAX_ERROR), Math.min(1, nextFloats[6] + MAX_ERROR), + Math.max(0, nextFloats[7] - MAX_ERROR), Math.min(1, nextFloats[7] + MAX_ERROR), + Math.max(0, nextFloats[8] - MAX_ERROR), Math.min(1, nextFloats[8] + MAX_ERROR), + Math.max(0, nextFloats[9] - MAX_ERROR), Math.min(1, nextFloats[9] + MAX_ERROR) + ).toArray(); + + if (seeds.length != 1) { attemptCount++; if (attemptCount > MAX_ATTEMPTS) { ClientCommandHelper.sendError(Component.translatable("commands.ccrackrng.failed")); @@ -73,30 +82,13 @@ public static void attemptCrack() Configs.playerCrackState = PlayerRandCracker.CrackState.UNCRACKED; currentTaskName = null; } else { - SeedCracker.doCrack(SeedCracker.callback); + CCrackRng.doCrack(CCrackRng.callback); } return; } - //Else, got a seed Configs.playerCrackState = PlayerRandCracker.CrackState.CRACKED; - - RandomSource rand=RandomSource.create(seed ^ 0x5deece66dL); - rand.nextFloat(); - rand.nextFloat(); - //rand.nextFloat(); - - /* - for(int i=0;i<13;i++) { - long x = (((long) (rand.nextFloat() * ((float) (1 << 24)))) >> (24 - 4))&0xFL; - System.out.print("Expected: "+padLeftZeros(Long.toBinaryString(x), 4)+" "); - System.out.print(padLeftZeros(Long.toBinaryString((((long) (rand.nextFloat() * ((float) (1 << 24)))) >> (24 - 4))&0xFL), 4)+" "); - System.out.print(padLeftZeros(Long.toBinaryString((((long) (rand.nextFloat() * ((float) (1 << 24)))) >> (24 - 4))&0xFL), 4)+" "); - System.out.print(padLeftZeros(Long.toBinaryString((((long) (rand.nextFloat() * ((float) (1 << 24)))) >> (24 - 4))&0xFL), 4)+" \n"); - }*/ - - currentTaskName = null; - callback.callback(((LegacyRandomSourceAccessor) rand).getSeed().get());//extract seed and call callback + callback.callback(seeds[0]); } public static void crack(OnCrack callback) { @@ -109,7 +101,7 @@ private static void doCrack(OnCrack Callback){ ClientCommandHelper.addOverlayMessage(Component.translatable("commands.ccrackrng.retries", attemptCount, MAX_ATTEMPTS), 100); currentTaskName = throwItems(); Configs.playerCrackState = PlayerRandCracker.CrackState.CRACKING; - expectedItems = 20; + expectedItems = 10; if (attemptCount == 1) { Component message = Component.translatable("commands.ccrackrng.starting") .append(" ") @@ -120,12 +112,10 @@ private static void doCrack(OnCrack Callback){ public static void onEntityCreation(ClientboundAddEntityPacket packet) { if (Configs.playerCrackState == PlayerRandCracker.CrackState.CRACKING) { - if (SeedCracker.expectedItems > 0) { - long rand_val = (long) ((Math.atan2(packet.getZa(), packet.getXa()) + Math.PI) / (Math.PI * 2) * ((float) (1 << 24))); - long top_bits = rand_val; - short value = (short) (((top_bits >> (24 - 4)) ^ 0x8L )&0xFL);//INSTEAD OF ^0x8L MAYBE DO +math.pi OR SOMETHING ELSE - SeedCracker.bits[20-SeedCracker.expectedItems]=(long)value;//could be improved - SeedCracker.expectedItems--; + if (CCrackRng.expectedItems > 0) { + float nextFloat = (float) Math.sqrt(packet.getXa() * packet.getXa() + packet.getZa() * packet.getZa()) * 50f; + CCrackRng.nextFloats[10 - CCrackRng.expectedItems] = nextFloat; + CCrackRng.expectedItems--; } } } diff --git a/src/main/java/net/earthcomputer/clientcommands/features/CCrackRngGen.java b/src/main/java/net/earthcomputer/clientcommands/features/CCrackRngGen.java new file mode 100644 index 000000000..74c8c23fd --- /dev/null +++ b/src/main/java/net/earthcomputer/clientcommands/features/CCrackRngGen.java @@ -0,0 +1,114 @@ +package net.earthcomputer.clientcommands.features; + +import com.seedfinding.latticg.math.component.BigMatrix; +import com.seedfinding.latticg.math.component.BigVector; +import com.seedfinding.latticg.math.lattice.enumerate.EnumerateRt; +import com.seedfinding.latticg.math.optimize.Optimize; +import com.seedfinding.latticg.util.DeserializeRt; +import java.util.stream.LongStream; + +// CLASS GENERATED BY LATTICG, DO NOT EDIT MANUALLY +public final class CCrackRngGen { + private CCrackRngGen() {} + private static final BigMatrix BASIS = DeserializeRt.mat( + "ਊ\ued95膕쩅˴ꋄꊝ\ue001ʁ銧릿挂\ua7ebꇽ\ue702ʬ\uf198믅씁˚辑톹鄁˝ꊘ\udae2\udf02ʝ\ue7bf\ue0b1\ue602ˬ삭겦褂ʎ뇽\udeb1윁ʭ鮊\ue8cd쨂ˍ雏ꧮᄂ膲\uf5ba霆ʇ풁菆밁ˬ꺆\uf3e6" + + "ꔁ˺횪钖܂\ue4e9\ude80\uf6afȂ\udda2飚\ue2dfȂ곶\ue5ecꌱʓ\ud999쿀稂钇잕ꄥ˴鞹킔ं肮颖鋀Ă\ue788鶆뎩Ă계\uf0b1谫˧귁臝숃ʤ뺎螴鈁ˤ\ue9de胶꼂ʕﲥꓵᴂ캸싲\ue4a4Ђ궮뢉难Ă췑뗧\uf4fc" + + "Ă臲뷒草ʺ뛪ꚪ윁ˬ뇲\uf19cꈁʺ솋飖츁ˤ\udaef\uea8d\ue001ʤ뺎螴鈁ʬ\ue994궶쐂ʮꚍ\ue683ᜂ铄鲎낺Ȃ\uf4acꆚ\uef89Ă胮잶贵ʧ횤쿔鸃ʬ\uf7d6\udab2fiʧ鯈ꮴ頂ʤ뾋쯡搂\ue4da\uefea跠Ă\ueca6" + + "톀\uf19aĂ\uf3cf藪谘˔\udeba\uda92茁ʴ鏋뺌퐂ʀ컩铚\uda01ʇ\uef9bꂸ㜂\uec94馷ﻏĂ\ufafb퇮\ue89d̂鶔薚켑ʤ뾋쯡搂겼襁鉵ˮ闵\ueb9bꨂ˭\ude98\uf2fb茁˴\ue1a4ꛝ愂肮\ue7e3鰞" + + "˧폤\ufae2똁ʬ諤쯬켂ʚ쟐雂䄂\udd9f馕ሂ鶔薚켑ʕ훔힢蔂ˎ鞡룩\uf201ʭ\uf4c8웰㸂뒘\udb83뫆Ă臲ﺈ\ue485Ђ못ᄋ\udaecȂ閨\uedf3藧Ă쟹\ued91쐜ˤ鲈\uecff갂˝龙锒ʬ\uefae뫇圂껵\ud9a8ﺹĂ\uede1" + + "\uf0e8\ue0a7Ȃ跉铫꾞Ă膒覦︕ʧ膉黖漂햂탎鲮̂Ꞇꎪv˝\uded7軟蔁ˤ鲈\uecff갂ˬ貀횘ꈁ˳郍킇툂ʭ\ua7db賧\u0602뒽ꊽ钾Ȃ胎裐ꋃȂ蝹킜탚Ă\uecfa\uf6af验Ă\ufae0\udf89衕ʝ鋠횅褂˝\uded7軟蔁˕ﶵ" + + "싳옃ʓ뮈ꚋ\uf101Ȁ"); + private static final BigMatrix ROOT_INV = DeserializeRt.mat( + "ਊ\u0380肀肀耐ހ肀肀耠ᎀ肀肀肀ċ肀肀肀䀆肀肀肀䀂肀肀肀䀏肀肀肀䀋肀肀肀老\u0b80肀肀耠\u0b80肀肀聀ڀ肀肀聀ኀ肀肀肀Ć肀肀肀老ྀ肀肀肀Ě肀肀肀老\u0e80肀肀聀\u0380肀肀耠ኀ肀肀聀 肀肀肀Ģ肀肀肀老\u0380肀肀耠᪀肀肀肀Ģ肀" + + "肀肀老ʀ肀肀聀ᎀ肀肀肀Ě肀肀肀老ᮀ肀肀聀ᾀ肀肀肀ă肀肀肀䀖肀肀肀老ʀ肀肀耠ྀ肀肀肀Ă肀肀肀ည肀肀肀 肀肀肀 肀肀肀ဟ肀肀肀老\u0e80肀肀肀ă肀肀肀ဦ肀肀肀老ʀ肀肀耐\u0b80肀肀肀ć肀肀肀老ڀ肀肀耐⊀肀肀肀ě肀肀肀老ʀ肀肀耈\u0380肀肀肀ď" + + "肀肀肀老ڀ肀肀耠\u0b80肀肀聀ހ肀肀肀ģ肀肀肀老\u0380肀肀耠ក肀肀肀Ċ肀肀肀 肀肀肀䀃肀肀肀 ț肀肀肀老➀肀肀肀Ħ肀肀肀老ʀ肀肀聀\2ʀ肀肀肀Ċ肀肀肀䀋肀肀肀䀎肀肀肀老\u0380肀肀耐\u0380肀肀聀ྀ肀肀肀ă肀肀肀ࠀȎ肀肀肀䀖肀肀肀老" + + "ڀ肀肀肀Ă肀肀肀ࠆ肀肀肀䀞肀肀肀老ڀ肀肀聀Ẁ肀肀肀Ć肀肀肀䀆肀肀肀䀆肀肀肀 肀肀肀ည肀肀肀老⾀肀肀肀ă肀肀肀老ʀ肀肀耠\2ʀ肀肀耠\u0380肀肀耠᪀肀肀肀ć肀肀肀䀟肀肀肀老ڀ肀肀聀\u0a80肀肀肀ă肀肀肀老ހ肀肀聀ހ肀肀耠"); + private static final BigVector ORIGIN = DeserializeRt.vec( + "\u0a00ʈ뒦벎츖ʐ駗질긾ʘ뾖黱덪ʠ뚊ꃪ쀆ʨ躛\ue6d4锦ʰ힒볩ﱁʸꆽ\uaaf8葉ˀﲈ쎉錏ˈ\uf8a5\uf19e똠Ȁ"); + private static final BigVector ROOT_ORIGIN = DeserializeRt.vec( + "\u0ad7醌뗤ꪜހ肀肀耠횑貵\ue4aaﰃ肀肀肀‟ࣞ뚂\uf1e0뮚Ҁ肀肀耠骤蟓ꊳ輆肀肀肀⃟뚂\uf1e0뭲肀肀肀ဦ\u089aꒇ펢뎧ڀ肀肀耠\udeb6英\ue0bb㺀肀肀耐\udfb6英\ue0bbʀ肀肀耠"); + + /** + * Finds all values of {@code seed} that could produce the given results in the following code: + *
{@code
+     *    Random rand = new Random(seed ^ 0x5DEECE66DL);
+     *    // Go backwards by 39 random calls
+     *    float nextFloat1 = rand.nextFloat();
+     *    assert nextFloat1 >= minNextFloat1 && nextFloat1 < maxNextFloat1;
+     *    // Skip 3 random calls
+     *    float nextFloat2 = rand.nextFloat();
+     *    assert nextFloat2 >= minNextFloat2 && nextFloat2 < maxNextFloat2;
+     *    // Skip 3 random calls
+     *    float nextFloat3 = rand.nextFloat();
+     *    assert nextFloat3 >= minNextFloat3 && nextFloat3 < maxNextFloat3;
+     *    // Skip 3 random calls
+     *    float nextFloat4 = rand.nextFloat();
+     *    assert nextFloat4 >= minNextFloat4 && nextFloat4 < maxNextFloat4;
+     *    // Skip 3 random calls
+     *    float nextFloat5 = rand.nextFloat();
+     *    assert nextFloat5 >= minNextFloat5 && nextFloat5 < maxNextFloat5;
+     *    // Skip 3 random calls
+     *    float nextFloat6 = rand.nextFloat();
+     *    assert nextFloat6 >= minNextFloat6 && nextFloat6 < maxNextFloat6;
+     *    // Skip 3 random calls
+     *    float nextFloat7 = rand.nextFloat();
+     *    assert nextFloat7 >= minNextFloat7 && nextFloat7 < maxNextFloat7;
+     *    // Skip 3 random calls
+     *    float nextFloat8 = rand.nextFloat();
+     *    assert nextFloat8 >= minNextFloat8 && nextFloat8 < maxNextFloat8;
+     *    // Skip 3 random calls
+     *    float nextFloat9 = rand.nextFloat();
+     *    assert nextFloat9 >= minNextFloat9 && nextFloat9 < maxNextFloat9;
+     *    // Skip 3 random calls
+     *    float nextFloat10 = rand.nextFloat();
+     *    assert nextFloat10 >= minNextFloat10 && nextFloat10 < maxNextFloat10;
+     * }
+ * + *

This code skips 0.000000% of seeds in its search. + */ + public static LongStream getSeeds(float minNextFloat1, float maxNextFloat1, float minNextFloat2, float maxNextFloat2, float minNextFloat3, float maxNextFloat3, float minNextFloat4, float maxNextFloat4, float minNextFloat5, float maxNextFloat5, float minNextFloat6, float maxNextFloat6, float minNextFloat7, float maxNextFloat7, float minNextFloat8, float maxNextFloat8, float minNextFloat9, float maxNextFloat9, float minNextFloat10, float maxNextFloat10) { + Optimize.Builder builder = Optimize.Builder.ofSize(10); + if (minNextFloat1 >= maxNextFloat1) { + return LongStream.empty(); + } + builder.withLowerBound(0, (long) (minNextFloat1 * 0x1.0p24f) << 24).withUpperBound(0, (long) (maxNextFloat1 * 0x1.0p24f) << 24); + if (minNextFloat2 >= maxNextFloat2) { + return LongStream.empty(); + } + builder.withLowerBound(1, (long) (minNextFloat2 * 0x1.0p24f) << 24).withUpperBound(1, (long) (maxNextFloat2 * 0x1.0p24f) << 24); + if (minNextFloat3 >= maxNextFloat3) { + return LongStream.empty(); + } + builder.withLowerBound(2, (long) (minNextFloat3 * 0x1.0p24f) << 24).withUpperBound(2, (long) (maxNextFloat3 * 0x1.0p24f) << 24); + if (minNextFloat4 >= maxNextFloat4) { + return LongStream.empty(); + } + builder.withLowerBound(3, (long) (minNextFloat4 * 0x1.0p24f) << 24).withUpperBound(3, (long) (maxNextFloat4 * 0x1.0p24f) << 24); + if (minNextFloat5 >= maxNextFloat5) { + return LongStream.empty(); + } + builder.withLowerBound(4, (long) (minNextFloat5 * 0x1.0p24f) << 24).withUpperBound(4, (long) (maxNextFloat5 * 0x1.0p24f) << 24); + if (minNextFloat6 >= maxNextFloat6) { + return LongStream.empty(); + } + builder.withLowerBound(5, (long) (minNextFloat6 * 0x1.0p24f) << 24).withUpperBound(5, (long) (maxNextFloat6 * 0x1.0p24f) << 24); + if (minNextFloat7 >= maxNextFloat7) { + return LongStream.empty(); + } + builder.withLowerBound(6, (long) (minNextFloat7 * 0x1.0p24f) << 24).withUpperBound(6, (long) (maxNextFloat7 * 0x1.0p24f) << 24); + if (minNextFloat8 >= maxNextFloat8) { + return LongStream.empty(); + } + builder.withLowerBound(7, (long) (minNextFloat8 * 0x1.0p24f) << 24).withUpperBound(7, (long) (maxNextFloat8 * 0x1.0p24f) << 24); + if (minNextFloat9 >= maxNextFloat9) { + return LongStream.empty(); + } + builder.withLowerBound(8, (long) (minNextFloat9 * 0x1.0p24f) << 24).withUpperBound(8, (long) (maxNextFloat9 * 0x1.0p24f) << 24); + if (minNextFloat10 >= maxNextFloat10) { + return LongStream.empty(); + } + builder.withLowerBound(9, (long) (minNextFloat10 * 0x1.0p24f) << 24).withUpperBound(9, (long) (maxNextFloat10 * 0x1.0p24f) << 24); + return EnumerateRt.enumerate(BASIS, ORIGIN, builder.build(), ROOT_INV, ROOT_ORIGIN) + .mapToLong(vec -> (vec.get(0).getNumerator().longValue() * 0x641598c21879L + 0x60dd589d4b7eL) & ((1L << 48) - 1)); + } +}