Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-08 17:20:24 +01:00
Add todos
Dieser Commit ist enthalten in:
Ursprung
e51d7b3fdb
Commit
6ffa24b50b
@ -47,10 +47,8 @@ public final class StructuredDataContainer {
|
||||
* @param <T> data type
|
||||
* @return structured data
|
||||
*/
|
||||
public <T> Optional<StructuredData<T>> get(final int id) {
|
||||
final Optional<StructuredData<?>> data = this.data.getOrDefault(id, Optional.empty());
|
||||
//noinspection unchecked
|
||||
return data.map(value -> (StructuredData<T>) value);
|
||||
public Optional<StructuredData<?>> get(final int id) {
|
||||
return this.data.getOrDefault(id, Optional.empty());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,7 +76,7 @@ public final class StructuredDataContainer {
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void addEmpty(final Protocol<?, ?, ?, ?> protocol, final StructuredDataKey<T> key) {
|
||||
public void addEmpty(final Protocol<?, ?, ?, ?> protocol, final StructuredDataKey<?> key) {
|
||||
final int id = serializerId(protocol, key);
|
||||
if (id != -1) {
|
||||
this.data.put(id, Optional.empty());
|
||||
|
@ -24,6 +24,7 @@ package com.viaversion.viaversion.api.rewriter;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
public interface ItemRewriter<T extends Protocol> extends Rewriter<T> {
|
||||
@ -43,4 +44,12 @@ public interface ItemRewriter<T extends Protocol> extends Rewriter<T> {
|
||||
* @return rewritten item
|
||||
*/
|
||||
@Nullable Item handleItemToServer(@Nullable Item item);
|
||||
|
||||
Type<Item> itemType();
|
||||
|
||||
Type<Item[]> itemArrayType();
|
||||
|
||||
Type<Item> mappedItemType();
|
||||
|
||||
Type<Item[]> mappedItemArrayType();
|
||||
}
|
||||
|
@ -46,11 +46,21 @@ public class RecipeRewriter1_20_3<C extends ClientboundPacketType> extends Recip
|
||||
|
||||
@Override
|
||||
protected Type<Item> itemType() {
|
||||
return Type.ITEM1_20_2;
|
||||
return protocol.getItemRewriter().itemType();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Type<Item[]> itemArrayType() {
|
||||
return Type.ITEM1_20_2_ARRAY;
|
||||
return protocol.getItemRewriter().itemArrayType();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Type<Item> mappedItemType() {
|
||||
return protocol.getItemRewriter().mappedItemType();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Type<Item[]> mappedItemArrayType() {
|
||||
return protocol.getItemRewriter().mappedItemArrayType();
|
||||
}
|
||||
}
|
@ -156,17 +156,7 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
}
|
||||
});
|
||||
|
||||
final RecipeRewriter1_20_3<ClientboundPacket1_20_3> recipeRewriter = new RecipeRewriter1_20_3<ClientboundPacket1_20_3>(protocol) {
|
||||
@Override
|
||||
protected Type<Item> mappedItemType() {
|
||||
return Types1_20_5.ITEM;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Type<Item[]> mappedItemArrayType() {
|
||||
return Types1_20_5.ITEM_ARRAY;
|
||||
}
|
||||
};
|
||||
final RecipeRewriter1_20_3<ClientboundPacket1_20_3> recipeRewriter = new RecipeRewriter1_20_3<>(protocol);
|
||||
protocol.registerClientbound(ClientboundPackets1_20_3.DECLARE_RECIPES, wrapper -> {
|
||||
final int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
@ -197,11 +187,9 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
}
|
||||
|
||||
public Item toOldItem(final Item item) {
|
||||
final StructuredDataContainer data = item.structuredData();
|
||||
final Optional<StructuredData<CompoundTag>> customData = data.get(protocol, StructuredDataKey.CUSTOM_DATA);
|
||||
|
||||
// Start out with custom data and add the rest on top
|
||||
final CompoundTag tag = customData.map(StructuredData::value).orElse(new CompoundTag());
|
||||
final StructuredDataContainer data = item.structuredData();
|
||||
final CompoundTag tag = data.get(protocol, StructuredDataKey.CUSTOM_DATA).map(StructuredData::value).orElse(new CompoundTag());
|
||||
|
||||
// TODO
|
||||
|
||||
@ -277,6 +265,44 @@ public final class BlockItemPacketRewriter1_20_5 extends ItemRewriter<Clientboun
|
||||
updateEnchantments(data, tag, "StoredEnchantments", StructuredDataKey.STORED_ENCHANTMENTS, (hideFlagsValue & 0x20) != 0);
|
||||
|
||||
// TODO
|
||||
// tructuredDataKey.CUSTOM_NAME
|
||||
// tructuredDataKey.LORE
|
||||
// tructuredDataKey.CAN_PLACE_ON
|
||||
// tructuredDataKey.CAN_BREAK
|
||||
// tructuredDataKey.ATTRIBUTE_MODIFIERS
|
||||
// tructuredDataKey.HIDE_ADDITIONAL_TOOLTIP
|
||||
// tructuredDataKey.REPAIR_COST
|
||||
// tructuredDataKey.CREATIVE_SLOT_LOCK
|
||||
// tructuredDataKey.INTANGIBLE_PROJECTILE
|
||||
// tructuredDataKey.DYED_COLOR
|
||||
// tructuredDataKey.MAP_COLOR
|
||||
// tructuredDataKey.MAP_ID
|
||||
// tructuredDataKey.MAP_DECORATIONS
|
||||
// tructuredDataKey.MAP_POST_PROCESSING
|
||||
// tructuredDataKey.CHARGED_PROJECTILES
|
||||
// tructuredDataKey.BUNDLE_CONTENTS
|
||||
// tructuredDataKey.POTION_CONTENTS
|
||||
// tructuredDataKey.SUSPICIOUS_STEW_EFFECTS
|
||||
// tructuredDataKey.WRITABLE_BOOK_CONTENT
|
||||
// tructuredDataKey.WRITTEN_BOOK_CONTENT
|
||||
// tructuredDataKey.TRIM
|
||||
// tructuredDataKey.DEBUG_STICK_STATE
|
||||
// tructuredDataKey.BUCKET_ENTITY_DATA
|
||||
// tructuredDataKey.BLOCK_ENTITY_DATA
|
||||
// tructuredDataKey.INSTRUMENT
|
||||
// tructuredDataKey.RECIPES
|
||||
// tructuredDataKey.LODESTONE_TARGET
|
||||
// tructuredDataKey.FIREWORK_EXPLOSION
|
||||
// tructuredDataKey.FIREWORKS
|
||||
// tructuredDataKey.PROFILE
|
||||
// tructuredDataKey.NOTE_BLOCK_SOUND
|
||||
// tructuredDataKey.BANNER_PATTERNS
|
||||
// tructuredDataKey.BASE_COLOR
|
||||
// tructuredDataKey.POT_DECORATIONS
|
||||
// tructuredDataKey.CONTAINER
|
||||
// tructuredDataKey.BEES
|
||||
// tructuredDataKey.LOCK
|
||||
// tructuredDataKey.CONTAINER_LOOT
|
||||
|
||||
// Add the rest as custom data
|
||||
data.add(protocol, StructuredDataKey.CUSTOM_DATA, tag);
|
||||
|
@ -543,11 +543,23 @@ public class ItemRewriter<C extends ClientboundPacketType, S extends Serverbound
|
||||
particle.setId(protocol.getMappingData().getNewParticleId(id));
|
||||
}
|
||||
|
||||
public Type<Item> getItemType() {
|
||||
@Override
|
||||
public Type<Item> itemType() {
|
||||
return itemType;
|
||||
}
|
||||
|
||||
public Type<Item[]> getItemArrayType() {
|
||||
@Override
|
||||
public Type<Item[]> itemArrayType() {
|
||||
return itemArrayType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<Item> mappedItemType() {
|
||||
return mappedItemType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<Item[]> mappedItemArrayType() {
|
||||
return mappedItemArrayType;
|
||||
}
|
||||
}
|
||||
|
@ -38,9 +38,7 @@ import com.viaversion.viaversion.template.protocols.rewriter.EntityPacketRewrite
|
||||
// Protocol1_99To_98, EntityPacketRewriter1_99, BlockItemPacketRewriter1_99
|
||||
// ClientboundPacket1_20_5
|
||||
// ServerboundPacket1_20_5
|
||||
// ClientboundConfigurationPackets1_20_3
|
||||
// ServerboundConfigurationPackets1_20_2
|
||||
// Entity1_19_4Types (MAPPED type)
|
||||
// EntityTypes1_20_5 (MAPPED type)
|
||||
// 1.99, 1.98
|
||||
public final class Protocol1_99To_98 extends AbstractProtocol<ClientboundPacket1_20_5, ClientboundPacket1_20_5, ServerboundPacket1_20_5, ServerboundPacket1_20_5> {
|
||||
|
||||
|
@ -35,7 +35,7 @@ import com.viaversion.viaversion.template.protocols.Protocol1_99To_98;
|
||||
public final class BlockItemPacketRewriter1_99 extends ItemRewriter<ClientboundPacket1_20_5, ServerboundPacket1_20_5, Protocol1_99To_98> {
|
||||
|
||||
public BlockItemPacketRewriter1_99(final Protocol1_99To_98 protocol) {
|
||||
super(protocol, Type.ITEM1_20_2, Type.ITEM1_20_2_ARRAY); // Add two more types if they changed
|
||||
super(protocol, /*TypesOLD.ITEM, TypesOLD.ITEM_ARRAY, */Types1_20_5.ITEM, Types1_20_5.ITEM_ARRAY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren