From dfae7e316b28e77d34db61896638294d85903f81 Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 21:39:03 +1000 Subject: [PATCH 01/15] made rng constants and getSeed public --- .../clientcommands/features/EnchantmentCracker.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java index 080940655..7cbf7bcd0 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java @@ -287,9 +287,9 @@ public static void drawEnchantmentGUIOverlay() { * This section is in charge of the logic of the cracking */ - private static final long MULTIPLIER = 0x5deece66dL; - private static final long ADDEND = 0xbL; - private static final long MASK = (1L << 48) - 1; + public static final long MULTIPLIER = 0x5deece66dL; + public static final long ADDEND = 0xbL; + public static final long MASK = (1L << 48) - 1; private static Set possibleXPSeeds = new HashSet<>(1 << 20); private static boolean onFirstXPSeed = true; @@ -763,7 +763,7 @@ public static List getEnchantmentsInTable(int slot) { } RANDOM_SEED.setAccessible(true); } - private static long getSeed(Random rand) { + public static long getSeed(Random rand) { try { return ((AtomicLong) RANDOM_SEED.get(rand)).get(); } catch (ReflectiveOperationException e) { @@ -787,4 +787,4 @@ public String asString() { } } -} \ No newline at end of file +} From f4ac6caacd25705c5e089563824b3d9739198440 Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 12:52:34 +0100 Subject: [PATCH 02/15] Added cracker mixin --- .../clientAddon/mixin/S2CEntityCreation.java | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java diff --git a/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java b/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java new file mode 100644 index 000000000..a05006c31 --- /dev/null +++ b/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java @@ -0,0 +1,82 @@ +package net.cortex.clientAddon.mixin; + + +import net.cortex.clientAddon.cracker.SeedCracker; +import net.cortex.clientAddon.cracker.Lattice_cracker; +import net.earthcomputer.clientcommands.features.EnchantmentCracker; +import net.minecraft.client.network.packet.EntitySpawnS2CPacket; +import net.minecraft.entity.EntityType; +import net.minecraft.util.PacketByteBuf; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + +import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; + +@Mixin(EntitySpawnS2CPacket.class) +public abstract class S2CEntityCreation { + @Shadow + public abstract double getVelocityz(); + + @Shadow + public abstract double getVelocityX(); + + @Shadow + public abstract int getId(); + + @Shadow + public abstract EntityType getEntityTypeId(); + + @Inject(at = @At("TAIL"), method = "read") + public void read(PacketByteBuf packetByteBuf_1, CallbackInfo ci) throws IOException + { + if(this.getEntityTypeId() == EntityType.ITEM && SeedCracker.expectedItems>0) { + + long rand_val = (long) ((Math.atan2(this.getVelocityz(), this.getVelocityX()) + 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(SeedCracker.expectedItems==0&&SeedCracker.cracking)//if its the last item + { + SeedCracker.attemptCrack(); + } + else + { + long rand_val = (long) ((Math.atan2(this.getVelocityz(), this.getVelocityX()) + Math.PI) / (Math.PI * 2) * ((float) (1 << 24))); + long top_bits = rand_val; + short value = (short) ((top_bits >> (24 - 4)) ^ 0x8L); + System.out.println("Entity item spawn: Top 4 bits of direction: "+padLeftZeros(Long.toBinaryString(value), 4)); + } + } + + + + + + + + + + public String padLeftZeros(String inputString, int length) { + if (inputString.length() >= length) { + return inputString; + } + StringBuilder sb = new StringBuilder(); + while (sb.length() < length - inputString.length()) { + sb.append('0'); + } + sb.append(inputString); + + return sb.toString(); + } +} From 5cbc23ed645e2558cc2d0021cc90579f8fb9c9cd Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 12:53:50 +0100 Subject: [PATCH 03/15] Added the core lattice cracker and core cracker class --- .../clientAddon/cracker/Lattice_cracker.java | 253 ++++++++++++++++++ .../clientAddon/cracker/SeedCracker.java | 83 ++++++ 2 files changed, 336 insertions(+) create mode 100644 src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java create mode 100644 src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java diff --git a/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java b/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java new file mode 100644 index 000000000..83c967860 --- /dev/null +++ b/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java @@ -0,0 +1,253 @@ +package net.cortex.clientAddon.cracker; + +import java.util.ArrayList; +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)) + { + System.out.println("404 NOT FOUND"); + 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/SeedCracker.java b/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java new file mode 100644 index 000000000..5c89c1f34 --- /dev/null +++ b/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java @@ -0,0 +1,83 @@ +package net.cortex.clientAddon.cracker; + +import net.earthcomputer.clientcommands.features.EnchantmentCracker; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.network.MessageType; +import net.minecraft.server.network.packet.PlayerActionC2SPacket; +import net.minecraft.server.network.packet.PlayerMoveC2SPacket; +import net.minecraft.text.LiteralText; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; + +import java.util.Random; + +import static net.earthcomputer.clientcommands.command.CrackPlayerRNGUsingItemsCommand.padLeftZeros; +import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; + +public class SeedCracker { + public interface OnCrack {void callback(long seed); } + + + public static OnCrack callback; + public static long[] bits=new long[20]; + public static int expectedItems=0; + public static boolean cracking=false; + + //returns True on success or false on failer + private static boolean throwItems() + { + MinecraftClient minecraft = MinecraftClient.getInstance(); + if ( minecraft.player.inventory.getMainHandStack().getCount()>19) {//check that have at least 19 items in current hand (doesnt seem to work) + System.out.println("hand item count: "+(minecraft.player.inventory.getMainHandStack().getCount())); + ClientPlayNetworkHandler networkHandler = minecraft.getNetworkHandler(); + networkHandler.sendPacket(new PlayerMoveC2SPacket.LookOnly(0.0f, 90.0f, true)); //point to correct location + for (int i = 0; i < 20; i++)//drop 20 items + test items+13; + networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.DROP_ITEM, BlockPos.ORIGIN, Direction.DOWN)); + } + else { + minecraft.inGameHud.addChatMessage(MessageType.CHAT.GAME_INFO, new LiteralText(Formatting.RED+"Unable to use rng SeedCracker |not enough items in player hand|")); + System.out.println("Unable to use rng SeedCracker |not enough items|"); + return false; + } + return true; + } + public static void attemptCrack() + { + cracking=false; + long seed= Lattice_cracker.crack(SeedCracker.bits); + + if(seed==0)//Basicaly if seed is zero it means it failed to try to crack again + { + SeedCracker.crack(SeedCracker.callback); + return; + } + //Else, got a seed + + Random rand=new Random(); + rand.setSeed(seed ^ MULTIPLIER); + 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"); + }*/ + + callback.callback(EnchantmentCracker.getSeed(rand));//extract seed and call callback + } + public static void crack(OnCrack Callback){ + callback=Callback; + if(throwItems()) + { + cracking=true; + expectedItems=20; + } + } +} From bbe2087ec624da3a55662ff38d62b8504d751728 Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 21:59:03 +1000 Subject: [PATCH 04/15] added client_addon --- src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c162f62bd..49a9fb9c6 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -11,6 +11,6 @@ "fabric": "*" }, "mixins": { - "client": "mixins.clientcommands.json" + "client": ["mixins.clientcommands.json","mixins.client_addon.json"] } } From 949d0f5f58ea41783cb10f2e84ef2220bc7b55be Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 22:01:26 +1000 Subject: [PATCH 05/15] added mixin file --- src/main/resources/mixin.client_addon.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/resources/mixin.client_addon.json diff --git a/src/main/resources/mixin.client_addon.json b/src/main/resources/mixin.client_addon.json new file mode 100644 index 000000000..1cd24f246 --- /dev/null +++ b/src/main/resources/mixin.client_addon.json @@ -0,0 +1,17 @@ +{ + "required": true, + "package": "net.cortex.clientAddon.mixin", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "S2CEntityCreation", + "ClientPlayer", + "GameRendererInjection", + "EntityRendererInjection", + "MixinKeyboardInput", + "KeyPressOverride", + "BlockUpdate" + ], + "injectors": { + "defaultRequire": 1 + } +} From cf448fb344592fb6089b67c919556a5da249ebc3 Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 22:02:24 +1000 Subject: [PATCH 06/15] Removed oopsie --- src/main/resources/mixin.client_addon.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/main/resources/mixin.client_addon.json b/src/main/resources/mixin.client_addon.json index 1cd24f246..e1c39fb28 100644 --- a/src/main/resources/mixin.client_addon.json +++ b/src/main/resources/mixin.client_addon.json @@ -3,13 +3,7 @@ "package": "net.cortex.clientAddon.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ - "S2CEntityCreation", - "ClientPlayer", - "GameRendererInjection", - "EntityRendererInjection", - "MixinKeyboardInput", - "KeyPressOverride", - "BlockUpdate" + "S2CEntityCreation" ], "injectors": { "defaultRequire": 1 From 90678ea619764b2d0bf182561daaeac16aaf1e9c Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 22:06:01 +1000 Subject: [PATCH 07/15] made playerRand public --- .../clientcommands/features/EnchantmentCracker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java index 7cbf7bcd0..56b81ede1 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java @@ -294,7 +294,7 @@ public static void drawEnchantmentGUIOverlay() { private static Set possibleXPSeeds = new HashSet<>(1 << 20); private static boolean onFirstXPSeed = true; private static Set possiblePlayerRandSeeds = new HashSet<>(1 << 16); - private static Random playerRand = new Random(); + public static Random playerRand = new Random(); private static boolean doneEnchantment = false; public static BlockPos enchantingTablePos = null; From 15d0bea0ef55914ef08c35fe191bb1f92d656bcf Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 22:11:34 +1000 Subject: [PATCH 08/15] Update S2CEntityCreation.java --- .../java/net/cortex/clientAddon/mixin/S2CEntityCreation.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java b/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java index a05006c31..9eb2b6c72 100644 --- a/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java +++ b/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java @@ -50,13 +50,14 @@ public void read(PacketByteBuf packetByteBuf_1, CallbackInfo ci) throws IOExcept { SeedCracker.attemptCrack(); } + /* else { long rand_val = (long) ((Math.atan2(this.getVelocityz(), this.getVelocityX()) + Math.PI) / (Math.PI * 2) * ((float) (1 << 24))); long top_bits = rand_val; short value = (short) ((top_bits >> (24 - 4)) ^ 0x8L); System.out.println("Entity item spawn: Top 4 bits of direction: "+padLeftZeros(Long.toBinaryString(value), 4)); - } + }*/ } From bd4289bf1da2de690952f4322096aac5af1ff3fb Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 22:13:36 +1000 Subject: [PATCH 09/15] Compile fix --- src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java b/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java index 5c89c1f34..883914b18 100644 --- a/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java +++ b/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java @@ -12,8 +12,6 @@ import net.minecraft.util.math.Direction; import java.util.Random; - -import static net.earthcomputer.clientcommands.command.CrackPlayerRNGUsingItemsCommand.padLeftZeros; import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; public class SeedCracker { From f6984aaaaacb0bebed00c9a5b7ce185f81e1165b Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 22:57:52 +1000 Subject: [PATCH 10/15] fixed naming oopsie --- .../{mixin.client_addon.json => mixins.client_addon.json} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/{mixin.client_addon.json => mixins.client_addon.json} (100%) diff --git a/src/main/resources/mixin.client_addon.json b/src/main/resources/mixins.client_addon.json similarity index 100% rename from src/main/resources/mixin.client_addon.json rename to src/main/resources/mixins.client_addon.json From 66c6848c166ce1fb42421b1cb34cb64e3f99a8ba Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 13:58:39 +0100 Subject: [PATCH 11/15] crack rng with items command --- .../CrackPlayerRNGWithItemsCommand.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGWithItemsCommand.java diff --git a/src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGWithItemsCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGWithItemsCommand.java new file mode 100644 index 000000000..11c03bf3e --- /dev/null +++ b/src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGWithItemsCommand.java @@ -0,0 +1,34 @@ +package net.earthcomputer.clientcommands.command; + +import com.mojang.brigadier.CommandDispatcher; +import net.cortex.clientAddon.cracker.SeedCracker; +import net.earthcomputer.clientcommands.TempRules; +import net.earthcomputer.clientcommands.features.EnchantmentCracker; +import net.minecraft.server.command.ServerCommandSource; +import net.minecraft.text.TranslatableText; + +import static net.earthcomputer.clientcommands.command.ClientCommandManager.addClientSideCommand; +import static net.earthcomputer.clientcommands.command.ClientCommandManager.sendFeedback; +import static net.earthcomputer.clientcommands.features.EnchantmentCracker.EnumCrackState.CRACKED_PLAYER_SEED; +import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; +import static net.minecraft.server.command.CommandManager.literal; + +public class CrackPlayerRNGWithItemsCommand { + + public static void register(CommandDispatcher dispatcher) { + addClientSideCommand("citemrngcrack"); + + dispatcher.register(literal("citemrngcrack") + .executes(ctx -> crackPlayerRNG(ctx.getSource()))); + } + + private static int crackPlayerRNG(ServerCommandSource source) { + SeedCracker.crack(seed -> { + sendFeedback(new TranslatableText("commands.ccrackplayerrng.success", Long.toHexString(seed))); + EnchantmentCracker.playerRand.setSeed(seed ^ MULTIPLIER); + TempRules.enchCrackState=CRACKED_PLAYER_SEED; + }); + return 0; + } + +} From ec3473c49f80875ff41fe6284bce604474ee900f Mon Sep 17 00:00:00 2001 From: MCRcortex Date: Wed, 7 Aug 2019 22:59:52 +1000 Subject: [PATCH 12/15] register crack command --- .../java/net/earthcomputer/clientcommands/ClientCommands.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java b/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java index 5075a6695..66a6ca570 100644 --- a/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java +++ b/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java @@ -30,6 +30,8 @@ public static void registerCommands(CommandDispatcher dispa WikiCommand.register(dispatcher); CEnchantCommand.register(dispatcher); + CrackPlayerRNGWithItemsCommand.register(dispatcher); + if (MinecraftClient.getInstance().isIntegratedServerRunning()) { CrackPlayerRNGCommand.register(dispatcher); } From e6b9465455862f391a366377837712ceb8aefe77 Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 7 Aug 2019 18:20:59 +0100 Subject: [PATCH 13/15] Fix not working in singleplayer --- .../clientAddon/cracker/SeedCracker.java | 187 ++++++++++-------- .../clientAddon/mixin/S2CEntityCreation.java | 83 -------- .../mixin/MixinClientPlayNetworkHandler.java | 7 + src/main/resources/fabric.mod.json | 2 +- src/main/resources/mixins.client_addon.json | 11 -- 5 files changed, 114 insertions(+), 176 deletions(-) delete mode 100644 src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java delete mode 100644 src/main/resources/mixins.client_addon.json diff --git a/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java b/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java index 883914b18..55ac8d103 100644 --- a/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java +++ b/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java @@ -1,81 +1,106 @@ -package net.cortex.clientAddon.cracker; - -import net.earthcomputer.clientcommands.features.EnchantmentCracker; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; -import net.minecraft.network.MessageType; -import net.minecraft.server.network.packet.PlayerActionC2SPacket; -import net.minecraft.server.network.packet.PlayerMoveC2SPacket; -import net.minecraft.text.LiteralText; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; - -import java.util.Random; -import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; - -public class SeedCracker { - public interface OnCrack {void callback(long seed); } - - - public static OnCrack callback; - public static long[] bits=new long[20]; - public static int expectedItems=0; - public static boolean cracking=false; - - //returns True on success or false on failer - private static boolean throwItems() - { - MinecraftClient minecraft = MinecraftClient.getInstance(); - if ( minecraft.player.inventory.getMainHandStack().getCount()>19) {//check that have at least 19 items in current hand (doesnt seem to work) - System.out.println("hand item count: "+(minecraft.player.inventory.getMainHandStack().getCount())); - ClientPlayNetworkHandler networkHandler = minecraft.getNetworkHandler(); - networkHandler.sendPacket(new PlayerMoveC2SPacket.LookOnly(0.0f, 90.0f, true)); //point to correct location - for (int i = 0; i < 20; i++)//drop 20 items + test items+13; - networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.DROP_ITEM, BlockPos.ORIGIN, Direction.DOWN)); - } - else { - minecraft.inGameHud.addChatMessage(MessageType.CHAT.GAME_INFO, new LiteralText(Formatting.RED+"Unable to use rng SeedCracker |not enough items in player hand|")); - System.out.println("Unable to use rng SeedCracker |not enough items|"); - return false; - } - return true; - } - public static void attemptCrack() - { - cracking=false; - long seed= Lattice_cracker.crack(SeedCracker.bits); - - if(seed==0)//Basicaly if seed is zero it means it failed to try to crack again - { - SeedCracker.crack(SeedCracker.callback); - return; - } - //Else, got a seed - - Random rand=new Random(); - rand.setSeed(seed ^ MULTIPLIER); - 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"); - }*/ - - callback.callback(EnchantmentCracker.getSeed(rand));//extract seed and call callback - } - public static void crack(OnCrack Callback){ - callback=Callback; - if(throwItems()) - { - cracking=true; - expectedItems=20; - } - } -} +package net.cortex.clientAddon.cracker; + +import net.earthcomputer.clientcommands.features.EnchantmentCracker; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.client.network.packet.EntitySpawnS2CPacket; +import net.minecraft.entity.EntityType; +import net.minecraft.network.MessageType; +import net.minecraft.server.network.packet.PlayerActionC2SPacket; +import net.minecraft.server.network.packet.PlayerMoveC2SPacket; +import net.minecraft.text.LiteralText; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Direction; + +import java.util.Random; +import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; + +public class SeedCracker { + public interface OnCrack {void callback(long seed); } + + + public static OnCrack callback; + public static long[] bits=new long[20]; + public static int expectedItems=0; + public static boolean cracking=false; + + //returns True on success or false on failer + private static boolean throwItems() + { + MinecraftClient minecraft = MinecraftClient.getInstance(); + if ( minecraft.player.inventory.getMainHandStack().getCount()>19) {//check that have at least 19 items in current hand (doesnt seem to work) + System.out.println("hand item count: "+(minecraft.player.inventory.getMainHandStack().getCount())); + ClientPlayNetworkHandler networkHandler = minecraft.getNetworkHandler(); + networkHandler.sendPacket(new PlayerMoveC2SPacket.LookOnly(0.0f, 90.0f, true)); //point to correct location + for (int i = 0; i < 20; i++)//drop 20 items + test items+13; + networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.DROP_ITEM, BlockPos.ORIGIN, Direction.DOWN)); + } + else { + minecraft.inGameHud.addChatMessage(MessageType.CHAT.GAME_INFO, new LiteralText(Formatting.RED+"Unable to use rng SeedCracker |not enough items in player hand|")); + System.out.println("Unable to use rng SeedCracker |not enough items|"); + return false; + } + return true; + } + public static void attemptCrack() + { + cracking=false; + long seed= Lattice_cracker.crack(SeedCracker.bits); + + if(seed==0)//Basicaly if seed is zero it means it failed to try to crack again + { + SeedCracker.crack(SeedCracker.callback); + return; + } + //Else, got a seed + + Random rand=new Random(); + rand.setSeed(seed ^ MULTIPLIER); + 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"); + }*/ + + callback.callback(EnchantmentCracker.getSeed(rand));//extract seed and call callback + } + public static void crack(OnCrack Callback){ + callback=Callback; + if(throwItems()) + { + cracking=true; + expectedItems=20; + } + } + + public static void onEntityCreation(EntitySpawnS2CPacket packet) { + if (packet.getEntityTypeId() == EntityType.ITEM && SeedCracker.expectedItems>0) { + + long rand_val = (long) ((Math.atan2(packet.getVelocityz(), packet.getVelocityX()) + 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(SeedCracker.expectedItems==0&&SeedCracker.cracking)//if its the last item + { + SeedCracker.attemptCrack(); + } + /* + else + { + long rand_val = (long) ((Math.atan2(this.getVelocityz(), this.getVelocityX()) + Math.PI) / (Math.PI * 2) * ((float) (1 << 24))); + long top_bits = rand_val; + short value = (short) ((top_bits >> (24 - 4)) ^ 0x8L); + System.out.println("Entity item spawn: Top 4 bits of direction: "+padLeftZeros(Long.toBinaryString(value), 4)); + }*/ + } +} diff --git a/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java b/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java deleted file mode 100644 index 9eb2b6c72..000000000 --- a/src/main/java/net/cortex/clientAddon/mixin/S2CEntityCreation.java +++ /dev/null @@ -1,83 +0,0 @@ -package net.cortex.clientAddon.mixin; - - -import net.cortex.clientAddon.cracker.SeedCracker; -import net.cortex.clientAddon.cracker.Lattice_cracker; -import net.earthcomputer.clientcommands.features.EnchantmentCracker; -import net.minecraft.client.network.packet.EntitySpawnS2CPacket; -import net.minecraft.entity.EntityType; -import net.minecraft.util.PacketByteBuf; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Random; - -import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; - -@Mixin(EntitySpawnS2CPacket.class) -public abstract class S2CEntityCreation { - @Shadow - public abstract double getVelocityz(); - - @Shadow - public abstract double getVelocityX(); - - @Shadow - public abstract int getId(); - - @Shadow - public abstract EntityType getEntityTypeId(); - - @Inject(at = @At("TAIL"), method = "read") - public void read(PacketByteBuf packetByteBuf_1, CallbackInfo ci) throws IOException - { - if(this.getEntityTypeId() == EntityType.ITEM && SeedCracker.expectedItems>0) { - - long rand_val = (long) ((Math.atan2(this.getVelocityz(), this.getVelocityX()) + 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(SeedCracker.expectedItems==0&&SeedCracker.cracking)//if its the last item - { - SeedCracker.attemptCrack(); - } - /* - else - { - long rand_val = (long) ((Math.atan2(this.getVelocityz(), this.getVelocityX()) + Math.PI) / (Math.PI * 2) * ((float) (1 << 24))); - long top_bits = rand_val; - short value = (short) ((top_bits >> (24 - 4)) ^ 0x8L); - System.out.println("Entity item spawn: Top 4 bits of direction: "+padLeftZeros(Long.toBinaryString(value), 4)); - }*/ - } - - - - - - - - - - public String padLeftZeros(String inputString, int length) { - if (inputString.length() >= length) { - return inputString; - } - StringBuilder sb = new StringBuilder(); - while (sb.length() < length - inputString.length()) { - sb.append('0'); - } - sb.append(inputString); - - return sb.toString(); - } -} diff --git a/src/main/java/net/earthcomputer/clientcommands/mixin/MixinClientPlayNetworkHandler.java b/src/main/java/net/earthcomputer/clientcommands/mixin/MixinClientPlayNetworkHandler.java index 40400bd30..e0ab0f7eb 100644 --- a/src/main/java/net/earthcomputer/clientcommands/mixin/MixinClientPlayNetworkHandler.java +++ b/src/main/java/net/earthcomputer/clientcommands/mixin/MixinClientPlayNetworkHandler.java @@ -1,9 +1,11 @@ package net.earthcomputer.clientcommands.mixin; import com.mojang.brigadier.CommandDispatcher; +import net.cortex.clientAddon.cracker.SeedCracker; import net.earthcomputer.clientcommands.ClientCommands; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.client.network.packet.CommandTreeS2CPacket; +import net.minecraft.client.network.packet.EntitySpawnS2CPacket; import net.minecraft.server.command.CommandSource; import net.minecraft.server.command.ServerCommandSource; import org.spongepowered.asm.mixin.Mixin; @@ -24,4 +26,9 @@ public void onOnCommandTree(CommandTreeS2CPacket packet, CallbackInfo ci) { ClientCommands.registerCommands((CommandDispatcher) (Object) commandDispatcher); } + @Inject(method = "onEntitySpawn", at = @At("RETURN")) + public void onOnEntitySpawn(EntitySpawnS2CPacket packet, CallbackInfo ci) { + SeedCracker.onEntityCreation(packet); + } + } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 49a9fb9c6..d50b92b0b 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -11,6 +11,6 @@ "fabric": "*" }, "mixins": { - "client": ["mixins.clientcommands.json","mixins.client_addon.json"] + "client": ["mixins.clientcommands.json"] } } diff --git a/src/main/resources/mixins.client_addon.json b/src/main/resources/mixins.client_addon.json deleted file mode 100644 index e1c39fb28..000000000 --- a/src/main/resources/mixins.client_addon.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "required": true, - "package": "net.cortex.clientAddon.mixin", - "compatibilityLevel": "JAVA_8", - "mixins": [ - "S2CEntityCreation" - ], - "injectors": { - "defaultRequire": 1 - } -} From a4d595e10a58854842ffc6373fd2f4b5dc559eef Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 7 Aug 2019 19:02:17 +0100 Subject: [PATCH 14/15] Switch to translation and fix item throwing --- .../clientAddon/cracker/Lattice_cracker.java | 509 +++++++++--------- .../clientAddon/cracker/SeedCracker.java | 29 +- .../features/EnchantmentCracker.java | 47 +- .../assets/clientcommands/lang/en_us.json | 4 +- 4 files changed, 296 insertions(+), 293 deletions(-) diff --git a/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java b/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java index 83c967860..f69df4615 100644 --- a/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java +++ b/src/main/java/net/cortex/clientAddon/cracker/Lattice_cracker.java @@ -1,253 +1,256 @@ -package net.cortex.clientAddon.cracker; - -import java.util.ArrayList; -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)) - { - System.out.println("404 NOT FOUND"); - 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 - } -} - - - - - - - - - - - - - - - - - - - - - - - - - +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/SeedCracker.java b/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java index 55ac8d103..73e45476c 100644 --- a/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java +++ b/src/main/java/net/cortex/clientAddon/cracker/SeedCracker.java @@ -2,16 +2,13 @@ import net.earthcomputer.clientcommands.features.EnchantmentCracker; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.packet.EntitySpawnS2CPacket; import net.minecraft.entity.EntityType; import net.minecraft.network.MessageType; -import net.minecraft.server.network.packet.PlayerActionC2SPacket; import net.minecraft.server.network.packet.PlayerMoveC2SPacket; -import net.minecraft.text.LiteralText; +import net.minecraft.text.TranslatableText; import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Direction; import java.util.Random; import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; @@ -28,18 +25,16 @@ public interface OnCrack {void callback(long seed); } //returns True on success or false on failer private static boolean throwItems() { - MinecraftClient minecraft = MinecraftClient.getInstance(); - if ( minecraft.player.inventory.getMainHandStack().getCount()>19) {//check that have at least 19 items in current hand (doesnt seem to work) - System.out.println("hand item count: "+(minecraft.player.inventory.getMainHandStack().getCount())); - ClientPlayNetworkHandler networkHandler = minecraft.getNetworkHandler(); - networkHandler.sendPacket(new PlayerMoveC2SPacket.LookOnly(0.0f, 90.0f, true)); //point to correct location - for (int i = 0; i < 20; i++)//drop 20 items + test items+13; - networkHandler.sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.DROP_ITEM, BlockPos.ORIGIN, Direction.DOWN)); - } - else { - minecraft.inGameHud.addChatMessage(MessageType.CHAT.GAME_INFO, new LiteralText(Formatting.RED+"Unable to use rng SeedCracker |not enough items in player hand|")); - System.out.println("Unable to use rng SeedCracker |not enough items|"); - return false; + ClientPlayerEntity player = MinecraftClient.getInstance().player; + player.setPositionAndAngles(player.x, player.y, player.z, 0, 90); + MinecraftClient.getInstance().getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookOnly(0, 90, true)); // point to correct location + for (int i = 0; i < 20; i++) { + EnchantmentCracker.EnchantManipulationStatus status = EnchantmentCracker.throwItem(); + if (status != EnchantmentCracker.EnchantManipulationStatus.OK && status != EnchantmentCracker.EnchantManipulationStatus.NOT_CRACKED) { + MinecraftClient.getInstance().inGameHud.addChatMessage(MessageType.GAME_INFO, new TranslatableText("itemCrack.notEnoughItems").formatted(Formatting.RED)); + EnchantmentCracker.LOGGER.info("Unable to use rng SeedCracker |not enough items|"); + return false; + } } return true; } diff --git a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java index 56b81ede1..477e9a98e 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java @@ -94,7 +94,7 @@ public class EnchantmentCracker { * we want and determine n. */ - private static final Logger LOGGER = LogManager.getLogger("EnchantmentCracker"); + public static final Logger LOGGER = LogManager.getLogger("EnchantmentCracker"); // RNG CHECK /* @@ -558,13 +558,8 @@ public void body() { @Override public void onCompleted() { - Slot matchingSlot = player.container.slotList.stream() - .filter(Slot::hasStack).findAny().orElse(null); - assert matchingSlot != null; - expectedThrows++; - for (int i = 0; i < 4; i++) playerRand.nextInt(); - - MinecraftClient.getInstance().interactionManager.method_2906(player.container.syncId, matchingSlot.id, 0, SlotActionType.THROW, player); + EnchantManipulationStatus status = throwItem(); + assert status == EnchantManipulationStatus.OK; scheduleDelay(); } @@ -615,12 +610,11 @@ public static EnchantManipulationStatus throwItemsUntil(Predicate condit } */ - /* public static EnchantManipulationStatus throwItemsUntil(Predicate condition, int max) { if (TempRules.enchCrackState != EnumCrackState.CRACKED) return EnchantManipulationStatus.NOT_CRACKED; - long seed = ReflectionHelper.getPrivateValue(Random.class, playerRand, "seed").get(); + long seed = getSeed(playerRand); Random rand = new Random(seed ^ MULTIPLIER); int itemsNeeded = 0; @@ -632,28 +626,37 @@ public static EnchantManipulationStatus throwItemsUntil(Predicate condit if (itemsNeeded > max) return EnchantManipulationStatus.IMPOSSIBLE; - EntityPlayerSP player = Minecraft.getMinecraft().player; - for (int i = 0; i < itemsNeeded; i++) { - EnchantManipulationStatus status = manipulateEnchantmentsSanityCheck(player); + EnchantManipulationStatus status = throwItem(); if (status != EnchantManipulationStatus.OK) return status; - Slot matchingSlot = player.inventoryContainer.inventorySlots.stream() - .filter(Slot::getHasStack).findAny().orElse(null); - if (matchingSlot == null) { - return EnchantManipulationStatus.EMPTY_INVENTORY; - } + } + + return EnchantManipulationStatus.OK; + } + + public static EnchantManipulationStatus throwItem() { + ClientPlayerEntity player = MinecraftClient.getInstance().player; + + EnchantManipulationStatus status = manipulateEnchantmentsSanityCheck(player); + if (status != EnchantManipulationStatus.OK && status != EnchantManipulationStatus.NOT_CRACKED) + return status; + Slot matchingSlot = player.container.slotList.stream() + .filter(Slot::hasStack).findAny().orElse(null); + if (matchingSlot == null) { + return EnchantManipulationStatus.EMPTY_INVENTORY; + } + if (status != EnchantManipulationStatus.NOT_CRACKED) { expectedThrows++; for (int j = 0; j < 4; j++) { playerRand.nextInt(); } - Minecraft.getMinecraft().playerController.windowClick(player.inventoryContainer.windowId, - matchingSlot.slotNumber, 0, ClickType.THROW, player); } + MinecraftClient.getInstance().interactionManager.method_2906(player.container.syncId, + matchingSlot.id, 0, SlotActionType.THROW, player); - return EnchantManipulationStatus.OK; + return status; } - */ public static long singlePlayerCrackRNG() { ServerPlayerEntity serverPlayer = MinecraftClient.getInstance().getServer().getPlayerManager().getPlayer(MinecraftClient.getInstance().player.getUuid()); diff --git a/src/main/resources/assets/clientcommands/lang/en_us.json b/src/main/resources/assets/clientcommands/lang/en_us.json index d681f313f..8743217fe 100644 --- a/src/main/resources/assets/clientcommands/lang/en_us.json +++ b/src/main/resources/assets/clientcommands/lang/en_us.json @@ -93,6 +93,8 @@ "enchCrack.addInfo": "Add Info", - "enchCrack.toolBreakWarning": "Warning: tool has %d durability left" + "enchCrack.toolBreakWarning": "Warning: tool has %d durability left", + + "itemCrack.notEnoughItems": "Unable to use RNG SeedCracker: Not Enough Items in Player Hand" } \ No newline at end of file From fdefe8e0edb317f8643f4bea9931d2b9a584d11c Mon Sep 17 00:00:00 2001 From: Joe Date: Wed, 7 Aug 2019 19:12:02 +0100 Subject: [PATCH 15/15] Rename commands --- .../net/earthcomputer/clientcommands/ClientCommands.java | 4 ++-- ...ackPlayerRNGCommand.java => CheatCrackRNGCommand.java} | 8 ++++---- ...layerRNGWithItemsCommand.java => CrackRNGCommand.java} | 8 ++++---- src/main/resources/assets/clientcommands/lang/en_us.json | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) rename src/main/java/net/earthcomputer/clientcommands/command/{CrackPlayerRNGCommand.java => CheatCrackRNGCommand.java} (75%) rename src/main/java/net/earthcomputer/clientcommands/command/{CrackPlayerRNGWithItemsCommand.java => CrackRNGCommand.java} (83%) diff --git a/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java b/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java index 66a6ca570..351360e44 100644 --- a/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java +++ b/src/main/java/net/earthcomputer/clientcommands/ClientCommands.java @@ -30,10 +30,10 @@ public static void registerCommands(CommandDispatcher dispa WikiCommand.register(dispatcher); CEnchantCommand.register(dispatcher); - CrackPlayerRNGWithItemsCommand.register(dispatcher); + CrackRNGCommand.register(dispatcher); if (MinecraftClient.getInstance().isIntegratedServerRunning()) { - CrackPlayerRNGCommand.register(dispatcher); + CheatCrackRNGCommand.register(dispatcher); } } } diff --git a/src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/CheatCrackRNGCommand.java similarity index 75% rename from src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGCommand.java rename to src/main/java/net/earthcomputer/clientcommands/command/CheatCrackRNGCommand.java index fa064bb7f..4c978463f 100644 --- a/src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGCommand.java +++ b/src/main/java/net/earthcomputer/clientcommands/command/CheatCrackRNGCommand.java @@ -8,18 +8,18 @@ import static net.earthcomputer.clientcommands.command.ClientCommandManager.*; import static net.minecraft.server.command.CommandManager.*; -public class CrackPlayerRNGCommand { +public class CheatCrackRNGCommand { public static void register(CommandDispatcher dispatcher) { - addClientSideCommand("ccrackplayerrng"); + addClientSideCommand("ccheatcrackrng"); - dispatcher.register(literal("ccrackplayerrng") + dispatcher.register(literal("ccheatcrackrng") .executes(ctx -> crackPlayerRNG(ctx.getSource()))); } private static int crackPlayerRNG(ServerCommandSource source) { long seed = EnchantmentCracker.singlePlayerCrackRNG(); - sendFeedback(new TranslatableText("commands.ccrackplayerrng.success", Long.toHexString(seed))); + sendFeedback(new TranslatableText("commands.ccrackrng.success", Long.toHexString(seed))); return (int) seed; } diff --git a/src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGWithItemsCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/CrackRNGCommand.java similarity index 83% rename from src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGWithItemsCommand.java rename to src/main/java/net/earthcomputer/clientcommands/command/CrackRNGCommand.java index 11c03bf3e..5a131a011 100644 --- a/src/main/java/net/earthcomputer/clientcommands/command/CrackPlayerRNGWithItemsCommand.java +++ b/src/main/java/net/earthcomputer/clientcommands/command/CrackRNGCommand.java @@ -13,18 +13,18 @@ import static net.earthcomputer.clientcommands.features.EnchantmentCracker.MULTIPLIER; import static net.minecraft.server.command.CommandManager.literal; -public class CrackPlayerRNGWithItemsCommand { +public class CrackRNGCommand { public static void register(CommandDispatcher dispatcher) { - addClientSideCommand("citemrngcrack"); + addClientSideCommand("ccrackrng"); - dispatcher.register(literal("citemrngcrack") + dispatcher.register(literal("ccrackrng") .executes(ctx -> crackPlayerRNG(ctx.getSource()))); } private static int crackPlayerRNG(ServerCommandSource source) { SeedCracker.crack(seed -> { - sendFeedback(new TranslatableText("commands.ccrackplayerrng.success", Long.toHexString(seed))); + sendFeedback(new TranslatableText("commands.ccrackrng.success", Long.toHexString(seed))); EnchantmentCracker.playerRand.setSeed(seed ^ MULTIPLIER); TempRules.enchCrackState=CRACKED_PLAYER_SEED; }); diff --git a/src/main/resources/assets/clientcommands/lang/en_us.json b/src/main/resources/assets/clientcommands/lang/en_us.json index 8743217fe..57a1a7210 100644 --- a/src/main/resources/assets/clientcommands/lang/en_us.json +++ b/src/main/resources/assets/clientcommands/lang/en_us.json @@ -4,7 +4,7 @@ "commands.ccalc.expected": "Expected %s", "commands.ccalc.invalidArgumentCount": "Function \"%s\" cannot take %d arguments", - "commands.ccrackplayerrng.success": "Player RNG cracked: %d", + "commands.ccrackrng.success": "Player RNG cracked: %d", "commands.cenchant.expectedWithWithout": "Expected \"with\"/\"without\"", "commands.cenchant.incompatible": "Incompatible enchantments",