1.19 Experimental Snapshot 1

This commit is contained in:
Nassim Jahnke 2022-02-18 11:49:15 +01:00
parent eda8abf55c
commit 422f2b699b
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
9 changed files with 491 additions and 3 deletions

View File

@ -5,7 +5,7 @@ plugins {
allprojects {
group = "com.viaversion"
version = "4.2.1-SNAPSHOT"
version = "4.3.0-22w11a-SNAPSHOT"
description = "Allow older clients to join newer server versions."
}

View File

@ -45,6 +45,7 @@ import com.viaversion.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4T
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_18_2to1_19.Protocol1_18_2To1_19;
import com.viaversion.viabackwards.protocol.protocol1_18to1_18_2.Protocol1_18To1_18_2;
import com.viaversion.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
import com.viaversion.viaversion.api.Via;
@ -110,7 +111,9 @@ public interface ViaBackwardsPlatform {
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);
protocolManager.registerProtocol(new Protocol1_18To1_18_2(), ProtocolVersion.v1_18, ProtocolVersion.v1_18_2);
//protocolManager.registerProtocol(new Protocol1_18To1_18_2(), ProtocolVersion.v1_18, ProtocolVersion.v1_18_2); //TODO
protocolManager.registerProtocol(new Protocol1_18_2To1_19(), ProtocolVersion.v1_18, ProtocolVersion.v1_19);
}
/**

View File

@ -0,0 +1,103 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2022 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_18_2to1_19;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappings;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.packets.BlockItemPackets1_19;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.packets.EntityPackets1_19;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types;
import com.viaversion.viaversion.api.rewriter.EntityRewriter;
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.ClientboundPackets1_18;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.Protocol1_19To1_18_2;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
public final class Protocol1_18_2To1_19 extends BackwardsProtocol<ClientboundPackets1_19, ClientboundPackets1_18, ServerboundPackets1_17, ServerboundPackets1_17> {
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.19", "1.18", Protocol1_19To1_18_2.class, true);
private final EntityPackets1_19 entityRewriter = new EntityPackets1_19(this);
private final BlockItemPackets1_19 blockItemPackets = new BlockItemPackets1_19(this);
private final TranslatableRewriter translatableRewriter = new TranslatableRewriter(this);
public Protocol1_18_2To1_19() {
super(ClientboundPackets1_19.class, ClientboundPackets1_18.class, ServerboundPackets1_17.class, ServerboundPackets1_17.class);
}
@Override
protected void registerPackets() {
//TODO block entity update, chunk?
executeAsyncAfterLoaded(Protocol1_19To1_18_2.class, MAPPINGS::load);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19.CHAT_MESSAGE);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19.ACTIONBAR);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19.TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_19.TITLE_SUBTITLE);
translatableRewriter.registerBossBar(ClientboundPackets1_19.BOSSBAR);
translatableRewriter.registerDisconnect(ClientboundPackets1_19.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_19.TAB_LIST);
translatableRewriter.registerOpenWindow(ClientboundPackets1_19.OPEN_WINDOW);
translatableRewriter.registerCombatKill(ClientboundPackets1_19.COMBAT_KILL);
translatableRewriter.registerPing();
blockItemPackets.register();
entityRewriter.register();
final SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_19.SOUND);
soundRewriter.registerSound(ClientboundPackets1_19.ENTITY_SOUND);
soundRewriter.registerNamedSound(ClientboundPackets1_19.NAMED_SOUND);
soundRewriter.registerStopSound(ClientboundPackets1_19.STOP_SOUND);
new TagRewriter(this).registerGeneric(ClientboundPackets1_19.TAGS);
new StatisticsRewriter(this).register(ClientboundPackets1_19.STATISTICS);
}
@Override
public void init(final UserConnection user) {
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19Types.PLAYER));
}
@Override
public BackwardsMappings getMappingData() {
return MAPPINGS;
}
@Override
public TranslatableRewriter getTranslatableRewriter() {
return translatableRewriter;
}
@Override
public EntityRewriter getEntityRewriter() {
return entityRewriter;
}
@Override
public ItemRewriter getItemRewriter() {
return blockItemPackets;
}
}

View File

@ -0,0 +1,146 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2022 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_18_2to1_19.packets;
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.Protocol1_18_2To1_19;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_16to1_15_2.data.RecipeRewriter1_16;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.util.MathUtil;
public final class BlockItemPackets1_19 extends ItemRewriter<Protocol1_18_2To1_19> {
public BlockItemPackets1_19(final Protocol1_18_2To1_19 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
final BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14);
new RecipeRewriter1_16(protocol).registerDefaultHandler(ClientboundPackets1_19.DECLARE_RECIPES);
registerSetCooldown(ClientboundPackets1_19.COOLDOWN);
registerWindowItems1_17_1(ClientboundPackets1_19.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT, Type.FLAT_VAR_INT_ITEM);
registerSetSlot1_17_1(ClientboundPackets1_19.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
registerEntityEquipmentArray(ClientboundPackets1_19.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
registerTradeList(ClientboundPackets1_19.TRADE_LIST, Type.FLAT_VAR_INT_ITEM);
registerAdvancements(ClientboundPackets1_19.ADVANCEMENTS, Type.FLAT_VAR_INT_ITEM);
registerClickWindow1_17_1(ServerboundPackets1_17.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_19.ACKNOWLEDGE_PLAYER_DIGGING);
blockRewriter.registerBlockAction(ClientboundPackets1_19.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_19.BLOCK_CHANGE);
blockRewriter.registerVarLongMultiBlockChange(ClientboundPackets1_19.MULTI_BLOCK_CHANGE);
blockRewriter.registerEffect(ClientboundPackets1_19.EFFECT, 1010, 2001);
registerCreativeInvAction(ServerboundPackets1_17.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
protocol.registerServerbound(ServerboundPackets1_17.EDIT_BOOK, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
}
});
protocol.registerClientbound(ClientboundPackets1_19.WINDOW_PROPERTY, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // Window Id
map(Type.SHORT); // Property
map(Type.SHORT); // Value
handler(wrapper -> {
short property = wrapper.get(Type.SHORT, 0);
if (property >= 4 && property <= 6) { // Enchantment id
short enchantmentId = wrapper.get(Type.SHORT, 1);
if (enchantmentId > 12) { // Fast sneaking
wrapper.set(Type.SHORT, 1, --enchantmentId);
} else if (enchantmentId == 12) {
wrapper.set(Type.SHORT, 1, (short) -1);
}
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_19.SPAWN_PARTICLE, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Particle id
map(Type.BOOLEAN); // Override limiter
map(Type.DOUBLE); // X
map(Type.DOUBLE); // Y
map(Type.DOUBLE); // Z
map(Type.FLOAT); // Offset X
map(Type.FLOAT); // Offset Y
map(Type.FLOAT); // Offset Z
map(Type.FLOAT); // Max speed
map(Type.INT); // Particle Count
handler(wrapper -> {
final int id = wrapper.get(Type.INT, 0);
final ParticleMappings particleMappings = protocol.getMappingData().getParticleMappings();
if (id == particleMappings.id("sculk_charge")) {
//TODO
wrapper.set(Type.INT, 0, -1);
wrapper.cancel();
} else if (id == particleMappings.id("shriek")) {
//TODO
wrapper.set(Type.INT, 0, -1);
wrapper.cancel();
} else if (id == particleMappings.id("vibration")) {
// Can't do without the position
wrapper.set(Type.INT, 0, -1);
wrapper.cancel();
}
});
handler(getSpawnParticleHandler(Type.FLAT_VAR_INT_ITEM));
}
});
protocol.registerClientbound(ClientboundPackets1_19.CHUNK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(),
MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().size()),
MathUtil.ceilLog2(tracker.biomesSent()));
final Chunk chunk = wrapper.passthrough(chunkType);
for (final ChunkSection section : chunk.getSections()) {
final DataPalette blockPalette = section.palette(PaletteType.BLOCKS);
for (int i = 0; i < blockPalette.size(); i++) {
final int id = blockPalette.idByIndex(i);
blockPalette.setIdByIndex(i, protocol.getMappingData().getNewBlockStateId(id));
}
}
});
}
});
}
}

View File

@ -0,0 +1,141 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2022 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_18_2to1_19.packets;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.protocol1_18_2to1_19.Protocol1_18_2To1_19;
import com.viaversion.viaversion.api.data.ParticleMappings;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19Types;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
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_18;
import com.viaversion.viaversion.api.type.types.version.Types1_19;
import com.viaversion.viaversion.protocols.protocol1_19to1_18_2.ClientboundPackets1_19;
public final class EntityPackets1_19 extends EntityRewriter<Protocol1_18_2To1_19> {
public EntityPackets1_19(final Protocol1_18_2To1_19 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
registerTrackerWithData(ClientboundPackets1_19.SPAWN_ENTITY, Entity1_19Types.FALLING_BLOCK);
registerSpawnTracker(ClientboundPackets1_19.SPAWN_MOB);
registerTracker(ClientboundPackets1_19.SPAWN_EXPERIENCE_ORB, Entity1_19Types.EXPERIENCE_ORB);
registerTracker(ClientboundPackets1_19.SPAWN_PAINTING, Entity1_19Types.PAINTING);
registerTracker(ClientboundPackets1_19.SPAWN_PLAYER, Entity1_19Types.PLAYER);
registerMetadataRewriter(ClientboundPackets1_19.ENTITY_METADATA, Types1_19.METADATA_LIST, Types1_18.METADATA_LIST);
registerRemoveEntities(ClientboundPackets1_19.REMOVE_ENTITIES);
protocol.registerClientbound(ClientboundPackets1_19.ENTITY_EFFECT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // Entity id
map(Type.BYTE); // Effect id
map(Type.BYTE); // Amplifier
map(Type.VAR_INT); // Duration
map(Type.BYTE); // Flags
handler(wrapper -> {
// Remove factor data
if (wrapper.read(Type.BOOLEAN)) {
wrapper.read(Type.NBT);
}
});
}
});
protocol.registerClientbound(ClientboundPackets1_19.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
map(Type.LONG); // Seed
map(Type.VAR_INT); // Max players
map(Type.VAR_INT); // Chunk radius
map(Type.VAR_INT); // Read simulation distance
handler(worldDataTrackerHandler(1));
}
});
protocol.registerClientbound(ClientboundPackets1_19.RESPAWN, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.NBT); // Dimension data
map(Type.STRING); // World
handler(worldDataTrackerHandler(0));
}
});
}
@Override
protected void registerRewrites() {
filter().handler((event, meta) -> {
meta.setMetaType(Types1_18.META_TYPES.byId(meta.metaType().typeId()));
final MetaType type = meta.metaType();
if (type == Types1_18.META_TYPES.particleType) {
final Particle particle = (Particle) meta.getValue();
final ParticleMappings particleMappings = protocol.getMappingData().getParticleMappings();
if (particle.getId() == particleMappings.id("sculk_charge")) {
//TODO
event.cancel();
return;
} else if (particle.getId() == particleMappings.id("shriek")) {
//TODO
event.cancel();
return;
} else if (particle.getId() == particleMappings.id("vibration")) {
// Can't do without the position
event.cancel();
return;
}
rewriteParticle(particle);
} else if (type == Types1_18.META_TYPES.poseType) {
final int pose = meta.value();
if (pose >= 8) {
// Roaring, sniffing, emerging, digging -> standing
meta.setValue(0);
}
}
});
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, Types1_18.META_TYPES.blockStateType, null, Types1_18.META_TYPES.optionalComponentType);
mapTypes(Entity1_19Types.values(), Entity1_17Types.class);
filter().type(Entity1_19Types.WARDEN).cancel(16); // Anger
mapEntityTypeWithData(Entity1_19Types.WARDEN, Entity1_19Types.IRON_GOLEM).jsonName();
}
@Override
public EntityType typeFromId(final int typeId) {
return Entity1_19Types.getTypeFromId(typeId);
}
}

View File

@ -0,0 +1,92 @@
{
"blockstates": {
"minecraft:sculk": "minecraft:black_concrete_powder",
"minecraft:sculk_vein": "minecraft:glow_lichen[",
"minecraft:sculk_catalyst[bloom=true]": "minecraft:end_stone",
"minecraft:sculk_catalyst[bloom=false]": "minecraft:end_stone",
"minecraft:sculk_shrieker[shrieking=true]": "minecraft:end_portal_frame[eye=true,facing=north]",
"minecraft:sculk_shrieker[shrieking=false]": "minecraft:end_portal_frame[eye=false,facing=north]",
"minecraft:reinforced_deepslate": "minecraft:obsidian"
},
"sounds": {
"music.overworld.deep_dark": "",
"entity.parrot.imitate_warden": "",
"block.sculk_vein.break": "",
"block.sculk_vein.fall": "",
"block.sculk_vein.hit": "",
"block.sculk_vein.place": "",
"block.sculk_vein.step": "",
"block.sculk_catalyst.bloom": "",
"block.sculk_catalyst.break": "",
"block.sculk_catalyst.fall": "",
"block.sculk_catalyst.hit": "",
"block.sculk_catalyst.place": "",
"block.sculk_catalyst.step": "",
"block.sculk.spread": "",
"block.sculk.charge": "",
"block.sculk.break": "",
"block.sculk.fall": "",
"block.sculk.hit": "",
"block.sculk.place": "",
"block.sculk.step": "",
"block.sculk_shrieker.break": "",
"block.sculk_shrieker.fall": "",
"block.sculk_shrieker.hit": "",
"block.sculk_shrieker.place": "",
"block.sculk_shrieker.step": "",
"block.sculk_shrieker.shriek": "",
"entity.warden.ambient": "",
"entity.warden.listening": "",
"entity.warden.listening_angry": "",
"entity.warden.angry": "",
"entity.warden.hurt": "",
"entity.warden.death": "",
"entity.warden.step": "",
"entity.warden.tendril_clicks": "",
"entity.warden.heartbeat": "",
"entity.warden.agitated": "",
"entity.warden.attack_impact": "",
"entity.warden.roar": "",
"entity.warden.sniff": "",
"entity.warden.emerge": "",
"entity.warden.dig": "",
"entity.warden.nearby_closest": "",
"entity.warden.nearby_closer": "",
"entity.warden.nearby_close": ""
},
"items": {
"minecraft:warden_spawn_egg": {
"id": "minecraft:glow_squid_spawn_egg",
"name": "1.19 Warden Spawn Egg"
},
"minecraft:sculk_vein": {
"id": "minecraft:glow_lichen",
"name": "1.19 Sculk Vein"
},
"minecraft:sculk_catalyst": {
"id": "minecraft:end_stone",
"name": "1.19 Sculk Catalyst"
},
"minecraft:sculk": {
"id": "minecraft:black_concrete_powder",
"name": "1.19 Sculk"
},
"minecraft:sculk_shrieker": {
"id": "minecraft:end_portal_frame",
"name": "1.19 Sculk Shrieker"
},
"minecraft:reinforced_deepslate": {
"id": "minecraft:obsidian",
"name": "1.19 Reinforced Deepslate"
}
},
"particles": {
"sculk_soul": "soul",
"sculk_charge": "",
"sculk_charge_pop": "bubble_pop",
"shriek": ""
},
"entitynames": {
"warden": "Warden"
}
}

View File

@ -1,4 +1,6 @@
{
"1.19": {
},
"1.18": {
"selectWorld.conversion.tooltip": "This world must be opened in an older version (like 1.6.4) to be safely converted",
"selectWorld.incompatible_series": "Created by an incompatible version",

View File

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions]
# ViaVersion
viaver = "4.2.1"
viaver = "4.3.0-22w11a-SNAPSHOT"
# Common provided
netty = "4.0.20.Final"

View File

@ -4,6 +4,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/")