Merge branch 'proto_1.12.2' into world-loader-anvil
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-06-11
|
||||
*/
|
||||
package mc.core.network.proto_1_12_2;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.security.KeyPair;
|
||||
import java.security.KeyPairGenerator;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Random;
|
||||
|
||||
@Slf4j
|
||||
public class Crypter {
|
||||
private static final Crypter instance = new Crypter();
|
||||
private KeyPair keyPair;
|
||||
private byte[] verifyToken;
|
||||
|
||||
public static KeyPair getKeyPair() {
|
||||
if (instance.keyPair == null) {
|
||||
try {
|
||||
KeyPairGenerator keypairgenerator = KeyPairGenerator.getInstance("RSA");
|
||||
keypairgenerator.initialize(1024);
|
||||
instance.keyPair = keypairgenerator.generateKeyPair();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
log.error("WTF?! Algorithm \"RSA\" not defined?!", e);
|
||||
}
|
||||
}
|
||||
|
||||
return instance.keyPair;
|
||||
}
|
||||
|
||||
public static byte[] getVerifyToken() {
|
||||
if (instance.verifyToken == null) {
|
||||
instance.verifyToken = new byte[4];
|
||||
Random rand = new Random();
|
||||
rand.nextBytes(instance.verifyToken);
|
||||
}
|
||||
|
||||
return instance.verifyToken;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,3 @@
|
||||
/*
|
||||
* DmitriyMX <dimon550@gmail.com>
|
||||
* 2018-06-11
|
||||
*/
|
||||
package mc.core.network.proto_1_12_2.packets;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -19,15 +15,10 @@ import mc.core.network.SCPacket;
|
||||
public class SpawnPositionPacket implements SCPacket {
|
||||
private EntityLocation location;
|
||||
|
||||
private int floor_double(double value) {
|
||||
int i = (int)value;
|
||||
return value < (double)i ? i - 1 : i;
|
||||
}
|
||||
|
||||
private long location2long(EntityLocation entityLocation) {
|
||||
return ((floor_double(entityLocation.getX()) & 0x3FFFFFF) << 38)
|
||||
| ((floor_double(entityLocation.getY()) & 0xFFF) << 26)
|
||||
| (floor_double(entityLocation.getZ()) & 0x3FFFFFF);
|
||||
return (((long) entityLocation.getBlockX() & 0x3FFFFFF) << 38)
|
||||
| (((long) entityLocation.getBlockY() & 0x0000FFF) << 26)
|
||||
| ((long) entityLocation.getBlockZ() & 0x3FFFFFF);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user