Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static NBTTagCompound keyNbtTag = null;
- public static int generateStackToken(ItemStack theStack, World worldp) {
- if ((worldp == null) || (!(worldp instanceof WorldServer)))
- throw new IllegalStateException("Item UUID encoding failed due to the world being null. Please report this!");
- WorldServer world = (WorldServer) worldp;
- String itemIdXorKey = "a";
- String itemDamageXorKey = "b";
- String idKeyA = "c";
- String idKeyB = "d";
- String idKeyC = "e";
- if (keyNbtTag == null) {
- File keyFile = new File(world.getChunkSaveLocation(), "iuuidk.dat");
- if (keyFile.exists()) {
- try {
- keyNbtTag = CompressedStreamTools.read(keyFile);
- } catch (Throwable e) {
- keyNbtTag.printStackTrace();
- throw new IllegalStateException("Corrupted world UUID keys, please report this!");
- }
- } else {
- keyNbtTag = new NBTTagCompound();
- // RichardG867 is immature, Exhibit A
- keyNbtTag.setByte("IF_YOURE_WILLING_TO_CHEAT_GO_AHEAD", 0);
- keyNbtTag.setShort(itemIdXorKey , (short)world.rand.nextInt(32768));
- keyNbtTag.setShort(itemDamageXorKey, (short)world.rand.nextInt(32768));
- keyNbtTag.setInteger(idKeyA, Math.abs(world.rand.nextInt()));
- keyNbtTag.setInteger(idKeyB, Math.abs(world.rand.nextInt()));
- keyNbtTag.setInteger(idKeyC, Math.abs(world.rand.nextInt()));
- try {
- CompressedStreamTools.write(keyNbtTag, keyFile);
- } catch (Throwable e) {
- throw new IllegalStateException("Corrupted world UUID keys, please report this!");
- }
- }
- }
- // RichardG867 is immature, Exhibit B
- String[] DIE_IN_A_FIRE = { "You are breaking the fun for other people who want to play this legit. Please go away." };
- short itemDamage = (theStack.getItem() != null) && (theStack.getItem().isDamageable()) ? 0 : theStack.getItemDamage();
- short obfusicatedItemId = (short) (theStack.itemID ^ keyNbtTag.getShort(itemIdXorKey));
- short obfusicatedItemDamage = (short) (itemDamage ^ keyNbtTag.getShort(itemDamageXorKey));
- int itemIdentifier = obfusicatedItemId * 32768 + obfusicatedItemDamage;
- int idKey = keyNbtTag.getInteger(idKeyA) ^ keyNbtTag.getInteger(idKeyB) ^ keyNbtTag.getInteger(idKeyC);
- return itemIdentifier ^ idKey;
- }
Advertisement
Add Comment
Please, Sign In to add comment