3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-05-15 16:38:34 +02:00
Ursprung ccc509432b
Commit 832dbdf493
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
9 geänderte Dateien mit 233 neuen und 65 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,47 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.misc.HolderType;
import io.netty.buffer.ByteBuf;
public record PaintingVariant(int width, int height, String assetId) {
public static HolderType<PaintingVariant> TYPE = new HolderType<>() {
@Override
public PaintingVariant readDirect(final ByteBuf buffer) {
final int width = Types.VAR_INT.readPrimitive(buffer);
final int height = Types.VAR_INT.readPrimitive(buffer);
final String assetId = Types.STRING.read(buffer);
return new PaintingVariant(width, height, assetId);
}
@Override
public void writeDirect(final ByteBuf buffer, final PaintingVariant variant) {
Types.VAR_INT.writePrimitive(buffer, variant.width());
Types.VAR_INT.writePrimitive(buffer, variant.height());
Types.STRING.write(buffer, variant.assetId());
}
};
}

Datei anzeigen

@ -0,0 +1,49 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.misc.HolderType;
import io.netty.buffer.ByteBuf;
public record WolfVariant(String wildTexture, String tameTexture, String angryTexture, HolderSet biomes) {
public static HolderType<WolfVariant> TYPE = new HolderType<>() {
@Override
public WolfVariant readDirect(final ByteBuf buffer) {
final String wildTexture = Types.STRING.read(buffer);
final String tameTexture = Types.STRING.read(buffer);
final String angryTexture = Types.STRING.read(buffer);
final HolderSet biomes = Types.HOLDER_SET.read(buffer);
return new WolfVariant(wildTexture, tameTexture, angryTexture, biomes);
}
@Override
public void writeDirect(final ByteBuf buffer, final WolfVariant variant) {
Types.STRING.write(buffer, variant.wildTexture());
Types.STRING.write(buffer, variant.tameTexture());
Types.STRING.write(buffer, variant.angryTexture());
Types.HOLDER_SET.write(buffer, variant.biomes());
}
};
}

Datei anzeigen

@ -0,0 +1,73 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2024 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.minecraft.entitydata.types;
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.WolfVariant;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
import com.viaversion.viaversion.api.type.Types;
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;
public final class EntityDataTypes1_21 extends AbstractEntityDataTypes {
public final EntityDataType byteType = add(0, Types.BYTE);
public final EntityDataType varIntType = add(1, Types.VAR_INT);
public final EntityDataType longType = add(2, Types.VAR_LONG);
public final EntityDataType floatType = add(3, Types.FLOAT);
public final EntityDataType stringType = add(4, Types.STRING);
public final EntityDataType componentType = add(5, Types.TAG);
public final EntityDataType optionalComponentType = add(6, Types.OPTIONAL_TAG);
public final EntityDataType itemType = add(7, Types1_20_5.ITEM);
public final EntityDataType booleanType = add(8, Types.BOOLEAN);
public final EntityDataType rotationsType = add(9, Types.ROTATIONS);
public final EntityDataType blockPositionType = add(10, Types.BLOCK_POSITION1_14);
public final EntityDataType optionalBlockPositionType = add(11, Types.OPTIONAL_POSITION_1_14);
public final EntityDataType directionType = add(12, Types.VAR_INT);
public final EntityDataType optionalUUIDType = add(13, Types.OPTIONAL_UUID);
public final EntityDataType blockStateType = add(14, Types.VAR_INT);
public final EntityDataType optionalBlockStateType = add(15, Types.VAR_INT);
public final EntityDataType compoundTagType = add(16, Types.COMPOUND_TAG);
public final EntityDataType particleType;
public final EntityDataType particlesType;
public final EntityDataType villagerDatatType = add(19, Types.VILLAGER_DATA);
public final EntityDataType optionalVarIntType = add(20, Types.OPTIONAL_VAR_INT);
public final EntityDataType poseType = add(21, Types.VAR_INT);
public final EntityDataType catVariantType = add(22, Types.VAR_INT);
public final EntityDataType wolfVariantType = add(23, WolfVariant.TYPE);
public final EntityDataType frogVariantType = add(24, Types.VAR_INT);
public final EntityDataType optionalGlobalPosition = add(25, Types.OPTIONAL_GLOBAL_POSITION);
public final EntityDataType paintingVariantType = add(26, PaintingVariant.TYPE);
public final EntityDataType snifferState = add(27, Types.VAR_INT);
public final EntityDataType armadilloState = add(28, Types.VAR_INT);
public final EntityDataType vector3FType = add(29, Types.VECTOR3F);
public final EntityDataType quaternionType = add(30, Types.QUATERNION);
public EntityDataTypes1_21(final ParticleType particleType, final ArrayType<Particle> particlesType) {
super(31);
this.particleType = add(17, particleType);
this.particlesType = add(18, particlesType);
}
}

Datei anzeigen

@ -84,7 +84,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
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, "1.20.5-1.20.6", new SubVersionRange("1.20", 5, 6));
public static final ProtocolVersion v1_21 = register(767, 195, "1.21");
public static final ProtocolVersion v1_21 = register(767, 196, "1.21");
public static final ProtocolVersion unknown = new ProtocolVersion(VersionType.SPECIAL, -1, -1, "UNKNOWN", null);
public static ProtocolVersion register(int version, String name) {

Datei anzeigen

@ -25,7 +25,7 @@ package com.viaversion.viaversion.api.type.types.version;
import com.viaversion.viaversion.api.minecraft.Particle;
import com.viaversion.viaversion.api.minecraft.data.StructuredData;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_20_5;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.ArrayType;
@ -50,7 +50,7 @@ public final class Types1_21 {
public static final ParticleType PARTICLE = new ParticleType();
public static final ArrayType<Particle> PARTICLES = new ArrayType<>(PARTICLE);
public static final EntityDataTypes1_20_5 ENTITY_DATA_TYPES = new EntityDataTypes1_20_5(PARTICLE, PARTICLES);
public static final EntityDataTypes1_21 ENTITY_DATA_TYPES = new EntityDataTypes1_21(PARTICLE, PARTICLES);
public static final Type<EntityData> ENTITY_DATA = new EntityDataType(ENTITY_DATA_TYPES);
public static final Type<List<EntityData>> ENTITY_DATA_LIST = new EntityDataListType(ENTITY_DATA);
}

Datei anzeigen

@ -17,62 +17,40 @@
*/
package com.viaversion.viaversion.protocols.v1_20_5to1_21.data;
import com.viaversion.viaversion.api.minecraft.PaintingVariant;
public final class Paintings1_20_5 {
public static final PaintingVariant[] PAINTINGS = {
new PaintingVariant("kebab", 1, 1),
new PaintingVariant("aztec", 1, 1),
new PaintingVariant("alban", 1, 1),
new PaintingVariant("aztec2", 1, 1),
new PaintingVariant("bomb", 1, 1),
new PaintingVariant("plant", 1, 1),
new PaintingVariant("wasteland", 1, 1),
new PaintingVariant("pool", 2, 1),
new PaintingVariant("courbet", 2, 1),
new PaintingVariant("sea", 2, 1),
new PaintingVariant("sunset", 2, 1),
new PaintingVariant("creebet", 2, 1),
new PaintingVariant("wanderer", 1, 2),
new PaintingVariant("graham", 1, 2),
new PaintingVariant("match", 2, 2),
new PaintingVariant("bust", 2, 2),
new PaintingVariant("stage", 2, 2),
new PaintingVariant("void", 2, 2),
new PaintingVariant("skull_and_roses", 2, 2),
new PaintingVariant("wither", 2, 2),
new PaintingVariant("fighters", 4, 2),
new PaintingVariant("pointer", 4, 4),
new PaintingVariant("pigscene", 4, 4),
new PaintingVariant("burning_skull", 4, 4),
new PaintingVariant("skeleton", 4, 3),
new PaintingVariant("earth", 2, 2),
new PaintingVariant("wind", 2, 2),
new PaintingVariant("water", 2, 2),
new PaintingVariant("fire", 2, 2),
new PaintingVariant("donkey_kong", 4, 3)
new PaintingVariant(1, 1, "kebab"),
new PaintingVariant(1, 1, "aztec"),
new PaintingVariant(1, 1, "alban"),
new PaintingVariant(1, 1, "aztec2"),
new PaintingVariant(1, 1, "bomb"),
new PaintingVariant(1, 1, "plant"),
new PaintingVariant(1, 1, "wasteland"),
new PaintingVariant(2, 1, "pool"),
new PaintingVariant(2, 1, "courbet"),
new PaintingVariant(2, 1, "sea"),
new PaintingVariant(2, 1, "sunset"),
new PaintingVariant(2, 1, "creebet"),
new PaintingVariant(1, 2, "wanderer"),
new PaintingVariant(1, 2, "graham"),
new PaintingVariant(2, 2, "match"),
new PaintingVariant(2, 2, "bust"),
new PaintingVariant(2, 2, "stage"),
new PaintingVariant(2, 2, "void"),
new PaintingVariant(2, 2, "skull_and_roses"),
new PaintingVariant(2, 2, "wither"),
new PaintingVariant(4, 2, "fighters"),
new PaintingVariant(4, 4, "pointer"),
new PaintingVariant(4, 4, "pigscene"),
new PaintingVariant(4, 4, "burning_skull"),
new PaintingVariant(4, 3, "skeleton"),
new PaintingVariant(2, 2, "earth"),
new PaintingVariant(2, 2, "wind"),
new PaintingVariant(2, 2, "water"),
new PaintingVariant(2, 2, "fire"),
new PaintingVariant(4, 3, "donkey_kong")
};
public static final class PaintingVariant {
private final String key;
private final int width;
private final int height;
public PaintingVariant(final String key, final int width, final int height) {
this.key = key;
this.width = width;
this.height = height;
}
public String key() {
return key;
}
public int width() {
return width;
}
public int height() {
return height;
}
}
}

Datei anzeigen

@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataKey;
import com.viaversion.viaversion.api.minecraft.item.Item;
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.version.Types1_20_5;
import com.viaversion.viaversion.api.type.types.version.Types1_21;
@ -61,6 +62,13 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<Cl
registerLevelParticles1_20_5(ClientboundPackets1_20_5.LEVEL_PARTICLES, Types1_20_5.PARTICLE, Types1_21.PARTICLE);
registerExplosion(ClientboundPackets1_20_5.EXPLODE, Types1_20_5.PARTICLE, Types1_21.PARTICLE); // Rewrites the included sound and particles
protocol.registerServerbound(ServerboundPackets1_20_5.USE_ITEM, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Hand
wrapper.passthrough(Types.VAR_INT); // Sequence
wrapper.read(Types.FLOAT); // Y rotation
wrapper.read(Types.FLOAT); // X rotation
});
new RecipeRewriter1_20_3<>(protocol).register1_20_5(ClientboundPackets1_20_5.UPDATE_RECIPES);
}

Datei anzeigen

@ -18,20 +18,23 @@
package com.viaversion.viaversion.protocols.v1_20_5to1_21.rewriter;
import com.viaversion.nbt.tag.CompoundTag;
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.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_20_5;
import com.viaversion.viaversion.api.minecraft.entitydata.EntityDataType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
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_21;
import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21;
import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.Paintings1_20_5;
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.data.Enchantments1_20_5;
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundConfigurationPackets1_20_5;
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPacket1_20_5;
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPackets1_20_5;
import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21;
import com.viaversion.viaversion.protocols.v1_20_5to1_21.data.Paintings1_20_5;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import com.viaversion.viaversion.util.Key;
@ -68,12 +71,12 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
paintingRegistryPacket.write(Types.STRING, "minecraft:painting_variant");
final RegistryEntry[] paintingsRegistry = new RegistryEntry[Paintings1_20_5.PAINTINGS.length];
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];
final CompoundTag tag = new CompoundTag();
tag.putInt("width", painting.width());
tag.putInt("height", painting.height());
tag.putString("asset_id", painting.key());
paintingsRegistry[i] = new RegistryEntry(painting.key(), tag);
tag.putString("asset_id", painting.assetId());
paintingsRegistry[i] = new RegistryEntry(painting.assetId(), tag);
}
paintingRegistryPacket.write(Types.REGISTRY_ENTRY_ARRAY, paintingsRegistry);
paintingRegistryPacket.send(Protocol1_20_5To1_21.class);
@ -118,8 +121,18 @@ public final class EntityPacketRewriter1_21 extends EntityRewriter<ClientboundPa
@Override
protected void registerRewrites() {
filter().mapDataType(Types1_21.ENTITY_DATA_TYPES::byId);
filter().handler((event, data) -> {
final EntityDataType type = data.dataType();
if (type == Types1_20_5.ENTITY_DATA_TYPES.wolfVariantType) {
final int variant = data.value();
data.setTypeAndValue(Types1_21.ENTITY_DATA_TYPES.wolfVariantType, Holder.of(variant));
} else if (type == Types1_20_5.ENTITY_DATA_TYPES.paintingVariantType) {
final int variant = data.value();
data.setTypeAndValue(Types1_21.ENTITY_DATA_TYPES.paintingVariantType, Holder.of(variant));
} else {
data.setDataType(Types1_21.ENTITY_DATA_TYPES.byId(type.typeId()));
}
});
registerEntityDataTypeHandler(
Types1_21.ENTITY_DATA_TYPES.itemType,
Types1_21.ENTITY_DATA_TYPES.blockStateType,

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=5.0.0-24w19b-SNAPSHOT
projectVersion=5.0.0-24w20a-SNAPSHOT
# 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, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9