Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f01f0100c | ||
|
|
29d3787de8 | ||
|
|
59df758ceb | ||
|
|
80360bf27c | ||
|
|
3da7d7513e | ||
|
|
a654becac8 | ||
|
|
77a5b2212b | ||
|
|
7013ed8acf | ||
|
|
9d41854e22 | ||
|
|
edf9ccca8b | ||
|
|
d62165bf51 | ||
|
|
00bc4a9d6a | ||
|
|
7885babe1e | ||
|
|
9a53678838 | ||
|
|
91874ffc3b | ||
|
|
e71c34255b | ||
|
|
8e78a14c14 | ||
|
|
3b85200641 | ||
|
|
1dc0f72e54 | ||
|
|
13d27a6f4d | ||
|
|
3cec1751c9 | ||
|
|
80f9dce513 | ||
|
|
cf7c718493 | ||
|
|
0ba20299a3 |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
name: Bug Report
|
||||
description: Report a bug or console error
|
||||
labels: [unconfirmed]
|
||||
|
||||
body:
|
||||
- type: markdown
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.0.0"
|
||||
version = "4.0.1"
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.viaversion.viabackwards.protocol.protocol1_16_2to1_16_3.Protocol1_16_
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_3to1_16_4.Protocol1_16_3To1_16_4;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16to1_16_1.Protocol1_16To1_16_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_17to1_17_1.Protocol1_17To1_17_1;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.protocol.ProtocolManager;
|
||||
@@ -54,7 +55,7 @@ import java.util.logging.Logger;
|
||||
|
||||
public interface ViaBackwardsPlatform {
|
||||
|
||||
String MINIMUM_VV_VERSION = "4.0.0";
|
||||
String MINIMUM_VV_VERSION = "4.0.1";
|
||||
String IMPL_VERSION = "$IMPL_VERSION";
|
||||
|
||||
/**
|
||||
@@ -104,6 +105,7 @@ public interface ViaBackwardsPlatform {
|
||||
protocolManager.registerProtocol(new Protocol1_16_3To1_16_4(), ProtocolVersion.v1_16_3, ProtocolVersion.v1_16_4);
|
||||
|
||||
protocolManager.registerProtocol(new Protocol1_16_4To1_17(), ProtocolVersion.v1_16_4, ProtocolVersion.v1_17);
|
||||
protocolManager.registerProtocol(new Protocol1_17To1_17_1(), ProtocolVersion.v1_17, ProtocolVersion.v1_17_1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
@@ -174,6 +174,8 @@ public abstract class LegacyBlockItemRewriter<T extends BackwardsProtocol> exten
|
||||
tags.put(pos, tag);
|
||||
|
||||
// Handle given Block Entities
|
||||
if (pos.getY() < 0 || pos.getY() > 255) continue; // 1.17
|
||||
|
||||
ChunkSection section = chunk.getSections()[pos.getY() >> 4];
|
||||
if (section == null) continue;
|
||||
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<Protocol1_10To
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.ITEM); // 2 - Slot Value
|
||||
|
||||
|
||||
+6
-1
@@ -271,7 +271,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE);
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
map(Type.SHORT);
|
||||
map(Type.FLAT_ITEM, Type.ITEM);
|
||||
|
||||
@@ -302,6 +302,11 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
if (!provider.isHandled(id)) continue;
|
||||
|
||||
int sectionIndex = ((NumberTag) tag.get("y")).asInt() >> 4;
|
||||
if (sectionIndex < 0 || sectionIndex > 15) {
|
||||
// 1.17 chunks
|
||||
continue;
|
||||
}
|
||||
|
||||
ChunkSection section = chunk.getSections()[sectionIndex];
|
||||
|
||||
int x = ((NumberTag) tag.get("x")).asInt();
|
||||
|
||||
+23
-19
@@ -187,7 +187,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
UUID uuid = packetWrapper.passthrough(Type.UUID);
|
||||
if (action == 0) { // Add
|
||||
String name = packetWrapper.passthrough(Type.STRING);
|
||||
storage.usernames.put(uuid, name);
|
||||
storage.usernames().put(uuid, name);
|
||||
int nProperties = packetWrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < nProperties; j++) {
|
||||
packetWrapper.passthrough(Type.STRING);
|
||||
@@ -210,7 +210,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
packetWrapper.passthrough(Type.COMPONENT);
|
||||
}
|
||||
} else if (action == 4) { // Remove Player
|
||||
storage.usernames.remove(uuid);
|
||||
storage.usernames().remove(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,11 +313,12 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
|
||||
if (!storage.commands.isEmpty()) {
|
||||
storage.commands.clear();
|
||||
if (!storage.commands().isEmpty()) {
|
||||
storage.commands().clear();
|
||||
}
|
||||
|
||||
int size = wrapper.read(Type.VAR_INT);
|
||||
boolean initialNodes = true;
|
||||
for (int i = 0; i < size; i++) {
|
||||
byte flags = wrapper.read(Type.BYTE);
|
||||
wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE); // Children indices
|
||||
@@ -326,11 +327,14 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
}
|
||||
|
||||
byte nodeType = (byte) (flags & 0x03);
|
||||
if (initialNodes && nodeType == 2) {
|
||||
initialNodes = false;
|
||||
}
|
||||
|
||||
if (nodeType == 1 || nodeType == 2) { // Literal/argument node
|
||||
String name = wrapper.read(Type.STRING);
|
||||
|
||||
if (nodeType == 1) {
|
||||
storage.commands.add('/' + name);
|
||||
if (nodeType == 1 && initialNodes) {
|
||||
storage.commands().add('/' + name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,25 +357,25 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
TabCompleteStorage storage = wrapper.user().get(TabCompleteStorage.class);
|
||||
if (storage.lastRequest == null) {
|
||||
if (storage.lastRequest() == null) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
if (storage.lastId != wrapper.read(Type.VAR_INT)) wrapper.cancel();
|
||||
if (storage.lastId() != wrapper.read(Type.VAR_INT)) wrapper.cancel();
|
||||
int start = wrapper.read(Type.VAR_INT);
|
||||
int length = wrapper.read(Type.VAR_INT);
|
||||
|
||||
int lastRequestPartIndex = storage.lastRequest.lastIndexOf(' ') + 1;
|
||||
int lastRequestPartIndex = storage.lastRequest().lastIndexOf(' ') + 1;
|
||||
if (lastRequestPartIndex != start) wrapper.cancel(); // Client only replaces after space
|
||||
|
||||
if (length != storage.lastRequest.length() - lastRequestPartIndex) {
|
||||
if (length != storage.lastRequest().length() - lastRequestPartIndex) {
|
||||
wrapper.cancel(); // We can't set the length in previous versions
|
||||
}
|
||||
|
||||
int count = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < count; i++) {
|
||||
String match = wrapper.read(Type.STRING);
|
||||
wrapper.write(Type.STRING, (start == 0 && !storage.lastAssumeCommand ? "/" : "") + match);
|
||||
wrapper.write(Type.STRING, (start == 0 && !storage.isLastAssumeCommand() ? "/" : "") + match);
|
||||
// Ignore tooltip
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.STRING);
|
||||
@@ -396,14 +400,14 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
if (!assumeCommand && !command.startsWith("/")) {
|
||||
// Complete usernames for non-commands
|
||||
String buffer = command.substring(command.lastIndexOf(' ') + 1);
|
||||
for (String value : storage.usernames.values()) {
|
||||
for (String value : storage.usernames().values()) {
|
||||
if (startsWithIgnoreCase(value, buffer)) {
|
||||
suggestions.add(value);
|
||||
}
|
||||
}
|
||||
} else if (!storage.commands.isEmpty() && !command.contains(" ")) {
|
||||
} else if (!storage.commands().isEmpty() && !command.contains(" ")) {
|
||||
// Complete commands names with values from 'Declare Commands' packet
|
||||
for (String value : storage.commands) {
|
||||
for (String value : storage.commands()) {
|
||||
if (startsWithIgnoreCase(value, command)) {
|
||||
suggestions.add(value);
|
||||
}
|
||||
@@ -418,7 +422,7 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
response.write(Type.STRING, value);
|
||||
}
|
||||
response.scheduleSend(Protocol1_12_2To1_13.class);
|
||||
storage.lastRequest = null;
|
||||
storage.setLastRequest(null);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -430,9 +434,9 @@ public class PlayerPacket1_13 extends RewriterBase<Protocol1_12_2To1_13> {
|
||||
wrapper.write(Type.VAR_INT, id);
|
||||
wrapper.write(Type.STRING, command);
|
||||
|
||||
storage.lastId = id;
|
||||
storage.lastAssumeCommand = assumeCommand;
|
||||
storage.lastRequest = command;
|
||||
storage.setLastId(id);
|
||||
storage.setLastAssumeCommand(assumeCommand);
|
||||
storage.setLastRequest(command);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
+37
-5
@@ -26,9 +26,41 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TabCompleteStorage implements StorableObject {
|
||||
public int lastId;
|
||||
public String lastRequest;
|
||||
public boolean lastAssumeCommand;
|
||||
public Map<UUID, String> usernames = new HashMap<>();
|
||||
public Set<String> commands = new HashSet<>();
|
||||
private final Map<UUID, String> usernames = new HashMap<>();
|
||||
private final Set<String> commands = new HashSet<>();
|
||||
private int lastId;
|
||||
private String lastRequest;
|
||||
private boolean lastAssumeCommand;
|
||||
|
||||
public Map<UUID, String> usernames() {
|
||||
return usernames;
|
||||
}
|
||||
|
||||
public Set<String> commands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public int lastId() {
|
||||
return lastId;
|
||||
}
|
||||
|
||||
public void setLastId(final int lastId) {
|
||||
this.lastId = lastId;
|
||||
}
|
||||
|
||||
public String lastRequest() {
|
||||
return lastRequest;
|
||||
}
|
||||
|
||||
public void setLastRequest(String lastRequest) {
|
||||
this.lastRequest = lastRequest;
|
||||
}
|
||||
|
||||
public boolean isLastAssumeCommand() {
|
||||
return lastAssumeCommand;
|
||||
}
|
||||
|
||||
public void setLastAssumeCommand(boolean lastAssumeCommand) {
|
||||
this.lastAssumeCommand = lastAssumeCommand;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class InventoryPackets1_13_2 {
|
||||
protocol.registerClientbound(ClientboundPackets1_13.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM, Type.FLAT_ITEM); // 2 - Slot Value
|
||||
}
|
||||
|
||||
+1
-7
@@ -393,6 +393,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
EntityType type = event.entityType();
|
||||
if (type == null) return;
|
||||
if (type.isOrHasParent(Entity1_14Types.ABSTRACT_ILLAGER_BASE) || type == Entity1_14Types.RAVAGER || type == Entity1_14Types.WITCH) {
|
||||
int index = event.index();
|
||||
if (index == 14) {
|
||||
@@ -473,13 +474,6 @@ public class EntityPackets1_14 extends LegacyEntityRewriter<Protocol1_13_2To1_14
|
||||
// Something
|
||||
filter().removeIndex(6);
|
||||
|
||||
filter().handler((event, meta) -> {
|
||||
int typeId = meta.metaType().typeId();
|
||||
if (typeId > 15) {
|
||||
ViaBackwards.getPlatform().getLogger().warning("New 1.14 metadata was not handled: " + meta + " entity: " + event.entityType());
|
||||
}
|
||||
});
|
||||
|
||||
filter().type(Entity1_14Types.OCELOT).index(13).handler((event, meta) -> {
|
||||
event.setIndex(15);
|
||||
meta.setTypeAndValue(MetaType1_13_2.VarInt, 0);
|
||||
|
||||
+6
-2
@@ -29,6 +29,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -50,7 +51,7 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
if (!wrapper.user().get(ImmediateRespawn.class).isImmediateRespawn()) return;
|
||||
|
||||
// Instantly request respawn when 1.15 gamerule is set
|
||||
PacketWrapper statusPacket = wrapper.create(0x04);
|
||||
PacketWrapper statusPacket = wrapper.create(ServerboundPackets1_14.CLIENT_STATUS);
|
||||
statusPacket.write(Type.VAR_INT, 0);
|
||||
statusPacket.sendToServer(Protocol1_14_4To1_15.class);
|
||||
});
|
||||
@@ -122,7 +123,10 @@ public class EntityPackets1_15 extends EntityRewriter<Protocol1_14_4To1_15> {
|
||||
|
||||
handler(getTrackerHandler(Entity1_15Types.PLAYER, Type.INT));
|
||||
|
||||
handler(wrapper -> wrapper.user().get(ImmediateRespawn.class).setImmediateRespawn(wrapper.read(Type.BOOLEAN)));
|
||||
handler(wrapper -> {
|
||||
boolean immediateRespawn = !wrapper.read(Type.BOOLEAN); // Inverted
|
||||
wrapper.user().get(ImmediateRespawn.class).setImmediateRespawn(immediateRespawn);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+6
-2
@@ -30,9 +30,11 @@ import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer;
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
|
||||
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
|
||||
@@ -113,7 +115,9 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
|
||||
// Send a dummy respawn with a different dimension if the world name was different and the same dimension was used
|
||||
if (clientWorld.getEnvironment() != null && dimension == clientWorld.getEnvironment().getId()
|
||||
&& (wrapper.user().isClientSide() || Via.getPlatform().isProxy() || !nextWorldName.equals(worldNameTracker.getWorldName()))) {
|
||||
&& (wrapper.user().isClientSide() || Via.getPlatform().isProxy()
|
||||
|| wrapper.user().getProtocolInfo().getProtocolVersion() <= ProtocolVersion.v1_12_2.getVersion() // Hotfix for https://github.com/ViaVersion/ViaBackwards/issues/381
|
||||
|| !nextWorldName.equals(worldNameTracker.getWorldName()))) {
|
||||
PacketWrapper packet = wrapper.create(ClientboundPackets1_15.RESPAWN);
|
||||
packet.write(Type.INT, dimension == 0 ? -1 : 0);
|
||||
packet.write(Type.LONG, 0L);
|
||||
@@ -176,7 +180,7 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
|
||||
registerTracker(ClientboundPackets1_16.SPAWN_PAINTING, Entity1_16Types.PAINTING);
|
||||
registerTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16Types.PLAYER);
|
||||
registerRemoveEntities(ClientboundPackets1_16.DESTROY_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_14.METADATA_LIST);
|
||||
registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_16.METADATA_LIST, Types1_14.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.ENTITY_PROPERTIES, new PacketRemapper() {
|
||||
@Override
|
||||
|
||||
+2
@@ -187,7 +187,9 @@ public final class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPac
|
||||
wrapper.cancel();
|
||||
|
||||
// Plugins expecting a real response will have to handle this accordingly themselves
|
||||
int id = wrapper.read(Type.INT);
|
||||
PacketWrapper pongPacket = wrapper.create(ServerboundPackets1_17.PONG);
|
||||
pongPacket.write(Type.INT, id);
|
||||
pongPacket.sendToServer(Protocol1_16_4To1_17.class);
|
||||
});
|
||||
}
|
||||
|
||||
+4
-3
@@ -109,7 +109,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<Protocol1_16_4To1_1
|
||||
map(Type.INT); // Particle count
|
||||
handler(wrapper -> {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 15) {
|
||||
if (id == 16) {
|
||||
wrapper.passthrough(Type.FLOAT); // R
|
||||
wrapper.passthrough(Type.FLOAT); // G
|
||||
wrapper.passthrough(Type.FLOAT); // B
|
||||
@@ -119,7 +119,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<Protocol1_16_4To1_1
|
||||
wrapper.read(Type.FLOAT); // R
|
||||
wrapper.read(Type.FLOAT); // G
|
||||
wrapper.read(Type.FLOAT); // B
|
||||
} else if (id == 36) {
|
||||
} else if (id == 37) {
|
||||
// Vibration signal - no nice mapping possible without tracking entity positions and doing particle tasks
|
||||
wrapper.cancel();
|
||||
}
|
||||
@@ -307,9 +307,10 @@ public final class BlockItemPackets1_17 extends ItemRewriter<Protocol1_16_4To1_1
|
||||
boolean hasMarkers = wrapper.read(Type.BOOLEAN);
|
||||
if (!hasMarkers) {
|
||||
wrapper.write(Type.VAR_INT, 0); // Array size
|
||||
} else {
|
||||
MapColorRewriter.getRewriteHandler(MapColorRewrites::getMappedColor).handle(wrapper);
|
||||
}
|
||||
});
|
||||
handler(MapColorRewriter.getRewriteHandler(MapColorRewrites::getMappedColor));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+7
-7
@@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.Particle;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_14;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_16;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_17;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
@@ -46,12 +46,12 @@ public final class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerTrackerWithData(ClientboundPackets1_17.SPAWN_ENTITY, Entity1_16_2Types.FALLING_BLOCK);
|
||||
registerTrackerWithData(ClientboundPackets1_17.SPAWN_ENTITY, Entity1_17Types.FALLING_BLOCK);
|
||||
registerSpawnTracker(ClientboundPackets1_17.SPAWN_MOB);
|
||||
registerTracker(ClientboundPackets1_17.SPAWN_EXPERIENCE_ORB, Entity1_16_2Types.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_17.SPAWN_PAINTING, Entity1_16_2Types.PAINTING);
|
||||
registerTracker(ClientboundPackets1_17.SPAWN_PLAYER, Entity1_16_2Types.PLAYER);
|
||||
registerMetadataRewriter(ClientboundPackets1_17.ENTITY_METADATA, Types1_17.METADATA_LIST, Types1_14.METADATA_LIST);
|
||||
registerTracker(ClientboundPackets1_17.SPAWN_EXPERIENCE_ORB, Entity1_17Types.EXPERIENCE_ORB);
|
||||
registerTracker(ClientboundPackets1_17.SPAWN_PAINTING, Entity1_17Types.PAINTING);
|
||||
registerTracker(ClientboundPackets1_17.SPAWN_PLAYER, Entity1_17Types.PLAYER);
|
||||
registerMetadataRewriter(ClientboundPackets1_17.ENTITY_METADATA, Types1_17.METADATA_LIST, Types1_16.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_17.REMOVE_ENTITY, ClientboundPackets1_16_2.DESTROY_ENTITIES, new PacketRemapper() {
|
||||
@Override
|
||||
@@ -83,7 +83,7 @@ public final class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17
|
||||
wrapper.set(Type.BYTE, 0, (byte) 0);
|
||||
}
|
||||
});
|
||||
handler(getTrackerHandler(Entity1_16_2Types.PLAYER, Type.INT));
|
||||
handler(getTrackerHandler(Entity1_17Types.PLAYER, Type.INT));
|
||||
handler(worldDataTrackerHandler(1));
|
||||
handler(wrapper -> {
|
||||
CompoundTag registry = wrapper.get(Type.NBT, 0);
|
||||
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_17to1_17_1;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_17to1_17_1.storage.InventoryStateIds;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ClientboundPackets1_17;
|
||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||
|
||||
public final class Protocol1_17To1_17_1 extends BackwardsProtocol<ClientboundPackets1_17_1, ClientboundPackets1_17, ServerboundPackets1_17, ServerboundPackets1_17> {
|
||||
|
||||
private static final int MAX_PAGE_LENGTH = 8192;
|
||||
private static final int MAX_TITLE_LENGTH = 128;
|
||||
private static final int MAX_PAGES = 200; // Actually limited to 100 when handling the read packet, but /shrug
|
||||
|
||||
public Protocol1_17To1_17_1() {
|
||||
super(ClientboundPackets1_17_1.class, ClientboundPackets1_17.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
registerClientbound(ClientboundPackets1_17_1.REMOVE_ENTITIES, null, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
int[] entityIds = wrapper.read(Type.VAR_INT_ARRAY_PRIMITIVE);
|
||||
wrapper.cancel();
|
||||
for (int entityId : entityIds) {
|
||||
// Send individual remove packets
|
||||
PacketWrapper newPacket = wrapper.create(ClientboundPackets1_17.REMOVE_ENTITY);
|
||||
newPacket.write(Type.VAR_INT, entityId);
|
||||
newPacket.send(Protocol1_17To1_17_1.class);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerClientbound(ClientboundPackets1_17_1.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_17_1.SET_SLOT, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
int stateId = wrapper.read(Type.VAR_INT);
|
||||
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerClientbound(ClientboundPackets1_17_1.WINDOW_ITEMS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
int stateId = wrapper.read(Type.VAR_INT);
|
||||
wrapper.user().get(InventoryStateIds.class).setStateId(containerId, stateId);
|
||||
|
||||
// Length is encoded as a var int in 1.17.1
|
||||
wrapper.write(Type.FLAT_VAR_INT_ITEM_ARRAY, wrapper.read(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT));
|
||||
|
||||
// Carried item - should work without adding it to the array above
|
||||
wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_17.CLOSE_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
|
||||
});
|
||||
}
|
||||
});
|
||||
registerServerbound(ServerboundPackets1_17.CLICK_WINDOW, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
short containerId = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
int stateId = wrapper.user().get(InventoryStateIds.class).removeStateId(containerId);
|
||||
wrapper.write(Type.VAR_INT, stateId == Integer.MAX_VALUE ? 0 : stateId);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
registerServerbound(ServerboundPackets1_17.EDIT_BOOK, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(wrapper -> {
|
||||
Item item = wrapper.read(Type.FLAT_VAR_INT_ITEM);
|
||||
boolean signing = wrapper.read(Type.BOOLEAN);
|
||||
wrapper.passthrough(Type.VAR_INT); // Slot comes first
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
ListTag pagesTag;
|
||||
StringTag titleTag = null;
|
||||
// Sanity checks
|
||||
if (tag == null || (pagesTag = tag.get("pages")) == null
|
||||
|| (signing && (titleTag = tag.get("title")) == null)) {
|
||||
wrapper.write(Type.VAR_INT, 0); // Pages length
|
||||
wrapper.write(Type.BOOLEAN, false); // Optional title
|
||||
return;
|
||||
}
|
||||
|
||||
// Write pages - limit them first
|
||||
if (pagesTag.size() > MAX_PAGES) {
|
||||
pagesTag = new ListTag(pagesTag.getValue().subList(0, MAX_PAGES));
|
||||
}
|
||||
|
||||
wrapper.write(Type.VAR_INT, pagesTag.size());
|
||||
for (Tag pageTag : pagesTag) {
|
||||
String page = ((StringTag) pageTag).getValue();
|
||||
// Limit page length
|
||||
if (page.length() > MAX_PAGE_LENGTH) {
|
||||
page = page.substring(0, MAX_PAGE_LENGTH);
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, page);
|
||||
}
|
||||
|
||||
// Write optional title
|
||||
wrapper.write(Type.BOOLEAN, signing);
|
||||
if (signing) {
|
||||
if (titleTag == null) {
|
||||
titleTag = tag.get("title");
|
||||
}
|
||||
|
||||
// Limit title length
|
||||
String title = titleTag.getValue();
|
||||
if (title.length() > MAX_TITLE_LENGTH) {
|
||||
title = title.substring(0, MAX_TITLE_LENGTH);
|
||||
}
|
||||
|
||||
wrapper.write(Type.STRING, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection connection) {
|
||||
connection.put(new InventoryStateIds());
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
|
||||
* Copyright (C) 2016-2021 ViaVersion and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_17to1_17_1.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.ints.Int2IntOpenHashMap;
|
||||
|
||||
public final class InventoryStateIds implements StorableObject {
|
||||
private final Int2IntMap ids = new Int2IntOpenHashMap();
|
||||
|
||||
public InventoryStateIds() {
|
||||
// Inventory ids are unsigned bytes, so this is safe to do
|
||||
ids.defaultReturnValue(Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public void setStateId(short containerId, int id) {
|
||||
ids.put(containerId, id);
|
||||
}
|
||||
|
||||
public int removeStateId(short containerId) {
|
||||
return ids.remove(containerId);
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,9 @@ public class ViaFabricAddon implements ViaBackwardsPlatform, Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Path configDirPath = FabricLoader.getInstance().getConfigDirectory().toPath().resolve("ViaBackwards");
|
||||
Path configDirPath = FabricLoader.getInstance().getConfigDir().resolve("ViaBackwards");
|
||||
configDir = configDirPath.toFile();
|
||||
this.init(configDirPath.resolve("config.yml").toFile());
|
||||
this.init(getDataFolder());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,7 +3,7 @@ metadata.format.version = "1.0"
|
||||
[versions]
|
||||
|
||||
# ViaVersion
|
||||
viaver = "4.0.0-1.17-rc2-SNAPSHOT"
|
||||
viaver = "4.0.1-1.17.1-rc1-SNAPSHOT"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
@@ -17,7 +17,7 @@ paper = "1.16.5-R0.1-SNAPSHOT"
|
||||
bungee = "1.16-R0.5-SNAPSHOT"
|
||||
sponge = "5.0.0"
|
||||
velocity = "3.0.0-SNAPSHOT"
|
||||
fabricLoader = "0.4.8+build.154"
|
||||
fabricLoader = "0.11.6"
|
||||
|
||||
|
||||
[libraries]
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -5,6 +5,7 @@ rootProject.name = "viabackwards-parent"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven("https://repo.viaversion.com")
|
||||
maven("https://papermc.io/repo/repository/maven-public/")
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||
|
||||
Reference in new issue
Block a user