Skip to content

Commit 43bb38f

Browse files
committed
Rename RESOURCE_LOCATION Type to IDENTIFIER
Includes method and local variable names of cross-version code. Key stays unchanged, as it's quite clear what it represents (and is shorter)
1 parent b9f1102 commit 43bb38f

33 files changed

+68
-70
lines changed

api/src/main/java/com/viaversion/viaversion/api/data/MappingDataBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public void load() {
172172
}
173173

174174
private void loadTags(final RegistryType type, final CompoundTag data) {
175-
final CompoundTag tag = data.getCompoundTag(type.resourceLocation());
175+
final CompoundTag tag = data.getCompoundTag(type.identifier());
176176
if (tag == null) {
177177
return;
178178
}

api/src/main/java/com/viaversion/viaversion/api/minecraft/PaintingVariant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void writeDirect(final Ops ops, final PaintingVariant value) {
7878
ops.writeMap(map -> map
7979
.write("width", Types.INT, value.width())
8080
.write("height", Types.INT, value.height())
81-
.write("asset_id", Types.RESOURCE_LOCATION, Key.of(value.assetId()))
81+
.write("asset_id", Types.IDENTIFIER, Key.of(value.assetId()))
8282
.writeOptional("title", Types.TAG, value.title())
8383
.writeOptional("author", Types.TAG, value.author()));
8484
}

api/src/main/java/com/viaversion/viaversion/api/minecraft/RegistryType.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,30 @@ public enum RegistryType implements RegistryKey {
4141

4242
static {
4343
for (RegistryType type : getValues()) {
44-
MAP.put(type.resourceLocation, type);
44+
MAP.put(type.identifier, type);
4545
}
4646
}
4747

4848
public static RegistryType[] getValues() {
4949
return VALUES;
5050
}
5151

52-
public static @Nullable RegistryType getByKey(String resourceKey) {
53-
return MAP.get(resourceKey);
52+
public static @Nullable RegistryType getByKey(String identifier) {
53+
return MAP.get(identifier);
5454
}
5555

56-
private final String resourceLocation;
56+
private final String identifier;
5757

58-
RegistryType(final String resourceLocation) {
59-
this.resourceLocation = resourceLocation;
58+
RegistryType(final String identifier) {
59+
this.identifier = identifier;
6060
}
6161

62-
public String resourceLocation() {
63-
return resourceLocation;
62+
public String identifier() {
63+
return identifier;
6464
}
6565

6666
@Override
6767
public Key key() {
68-
return Key.of(resourceLocation);
68+
return Key.of(identifier);
6969
}
7070
}

api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataKey.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
import com.viaversion.viaversion.api.type.Type;
8787
import com.viaversion.viaversion.api.type.Types;
8888
import com.viaversion.viaversion.api.type.types.ArrayType;
89-
import com.viaversion.viaversion.api.type.types.EitherType;
9089
import com.viaversion.viaversion.api.type.types.misc.SynchronizedRegistryEitherType;
9190
import com.viaversion.viaversion.api.type.types.misc.SynchronizedRegistryValueType;
9291
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
@@ -152,7 +151,7 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
152151
public static final StructuredDataKey<Equippable> EQUIPPABLE1_21_6 = new StructuredDataKey<>("equippable", Equippable.TYPE1_21_6);
153152
public static final StructuredDataKey<Repairable> REPAIRABLE = new StructuredDataKey<>("repairable", Repairable.TYPE);
154153
public static final StructuredDataKey<Unit> GLIDER = new StructuredDataKey<>("glider", Types.EMPTY);
155-
public static final StructuredDataKey<Key> TOOLTIP_STYLE = new StructuredDataKey<>("tooltip_style", Types.RESOURCE_LOCATION);
154+
public static final StructuredDataKey<Key> TOOLTIP_STYLE = new StructuredDataKey<>("tooltip_style", Types.IDENTIFIER);
156155
public static final StructuredDataKey<DeathProtection> DEATH_PROTECTION = new StructuredDataKey<>("death_protection", DeathProtection.TYPE);
157156
public static final StructuredDataKey<BlocksAttacks> BLOCKS_ATTACKS = new StructuredDataKey<>("blocks_attacks", BlocksAttacks.TYPE);
158157
public static final StructuredDataKey<PiercingWeapon> PIERCING_WEAPON = new StructuredDataKey<>("piercing_weapon", PiercingWeapon.TYPE);
@@ -196,7 +195,7 @@ public record StructuredDataKey<T>(String identifier, Type<T> type) {
196195
public static final StructuredDataKey<Fireworks> FIREWORKS = new StructuredDataKey<>("fireworks", Fireworks.TYPE);
197196
public static final StructuredDataKey<GameProfile> PROFILE1_20_5 = new StructuredDataKey<>("profile", Types.GAME_PROFILE);
198197
public static final StructuredDataKey<ResolvableProfile> PROFILE1_21_9 = new StructuredDataKey<>("profile", Types.RESOLVABLE_PROFILE);
199-
public static final StructuredDataKey<Key> NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Types.RESOURCE_LOCATION);
198+
public static final StructuredDataKey<Key> NOTE_BLOCK_SOUND = new StructuredDataKey<>("note_block_sound", Types.IDENTIFIER);
200199
public static final StructuredDataKey<BannerPatternLayer[]> BANNER_PATTERNS = new StructuredDataKey<>("banner_patterns", BannerPatternLayer.ARRAY_TYPE);
201200
public static final StructuredDataKey<Integer> BASE_COLOR = new StructuredDataKey<>("base_color", EnumTypes.DYE_COLOR);
202201
public static final StructuredDataKey<PotDecorations> POT_DECORATIONS = new StructuredDataKey<>("pot_decorations", PotDecorations.TYPE);

api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimMaterial.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public void writeDirect(final Ops ops, final ArmorTrimMaterial object) {
186186
if (!object.overrideArmorMaterials.isEmpty()) {
187187
map.writeMap("override_armor_assets", materials -> {
188188
for (final Map.Entry<String, String> entry : object.overrideArmorMaterials.entrySet()) {
189-
materials.write(Types.RESOURCE_LOCATION, Key.of(entry.getKey()), Types.STRING, entry.getValue());
189+
materials.write(Types.IDENTIFIER, Key.of(entry.getKey()), Types.STRING, entry.getValue());
190190
}
191191
});
192192
}

api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/ArmorTrimPattern.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public void writeDirect(final ByteBuf buffer, final ArmorTrimPattern value) {
7676
@Override
7777
public void writeDirect(final Ops ops, final ArmorTrimPattern object) {
7878
ops.writeMap(map -> map
79-
.write("asset_id", Types.RESOURCE_LOCATION, Key.of(object.assetName()))
79+
.write("asset_id", Types.IDENTIFIER, Key.of(object.assetName()))
8080
.write("description", Types.TEXT_COMPONENT_TAG, object.description())
8181
.write("decal", Types.BOOLEAN, object.decal()));
8282
}

api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/AttributeModifiers1_21.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ public void write(final ByteBuf buffer, final AttributeModifier value) {
152152
public void write(final Ops ops, final AttributeModifier value) {
153153
final Key attribute = ops.context().registryAccess().attributeModifier(value.attribute);
154154
ops.writeMap(map -> map
155-
.write("type", Types.RESOURCE_LOCATION, attribute)
156-
.write("id", Types.RESOURCE_LOCATION, Key.of(value.modifier.id()))
155+
.write("type", Types.IDENTIFIER, attribute)
156+
.write("id", Types.IDENTIFIER, Key.of(value.modifier.id()))
157157
.write("amount", Types.DOUBLE, value.modifier.amount)
158158
.write("operation", Types.STRING, OPERATION[value.modifier.operation()])
159159
.writeOptional("slot", Types.STRING, EQUIPMENT_SLOT_GROUPS[value.slotType()], "any"));
@@ -184,8 +184,8 @@ public void write(final ByteBuf buffer, final AttributeModifier value) {
184184
public void write(final Ops ops, final AttributeModifier value) {
185185
final Key attribute = ops.context().registryAccess().attributeModifier(value.attribute);
186186
ops.writeMap(map -> {
187-
map.write("type", Types.RESOURCE_LOCATION, attribute)
188-
.write("id", Types.RESOURCE_LOCATION, Key.of(value.modifier.id()))
187+
map.write("type", Types.IDENTIFIER, attribute)
188+
.write("id", Types.IDENTIFIER, Key.of(value.modifier.id()))
189189
.write("amount", Types.DOUBLE, value.modifier.amount)
190190
.write("operation", Types.STRING, OPERATION[value.modifier.operation()])
191191
.writeOptional("slot", Types.STRING, EQUIPMENT_SLOT_GROUPS[value.slotType()], "any");

api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BannerPattern.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void writeDirect(final ByteBuf buffer, final BannerPattern value) {
4747
@Override
4848
public void writeDirect(final Ops ops, final BannerPattern object) {
4949
ops.writeMap(map -> map
50-
.write("asset_id", Types.RESOURCE_LOCATION, Key.of(object.assetId))
50+
.write("asset_id", Types.IDENTIFIER, Key.of(object.assetId))
5151
.write("translation_key", Types.STRING, object.translationKey));
5252
}
5353

api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/BlockEntityData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void write(final ByteBuf buffer, final BlockEntityData value) {
5050
@Override
5151
public void write(final Ops ops, final BlockEntityData data) {
5252
ops.writeMap(map -> map
53-
.write("id", Types.RESOURCE_LOCATION, ops.context().registryAccess().blockEntity(data.type))
53+
.write("id", Types.IDENTIFIER, ops.context().registryAccess().blockEntity(data.type))
5454
.writeInlinedMap(Types.COMPOUND_TAG, data.tag)
5555
);
5656
}

api/src/main/java/com/viaversion/viaversion/api/minecraft/item/data/DamageResistant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
public record DamageResistant(Key typesTagKey) {
3232

33-
public static final Type<DamageResistant> TYPE = new TransformingType<>(Types.RESOURCE_LOCATION, DamageResistant.class, DamageResistant::new, DamageResistant::typesTagKey) {
33+
public static final Type<DamageResistant> TYPE = new TransformingType<>(Types.IDENTIFIER, DamageResistant.class, DamageResistant::new, DamageResistant::typesTagKey) {
3434

3535
@Override
3636
public void write(final Ops ops, final DamageResistant value) {

0 commit comments

Comments
 (0)