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

Fix 1.21 food using_converts_to handling

Fixes #4280
Dieser Commit ist enthalten in:
Nassim Jahnke 2024-11-25 10:14:12 +01:00
Ursprung f93c64d6aa
Commit e32205ddaf
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
2 geänderte Dateien mit 11 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -28,9 +28,10 @@ import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.api.type.types.ArrayType; import com.viaversion.viaversion.api.type.types.ArrayType;
import com.viaversion.viaversion.api.type.types.version.Types1_21; import com.viaversion.viaversion.api.type.types.version.Types1_21;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import org.checkerframework.checker.nullness.qual.Nullable;
public record FoodProperties1_20_5(int nutrition, float saturationModifier, boolean canAlwaysEat, float eatSeconds, public record FoodProperties1_20_5(int nutrition, float saturationModifier, boolean canAlwaysEat, float eatSeconds,
Item usingConvertsTo, FoodEffect[] possibleEffects) { @Nullable Item usingConvertsTo, FoodEffect[] possibleEffects) {
public static final Type<FoodProperties1_20_5> TYPE1_20_5 = new Type<>(FoodProperties1_20_5.class) { public static final Type<FoodProperties1_20_5> TYPE1_20_5 = new Type<>(FoodProperties1_20_5.class) {
@Override @Override

Datei anzeigen

@ -423,12 +423,20 @@ public final class BlockItemPacketRewriter1_21_2 extends StructuredItemRewriter<
} }
super.handleItemToClient(connection, item); super.handleItemToClient(connection, item);
// Handle food properties item manually here - the only protocol that has it
// The other way around it's handled by the super handleItemToServer method
final StructuredDataContainer data = item.dataContainer();
final FoodProperties1_20_5 food = data.get(StructuredDataKey.FOOD1_21);
if (food != null && food.usingConvertsTo() != null) {
this.handleItemToClient(connection, food.usingConvertsTo());
}
updateItemData(item); updateItemData(item);
// Add data components to fix issues in older protocols // Add data components to fix issues in older protocols
appendItemDataFixComponents(connection, item); appendItemDataFixComponents(connection, item);
final StructuredDataContainer data = item.dataContainer();
final Enchantments enchantments = data.get(StructuredDataKey.ENCHANTMENTS); final Enchantments enchantments = data.get(StructuredDataKey.ENCHANTMENTS);
if (enchantments != null && enchantments.size() != 0) { if (enchantments != null && enchantments.size() != 0) {
// Level 0 is no longer allowed // Level 0 is no longer allowed