Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 08:30:10 +01:00
Add constructors to LegacyBlockItemRewriter to define item types
Dieser Commit ist enthalten in:
Ursprung
27dd2e39bd
Commit
78a667c5b9
@ -59,14 +59,22 @@ public abstract class LegacyBlockItemRewriter<C extends ClientboundPacketType, S
|
|||||||
|
|
||||||
protected final Int2ObjectMap<MappedLegacyBlockItem> replacementData = new Int2ObjectOpenHashMap<>(8); // Raw id -> mapped data
|
protected final Int2ObjectMap<MappedLegacyBlockItem> replacementData = new Int2ObjectOpenHashMap<>(8); // Raw id -> mapped data
|
||||||
|
|
||||||
protected LegacyBlockItemRewriter(T protocol, String name) {
|
protected LegacyBlockItemRewriter(T protocol, String name, Type<Item> itemType, Type<Item[]> itemArrayType, Type<Item> mappedItemType, Type<Item[]> mappedItemArrayType) {
|
||||||
super(protocol, Type.ITEM1_8, Type.ITEM1_8_SHORT_ARRAY, false);
|
super(protocol, itemType, itemArrayType, mappedItemType, mappedItemArrayType, false);
|
||||||
final JsonObject jsonObject = readMappingsFile("item-mappings-" + name + ".json");
|
final JsonObject jsonObject = readMappingsFile("item-mappings-" + name + ".json");
|
||||||
for (final MappedLegacyBlockItem.Type value : MappedLegacyBlockItem.Type.values()) {
|
for (final MappedLegacyBlockItem.Type value : MappedLegacyBlockItem.Type.values()) {
|
||||||
addMappings(value, jsonObject, replacementData);
|
addMappings(value, jsonObject, replacementData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected LegacyBlockItemRewriter(T protocol, String name, Type<Item> itemType, Type<Item[]> itemArrayType) {
|
||||||
|
this(protocol, name, itemType, itemArrayType, itemType, itemArrayType);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LegacyBlockItemRewriter(T protocol, String name) {
|
||||||
|
this(protocol, name, Type.ITEM1_8, Type.ITEM1_8_SHORT_ARRAY);
|
||||||
|
}
|
||||||
|
|
||||||
private void addMappings(MappedLegacyBlockItem.Type type, JsonObject object, Int2ObjectMap<MappedLegacyBlockItem> mappings) {
|
private void addMappings(MappedLegacyBlockItem.Type type, JsonObject object, Int2ObjectMap<MappedLegacyBlockItem> mappings) {
|
||||||
if (object.has(type.getName())) {
|
if (object.has(type.getName())) {
|
||||||
final JsonObject mappingsObject = object.getAsJsonObject(type.getName());
|
final JsonObject mappingsObject = object.getAsJsonObject(type.getName());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren