Merge remote-tracking branch 'upstream/master' into abstraction

This commit is contained in:
KennyTV 2019-08-23 21:20:13 +02:00
commit c4b23b8c87
17 changed files with 132 additions and 24 deletions

View File

@ -2,7 +2,6 @@ sudo: false
language: java
jdk:
- oraclejdk8
- openjdk11
cache:

View File

@ -1,4 +1,4 @@
# ViaVersion 2.1.1 - Spigot, Sponge, BungeeCord, Velocity
# ViaVersion 2.1.3 - Spigot, Sponge, BungeeCord, Velocity
[![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion)
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -7,6 +7,7 @@ import net.md_5.bungee.api.event.PlayerDisconnectEvent;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.protocol.ProtocolConstants;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.ViaAPI;
import us.myles.ViaVersion.api.command.ViaCommandSender;
@ -35,6 +36,17 @@ public class BungeePlugin extends Plugin implements ViaPlatform, Listener {
@Override
public void onLoad() {
try {
ProtocolConstants.class.getField("MINECRAFT_1_14_4");
} catch (NoSuchFieldException e) {
getLogger().warning(" / \\");
getLogger().warning(" / \\");
getLogger().warning(" / | \\");
getLogger().warning(" / | \\ BUNGEECORD IS OUTDATED");
getLogger().warning(" / \\ VIAVERSION MAY NOT WORK AS INTENDED");
getLogger().warning(" / o \\");
getLogger().warning("/_____________\\");
}
api = new BungeeViaAPI();
config = new BungeeViaConfig(getDataFolder());
commandHandler = new BungeeCommandHandler();

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -19,6 +19,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2;
import us.myles.ViaVersion.protocols.protocol1_14_1to1_14.Protocol1_14_1To1_14;
import us.myles.ViaVersion.protocols.protocol1_14_2to1_14_1.Protocol1_14_2To1_14_1;
import us.myles.ViaVersion.protocols.protocol1_14_3to1_14_2.Protocol1_14_3To1_14_2;
import us.myles.ViaVersion.protocols.protocol1_14_4to1_14_3.Protocol1_14_4To1_14_3;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1To1_9;
@ -61,13 +62,14 @@ public class ProtocolRegistry {
registerProtocol(new Protocol1_12_2To1_12_1(), Collections.singletonList(ProtocolVersion.v1_12_2.getId()), ProtocolVersion.v1_12_1.getId());
registerProtocol(new Protocol1_13To1_12_2(), Collections.singletonList(ProtocolVersion.v1_13.getId()), ProtocolVersion.v1_12_2.getId());
registerProtocol(new Protocol1_13_1To1_13(), Arrays.asList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13.getId());
registerProtocol(new Protocol1_13_2To1_13_1(), Arrays.asList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_13_1.getId());
registerProtocol(new Protocol1_13_1To1_13(), Collections.singletonList(ProtocolVersion.v1_13_1.getId()), ProtocolVersion.v1_13.getId());
registerProtocol(new Protocol1_13_2To1_13_1(), Collections.singletonList(ProtocolVersion.v1_13_2.getId()), ProtocolVersion.v1_13_1.getId());
registerProtocol(new Protocol1_14To1_13_2(), Arrays.asList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_13_2.getId());
registerProtocol(new Protocol1_14_1To1_14(), Arrays.asList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14.getId());
registerProtocol(new Protocol1_14_2To1_14_1(), Arrays.asList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_1.getId());
registerProtocol(new Protocol1_14_3To1_14_2(), Arrays.asList(ProtocolVersion.v1_14_3.getId()), ProtocolVersion.v1_14_2.getId());
registerProtocol(new Protocol1_14To1_13_2(), Collections.singletonList(ProtocolVersion.v1_14.getId()), ProtocolVersion.v1_13_2.getId());
registerProtocol(new Protocol1_14_1To1_14(), Collections.singletonList(ProtocolVersion.v1_14_1.getId()), ProtocolVersion.v1_14.getId());
registerProtocol(new Protocol1_14_2To1_14_1(), Collections.singletonList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_1.getId());
registerProtocol(new Protocol1_14_3To1_14_2(), Collections.singletonList(ProtocolVersion.v1_14_3.getId()), ProtocolVersion.v1_14_2.getId());
registerProtocol(new Protocol1_14_4To1_14_3(), Collections.singletonList(ProtocolVersion.v1_14_4.getId()), ProtocolVersion.v1_14_3.getId());
}
/**

View File

@ -39,6 +39,7 @@ public class ProtocolVersion {
public static final ProtocolVersion v1_14_1;
public static final ProtocolVersion v1_14_2;
public static final ProtocolVersion v1_14_3;
public static final ProtocolVersion v1_14_4;
public static final ProtocolVersion unknown;
private final int id;
@ -74,6 +75,7 @@ public class ProtocolVersion {
register(v1_14_1 = new ProtocolVersion(480, "1.14.1"));
register(v1_14_2 = new ProtocolVersion(485, "1.14.2"));
register(v1_14_3 = new ProtocolVersion(490, "1.14.3"));
register(v1_14_4 = new ProtocolVersion(498, "1.14.4"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
}

View File

@ -27,6 +27,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class InventoryPackets {
private static String NBT_TAG_NAME;
@ -404,13 +405,13 @@ public class InventoryPackets {
if (numberConverted != null) {
oldId = numberConverted;
}
String[] newValues = BlockIdData.blockIdMapping.get(oldId);
String[] newValues = BlockIdData.blockIdMapping.get(oldId.toLowerCase(Locale.ROOT));
if (newValues != null) {
for (String newValue : newValues) {
newCanPlaceOn.add(new StringTag("", newValue));
}
} else {
newCanPlaceOn.add(new StringTag("", oldId));
newCanPlaceOn.add(new StringTag("", oldId.toLowerCase(Locale.ROOT)));
}
}
tag.put(newCanPlaceOn);
@ -426,13 +427,13 @@ public class InventoryPackets {
if (numberConverted != null) {
oldId = numberConverted;
}
String[] newValues = BlockIdData.blockIdMapping.get(oldId);
String[] newValues = BlockIdData.blockIdMapping.get(oldId.toLowerCase(Locale.ROOT));
if (newValues != null) {
for (String newValue : newValues) {
newCanDestroy.add(new StringTag("", newValue));
}
} else {
newCanDestroy.add(new StringTag("", oldId));
newCanDestroy.add(new StringTag("", oldId.toLowerCase(Locale.ROOT)));
}
}
tag.put(newCanDestroy);

View File

@ -0,0 +1,47 @@
package us.myles.ViaVersion.protocols.protocol1_14_4to1_14_3;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
public class Protocol1_14_4To1_14_3 extends Protocol {
@Override
protected void registerPackets() {
// trade list
registerOutgoing(State.PLAY, 0x27, 0x27, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.VAR_INT);
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
}
wrapper.passthrough(Type.BOOLEAN);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.FLOAT);
wrapper.write(Type.INT, 0); // demand value added in pre5
}
}
});
}
});
}
@Override
public void init(UserConnection userConnection) {
}
}

View File

@ -40,7 +40,6 @@ public class Protocol1_14To1_13_2 extends Protocol {
registerOutgoing(State.PLAY, 0x1B, 0x1A);
registerOutgoing(State.PLAY, 0x1C, 0x1B);
registerOutgoing(State.PLAY, 0x1D, 0x54);
registerOutgoing(State.PLAY, 0x1E, 0x1C);
registerOutgoing(State.PLAY, 0x1F, 0x1D);
registerOutgoing(State.PLAY, 0x20, 0x1E);
registerOutgoing(State.PLAY, 0x21, 0x20);

View File

@ -22,11 +22,18 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker1
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.Arrays;
public class WorldPackets {
private static final int AIR = MappingData.blockStateMappings.getNewId(0);
private static final int VOID_AIR = MappingData.blockStateMappings.getNewId(8591);
private static final int CAVE_AIR = MappingData.blockStateMappings.getNewId(8592);
public static final int SERVERSIDE_VIEW_DISTANCE = 64;
private static final byte[] FULL_LIGHT = new byte[2048];
static {
Arrays.fill(FULL_LIGHT, (byte) 0xff);
}
public static void register(final Protocol protocol) {
@ -116,6 +123,30 @@ public class WorldPackets {
}
});
// Explosion
protocol.registerOutgoing(State.PLAY, 0x1E, 0x1C, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.FLOAT); // X
map(Type.FLOAT); // Y
map(Type.FLOAT); // Z
map(Type.FLOAT); // Radius
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
for (int i = 0; i < 3; i++) {
float coord = wrapper.get(Type.FLOAT, i);
if (coord < 0f) {
coord = (int) coord;
wrapper.set(Type.FLOAT, i, coord);
}
}
}
});
}
});
// Chunk
protocol.registerOutgoing(State.PLAY, 0x22, 0x21, new PacketRemapper() {
@Override
@ -172,24 +203,39 @@ public class WorldPackets {
PacketWrapper lightPacket = wrapper.create(0x24);
lightPacket.write(Type.VAR_INT, chunk.getX());
lightPacket.write(Type.VAR_INT, chunk.getZ());
int skyLightMask = 0;
int skyLightMask = chunk.isGroundUp() ? 0x3ffff : 0; // all 18 bits set if ground up
int blockLightMask = 0;
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection sec = chunk.getSections()[i];
if (sec == null) continue;
if (sec.hasSkyLight()) {
if (!chunk.isGroundUp() && sec.hasSkyLight()) {
skyLightMask |= (1 << (i + 1));
}
blockLightMask |= (1 << (i + 1));
}
lightPacket.write(Type.VAR_INT, skyLightMask);
lightPacket.write(Type.VAR_INT, blockLightMask);
lightPacket.write(Type.VAR_INT, 0); // empty sky light mask
lightPacket.write(Type.VAR_INT, 0); // empty block light mask
// not sending skylight/setting empty skylight causes client lag due to some weird calculations
// only do this on the initial chunk send (not when chunk.isGroundUp() is false)
if (chunk.isGroundUp())
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(FULL_LIGHT).toArray(new Byte[0])); // chunk below 0
for (ChunkSection section : chunk.getSections()) {
if (section == null || !section.hasSkyLight()) continue;
if (section == null || !section.hasSkyLight()) {
if (chunk.isGroundUp()) {
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(FULL_LIGHT).toArray(new Byte[0]));
}
continue;
}
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(section.getSkyLight()).toArray(new Byte[0]));
}
if (chunk.isGroundUp())
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(FULL_LIGHT).toArray(new Byte[0])); // chunk above 255
for (ChunkSection section : chunk.getSections()) {
if (section == null) continue;
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(section.getBlockLight()).toArray(new Byte[0]));

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name>

View File

@ -6,7 +6,7 @@
<groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
<packaging>pom</packaging>
<name>viaversion-parent</name>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>2.1.3-SNAPSHOT</version>
<version>2.1.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>