Here you can find the source of intToMCInts(int i)
Parameter | Description |
---|---|
i | Integer to convert to two MC integers |
public static int[] intToMCInts(int i)
//package com.java2s; //License from project: Creative Commons License public class Main { /**/* w w w . ja v a 2 s . c o m*/ * Spilts a Java int into a so-called Minecraft int - iCrafting.sendProgressBarUpdate truncates * to short. You end up being able to send 16 bits instead of full 32. * * @param i Integer to convert to two MC integers * @return Array of two minecraft integers, 0th int holding first 16 bits */ public static int[] intToMCInts(int i) { byte[] bytes = intToBytes(i); int[] mcInts = new int[] { (int) (bytes[0] << 8 | (bytes[1] & 0xFF)), (int) (bytes[2] << 8 | (bytes[3] & 0xFF)) }; return mcInts; } /** * Spilts an int into 4 bytes * @param i Integer to split * @return 4-byte array, 0th byte being the first byte in an integer */ private static byte[] intToBytes(int i) { return new byte[] { (byte) (i >> 24), (byte) (i >> 16), (byte) (i >> 8), (byte) i }; } }