3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Start working on 24w11a

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-03-14 18:25:18 +01:00
Ursprung 7d41706026
Commit bf11a0a7de
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
29 geänderte Dateien mit 97 neuen und 60 gelöschten Zeilen

Datei anzeigen

@ -22,8 +22,10 @@
*/
package com.viaversion.viaversion.api.minecraft.metadata.types;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.ArrayType;
import com.viaversion.viaversion.api.type.types.misc.ParticleType;
import com.viaversion.viaversion.api.type.types.version.Types1_20_5;
@ -47,21 +49,23 @@ public final class MetaTypes1_20_5 extends AbstractMetaTypes {
public final MetaType optionalBlockStateType = add(15, Type.VAR_INT);
public final MetaType nbtType = add(16, Type.COMPOUND_TAG);
public final MetaType particleType;
public final MetaType villagerDatatType = add(18, Type.VILLAGER_DATA);
public final MetaType optionalVarIntType = add(19, Type.OPTIONAL_VAR_INT);
public final MetaType poseType = add(20, Type.VAR_INT);
public final MetaType catVariantType = add(21, Type.VAR_INT);
public final MetaType wolfVariantType = add(22, Type.VAR_INT);
public final MetaType frogVariantType = add(23, Type.VAR_INT);
public final MetaType optionalGlobalPosition = add(24, Type.OPTIONAL_GLOBAL_POSITION);
public final MetaType paintingVariantType = add(25, Type.VAR_INT);
public final MetaType snifferState = add(26, Type.VAR_INT);
public final MetaType armadilloState = add(27, Type.VAR_INT);
public final MetaType vectorType = add(28, Type.VECTOR3F);
public final MetaType quaternionType = add(29, Type.QUATERNION);
public final MetaType particlesType;
public final MetaType villagerDatatType = add(19, Type.VILLAGER_DATA);
public final MetaType optionalVarIntType = add(20, Type.OPTIONAL_VAR_INT);
public final MetaType poseType = add(21, Type.VAR_INT);
public final MetaType catVariantType = add(22, Type.VAR_INT);
public final MetaType wolfVariantType = add(23, Type.VAR_INT);
public final MetaType frogVariantType = add(24, Type.VAR_INT);
public final MetaType optionalGlobalPosition = add(25, Type.OPTIONAL_GLOBAL_POSITION);
public final MetaType paintingVariantType = add(26, Type.VAR_INT);
public final MetaType snifferState = add(27, Type.VAR_INT);
public final MetaType armadilloState = add(28, Type.VAR_INT);
public final MetaType vectorType = add(29, Type.VECTOR3F);
public final MetaType quaternionType = add(30, Type.QUATERNION);
public MetaTypes1_20_5(final ParticleType particleType) {
super(30);
public MetaTypes1_20_5(final ParticleType particleType, final ArrayType<Particle> particlesType) {
super(31);
this.particleType = add(17, particleType);
this.particlesType = add(18, particlesType);
}
}

Datei anzeigen

@ -83,7 +83,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
public static final ProtocolVersion v1_20 = register(763, "1.20/1.20.1", new SubVersionRange("1.20", 0, 1));
public static final ProtocolVersion v1_20_2 = register(764, "1.20.2");
public static final ProtocolVersion v1_20_3 = register(765, "1.20.3/1.20.4", new SubVersionRange("1.20", 3, 4));
public static final ProtocolVersion v1_20_5 = register(766, 179, "1.20.5");
public static final ProtocolVersion v1_20_5 = register(766, 180, "1.20.5");
public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null);
public static ProtocolVersion register(int version, String name) {

Datei anzeigen

@ -135,5 +135,6 @@ public class ParticleType extends DynamicType<Particle> {
public static final DataReader<Particle> SHRIEK = (buf, particle) -> {
particle.add(Type.VAR_INT, Type.VAR_INT.readPrimitive(buf)); // Delay
};
public static final DataReader<Particle> COLOR = (buf, particle) -> particle.add(Type.INT, buf.readInt());
}
}

Datei anzeigen

@ -22,6 +22,7 @@
*/
package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaTypes1_20_5;
@ -38,10 +39,11 @@ public final class Types1_20_5 {
// Most of these are only safe to use after protocol loading
public static final ParticleType PARTICLE = new ParticleType();
public static final ArrayType<Particle> PARTICLES = new ArrayType<>(PARTICLE);
public static final StructuredDataType STRUCTURED_DATA = new StructuredDataType();
public static final Type<Item> ITEM = new ItemType1_20_5(STRUCTURED_DATA);
public static final Type<Item[]> ITEM_ARRAY = new ArrayType<>(ITEM);
public static final MetaTypes1_20_5 META_TYPES = new MetaTypes1_20_5(PARTICLE);
public static final MetaTypes1_20_5 META_TYPES = new MetaTypes1_20_5(PARTICLE, PARTICLES);
public static final Type<Metadata> METADATA = new MetadataType(META_TYPES);
public static final Type<List<Metadata>> METADATA_LIST = new MetaListType(METADATA);
}

Datei anzeigen

@ -32,7 +32,7 @@ public class MetadataRewriter1_13_1To1_13 extends EntityRewriter<ClientboundPack
@Override
protected void registerRewrites() {
registerMetaTypeHandler(Types1_13.META_TYPES.itemType, Types1_13.META_TYPES.blockStateType, null, Types1_13.META_TYPES.particleType);
registerMetaTypeHandler(Types1_13.META_TYPES.itemType, Types1_13.META_TYPES.blockStateType, null, Types1_13.META_TYPES.particleType, null);
filter().type(EntityTypes1_13.EntityType.MINECART_ABSTRACT).index(9).handler((event, meta) -> {
int data = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));

Datei anzeigen

@ -45,7 +45,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter<ClientboundPack
@Override
protected void registerRewrites() {
filter().mapMetaType(Types1_14.META_TYPES::byId);
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType);
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType, null);
filter().type(EntityTypes1_14.ENTITY).addIndex(6);
filter().type(EntityTypes1_14.LIVINGENTITY).addIndex(12);

Datei anzeigen

@ -33,7 +33,7 @@ public class MetadataRewriter1_15To1_14_4 extends EntityRewriter<ClientboundPack
@Override
protected void registerRewrites() {
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType);
registerMetaTypeHandler(Types1_14.META_TYPES.itemType, Types1_14.META_TYPES.blockStateType, null, Types1_14.META_TYPES.particleType, null);
filter().type(EntityTypes1_15.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
int data = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));

Datei anzeigen

@ -34,7 +34,7 @@ public class MetadataRewriter1_16_2To1_16_1 extends EntityRewriter<ClientboundPa
@Override
protected void registerRewrites() {
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.particleType);
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.particleType, null);
filter().type(EntityTypes1_16_2.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
int data = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));

Datei anzeigen

@ -37,7 +37,7 @@ public class MetadataRewriter1_16To1_15_2 extends EntityRewriter<ClientboundPack
@Override
protected void registerRewrites() {
filter().mapMetaType(Types1_16.META_TYPES::byId);
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.particleType);
registerMetaTypeHandler(Types1_16.META_TYPES.itemType, Types1_16.META_TYPES.blockStateType, null, Types1_16.META_TYPES.particleType, null);
filter().type(EntityTypes1_16.MINECART_ABSTRACT).index(10).handler((metadatas, meta) -> {
int data = meta.value();
meta.setValue(protocol.getMappingData().getNewBlockStateId(data));

Datei anzeigen

@ -20,7 +20,6 @@ package com.viaversion.viaversion.protocols.protocol1_17to1_16_4.packets;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.data.entity.EntityTracker;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_16_2;
@ -159,7 +158,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_16_2
meta.setValue(pose + 1);
}
});
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, null, Types1_17.META_TYPES.particleType);
registerMetaTypeHandler(Types1_17.META_TYPES.itemType, Types1_17.META_TYPES.blockStateType, null, Types1_17.META_TYPES.particleType, null);
// Ticks frozen added with id 7
filter().type(EntityTypes1_17.ENTITY).addIndex(7);

Datei anzeigen

@ -94,7 +94,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_17_1
}
});
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null, null);
registerMetaTypeHandler(Types1_18.META_TYPES.itemType, null, null, null, null);
}
@Override

Datei anzeigen

@ -152,7 +152,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_1
@Override
protected void registerRewrites() {
filter().mapMetaType(typeId -> Types1_19_3.META_TYPES.byId(typeId >= 2 ? typeId + 1 : typeId)); // Long added
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, null, Types1_19_3.META_TYPES.particleType);
registerMetaTypeHandler(Types1_19_3.META_TYPES.itemType, Types1_19_3.META_TYPES.blockStateType, null, Types1_19_3.META_TYPES.particleType, null);
filter().type(EntityTypes1_19_3.ENTITY).index(6).handler((event, meta) -> {
// Sitting pose added

Datei anzeigen

@ -21,7 +21,6 @@ import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
@ -227,7 +226,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_3
@Override
protected void registerRewrites() {
filter().mapMetaType(typeId -> Types1_19_4.META_TYPES.byId(typeId >= 14 ? typeId + 1 : typeId)); // Optional block state (and map block state=14 to optional block state)
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.optionalBlockStateType, Types1_19_4.META_TYPES.particleType);
registerMetaTypeHandler(Types1_19_4.META_TYPES.itemType, Types1_19_4.META_TYPES.blockStateType, Types1_19_4.META_TYPES.optionalBlockStateType, Types1_19_4.META_TYPES.particleType, null);
filter().type(EntityTypes1_19_4.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value();

Datei anzeigen

@ -338,7 +338,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_18,
rewriteParticle(particle);
});
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null, null);
registerMetaTypeHandler(Types1_19.META_TYPES.itemType, Types1_19.META_TYPES.blockStateType, null, null, null);
filter().type(EntityTypes1_19.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
// Convert to new block id

Datei anzeigen

@ -173,7 +173,7 @@ public final class EntityPacketRewriter1_20_2 extends EntityRewriter<Clientbound
@Override
protected void registerRewrites() {
filter().mapMetaType(Types1_20_2.META_TYPES::byId);
registerMetaTypeHandler(Types1_20_2.META_TYPES.itemType, Types1_20_2.META_TYPES.blockStateType, Types1_20_2.META_TYPES.optionalBlockStateType, Types1_20_2.META_TYPES.particleType);
registerMetaTypeHandler(Types1_20_2.META_TYPES.itemType, Types1_20_2.META_TYPES.blockStateType, Types1_20_2.META_TYPES.optionalBlockStateType, Types1_20_2.META_TYPES.particleType, null);
filter().type(EntityTypes1_19_4.DISPLAY).addIndex(10);

Datei anzeigen

@ -133,8 +133,8 @@ public final class EntityPacketRewriter1_20_3 extends EntityRewriter<Clientbound
Types1_20_3.META_TYPES.itemType,
Types1_20_3.META_TYPES.blockStateType,
Types1_20_3.META_TYPES.optionalBlockStateType,
Types1_20_3.META_TYPES.particleType
);
Types1_20_3.META_TYPES.particleType,
null);
filter().type(EntityTypes1_20_3.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
final int blockState = meta.value();

Datei anzeigen

@ -113,7 +113,8 @@ public final class Protocol1_20_5To1_20_3 extends AbstractProtocol<ClientboundPa
.reader("item", ParticleType.Readers.ITEM1_20_2)
.reader("vibration", ParticleType.Readers.VIBRATION1_20_3)
.reader("sculk_charge", ParticleType.Readers.SCULK_CHARGE)
.reader("shriek", ParticleType.Readers.SHRIEK);
.reader("shriek", ParticleType.Readers.SHRIEK)
.reader("entity_effect", ParticleType.Readers.COLOR);
Types1_20_5.STRUCTURED_DATA.filler(this)
.add(StructuredDataKey.CUSTOM_DATA).add(StructuredDataKey.DAMAGE).add(StructuredDataKey.UNBREAKABLE)
.add(StructuredDataKey.CUSTOM_NAME).add(StructuredDataKey.LORE).add(StructuredDataKey.ENCHANTMENTS)

Datei anzeigen

@ -22,7 +22,7 @@ import java.util.HashMap;
import java.util.Map;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class BannerPatterns1_20_3 {
public final class BannerPatterns1_20_5 {
private static final KeyMappings PATTERNS = new KeyMappings(
"base",
@ -65,7 +65,9 @@ public final class BannerPatterns1_20_3 {
"skull",
"flower",
"mojang",
"piglin"
"piglin",
"flow",
"guster"
);
private static final Map<String, String> PATTERN_IDS = new HashMap<>();

Datei anzeigen

@ -20,7 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data;
import com.viaversion.viaversion.util.KeyMappings;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class TrimPatterns1_20_3 {
public final class TrimPatterns1_20_5 {
private static final KeyMappings PATTERNS = new KeyMappings(
"sentry",
@ -38,7 +38,9 @@ public final class TrimPatterns1_20_3 {
"shaper",
"silence",
"raiser",
"host"
"host",
"flow",
"bolt"
);
public static @Nullable String idToKey(final int id) {

Datei anzeigen

@ -72,14 +72,14 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.rewriter.RecipeRewriter1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.DyeColors;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Enchantments1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Instruments1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.MapDecorations1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Potions1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimMaterials1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimPatterns1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.TrimPatterns1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPacket1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ServerboundPackets1_20_5;
import com.viaversion.viaversion.rewriter.BlockRewriter;
@ -597,7 +597,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final Tag patternTag = trimTag.get("pattern");
final Holder<ArmorTrimPattern> patternHolder;
if (patternTag instanceof StringTag) {
final int id = TrimPatterns1_20_3.keyToId(((StringTag) patternTag).getValue());
final int id = TrimPatterns1_20_5.keyToId(((StringTag) patternTag).getValue());
if (id == -1) {
return;
}
@ -978,7 +978,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
final BannerPatternLayer[] layers = patternsTag.stream().map(patternTag -> {
final String pattern = patternTag.getString("Pattern", "");
final int color = patternTag.getInt("Color", -1);
final String fullPatternIdentifier = BannerPatterns1_20_3.compactToFullId(pattern);
final String fullPatternIdentifier = BannerPatterns1_20_5.compactToFullId(pattern);
if (fullPatternIdentifier == null || color == -1) {
return null;
}
@ -988,7 +988,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
patternTag.putString("pattern", fullPatternIdentifier);
patternTag.putString("color", DyeColors.colorById(color));
final int id = BannerPatterns1_20_3.keyToId(fullPatternIdentifier);
final int id = BannerPatterns1_20_5.keyToId(fullPatternIdentifier);
return new BannerPatternLayer(Holder.of(id), color);
}).filter(Objects::nonNull).toArray(BannerPatternLayer[]::new);
tag.remove("Patterns");

Datei anzeigen

@ -22,6 +22,7 @@ import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.data.entity.DimensionData;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.RegistryEntry;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
@ -35,7 +36,7 @@ import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.Clientb
import com.viaversion.viaversion.protocols.protocol1_20_3to1_20_2.packet.ClientboundPackets1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.packet.ClientboundConfigurationPackets1_20_5;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.util.Key;
@ -113,8 +114,8 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
final PacketWrapper bannerPatternsPacket = wrapper.create(ClientboundConfigurationPackets1_20_5.REGISTRY_DATA);
bannerPatternsPacket.write(Type.STRING, "minecraft:banner_pattern");
final RegistryEntry[] patternEntries = new RegistryEntry[BannerPatterns1_20_3.keys().length];
final String[] keys = BannerPatterns1_20_3.keys();
final RegistryEntry[] patternEntries = new RegistryEntry[BannerPatterns1_20_5.keys().length];
final String[] keys = BannerPatterns1_20_5.keys();
for (int i = 0; i < keys.length; i++) {
final CompoundTag pattern = new CompoundTag();
final String key = keys[i];
@ -219,6 +220,9 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
protected void registerRewrites() {
filter().mapMetaType(typeId -> {
int id = typeId;
if (typeId >= Types1_20_5.META_TYPES.particlesType.typeId()) {
id++;
}
if (typeId >= Types1_20_5.META_TYPES.armadilloState.typeId()) {
id++;
}
@ -232,9 +236,17 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
Types1_20_5.META_TYPES.itemType,
Types1_20_5.META_TYPES.blockStateType,
Types1_20_5.META_TYPES.optionalBlockStateType,
Types1_20_5.META_TYPES.particleType
Types1_20_5.META_TYPES.particleType,
null
);
filter().type(EntityTypes1_20_5.LIVINGENTITY).index(10).handler((event, meta) -> {
final int effectColor = meta.value();
final Particle particle = new Particle(protocol.getMappingData().getParticleMappings().mappedId("entity_effect"));
particle.add(Type.INT, effectColor);
meta.setTypeAndValue(Types1_20_5.META_TYPES.particlesType, new Particle[]{particle});
});
filter().type(EntityTypes1_20_5.LLAMA).removeIndex(20); // Carpet color
filter().type(EntityTypes1_20_5.MINECART_ABSTRACT).index(11).handler((event, meta) -> {
@ -243,6 +255,14 @@ public final class EntityPacketRewriter1_20_5 extends EntityRewriter<Clientbound
});
}
@Override
public void rewriteParticle(final Particle particle) {
super.rewriteParticle(particle);
if (particle.id() == protocol.getMappingData().getParticleMappings().mappedId("entity_effect")) {
particle.add(Type.INT, 0); // rgb
}
}
@Override
public void onMappingDataLoaded() {
mapTypes();

Datei anzeigen

@ -43,7 +43,7 @@ import com.viaversion.viaversion.api.minecraft.item.data.SuspiciousStewEffect;
import com.viaversion.viaversion.protocols.protocol1_20_2to1_20.util.PotionEffects;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Attributes1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.BannerPatterns1_20_5;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Enchantments1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.Instruments1_20_3;
import com.viaversion.viaversion.protocols.protocol1_20_5to1_20_3.data.MapDecorations1_20_3;
@ -326,7 +326,7 @@ final class StructuredDataConverter {
register(StructuredDataKey.BANNER_PATTERNS, (data, tag) -> {
final ListTag<CompoundTag> patternsTag = getOrCreateListTag(tag, "Patterns");
for (final BannerPatternLayer layer : data) {
final String pattern = BannerPatterns1_20_3.fullIdToCompact(BannerPatterns1_20_3.idToKey(layer.pattern().id()));
final String pattern = BannerPatterns1_20_5.fullIdToCompact(BannerPatterns1_20_5.idToKey(layer.pattern().id()));
if (pattern == null) {
continue;
}

Datei anzeigen

@ -22,7 +22,6 @@ import com.github.steveice10.opennbt.tag.builtin.FloatTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.api.minecraft.Quaternion;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_19_4;
@ -129,7 +128,7 @@ public final class EntityPackets extends EntityRewriter<ClientboundPackets1_19_4
@Override
protected void registerRewrites() {
filter().mapMetaType(Types1_20.META_TYPES::byId);
registerMetaTypeHandler(Types1_20.META_TYPES.itemType, Types1_20.META_TYPES.blockStateType, Types1_20.META_TYPES.optionalBlockStateType, Types1_20.META_TYPES.particleType);
registerMetaTypeHandler(Types1_20.META_TYPES.itemType, Types1_20.META_TYPES.blockStateType, Types1_20.META_TYPES.optionalBlockStateType, Types1_20.META_TYPES.particleType, null);
// Rotate item display by 180 degrees around the Y axis
filter().type(EntityTypes1_19_4.ITEM_DISPLAY).handler((event, meta) -> {

Datei anzeigen

@ -20,7 +20,6 @@ package com.viaversion.viaversion.rewriter;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.NumberTag;
import com.github.steveice10.opennbt.tag.builtin.Tag;
import com.google.common.base.Preconditions;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
@ -59,7 +58,7 @@ import java.util.stream.Collectors;
import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class EntityRewriter<C extends ClientboundPacketType, T extends Protocol<C, ?, ?, ?>>
extends RewriterBase<T> implements com.viaversion.viaversion.api.rewriter.EntityRewriter<T> {
extends RewriterBase<T> implements com.viaversion.viaversion.api.rewriter.EntityRewriter<T> {
private static final Metadata[] EMPTY_ARRAY = new Metadata[0];
protected final List<MetaFilter> metadataFilters = new ArrayList<>();
protected final boolean trackMappedType;
@ -187,7 +186,7 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
} catch (IllegalArgumentException notFound) {
if (!typeMappings.contains(oldType.getId())) {
Via.getPlatform().getLogger().warning("Could not find new entity type for " + oldType + "! " +
"Old type: " + oldType.getClass().getEnclosingClass().getSimpleName() + ", new type: " + newTypeClass.getEnclosingClass().getSimpleName());
"Old type: " + oldType.getClass().getEnclosingClass().getSimpleName() + ", new type: " + newTypeClass.getEnclosingClass().getSimpleName());
}
}
}
@ -209,8 +208,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
* @param blockStateType block state meta type if needed
* @param optionalBlockStateType optional block state meta type if needed
* @param particleType particle meta type if needed
* @param particlesType particles meta type if needed
*/
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockStateType, @Nullable MetaType optionalBlockStateType, @Nullable MetaType particleType) {
public void registerMetaTypeHandler(@Nullable MetaType itemType, @Nullable MetaType blockStateType, @Nullable MetaType optionalBlockStateType, @Nullable MetaType particleType, @Nullable MetaType particlesType) {
filter().handler((event, meta) -> {
final MetaType type = meta.metaType();
if (type == itemType) {
@ -225,6 +225,11 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
}
} else if (type == particleType) {
rewriteParticle(meta.value());
} else if (type == particlesType) {
final Particle[] particles = meta.value();
for (final Particle particle : particles) {
rewriteParticle(particle);
}
}
});
}
@ -604,9 +609,9 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
Logger logger = Via.getPlatform().getLogger();
logger.severe("An error occurred in metadata handler " + this.getClass().getSimpleName()
+ " for " + (type != null ? type.name() : "untracked") + " entity type: " + metadata);
+ " for " + (type != null ? type.name() : "untracked") + " entity type: " + metadata);
logger.severe(metadataList.stream().sorted(Comparator.comparingInt(Metadata::id))
.map(Metadata::toString).collect(Collectors.joining("\n", "Full metadata: ", "")));
.map(Metadata::toString).collect(Collectors.joining("\n", "Full metadata: ", "")));
logger.log(Level.SEVERE, "Error: ", e);
}
}

Datei anzeigen

@ -1,5 +1,5 @@
# Project properties - we put these here so they can be modified without causing a recompile of the build scripts
projectVersion=4.10.0-24w10a-SNAPSHOT
projectVersion=4.10.0-24w11a-SNAPSHOT
# Smile emoji
mcVersions=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, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9

Datei anzeigen

@ -79,6 +79,8 @@ public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1
}
}.registerDeclareCommands1_19(ClientboundPackets1_20_5.DECLARE_COMMANDS);*/
// TODO Rewrite structured data ids and items within them
}
@Override

Datei anzeigen

@ -94,10 +94,11 @@ public final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPa
// Registers registry type id changes
registerMetaTypeHandler(
Types1_20_5.META_TYPES.itemType,
Types1_20_5.META_TYPES.blockStateType,
Types1_20_5.META_TYPES.optionalBlockStateType,
Types1_20_5.META_TYPES.particleType
Types1_20_5.META_TYPES.itemType,
Types1_20_5.META_TYPES.blockStateType,
Types1_20_5.META_TYPES.optionalBlockStateType,
Types1_20_5.META_TYPES.particleType,
Types1_20_5.META_TYPES.particlesType
);
// Minecarts are special