This commit is contained in:
Nassim Jahnke 2024-05-15 16:50:07 +02:00
parent e9d142e2ec
commit 1a24ce6d87
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
4 changed files with 43 additions and 22 deletions

View File

@ -32,6 +32,7 @@ import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey; import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.data.Enchantments; import com.viaversion.viaversion.api.minecraft.item.data.Enchantments;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2; import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_20_2;
import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
import com.viaversion.viaversion.api.type.types.version.Types1_21; import com.viaversion.viaversion.api.type.types.version.Types1_21;
@ -78,6 +79,13 @@ public final class BlockItemPacketRewriter1_21 extends BackwardsStructuredItemRe
registerLevelParticles1_20_5(ClientboundPackets1_20_5.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE); registerLevelParticles1_20_5(ClientboundPackets1_20_5.LEVEL_PARTICLES, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
registerExplosion(ClientboundPackets1_20_5.EXPLODE, Types1_21.PARTICLE, Types1_20_5.PARTICLE); registerExplosion(ClientboundPackets1_20_5.EXPLODE, Types1_21.PARTICLE, Types1_20_5.PARTICLE);
protocol.registerServerbound(ServerboundPackets1_20_5.USE_ITEM, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Hand
wrapper.passthrough(Types.VAR_INT); // Sequence
wrapper.write(Types.FLOAT, 0f); // Y rotation
wrapper.write(Types.FLOAT, 0f); // X rotation
});
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.UPDATE_RECIPES); new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.UPDATE_RECIPES);
} }

View File

@ -22,9 +22,13 @@ import com.viaversion.nbt.tag.Tag;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter; import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5; import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5;
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.EnchantmentsPaintingsStorage; import com.viaversion.viabackwards.protocol.v1_21to1_20_5.storage.EnchantmentsPaintingsStorage;
import com.viaversion.viaversion.api.minecraft.Holder;
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
import com.viaversion.viaversion.api.minecraft.RegistryEntry; import com.viaversion.viaversion.api.minecraft.RegistryEntry;
import com.viaversion.viaversion.api.minecraft.WolfVariant;
import com.viaversion.viaversion.api.minecraft.entities.EntityType; import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5; import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.version.Types1_20_5; import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
@ -46,8 +50,8 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
super(protocol, Types1_20_5.ENTITY_DATA_TYPES.optionalComponentType, Types1_20_5.ENTITY_DATA_TYPES.booleanType); super(protocol, Types1_20_5.ENTITY_DATA_TYPES.optionalComponentType, Types1_20_5.ENTITY_DATA_TYPES.booleanType);
for (int i = 0; i < Paintings1_20_5.PAINTINGS.length; i++) { for (int i = 0; i < Paintings1_20_5.PAINTINGS.length; i++) {
final Paintings1_20_5.PaintingVariant painting = Paintings1_20_5.PAINTINGS[i]; final PaintingVariant painting = Paintings1_20_5.PAINTINGS[i];
oldPaintings.put(painting.key(), new PaintingData(painting, i)); oldPaintings.put(painting.assetId(), new PaintingData(painting, i));
} }
} }
@ -130,7 +134,7 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
final CompoundTag tag = (CompoundTag) entry.tag(); final CompoundTag tag = (CompoundTag) entry.tag();
for (int j = 0; j < Paintings1_20_5.PAINTINGS.length; j++) { for (int j = 0; j < Paintings1_20_5.PAINTINGS.length; j++) {
final Paintings1_20_5.PaintingVariant painting = Paintings1_20_5.PAINTINGS[j]; final PaintingVariant painting = Paintings1_20_5.PAINTINGS[j];
if (painting.width() == tag.getInt("width") && painting.height() == tag.getInt("height")) { if (painting.width() == tag.getInt("width") && painting.height() == tag.getInt("height")) {
mappings[i] = j; mappings[i] = j;
break; break;
@ -142,6 +146,28 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
@Override @Override
protected void registerRewrites() { protected void registerRewrites() {
filter().handler((event, data) -> {
final EntityDataType type = data.dataType();
if (type == Types1_21.ENTITY_DATA_TYPES.wolfVariantType) {
final Holder<WolfVariant> variant = data.value();
if (variant.hasId()) {
data.setTypeAndValue(Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType, variant);
} else {
event.cancel();
}
} else if (type == Types1_21.ENTITY_DATA_TYPES.paintingVariantType) {
final Holder<PaintingVariant> variant = data.value();
if (variant.hasId()) {
final EnchantmentsPaintingsStorage storage = event.user().get(EnchantmentsPaintingsStorage.class);
final int mappedId = storage.mappedPainting(variant.id());
data.setTypeAndValue(Types1_20_5.ENTITY_DATA_TYPES.paintingVariantType, mappedId);
} else {
event.cancel();
}
} else {
data.setDataType(Types1_20_5.ENTITY_DATA_TYPES.byId(type.typeId()));
}
});
filter().mapDataType(Types1_20_5.ENTITY_DATA_TYPES::byId); filter().mapDataType(Types1_20_5.ENTITY_DATA_TYPES::byId);
registerMetaTypeHandler1_20_3( registerMetaTypeHandler1_20_3(
@ -154,15 +180,9 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
Types1_20_5.ENTITY_DATA_TYPES.optionalComponentType Types1_20_5.ENTITY_DATA_TYPES.optionalComponentType
); );
filter().dataType(Types1_20_5.ENTITY_DATA_TYPES.paintingVariantType).handler((event, meta) -> { filter().type(EntityTypes1_20_5.ABSTRACT_MINECART).index(11).handler((event, data) -> {
final EnchantmentsPaintingsStorage storage = event.user().get(EnchantmentsPaintingsStorage.class); final int blockState = data.value();
final int id = meta.value(); data.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
meta.setValue(storage.mappedPainting(id));
});
filter().type(EntityTypes1_20_5.ABSTRACT_MINECART).index(11).handler((event, meta) -> {
final int blockState = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(blockState));
}); });
} }
@ -171,13 +191,6 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
return EntityTypes1_20_5.getTypeFromId(type); return EntityTypes1_20_5.getTypeFromId(type);
} }
private static final class PaintingData { private record PaintingData(PaintingVariant painting, int id) {
private final Paintings1_20_5.PaintingVariant painting;
private final int id;
private PaintingData(final Paintings1_20_5.PaintingVariant painting, final int id) {
this.painting = painting;
this.id = id;
}
} }
} }

View File

@ -1,4 +1,4 @@
projectVersion=5.0.0-24w19b-SNAPSHOT projectVersion=5.0.0-24w20a-SNAPSHOT
# Smile emoji # Smile emoji
mcVersions=1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10 mcVersions=1.20.6,1.20.5,1.20.4, 1.20.3, 1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10

View File

@ -3,7 +3,7 @@ metadata.format.version = "1.1"
[versions] [versions]
# ViaVersion # ViaVersion
viaver = "5.0.0-24w19b-SNAPSHOT" viaver = "5.0.0-24w20a-SNAPSHOT"
# Common provided # Common provided
netty = "4.0.20.Final" netty = "4.0.20.Final"