Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-16 04:50:08 +01:00
Ursprung
87b041bf3a
Commit
0915afe43b
@ -46,6 +46,7 @@ public class MappingDataBase implements MappingData {
|
|||||||
protected ParticleMappings particleMappings;
|
protected ParticleMappings particleMappings;
|
||||||
protected BiMappings itemMappings;
|
protected BiMappings itemMappings;
|
||||||
protected BiMappings blockMappings;
|
protected BiMappings blockMappings;
|
||||||
|
protected BiMappings attributeMappings;
|
||||||
protected Mappings blockStateMappings;
|
protected Mappings blockStateMappings;
|
||||||
protected Mappings blockEntityMappings;
|
protected Mappings blockEntityMappings;
|
||||||
protected Mappings soundMappings;
|
protected Mappings soundMappings;
|
||||||
@ -53,7 +54,6 @@ public class MappingDataBase implements MappingData {
|
|||||||
protected Mappings enchantmentMappings;
|
protected Mappings enchantmentMappings;
|
||||||
protected Mappings paintingMappings;
|
protected Mappings paintingMappings;
|
||||||
protected Mappings menuMappings;
|
protected Mappings menuMappings;
|
||||||
protected Mappings attributeMappings;
|
|
||||||
protected Map<RegistryType, List<TagData>> tags;
|
protected Map<RegistryType, List<TagData>> tags;
|
||||||
|
|
||||||
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
|
public MappingDataBase(final String unmappedVersion, final String mappedVersion) {
|
||||||
@ -76,7 +76,7 @@ public class MappingDataBase implements MappingData {
|
|||||||
menuMappings = loadMappings(data, "menus");
|
menuMappings = loadMappings(data, "menus");
|
||||||
enchantmentMappings = loadMappings(data, "enchantments");
|
enchantmentMappings = loadMappings(data, "enchantments");
|
||||||
paintingMappings = loadMappings(data, "paintings");
|
paintingMappings = loadMappings(data, "paintings");
|
||||||
attributeMappings = loadMappings(data, "attributes");
|
attributeMappings = loadBiMappings(data, "attributes");
|
||||||
|
|
||||||
|
|
||||||
final CompoundTag unmappedIdentifierData = readUnmappedIdentifiersFile("identifiers-" + unmappedVersion + ".nbt");
|
final CompoundTag unmappedIdentifierData = readUnmappedIdentifiersFile("identifiers-" + unmappedVersion + ".nbt");
|
||||||
|
@ -41,6 +41,7 @@ import com.viaversion.viaversion.rewriter.BlockRewriter;
|
|||||||
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<ClientboundPacket1_20_5, ServerboundPacket1_20_5, Protocol1_20_5To1_21> {
|
public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<ClientboundPacket1_20_5, ServerboundPacket1_20_5, Protocol1_20_5To1_21> {
|
||||||
|
|
||||||
@ -139,9 +140,10 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<Cl
|
|||||||
dataContainer.replaceKey(StructuredDataKey.BUNDLE_CONTENTS1_20_5, StructuredDataKey.BUNDLE_CONTENTS1_21);
|
dataContainer.replaceKey(StructuredDataKey.BUNDLE_CONTENTS1_20_5, StructuredDataKey.BUNDLE_CONTENTS1_21);
|
||||||
dataContainer.replace(StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, StructuredDataKey.ATTRIBUTE_MODIFIERS1_21, attributeModifiers -> {
|
dataContainer.replace(StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, StructuredDataKey.ATTRIBUTE_MODIFIERS1_21, attributeModifiers -> {
|
||||||
final AttributeModifiers1_21.AttributeModifier[] modifiers = Arrays.stream(attributeModifiers.modifiers()).map(modifier -> {
|
final AttributeModifiers1_21.AttributeModifier[] modifiers = Arrays.stream(attributeModifiers.modifiers()).map(modifier -> {
|
||||||
|
final int mappedAttributeId = Protocol1_20_5To1_21.MAPPINGS.getNewAttributeId(modifier.attribute());
|
||||||
final AttributeModifiers1_20_5.ModifierData modData = modifier.modifier();
|
final AttributeModifiers1_20_5.ModifierData modData = modifier.modifier();
|
||||||
final AttributeModifiers1_21.ModifierData updatedModData = new AttributeModifiers1_21.ModifierData(Protocol1_20_5To1_21.mapAttributeUUID(modData.uuid(), modData.name()), modData.amount(), modData.operation());
|
final AttributeModifiers1_21.ModifierData updatedModData = new AttributeModifiers1_21.ModifierData(Protocol1_20_5To1_21.mapAttributeUUID(modData.uuid(), modData.name()), modData.amount(), modData.operation());
|
||||||
return new AttributeModifiers1_21.AttributeModifier(modifier.attribute(), updatedModData, modifier.slotType());
|
return new AttributeModifiers1_21.AttributeModifier(mappedAttributeId, updatedModData, modifier.slotType());
|
||||||
}).toArray(AttributeModifiers1_21.AttributeModifier[]::new);
|
}).toArray(AttributeModifiers1_21.AttributeModifier[]::new);
|
||||||
return new AttributeModifiers1_21(modifiers, attributeModifiers.showInTooltip());
|
return new AttributeModifiers1_21(modifiers, attributeModifiers.showInTooltip());
|
||||||
});
|
});
|
||||||
@ -168,6 +170,11 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<Cl
|
|||||||
dataContainer.remove(StructuredDataKey.JUKEBOX_PLAYABLE);
|
dataContainer.remove(StructuredDataKey.JUKEBOX_PLAYABLE);
|
||||||
dataContainer.replace(StructuredDataKey.ATTRIBUTE_MODIFIERS1_21, StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, attributeModifiers -> {
|
dataContainer.replace(StructuredDataKey.ATTRIBUTE_MODIFIERS1_21, StructuredDataKey.ATTRIBUTE_MODIFIERS1_20_5, attributeModifiers -> {
|
||||||
final AttributeModifiers1_20_5.AttributeModifier[] modifiers = Arrays.stream(attributeModifiers.modifiers()).map(modifier -> {
|
final AttributeModifiers1_20_5.AttributeModifier[] modifiers = Arrays.stream(attributeModifiers.modifiers()).map(modifier -> {
|
||||||
|
final int mappedAttributeId = Protocol1_20_5To1_21.MAPPINGS.getAttributeMappings().inverse().getNewId(modifier.attribute());
|
||||||
|
if (mappedAttributeId == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final AttributeModifiers1_21.ModifierData modData = modifier.modifier();
|
final AttributeModifiers1_21.ModifierData modData = modifier.modifier();
|
||||||
final String name = AttributeModifierMappings1_21.idToName(modData.id());
|
final String name = AttributeModifierMappings1_21.idToName(modData.id());
|
||||||
final AttributeModifiers1_20_5.ModifierData updatedModData = new AttributeModifiers1_20_5.ModifierData(
|
final AttributeModifiers1_20_5.ModifierData updatedModData = new AttributeModifiers1_20_5.ModifierData(
|
||||||
@ -176,8 +183,8 @@ public final class BlockItemPacketRewriter1_21 extends StructuredItemRewriter<Cl
|
|||||||
modData.amount(),
|
modData.amount(),
|
||||||
modData.operation()
|
modData.operation()
|
||||||
);
|
);
|
||||||
return new AttributeModifiers1_20_5.AttributeModifier(modifier.attribute(), updatedModData, modifier.slotType());
|
return new AttributeModifiers1_20_5.AttributeModifier(mappedAttributeId, updatedModData, modifier.slotType());
|
||||||
}).toArray(AttributeModifiers1_20_5.AttributeModifier[]::new);
|
}).filter(Objects::nonNull).toArray(AttributeModifiers1_20_5.AttributeModifier[]::new);
|
||||||
return new AttributeModifiers1_20_5(modifiers, attributeModifiers.showInTooltip());
|
return new AttributeModifiers1_20_5(modifiers, attributeModifiers.showInTooltip());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren