This commit is contained in:
KennyTV 2020-02-26 18:50:30 +01:00
parent 9ce209ef42
commit efbc246a72
8 changed files with 187 additions and 120 deletions

View File

@ -41,15 +41,15 @@ public class MappingDataLoader {
}
public static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null);
}
public static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
Map.Entry<String, JsonElement> value = mapIdentifierEntry(entry, oldIdentifiers, newIdentifiers, diffIdentifiers);
if (value != null) {
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
}
output.put(Integer.parseInt(entry.getKey()), Integer.parseInt(value.getKey()));
}
}
@ -59,32 +59,48 @@ public class MappingDataLoader {
public static void mapIdentifiers(short[] output, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) {
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
// Search in diff mappings
if (diffIdentifiers != null) {
value = findValue(newIdentifiers, diffIdentifiers.get(entry.getKey()).getAsString());
}
if (value == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
continue;
}
Map.Entry<String, JsonElement> value = mapIdentifierEntry(entry, oldIdentifiers, newIdentifiers, diffIdentifiers);
if (value != null) {
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
output[Integer.parseInt(entry.getKey())] = Short.parseShort(value.getKey());
}
}
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement v = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, v.getAsString());
if (index == null) {
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + v + " :( ");
private static Map.Entry<String, JsonElement> mapIdentifierEntry(Map.Entry<String, JsonElement> entry, JsonObject oldIdentifiers, JsonObject newIdentifiers, JsonObject diffIdentifiers) {
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
if (value == null) {
// Search in diff mappings
if (diffIdentifiers != null) {
value = findValue(newIdentifiers, diffIdentifiers.get(entry.getKey()).getAsString());
}
if (value == null) {
if (!Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + entry.getValue() + " :( ");
}
return null;
}
}
return value;
}
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, boolean warnOnMissing) {
mapIdentifiers(output, oldIdentifiers, newIdentifiers, null, warnOnMissing);
}
public static void mapIdentifiers(short[] output, JsonArray oldIdentifiers, JsonArray newIdentifiers, JsonObject diffIdentifiers, boolean warnOnMissing) {
for (int i = 0; i < oldIdentifiers.size(); i++) {
JsonElement value = oldIdentifiers.get(i);
Integer index = findIndex(newIdentifiers, value.getAsString());
if (index == null) {
if (diffIdentifiers != null) {
index = findIndex(newIdentifiers, diffIdentifiers.get(value.getAsString()).getAsString());
}
if (index == null) {
if (warnOnMissing && !Via.getConfig().isSuppressConversionWarnings() || Via.getManager().isDebug()) {
Via.getPlatform().getLogger().warning("No key for " + value + " :( ");
}
continue;
}
continue;
}
output[i] = index.shortValue();
}

View File

@ -54,12 +54,17 @@ public class Mappings {
* @param size set size of the underlying short array
* @param oldMapping mappings to map from
* @param newMapping mappings to map to
* @param diffMapping extra mappings that will be used/scanned when an entry cannot be found
* @param warnOnMissing should "No key for x" be printed if there is no matching identifier
*/
public Mappings(int size, JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
public Mappings(int size, JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping, boolean warnOnMissing) {
oldToNew = new short[size];
Arrays.fill(oldToNew, (short) -1);
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, warnOnMissing);
MappingDataLoader.mapIdentifiers(oldToNew, oldMapping, newMapping, diffMapping, warnOnMissing);
}
public Mappings(int size, JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
this(size, oldMapping, newMapping, null, warnOnMissing);
}
public Mappings(JsonArray oldMapping, JsonArray newMapping, boolean warnOnMissing) {
@ -70,6 +75,10 @@ public class Mappings {
this(size, oldMapping, newMapping, true);
}
public Mappings(JsonArray oldMapping, JsonArray newMapping, JsonObject diffMapping) {
this(oldMapping.size(), oldMapping, newMapping, diffMapping, true);
}
public Mappings(JsonArray oldMapping, JsonArray newMapping) {
this(oldMapping.size(), oldMapping, newMapping, true);
}

View File

@ -144,7 +144,7 @@ public class Entity1_16Types {
ZOMBIE(95, ABSTRACT_MONSTER),
DROWNED(16, ZOMBIE),
HUSK(33, ZOMBIE),
ZOMBIE_PIGMAN(57, ZOMBIE),
ZOMBIEFIED_PIGLIN(57, ZOMBIE),
ZOMBIE_VILLAGER(97, ZOMBIE),
// Flying entities

View File

@ -58,6 +58,7 @@ public class ProtocolVersion {
register(v_1_6_2 = new ProtocolVersion(74, "1.6.2"));
register(v_1_6_3 = new ProtocolVersion(77, "1.6.3"));
register(v_1_6_4 = new ProtocolVersion(78, "1.6.4"));
// After netty rewrite
register(v1_7_1 = new ProtocolVersion(4, "1.7-1.7.5"));
register(v1_7_6 = new ProtocolVersion(5, "1.7.6-1.7.10"));
@ -83,7 +84,8 @@ public class ProtocolVersion {
register(v1_15 = new ProtocolVersion(573, "1.15"));
register(v1_15_1 = new ProtocolVersion(575, "1.15.1"));
register(v1_15_2 = new ProtocolVersion(578, "1.15.2"));
register(v1_16 = new ProtocolVersion(703, "1.16"));
register(v1_16 = new ProtocolVersion(704, "1.16"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
}

View File

@ -96,7 +96,7 @@ public class Protocol1_16To1_15_2 extends Protocol {
public void registerMap() {
handler(wrapper -> {
int blockTagsSize = wrapper.read(Type.VAR_INT);
wrapper.write(Type.VAR_INT, blockTagsSize + 1); // new tag(s)
wrapper.write(Type.VAR_INT, blockTagsSize + 2); // new tag(s)
for (int i = 0; i < blockTagsSize; i++) {
wrapper.passthrough(Type.STRING);
@ -109,6 +109,8 @@ public class Protocol1_16To1_15_2 extends Protocol {
// Only send the necessary new tags
wrapper.write(Type.STRING, "minecraft:beacon_base_blocks");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{getNewBlockId(133), getNewBlockId(134), getNewBlockId(148), getNewBlockId(265)});
wrapper.write(Type.STRING, "minecraft:climbable");
wrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{getNewBlockId(160), getNewBlockId(241), getNewBlockId(658)});
int itemTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < itemTagsSize; i++) {

View File

@ -23,8 +23,8 @@ public class MappingData {
Via.getPlatform().getLogger().info("Loading 1.15 -> 1.16 block mapping...");
blockMappings = new Mappings(mapping1_15.getAsJsonObject("blocks"), mapping1_16.getAsJsonObject("blocks"));
Via.getPlatform().getLogger().info("Loading 1.15 -> 1.16 item mapping...");
MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_15.getAsJsonObject("items"), mapping1_16.getAsJsonObject("items"));
MappingDataLoader.mapIdentifiers(oldToNewItems, mapping1_15.getAsJsonObject("items"), mapping1_16.getAsJsonObject("items"), diffmapping.getAsJsonObject("items"));
Via.getPlatform().getLogger().info("Loading 1.15 -> 1.16 sound mapping...");
soundMappings = new Mappings(mapping1_15.getAsJsonArray("sounds"), mapping1_16.getAsJsonArray("sounds"));
soundMappings = new Mappings(mapping1_15.getAsJsonArray("sounds"), mapping1_16.getAsJsonArray("sounds"), diffmapping.getAsJsonObject("sounds"));
}
}

View File

@ -14927,7 +14927,7 @@
"14924": "minecraft:stripped_warped_stem[axis=y]",
"14925": "minecraft:stripped_warped_stem[axis=z]",
"14926": "minecraft:warped_nylium",
"14927": "minecraft:warped_fungi",
"14927": "minecraft:warped_fungus",
"14928": "minecraft:warped_wart_block",
"14929": "minecraft:warped_roots",
"14930": "minecraft:nether_sprouts",
@ -14938,7 +14938,7 @@
"14935": "minecraft:stripped_crimson_stem[axis=y]",
"14936": "minecraft:stripped_crimson_stem[axis=z]",
"14937": "minecraft:crimson_nylium",
"14938": "minecraft:crimson_fungi",
"14938": "minecraft:crimson_fungus",
"14939": "minecraft:shroomlight",
"14940": "minecraft:weeping_vines[age=0]",
"14941": "minecraft:weeping_vines[age=1]",
@ -15677,58 +15677,79 @@
"15674": "minecraft:composter[level=6]",
"15675": "minecraft:composter[level=7]",
"15676": "minecraft:composter[level=8]",
"15677": "minecraft:bee_nest[facing=north,honey_level=0]",
"15678": "minecraft:bee_nest[facing=north,honey_level=1]",
"15679": "minecraft:bee_nest[facing=north,honey_level=2]",
"15680": "minecraft:bee_nest[facing=north,honey_level=3]",
"15681": "minecraft:bee_nest[facing=north,honey_level=4]",
"15682": "minecraft:bee_nest[facing=north,honey_level=5]",
"15683": "minecraft:bee_nest[facing=south,honey_level=0]",
"15684": "minecraft:bee_nest[facing=south,honey_level=1]",
"15685": "minecraft:bee_nest[facing=south,honey_level=2]",
"15686": "minecraft:bee_nest[facing=south,honey_level=3]",
"15687": "minecraft:bee_nest[facing=south,honey_level=4]",
"15688": "minecraft:bee_nest[facing=south,honey_level=5]",
"15689": "minecraft:bee_nest[facing=west,honey_level=0]",
"15690": "minecraft:bee_nest[facing=west,honey_level=1]",
"15691": "minecraft:bee_nest[facing=west,honey_level=2]",
"15692": "minecraft:bee_nest[facing=west,honey_level=3]",
"15693": "minecraft:bee_nest[facing=west,honey_level=4]",
"15694": "minecraft:bee_nest[facing=west,honey_level=5]",
"15695": "minecraft:bee_nest[facing=east,honey_level=0]",
"15696": "minecraft:bee_nest[facing=east,honey_level=1]",
"15697": "minecraft:bee_nest[facing=east,honey_level=2]",
"15698": "minecraft:bee_nest[facing=east,honey_level=3]",
"15699": "minecraft:bee_nest[facing=east,honey_level=4]",
"15700": "minecraft:bee_nest[facing=east,honey_level=5]",
"15701": "minecraft:beehive[facing=north,honey_level=0]",
"15702": "minecraft:beehive[facing=north,honey_level=1]",
"15703": "minecraft:beehive[facing=north,honey_level=2]",
"15704": "minecraft:beehive[facing=north,honey_level=3]",
"15705": "minecraft:beehive[facing=north,honey_level=4]",
"15706": "minecraft:beehive[facing=north,honey_level=5]",
"15707": "minecraft:beehive[facing=south,honey_level=0]",
"15708": "minecraft:beehive[facing=south,honey_level=1]",
"15709": "minecraft:beehive[facing=south,honey_level=2]",
"15710": "minecraft:beehive[facing=south,honey_level=3]",
"15711": "minecraft:beehive[facing=south,honey_level=4]",
"15712": "minecraft:beehive[facing=south,honey_level=5]",
"15713": "minecraft:beehive[facing=west,honey_level=0]",
"15714": "minecraft:beehive[facing=west,honey_level=1]",
"15715": "minecraft:beehive[facing=west,honey_level=2]",
"15716": "minecraft:beehive[facing=west,honey_level=3]",
"15717": "minecraft:beehive[facing=west,honey_level=4]",
"15718": "minecraft:beehive[facing=west,honey_level=5]",
"15719": "minecraft:beehive[facing=east,honey_level=0]",
"15720": "minecraft:beehive[facing=east,honey_level=1]",
"15721": "minecraft:beehive[facing=east,honey_level=2]",
"15722": "minecraft:beehive[facing=east,honey_level=3]",
"15723": "minecraft:beehive[facing=east,honey_level=4]",
"15724": "minecraft:beehive[facing=east,honey_level=5]",
"15725": "minecraft:honey_block",
"15726": "minecraft:honeycomb_block",
"15727": "minecraft:netherite_block",
"15728": "minecraft:ancient_debris"
"15677": "minecraft:target[power=0]",
"15678": "minecraft:target[power=1]",
"15679": "minecraft:target[power=2]",
"15680": "minecraft:target[power=3]",
"15681": "minecraft:target[power=4]",
"15682": "minecraft:target[power=5]",
"15683": "minecraft:target[power=6]",
"15684": "minecraft:target[power=7]",
"15685": "minecraft:target[power=8]",
"15686": "minecraft:target[power=9]",
"15687": "minecraft:target[power=10]",
"15688": "minecraft:target[power=11]",
"15689": "minecraft:target[power=12]",
"15690": "minecraft:target[power=13]",
"15691": "minecraft:target[power=14]",
"15692": "minecraft:target[power=15]",
"15693": "minecraft:bee_nest[facing=north,honey_level=0]",
"15694": "minecraft:bee_nest[facing=north,honey_level=1]",
"15695": "minecraft:bee_nest[facing=north,honey_level=2]",
"15696": "minecraft:bee_nest[facing=north,honey_level=3]",
"15697": "minecraft:bee_nest[facing=north,honey_level=4]",
"15698": "minecraft:bee_nest[facing=north,honey_level=5]",
"15699": "minecraft:bee_nest[facing=south,honey_level=0]",
"15700": "minecraft:bee_nest[facing=south,honey_level=1]",
"15701": "minecraft:bee_nest[facing=south,honey_level=2]",
"15702": "minecraft:bee_nest[facing=south,honey_level=3]",
"15703": "minecraft:bee_nest[facing=south,honey_level=4]",
"15704": "minecraft:bee_nest[facing=south,honey_level=5]",
"15705": "minecraft:bee_nest[facing=west,honey_level=0]",
"15706": "minecraft:bee_nest[facing=west,honey_level=1]",
"15707": "minecraft:bee_nest[facing=west,honey_level=2]",
"15708": "minecraft:bee_nest[facing=west,honey_level=3]",
"15709": "minecraft:bee_nest[facing=west,honey_level=4]",
"15710": "minecraft:bee_nest[facing=west,honey_level=5]",
"15711": "minecraft:bee_nest[facing=east,honey_level=0]",
"15712": "minecraft:bee_nest[facing=east,honey_level=1]",
"15713": "minecraft:bee_nest[facing=east,honey_level=2]",
"15714": "minecraft:bee_nest[facing=east,honey_level=3]",
"15715": "minecraft:bee_nest[facing=east,honey_level=4]",
"15716": "minecraft:bee_nest[facing=east,honey_level=5]",
"15717": "minecraft:beehive[facing=north,honey_level=0]",
"15718": "minecraft:beehive[facing=north,honey_level=1]",
"15719": "minecraft:beehive[facing=north,honey_level=2]",
"15720": "minecraft:beehive[facing=north,honey_level=3]",
"15721": "minecraft:beehive[facing=north,honey_level=4]",
"15722": "minecraft:beehive[facing=north,honey_level=5]",
"15723": "minecraft:beehive[facing=south,honey_level=0]",
"15724": "minecraft:beehive[facing=south,honey_level=1]",
"15725": "minecraft:beehive[facing=south,honey_level=2]",
"15726": "minecraft:beehive[facing=south,honey_level=3]",
"15727": "minecraft:beehive[facing=south,honey_level=4]",
"15728": "minecraft:beehive[facing=south,honey_level=5]",
"15729": "minecraft:beehive[facing=west,honey_level=0]",
"15730": "minecraft:beehive[facing=west,honey_level=1]",
"15731": "minecraft:beehive[facing=west,honey_level=2]",
"15732": "minecraft:beehive[facing=west,honey_level=3]",
"15733": "minecraft:beehive[facing=west,honey_level=4]",
"15734": "minecraft:beehive[facing=west,honey_level=5]",
"15735": "minecraft:beehive[facing=east,honey_level=0]",
"15736": "minecraft:beehive[facing=east,honey_level=1]",
"15737": "minecraft:beehive[facing=east,honey_level=2]",
"15738": "minecraft:beehive[facing=east,honey_level=3]",
"15739": "minecraft:beehive[facing=east,honey_level=4]",
"15740": "minecraft:beehive[facing=east,honey_level=5]",
"15741": "minecraft:honey_block",
"15742": "minecraft:honeycomb_block",
"15743": "minecraft:netherite_block",
"15744": "minecraft:ancient_debris",
"15745": "minecraft:crying_obsidian",
"15746": "minecraft:potted_crimson_fungus",
"15747": "minecraft:potted_warped_fungus",
"15748": "minecraft:potted_crimson_roots",
"15749": "minecraft:potted_warped_roots"
},
"blocks": {
"0": "air",
@ -16413,14 +16434,14 @@
"679": "warped_stem",
"680": "stripped_warped_stem",
"681": "warped_nylium",
"682": "warped_fungi",
"682": "warped_fungus",
"683": "warped_wart_block",
"684": "warped_roots",
"685": "nether_sprouts",
"686": "crimson_stem",
"687": "stripped_crimson_stem",
"688": "crimson_nylium",
"689": "crimson_fungi",
"689": "crimson_fungus",
"690": "shroomlight",
"691": "weeping_vines",
"692": "weeping_vines_plant",
@ -16450,12 +16471,18 @@
"716": "structure_block",
"717": "jigsaw",
"718": "composter",
"719": "bee_nest",
"720": "beehive",
"721": "honey_block",
"722": "honeycomb_block",
"723": "netherite_block",
"724": "ancient_debris"
"719": "target",
"720": "bee_nest",
"721": "beehive",
"722": "honey_block",
"723": "honeycomb_block",
"724": "netherite_block",
"725": "ancient_debris",
"726": "crying_obsidian",
"727": "potted_crimson_fungus",
"728": "potted_warped_fungus",
"729": "potted_crimson_roots",
"730": "potted_warped_roots"
},
"items": {
"0": "minecraft:air",
@ -16579,8 +16606,8 @@
"118": "minecraft:wither_rose",
"119": "minecraft:brown_mushroom",
"120": "minecraft:red_mushroom",
"121": "minecraft:crimson_fungi",
"122": "minecraft:warped_fungi",
"121": "minecraft:crimson_fungus",
"122": "minecraft:warped_fungus",
"123": "minecraft:crimson_roots",
"124": "minecraft:warped_roots",
"125": "minecraft:nether_sprouts",
@ -17249,7 +17276,7 @@
"788": "minecraft:wolf_spawn_egg",
"789": "minecraft:zombie_spawn_egg",
"790": "minecraft:zombie_horse_spawn_egg",
"791": "minecraft:zombie_pigman_spawn_egg",
"791": "minecraft:zombified_piglin_spawn_egg",
"792": "minecraft:zombie_villager_spawn_egg",
"793": "minecraft:experience_bottle",
"794": "minecraft:fire_charge",
@ -17394,7 +17421,9 @@
"933": "minecraft:netherite_helmet",
"934": "minecraft:netherite_chestplate",
"935": "minecraft:netherite_leggings",
"936": "minecraft:netherite_boots"
"936": "minecraft:netherite_boots",
"937": "minecraft:target",
"938": "minecraft:crying_obsidian"
},
"sounds": [
"ambient.cave",
@ -17866,11 +17895,11 @@
"block.nether_sprouts.place",
"block.nether_sprouts.hit",
"block.nether_sprouts.fall",
"block.fungi.break",
"block.fungi.step",
"block.fungi.place",
"block.fungi.hit",
"block.fungi.fall",
"block.fungus.break",
"block.fungus.step",
"block.fungus.place",
"block.fungus.hit",
"block.fungus.fall",
"block.weeping_vines.break",
"block.weeping_vines.step",
"block.weeping_vines.place",
@ -18106,16 +18135,16 @@
"block.slime_block.hit",
"block.slime_block.place",
"block.slime_block.step",
"block.soul_sand_break",
"block.soul_sand_step",
"block.soul_sand_place",
"block.soul_sand_hit",
"block.soul_sand_fall",
"block.soul_soil_break",
"block.soul_soil_step",
"block.soul_soil_place",
"block.soul_soil_hit",
"block.soul_soil_fall",
"block.soul_sand.break",
"block.soul_sand.step",
"block.soul_sand.place",
"block.soul_sand.hit",
"block.soul_sand.fall",
"block.soul_soil.break",
"block.soul_soil.step",
"block.soul_soil.place",
"block.soul_soil.hit",
"block.soul_soil.fall",
"entity.slime.death_small",
"entity.slime.hurt_small",
"entity.slime.jump_small",
@ -18300,10 +18329,10 @@
"entity.zombie_horse.hurt",
"entity.zombie.hurt",
"entity.zombie.infect",
"entity.zombie_pigman.ambient",
"entity.zombie_pigman.angry",
"entity.zombie_pigman.death",
"entity.zombie_pigman.hurt",
"entity.zombified_piglin.ambient",
"entity.zombified_piglin.angry",
"entity.zombified_piglin.death",
"entity.zombified_piglin.hurt",
"entity.zombie.step",
"entity.zombie_villager.ambient",
"entity.zombie_villager.converted",

View File

@ -1,4 +1,13 @@
{
"items": {
"754": "minecraft:zombified_piglin_spawn_egg"
},
"sounds": {
"entity.zombie_pigman.ambient": "entity.zombified_piglin.ambient",
"entity.zombie_pigman.angry": "entity.zombified_piglin.angry",
"entity.zombie_pigman.death": "entity.zombified_piglin.death",
"entity.zombie_pigman.hurt": "entity.zombified_piglin.hurt"
},
"blockstates": {
"5641": "minecraft:cobblestone_wall[east=tall,north=tall,south=tall,up=true,waterlogged=true,west=tall]",
"5642": "minecraft:cobblestone_wall[east=tall,north=tall,south=tall,up=true,waterlogged=true,west=none]",