Added 1.21 client and server support

This commit is contained in:
RaphiMC 2024-06-16 18:27:05 +02:00
parent 9e85832a9f
commit f439382ee5
No known key found for this signature in database
GPG key ID: 0F6BB0657A03AC94
4 changed files with 16 additions and 17 deletions

View file

@ -53,16 +53,16 @@ repositories {
}
dependencies {
include "com.viaversion:viaversion-common:5.0.0-SNAPSHOT"
include "com.viaversion:viabackwards-common:5.0.0-SNAPSHOT"
include "com.viaversion:viarewind-common:4.0.0-SNAPSHOT"
include "net.raphimc:ViaLegacy:3.0.0-SNAPSHOT"
include "net.raphimc:ViaAprilFools:3.0.0-SNAPSHOT"
include("net.raphimc:ViaBedrock:0.0.8-SNAPSHOT") {
include "com.viaversion:viaversion-common:5.0.0"
include "com.viaversion:viabackwards-common:5.0.0"
include "com.viaversion:viarewind-common:4.0.0"
include "net.raphimc:ViaLegacy:3.0.0"
include "net.raphimc:ViaAprilFools:3.0.0"
include("net.raphimc:ViaBedrock:0.0.9-SNAPSHOT") {
exclude group: "io.netty"
exclude group: "io.jsonwebtoken"
}
include("net.raphimc:ViaLoader:3.0.0-SNAPSHOT") {
include("net.raphimc:ViaLoader:3.0.0") {
exclude group: "org.slf4j", module: "slf4j-api"
}

View file

@ -139,7 +139,7 @@ public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<Cl
}
if (user.getProtocolInfo().serverProtocolVersion().betweenInclusive(LegacyProtocolVersion.b1_8tob1_8_1, ProtocolVersion.v1_8)) {
if (this.swordItems1_8.contains(identifier)) {
data.set(StructuredDataKey.FOOD, new FoodProperties(0, 0F, true, 3600, new FoodEffect[0]));
data.set(StructuredDataKey.FOOD1_20_5, new FoodProperties(0, 0F, true, 3600, null, new FoodEffect[0]));
}
}
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_8tob1_8_1)) {
@ -150,7 +150,7 @@ public abstract class MixinBlockItemPacketRewriter1_20_5 extends ItemRewriter<Cl
if (user.getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.b1_7tob1_7_3)) {
if (this.foodItems_b1_7_3.contains(identifier)) {
data.set(StructuredDataKey.MAX_STACK_SIZE, 1);
data.addEmpty(StructuredDataKey.FOOD);
data.addEmpty(StructuredDataKey.FOOD1_20_5);
}
}

View file

@ -28,7 +28,6 @@ import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ClientboundPac
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.rewriter.EntityPacketRewriter1_20_5;
import com.viaversion.viaversion.rewriter.EntityRewriter;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@ -52,7 +51,7 @@ public abstract class MixinEntityPacketRewriter1_20_5 extends EntityRewriter<Cli
}
@Shadow
protected abstract void writeAttribute(PacketWrapper wrapper, String attributeId, double base, @Nullable UUID modifierId, double amount);
protected abstract void writeAttribute(PacketWrapper wrapper, String attributeId, double base, UUID modifierId, double amount);
/**
* @author RK_01

View file

@ -21,7 +21,7 @@ package net.raphimc.viaproxy.injection.mixins;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.minecraft.item.data.ModifierData;
import com.viaversion.viaversion.api.minecraft.item.data.AttributeModifiers1_20_5;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.viaversion.libs.gson.JsonElement;
@ -51,7 +51,7 @@ public abstract class MixinItemPacketRewriter1_9 extends ItemRewriter<Clientboun
private final Int2ObjectMap<String> itemIdentifiers = new Int2ObjectOpenHashMap<>();
@Unique
private final Map<String, Map<String, Pair<String, ModifierData>>> itemAttributes = new HashMap<>();
private final Map<String, Map<String, Pair<String, AttributeModifiers1_20_5.ModifierData>>> itemAttributes = new HashMap<>();
// TODO: ClassTransform bug: Constructor merging is broken
/*public MixinItemPacketRewriter1_9(Protocol1_8To1_9 protocol, Type<Item> itemType, Type<Item[]> itemArrayType, Type<Item> mappedItemType, Type<Item[]> mappedItemArrayType) {
@ -72,11 +72,11 @@ public abstract class MixinItemPacketRewriter1_9 extends ItemRewriter<Clientboun
final JsonObject itemAttributes = ViaProxyMappingDataLoader.INSTANCE.loadData("item-attributes-1.8.json");
for (Map.Entry<String, JsonElement> itemEntry : itemAttributes.entrySet()) {
final String itemIdentifier = itemEntry.getKey();
final Map<String, Pair<String, ModifierData>> attributes = new HashMap<>();
final Map<String, Pair<String, AttributeModifiers1_20_5.ModifierData>> attributes = new HashMap<>();
for (Map.Entry<String, JsonElement> attributeEntry : itemEntry.getValue().getAsJsonObject().entrySet()) {
final String attribute = attributeEntry.getKey();
final JsonObject attributeData = attributeEntry.getValue().getAsJsonObject();
final ModifierData modifierData = new ModifierData(UUID.fromString(attributeData.get("id").getAsString()), attributeData.get("name").getAsString(), attributeData.get("amount").getAsDouble(), attributeData.get("operation").getAsInt());
final AttributeModifiers1_20_5.ModifierData modifierData = new AttributeModifiers1_20_5.ModifierData(UUID.fromString(attributeData.get("id").getAsString()), attributeData.get("name").getAsString(), attributeData.get("amount").getAsDouble(), attributeData.get("operation").getAsInt());
final String slot = attributeData.get("slot").getAsString();
attributes.put(attribute, new Pair<>(slot, modifierData));
}
@ -91,7 +91,7 @@ public abstract class MixinItemPacketRewriter1_9 extends ItemRewriter<Clientboun
final String identifier = this.itemIdentifiers.get(item.identifier());
if (identifier != null && this.itemAttributes.containsKey(identifier)) {
final Map<String, Pair<String, ModifierData>> attributes = this.itemAttributes.get(identifier);
final Map<String, Pair<String, AttributeModifiers1_20_5.ModifierData>> attributes = this.itemAttributes.get(identifier);
final CompoundTag attributeFixTag = new CompoundTag();
CompoundTag tag = item.tag();
if (tag == null) {
@ -104,7 +104,7 @@ public abstract class MixinItemPacketRewriter1_9 extends ItemRewriter<Clientboun
ListTag<CompoundTag> attributeModifiers = tag.getListTag("AttributeModifiers", CompoundTag.class);
if (attributeModifiers == null) {
attributeModifiers = new ListTag<>(CompoundTag.class);
for (Map.Entry<String, Pair<String, ModifierData>> entry : attributes.entrySet()) {
for (Map.Entry<String, Pair<String, AttributeModifiers1_20_5.ModifierData>> entry : attributes.entrySet()) {
final CompoundTag attributeModifier = new CompoundTag();
attributeModifier.putString("AttributeName", entry.getKey());
attributeModifier.putString("Name", entry.getValue().value().name());