Archived
0

Merge branch 'proto_1.12.2' into world-loader-anvil

This commit is contained in:
2018-12-17 10:31:58 +03:00
7 changed files with 34 additions and 65 deletions

1
.gitignore vendored
View File

@@ -15,3 +15,4 @@ gradlew.*
## PROJECT ## ## PROJECT ##
libs/ libs/
*.log

View File

@@ -1,3 +1,27 @@
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath (group: 'org.sonarsource.scanner.gradle', name: 'sonarqube-gradle-plugin', version: '2.6.2')
}
}
/**
* Проверка кода в SonarQube.
* Для запуска локальной проверки кода, используются следующий command line:
* gradle sonarqube \
* -Dsonar.host.url=http://127.0.0.1:9000
* -Dsonar.login=<TOKEN>
* где
* - <TOKEN> - сгенерированный токен учетки "сонара"
*/
plugins {
id "org.sonarqube" version "2.6.2"
}
allprojects { allprojects {
apply plugin: 'java' apply plugin: 'java'

View File

@@ -3,6 +3,7 @@ package mc.core;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import org.springframework.lang.Nullable;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
@@ -32,15 +33,15 @@ public class EntityLocation implements Cloneable {
} }
public int getBlockX() { public int getBlockX() {
return Double.valueOf(Math.floor(x)).intValue(); return (int) Math.floor(x);
} }
public int getBlockY() { public int getBlockY() {
return Double.valueOf(Math.floor(y)).intValue(); return (int) Math.floor(y);
} }
public int getBlockZ() { public int getBlockZ() {
return Double.valueOf(Math.floor(z)).intValue(); return (int) Math.floor(z);
} }
@Override @Override
@@ -49,7 +50,7 @@ public class EntityLocation implements Cloneable {
return (EntityLocation) super.clone(); return (EntityLocation) super.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
e.printStackTrace(); e.printStackTrace();
return null; return ZERO();
} }
} }
} }

View File

@@ -1,12 +1,8 @@
package mc.core.world.block; package mc.core.world.block;
import com.flowpowered.nbt.Tag;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import java.util.HashMap;
import java.util.Map;
public abstract class AbstractBlock implements Block { public abstract class AbstractBlock implements Block {
@Getter @Getter
@Setter @Setter
@@ -15,7 +11,6 @@ public abstract class AbstractBlock implements Block {
private int light = 0; private int light = 0;
@Getter @Getter
private final BlockType blockType; private final BlockType blockType;
private final Map<String, Tag<?>> nbtTagsMap = new HashMap<>();
protected AbstractBlock(BlockType type) { protected AbstractBlock(BlockType type) {
this.blockType = type; this.blockType = type;

View File

@@ -43,7 +43,7 @@ public class BlockLocation implements Cloneable {
return (BlockLocation) super.clone(); return (BlockLocation) super.clone();
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
e.printStackTrace(); e.printStackTrace();
return null; return ZERO();
} }
} }
} }

View File

@@ -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;
}
}

View File

@@ -1,7 +1,3 @@
/*
* DmitriyMX <dimon550@gmail.com>
* 2018-06-11
*/
package mc.core.network.proto_1_12_2.packets; package mc.core.network.proto_1_12_2.packets;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@@ -19,15 +15,10 @@ import mc.core.network.SCPacket;
public class SpawnPositionPacket implements SCPacket { public class SpawnPositionPacket implements SCPacket {
private EntityLocation location; 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) { private long location2long(EntityLocation entityLocation) {
return ((floor_double(entityLocation.getX()) & 0x3FFFFFF) << 38) return (((long) entityLocation.getBlockX() & 0x3FFFFFF) << 38)
| ((floor_double(entityLocation.getY()) & 0xFFF) << 26) | (((long) entityLocation.getBlockY() & 0x0000FFF) << 26)
| (floor_double(entityLocation.getZ()) & 0x3FFFFFF); | ((long) entityLocation.getBlockZ() & 0x3FFFFFF);
} }
@Override @Override