mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-12-23 17:08:15 +01:00
Merge from master
This commit is contained in:
commit
6eabb17f67
@ -1,14 +1,12 @@
|
||||
# ViaVersion 2.2.0 - Spigot, Sponge, BungeeCord, Velocity
|
||||
# ViaVersion 2.2.1 - 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)
|
||||
|
||||
IRC: [#viaversion](http://irc.spi.gt/iris/?channels=viaversion) on irc.spi.gt for Support.
|
||||
|
||||
**Allows the connection of higher client versions to lower server versions**
|
||||
|
||||
Supported Versions:
|
||||
|
||||
![Table (https://i.imgur.com/iWAtD1p.png)](https://i.imgur.com/iWAtD1p.png)
|
||||
![Table (https://i.imgur.com/yDtAgF7.png)](https://i.imgur.com/yDtAgF7.png)
|
||||
|
||||
On Bukkit you may also use ProtocolSupport, but ensure you have the right build for your server version.
|
||||
|
||||
|
@ -63,12 +63,12 @@ public class MappingDataLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers) {
|
||||
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
|
||||
for (int i = 0; i < oldIdentifiers.size(); i++) {
|
||||
JsonElement v = oldIdentifiers.get(i);
|
||||
Integer index = findIndex(newIdentifiers, v.getAsString());
|
||||
if (index == null) {
|
||||
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
|
||||
}
|
||||
continue;
|
||||
|
@ -51,18 +51,27 @@ public class Mappings {
|
||||
/**
|
||||
* Maps old identifiers to the new ones.
|
||||
*
|
||||
* @param size set size of the underlying short array
|
||||
* @param oldMapping mappings to map from
|
||||
* @param newMapping mappings to map to
|
||||
* @param size set size of the underlying short array
|
||||
* @param oldMapping mappings to map from
|
||||
* @param newMapping mappings to map to
|
||||
* @param warnOnMissing should "No key for x" be printed if there is no matching identifier
|
||||
*/
|
||||
public Mappings(int size, JsonArray oldMapping, JsonArray newMapping) {
|
||||
public Mappings(int size, JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
|
||||
oldToNew = new short[size];
|
||||
Arrays.fill(oldToNew, (short) -1);
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping);
|
||||
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
public Mappings(JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
|
||||
this(oldMapping.size(), oldMapping, newMapping, warnOnMissing);
|
||||
}
|
||||
|
||||
public Mappings(int size, JsonArray oldMapping, JsonArray newMapping) {
|
||||
this(size, oldMapping, newMapping, true);
|
||||
}
|
||||
|
||||
public Mappings(JsonArray oldMapping, JsonArray newMapping) {
|
||||
this(oldMapping.size(), oldMapping, newMapping);
|
||||
this(oldMapping.size(), oldMapping, newMapping, true);
|
||||
}
|
||||
|
||||
public int getNewId(int old) {
|
||||
|
@ -1,14 +1,15 @@
|
||||
package us.myles.ViaVersion.api.type.types;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Preconditions;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class StringType extends Type<String> {
|
||||
// String#length() (used to limit the string in Minecraft source code) uses char[]#length
|
||||
private static final int maxJavaCharUtf8Length = Character.toString(Character.MAX_VALUE)
|
||||
.getBytes(Charsets.UTF_8).length;
|
||||
.getBytes(StandardCharsets.UTF_8).length;
|
||||
|
||||
public StringType() {
|
||||
super(String.class);
|
||||
@ -21,9 +22,9 @@ public class StringType extends Type<String> {
|
||||
Preconditions.checkArgument(len <= Short.MAX_VALUE * maxJavaCharUtf8Length,
|
||||
"Cannot receive string longer than Short.MAX_VALUE * " + maxJavaCharUtf8Length + " bytes (got %s bytes)", len);
|
||||
|
||||
byte[] b = new byte[len];
|
||||
buffer.readBytes(b);
|
||||
String string = new String(b, Charsets.UTF_8);
|
||||
String string = buffer.toString(buffer.readerIndex(), len, StandardCharsets.UTF_8);
|
||||
buffer.skipBytes(len);
|
||||
|
||||
Preconditions.checkArgument(string.length() <= Short.MAX_VALUE,
|
||||
"Cannot receive string longer than Short.MAX_VALUE characters (got %s bytes)", string.length());
|
||||
|
||||
@ -34,7 +35,7 @@ public class StringType extends Type<String> {
|
||||
public void write(ByteBuf buffer, String object) throws Exception {
|
||||
Preconditions.checkArgument(object.length() <= Short.MAX_VALUE, "Cannot send string longer than Short.MAX_VALUE (got %s characters)", object.length());
|
||||
|
||||
byte[] b = object.getBytes(Charsets.UTF_8);
|
||||
byte[] b = object.getBytes(StandardCharsets.UTF_8);
|
||||
Type.VAR_INT.write(buffer, b.length);
|
||||
buffer.writeBytes(b);
|
||||
}
|
||||
|
@ -36,10 +36,7 @@ public class NBTType extends Type<CompoundTag> {
|
||||
return null;
|
||||
} else {
|
||||
buffer.readerIndex(readerIndex);
|
||||
ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer);
|
||||
try (DataInputStream dataInputStream = new DataInputStream(bytebufStream)) {
|
||||
return (CompoundTag) NBTIO.readTag((DataInput) dataInputStream);
|
||||
}
|
||||
return (CompoundTag) NBTIO.readTag((DataInput) new ByteBufInputStream(buffer));
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,11 +46,7 @@ public class NBTType extends Type<CompoundTag> {
|
||||
buffer.writeByte(0);
|
||||
} else {
|
||||
ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer);
|
||||
DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream);
|
||||
|
||||
NBTIO.writeTag((DataOutput) dataOutputStream, object);
|
||||
|
||||
dataOutputStream.close();
|
||||
NBTIO.writeTag((DataOutput) bytebufStream, object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public class Protocol1_15To1_14_4 extends Protocol {
|
||||
});
|
||||
|
||||
// Edit Book
|
||||
registerIncoming(State.PLAY, 0x0C, 0x0D, new PacketRemapper() {
|
||||
registerIncoming(State.PLAY, 0x0C, 0x0C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
|
@ -25,6 +25,6 @@ public class MappingData {
|
||||
Via.getPlatform().getLogger().info("Loading 1.14.4 -> 1.15 item mapping...");
|
||||
MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_14.getAsJsonObject("items"), mapping1_15.getAsJsonObject("items"));
|
||||
Via.getPlatform().getLogger().info("Loading 1.14.4 -> 1.15 sound mapping...");
|
||||
soundMappings = new Mappings(mapping1_14.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"));
|
||||
soundMappings = new Mappings(mapping1_14.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"), false);
|
||||
}
|
||||
}
|
||||
|
@ -101,18 +101,20 @@ public class WorldPackets {
|
||||
if (chunk.isGroundUp()) {
|
||||
int[] biomeData = chunk.getBiomeData();
|
||||
int[] newBiomeData = new int[1024];
|
||||
// Now in 4x4x4 areas - take the biome of each "middle"
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
int x = (j << 2) + 2;
|
||||
int z = (i << 2) + 2;
|
||||
int oldIndex = (z << 4 | x);
|
||||
newBiomeData[i << 2 | j] = biomeData[oldIndex];
|
||||
if (biomeData != null) {
|
||||
// Now in 4x4x4 areas - take the biome of each "middle"
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
int x = (j << 2) + 2;
|
||||
int z = (i << 2) + 2;
|
||||
int oldIndex = (z << 4 | x);
|
||||
newBiomeData[i << 2 | j] = biomeData[oldIndex];
|
||||
}
|
||||
}
|
||||
// ... and copy it to the new y layers
|
||||
for (int i = 1; i < 64; ++i) {
|
||||
System.arraycopy(newBiomeData, 0, newBiomeData, i * 16, 16);
|
||||
}
|
||||
}
|
||||
// ... and copy it to the new y layers
|
||||
for (int i = 1; i < 64; ++i) {
|
||||
System.arraycopy(newBiomeData, 0, newBiomeData, i * 16, 16);
|
||||
}
|
||||
|
||||
chunk.setBiomeData(newBiomeData);
|
||||
|
Loading…
Reference in New Issue
Block a user