mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2025-01-02 18:48:06 +01:00
23w06a
This commit is contained in:
parent
15aa25f0d2
commit
27dd148c69
@ -5,7 +5,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
group = "com.viaversion"
|
||||
version = "4.6.0-23w05a-SNAPSHOT"
|
||||
version = "4.6.0-23w06a-SNAPSHOT"
|
||||
description = "Allow older clients to join newer server versions."
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ public abstract class EntityRewriterBase<C extends ClientboundPacketType, T exte
|
||||
* @see #mapEntityType(EntityType, EntityType) for id only rewriting
|
||||
*/
|
||||
protected EntityData mapEntityTypeWithData(EntityType type, EntityType mappedType) {
|
||||
Preconditions.checkArgument(type.getClass() == mappedType.getClass());
|
||||
Preconditions.checkArgument(type.getClass() == mappedType.getClass(), "Both entity types need to be of the same class");
|
||||
|
||||
// Already rewrite the id here
|
||||
int mappedReplacementId = newEntityId(mappedType.getId());
|
||||
|
@ -33,10 +33,10 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public abstract class ItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
public class ItemRewriter<C extends ClientboundPacketType, S extends ServerboundPacketType,
|
||||
T extends BackwardsProtocol<C, ?, ?, S>> extends ItemRewriterBase<C, S, T> {
|
||||
|
||||
protected ItemRewriter(T protocol) {
|
||||
public ItemRewriter(T protocol) {
|
||||
super(protocol, true);
|
||||
}
|
||||
|
||||
|
@ -18,22 +18,28 @@
|
||||
package com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4;
|
||||
|
||||
import com.viaversion.viabackwards.api.BackwardsProtocol;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappings;
|
||||
import com.viaversion.viabackwards.api.rewriters.ItemRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets.EntityPackets1_19_4;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
||||
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.data.entity.EntityTrackerBase;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.Protocol1_19_3To1_19_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ServerboundPackets1_19_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.Protocol1_19_4To1_19_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ServerboundPackets1_19_4;
|
||||
import com.viaversion.viaversion.rewriter.CommandRewriter;
|
||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||
|
||||
public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundPackets1_19_4, ClientboundPackets1_19_3, ServerboundPackets1_19_4, ServerboundPackets1_19_3> {
|
||||
|
||||
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.19.4", "1.19.3", Protocol1_19_4To1_19_3.class);
|
||||
private final EntityPackets1_19_4 entityRewriter = new EntityPackets1_19_4(this);
|
||||
private final ItemRewriter<ClientboundPackets1_19_4, ServerboundPackets1_19_3, Protocol1_19_3To1_19_4> itemRewriter = new ItemRewriter<>(this);
|
||||
|
||||
public Protocol1_19_3To1_19_4() {
|
||||
super(ClientboundPackets1_19_4.class, ClientboundPackets1_19_3.class, ServerboundPackets1_19_4.class, ServerboundPackets1_19_3.class);
|
||||
@ -42,7 +48,9 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
// TODO fallback field in components
|
||||
executeAsyncAfterLoaded(Protocol1_19_3To1_19_1.class, () -> {
|
||||
executeAsyncAfterLoaded(Protocol1_19_4To1_19_3.class, () -> {
|
||||
MAPPINGS.load();
|
||||
entityRewriter.onMappingDataLoaded();
|
||||
});
|
||||
|
||||
entityRewriter.register();
|
||||
@ -52,28 +60,55 @@ public final class Protocol1_19_3To1_19_4 extends BackwardsProtocol<ClientboundP
|
||||
public void handleArgument(final PacketWrapper wrapper, final String argumentType) throws Exception {
|
||||
if (argumentType.equals("minecraft:time")) {
|
||||
wrapper.read(Type.INT); // Minimum
|
||||
} else if (argumentType.equals("minecraft:resource") || argumentType.equals("minecraft:resource_or_tag")) {
|
||||
final String resource = wrapper.read(Type.STRING);
|
||||
// Replace damage types with... something
|
||||
wrapper.write(Type.STRING, resource.equals("minecraft:damage_type") ? "minecraft:mob_effect" : resource);
|
||||
} else {
|
||||
super.handleArgument(wrapper, argumentType);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String argumentType(final int argumentTypeId) {
|
||||
return Protocol1_19_3To1_19_1.MAPPINGS.getArgumentTypeMappings().mappedIdentifier(argumentTypeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int mappedArgumentTypeId(final String mappedArgumentType) {
|
||||
return Protocol1_19_3To1_19_1.MAPPINGS.getArgumentTypeMappings().mappedId(mappedArgumentType);
|
||||
}
|
||||
};
|
||||
commandRewriter.registerDeclareCommands1_19(ClientboundPackets1_19_4.DECLARE_COMMANDS);
|
||||
|
||||
final TagRewriter<ClientboundPackets1_19_4> tagRewriter = new TagRewriter<>(this);
|
||||
tagRewriter.removeTags("minecraft:damage_type");
|
||||
tagRewriter.registerGeneric(ClientboundPackets1_19_4.TAGS);
|
||||
|
||||
cancelClientbound(ClientboundPackets1_19_4.BUNDLE);
|
||||
|
||||
registerClientbound(ClientboundPackets1_19_4.DAMAGE_EVENT, ClientboundPackets1_19_3.ENTITY_STATUS, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT, Type.INT); // Entity id
|
||||
read(Type.VAR_INT); // Damage type
|
||||
read(Type.VAR_INT); // Cause entity
|
||||
read(Type.VAR_INT); // Direct cause entity
|
||||
handler(wrapper -> {
|
||||
// Source position
|
||||
if (wrapper.read(Type.BOOLEAN)) {
|
||||
wrapper.read(Type.DOUBLE);
|
||||
wrapper.read(Type.DOUBLE);
|
||||
wrapper.read(Type.DOUBLE);
|
||||
}
|
||||
});
|
||||
create(Type.BYTE, (byte) 2); // Generic hurt
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(final UserConnection user) {
|
||||
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_3Types.PLAYER));
|
||||
addEntityTracker(user, new EntityTrackerBase(user, Entity1_19_4Types.PLAYER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BackwardsMappings getMappingData() {
|
||||
return MAPPINGS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemRewriter<ClientboundPackets1_19_4, ServerboundPackets1_19_3, Protocol1_19_3To1_19_4> getItemRewriter() {
|
||||
return itemRewriter;
|
||||
}
|
||||
}
|
@ -17,11 +17,16 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.packets;
|
||||
|
||||
import com.viaversion.viabackwards.api.entities.storage.EntityData;
|
||||
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_19_3to1_19_4.Protocol1_19_3To1_19_4;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_3Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.Entity1_19_4Types;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_3;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_19_4;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
@ -29,7 +34,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_3to1_19_1.ClientboundPackets1_19_3;
|
||||
import com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.ClientboundPackets1_19_4;
|
||||
import com.viaversion.viaversion.rewriter.EntityRewriter;
|
||||
|
||||
public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets1_19_4, Protocol1_19_3To1_19_4> {
|
||||
|
||||
@ -39,6 +43,10 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
||||
|
||||
@Override
|
||||
public void registerPackets() {
|
||||
registerTrackerWithData1_19(ClientboundPackets1_19_4.SPAWN_ENTITY, null);
|
||||
registerRemoveEntities(ClientboundPackets1_19_4.REMOVE_ENTITIES);
|
||||
registerMetadataRewriter(ClientboundPackets1_19_4.ENTITY_METADATA, Types1_19_4.METADATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_19_4.JOIN_GAME, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
@ -57,6 +65,7 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
||||
final CompoundTag registry = wrapper.get(Type.NBT, 0);
|
||||
registry.remove("minecraft:trim_pattern");
|
||||
registry.remove("minecraft:trim_material");
|
||||
registry.remove("minecraft:damage_type");
|
||||
|
||||
final CompoundTag biomeRegistry = registry.get("minecraft:worldgen/biome");
|
||||
final ListTag biomes = biomeRegistry.get("value");
|
||||
@ -88,8 +97,46 @@ public final class EntityPackets1_19_4 extends EntityRewriter<ClientboundPackets
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerRewrites() {
|
||||
filter().handler((event, meta) -> {
|
||||
int id = meta.metaType().typeId();
|
||||
if (id >= 25) { // Vector3f/quaternion types
|
||||
event.cancel();
|
||||
return;
|
||||
} else if (id >= 15) { // Optional block state - just map down to block state
|
||||
id--;
|
||||
}
|
||||
|
||||
meta.setMetaType(Types1_19_3.META_TYPES.byId(id));
|
||||
});
|
||||
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, null, null);
|
||||
|
||||
filter().filterFamily(Entity1_19_4Types.DISPLAY).handler((event, meta) -> {
|
||||
// Remove a large heap of display metadata
|
||||
if (event.index() > 7) {
|
||||
event.cancel();
|
||||
}
|
||||
});
|
||||
filter().filterFamily(Entity1_19_4Types.ABSTRACT_HORSE).addIndex(18); // Owner UUID
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMappingDataLoaded() {
|
||||
mapTypes();
|
||||
// TODO Use text/item/block
|
||||
final EntityData.MetaCreator metaCreator = storage -> {
|
||||
storage.add(new Metadata(0, Types1_19_4.META_TYPES.byteType, (byte) 0x20)); // Invisible
|
||||
storage.add(new Metadata(5, Types1_19_4.META_TYPES.booleanType, true)); // No gravity
|
||||
storage.add(new Metadata(15, Types1_19_4.META_TYPES.byteType, (byte) (0x01 | 0x10))); // Small marker
|
||||
};
|
||||
mapEntityTypeWithData(Entity1_19_4Types.BLOCK_DISPLAY, Entity1_19_4Types.ARMOR_STAND).spawnMetadata(metaCreator);
|
||||
mapEntityTypeWithData(Entity1_19_4Types.ITEM_DISPLAY, Entity1_19_4Types.ARMOR_STAND).spawnMetadata(metaCreator);
|
||||
mapEntityTypeWithData(Entity1_19_4Types.TEXT_DISPLAY, Entity1_19_4Types.ARMOR_STAND).spawnMetadata(metaCreator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType typeFromId(final int type) {
|
||||
return Entity1_19_3Types.getTypeFromId(type);
|
||||
return Entity1_19_4Types.getTypeFromId(type);
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ metadata.format.version = "1.1"
|
||||
[versions]
|
||||
|
||||
# ViaVersion
|
||||
viaver = "4.6.0-23w05a-SNAPSHOT"
|
||||
viaver = "4.6.0-23w06a-SNAPSHOT"
|
||||
|
||||
# Common provided
|
||||
netty = "4.0.20.Final"
|
||||
|
Loading…
Reference in New Issue
Block a user