mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2025-01-02 18:48:06 +01:00
Start working on 1.18
This commit is contained in:
parent
9615a5aba2
commit
5777f4a117
@ -5,7 +5,7 @@ plugins {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
group = "com.viaversion"
|
group = "com.viaversion"
|
||||||
version = "4.0.2-SNAPSHOT"
|
version = "4.1.0-SNAPSHOT"
|
||||||
description = "Allow older clients to join newer server versions."
|
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_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_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_16to1_16_1.Protocol1_16To1_16_1;
|
||||||
|
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18;
|
||||||
import com.viaversion.viabackwards.protocol.protocol1_17to1_17_1.Protocol1_17To1_17_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.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||||
import com.viaversion.viaversion.api.Via;
|
import com.viaversion.viaversion.api.Via;
|
||||||
@ -106,6 +107,7 @@ public interface ViaBackwardsPlatform {
|
|||||||
|
|
||||||
protocolManager.registerProtocol(new Protocol1_16_4To1_17(), ProtocolVersion.v1_16_4, ProtocolVersion.v1_17);
|
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);
|
protocolManager.registerProtocol(new Protocol1_17To1_17_1(), ProtocolVersion.v1_17, ProtocolVersion.v1_17_1);
|
||||||
|
protocolManager.registerProtocol(new Protocol1_17_1To1_18(), ProtocolVersion.v1_17_1, ProtocolVersion.v1_18);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -88,8 +88,8 @@ public final class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17
|
|||||||
handler(worldDataTrackerHandler(1));
|
handler(worldDataTrackerHandler(1));
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
CompoundTag registry = wrapper.get(Type.NBT, 0);
|
CompoundTag registry = wrapper.get(Type.NBT, 0);
|
||||||
CompoundTag biomeRegsitry = registry.get("minecraft:worldgen/biome");
|
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
||||||
ListTag biomes = biomeRegsitry.get("value");
|
ListTag biomes = biomeRegistry.get("value");
|
||||||
for (Tag biome : biomes) {
|
for (Tag biome : biomes) {
|
||||||
CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
|
CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
|
||||||
StringTag category = biomeCompound.get("category");
|
StringTag category = biomeCompound.get("category");
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
* 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_17_1to1_18;
|
||||||
|
|
||||||
|
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||||
|
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||||
|
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.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
|
||||||
|
|
||||||
|
public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPackets1_17_1, ClientboundPackets1_17_1, ServerboundPackets1_17, ServerboundPackets1_17> {
|
||||||
|
|
||||||
|
public Protocol1_17_1To1_18() {
|
||||||
|
super(ClientboundPackets1_17_1.class, ClientboundPackets1_17_1.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets() {
|
||||||
|
registerClientbound(ClientboundPackets1_17_1.CHUNK_DATA, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(wrapper -> {
|
||||||
|
final EntityTracker tracker = getEntityRewriter().tracker(wrapper.user());
|
||||||
|
final Chunk chunk = wrapper.passthrough(new Chunk1_17Type(tracker.currentWorldSectionHeight()));
|
||||||
|
/*for (int s = 0; s < chunk.getSections().length; s++) {
|
||||||
|
ChunkSection section = chunk.getSections()[s];
|
||||||
|
if (section == null) continue;
|
||||||
|
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||||
|
int old = section.getPaletteEntry(i);
|
||||||
|
section.setPaletteEntry(i, protocol.getMappingData().getNewBlockStateId(old));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Create and send light packet first
|
||||||
|
final PacketWrapper lightPacket = wrapper.create(ClientboundPackets1_17_1.UPDATE_LIGHT);
|
||||||
|
lightPacket.write(Type.BOOLEAN, wrapper.read(Type.BOOLEAN)); // Trust edges
|
||||||
|
lightPacket.write(Type.LONG_ARRAY_PRIMITIVE, wrapper.read(Type.LONG_ARRAY_PRIMITIVE)); // Sky light mask
|
||||||
|
lightPacket.write(Type.LONG_ARRAY_PRIMITIVE, wrapper.read(Type.LONG_ARRAY_PRIMITIVE)); // Block light mask
|
||||||
|
lightPacket.write(Type.LONG_ARRAY_PRIMITIVE, wrapper.read(Type.LONG_ARRAY_PRIMITIVE)); // Empty sky light mask
|
||||||
|
lightPacket.write(Type.LONG_ARRAY_PRIMITIVE, wrapper.read(Type.LONG_ARRAY_PRIMITIVE)); // Empty block light mask
|
||||||
|
|
||||||
|
final int skyLightLength = wrapper.read(Type.VAR_INT);
|
||||||
|
lightPacket.write(Type.VAR_INT, skyLightLength);
|
||||||
|
for (int i = 0; i < skyLightLength; i++) {
|
||||||
|
lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
|
||||||
|
}
|
||||||
|
|
||||||
|
final int blockLightLength = wrapper.read(Type.VAR_INT);
|
||||||
|
lightPacket.write(Type.VAR_INT, blockLightLength);
|
||||||
|
for (int i = 0; i < blockLightLength; i++) {
|
||||||
|
lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, wrapper.read(Type.BYTE_ARRAY_PRIMITIVE));
|
||||||
|
}
|
||||||
|
|
||||||
|
lightPacket.send(Protocol1_17_1To1_18.class);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,95 @@
|
|||||||
|
/*
|
||||||
|
* 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_17_1to1_18.packets;
|
||||||
|
|
||||||
|
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||||
|
import com.viaversion.viabackwards.protocol.protocol1_17_1to1_18.Protocol1_17_1To1_18;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
||||||
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
|
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.FloatTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||||
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
|
|
||||||
|
public final class EntityPackets1_17 extends EntityRewriter<Protocol1_17_1To1_18> {
|
||||||
|
|
||||||
|
public EntityPackets1_17(Protocol1_17_1To1_18 protocol) {
|
||||||
|
super(protocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerPackets() {
|
||||||
|
/*registerTrackerWithData(ClientboundPackets1_17_1.SPAWN_ENTITY, Entity1_18Types.FALLING_BLOCK);
|
||||||
|
registerSpawnTracker(ClientboundPackets1_17_1.SPAWN_MOB);
|
||||||
|
registerTracker(ClientboundPackets1_17_1.SPAWN_EXPERIENCE_ORB, Entity1_18Types.EXPERIENCE_ORB);
|
||||||
|
registerTracker(ClientboundPackets1_17_1.SPAWN_PAINTING, Entity1_18Types.PAINTING);
|
||||||
|
registerTracker(ClientboundPackets1_17_1.SPAWN_PLAYER, Entity1_18Types.PLAYER);
|
||||||
|
registerMetadataRewriter(ClientboundPackets1_17_1.ENTITY_METADATA, Types1_17.METADATA_LIST);
|
||||||
|
registerRemoveEntities(ClientboundPackets1_17_1.REMOVE_ENTITIES);*/
|
||||||
|
|
||||||
|
protocol.registerClientbound(ClientboundPackets1_17_1.JOIN_GAME, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.INT); // Entity ID
|
||||||
|
map(Type.BOOLEAN); // Hardcore
|
||||||
|
map(Type.UNSIGNED_BYTE); // Gamemode
|
||||||
|
map(Type.BYTE); // Previous Gamemode
|
||||||
|
map(Type.STRING_ARRAY); // Worlds
|
||||||
|
map(Type.NBT); // Dimension registry
|
||||||
|
map(Type.NBT); // Current dimension data
|
||||||
|
map(Type.STRING); // World
|
||||||
|
handler(getTrackerHandler(Entity1_17Types.PLAYER, Type.INT));
|
||||||
|
handler(worldDataTrackerHandler(1));
|
||||||
|
handler(wrapper -> {
|
||||||
|
CompoundTag registry = wrapper.get(Type.NBT, 0);
|
||||||
|
CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
||||||
|
ListTag biomes = biomeRegistry.get("value");
|
||||||
|
for (Tag biome : biomes) {
|
||||||
|
CompoundTag biomeCompound = ((CompoundTag) biome).get("element");
|
||||||
|
// The client just needs something
|
||||||
|
biomeCompound.put("depth", new FloatTag(0.125F));
|
||||||
|
biomeCompound.put("scale", new FloatTag(0.05F));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
protocol.registerClientbound(ClientboundPackets1_17_1.RESPAWN, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
map(Type.NBT); // Dimension data
|
||||||
|
map(Type.STRING); // World
|
||||||
|
handler(worldDataTrackerHandler(0));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerRewrites() {
|
||||||
|
// Particles have already been handled
|
||||||
|
//registerMetaTypeHandler(MetaType1_17.ITEM, MetaType1_17.BLOCK_STATE, null, MetaType1_17.OPT_COMPONENT); //TODO correct types
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EntityType typeFromId(int typeId) {
|
||||||
|
return Entity1_17Types.getTypeFromId(typeId); //TODO
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
# ViaVersion
|
# ViaVersion
|
||||||
viaver = "4.0.1"
|
viaver = "4.1.0-SNAPSHOT"
|
||||||
|
|
||||||
# Common provided
|
# Common provided
|
||||||
netty = "4.0.20.Final"
|
netty = "4.0.20.Final"
|
||||||
|
Loading…
Reference in New Issue
Block a user