This commit is contained in:
KennyTV 2020-04-02 22:27:42 +02:00
parent 910f5d98dc
commit ecceac660d
5 changed files with 168 additions and 40 deletions

View File

@ -11,6 +11,7 @@ import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets.EntityPackets
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.TagRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.packets.State;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
@ -93,38 +94,10 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol {
});
// Tags
registerOutgoing(State.PLAY, 0x5C, 0x5C, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
int blockTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < blockTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < blockIds.length; j++) {
int id = blockIds[j];
blockIds[j] = BackwardsMappings.blockMappings.getNewId(id);
}
}
int itemTagsSize = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < itemTagsSize; i++) {
wrapper.passthrough(Type.STRING);
int[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
for (int j = 0; j < itemIds.length; j++) {
Integer oldId = MappingData.oldToNewItems.inverse().get(itemIds[j]);
itemIds[j] = oldId != null ? oldId : -1;
}
}
int fluidTagsSize = wrapper.passthrough(Type.VAR_INT); // fluid tags
for (int i = 0; i < fluidTagsSize; i++) {
wrapper.passthrough(Type.STRING);
wrapper.passthrough(Type.VAR_INT_ARRAY_PRIMITIVE);
}
});
}
});
new TagRewriter(this, BackwardsMappings.blockMappings::getNewId, id -> {
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
return oldId != null ? oldId : -1;
}, Protocol1_15_2To1_16::getNewEntityId).register(0x5C, 0x5C);
// Set Jigsaw
registerIncoming(State.PLAY, 0x27, 0x27, new PacketRemapper() {
@ -148,6 +121,17 @@ public class Protocol1_15_2To1_16 extends BackwardsProtocol {
registerOutgoing(State.PLAY, 0x4E, 0x4D);
}
public static int getNewEntityId(final int oldId) {
if (oldId == 95) {
return 57;
} else if (oldId > 56 && oldId < 95) {
return oldId + 1;
} else if (oldId > 103) {
return oldId - 1;
}
return oldId;
}
public static int getNewBlockStateId(int id) {
int newId = BackwardsMappings.blockStateMappings.getNewId(id);
if (newId == -1) {

View File

@ -7,13 +7,18 @@ import nl.matsv.viabackwards.api.data.VBMappings;
import nl.matsv.viabackwards.api.data.VBSoundMappings;
import us.myles.ViaVersion.api.data.MappingDataLoader;
import us.myles.ViaVersion.api.data.Mappings;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.data.MappingData;
import us.myles.viaversion.libs.gson.JsonObject;
import java.util.HashMap;
import java.util.Map;
public class BackwardsMappings {
public static Mappings blockStateMappings;
public static Mappings blockMappings;
public static VBSoundMappings soundMappings;
public static VBItemMappings itemMappings;
public static Map<String, String> attributeMappings = new HashMap<>();
public static void init() {
JsonObject mapping1_15 = MappingDataLoader.loadData("mapping-1.15.json");
@ -25,5 +30,9 @@ public class BackwardsMappings {
blockMappings = new VBMappings(mapping1_16.getAsJsonObject("blocks"), mapping1_15.getAsJsonObject("blocks"), mapping1_15to1_16.getAsJsonObject("blocks"), false);
itemMappings = new VBItemMappings(mapping1_16.getAsJsonObject("items"), mapping1_15.getAsJsonObject("items"), mapping1_15to1_16.getAsJsonObject("items"));
soundMappings = new VBSoundMappings(mapping1_16.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"), mapping1_15to1_16.getAsJsonObject("sounds"));
for (Map.Entry<String, String> entry : MappingData.attributeMappings.entrySet()) {
attributeMappings.put(entry.getValue(), entry.getKey());
}
}
}

View File

@ -3,6 +3,7 @@ package nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.packets;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_14_4to1_15.data.ParticleMapping;
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.BackwardsMappings;
import us.myles.ViaVersion.api.entities.Entity1_15Types;
import us.myles.ViaVersion.api.entities.Entity1_16Types;
import us.myles.ViaVersion.api.entities.EntityType;
@ -10,8 +11,11 @@ import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.MetaType;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.Particle;
import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.packets.State;
public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
@ -34,7 +38,7 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
registerJoinGame(0x26, 0x26, Entity1_16Types.EntityType.PLAYER);
// Spawn Experience Orb
registerExtraTracker(0x01, Entity1_16Types.EntityType.XP_ORB);
registerExtraTracker(0x01, Entity1_16Types.EntityType.EXPERIENCE_ORB);
// Spawn Global Object
registerExtraTracker(0x02, Entity1_16Types.EntityType.LIGHTNING_BOLT);
@ -50,6 +54,30 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
// Entity Metadata packet
registerMetadataRewriter(0x45, 0x44, Types1_14.METADATA_LIST);
// Entity Properties
protocol.out(State.PLAY, 0x59, 0x59, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
wrapper.passthrough(Type.VAR_INT);
int size = wrapper.passthrough(Type.INT);
for (int i = 0; i < size; i++) {
String attributeIdentifier = wrapper.read(Type.STRING);
String oldKey = BackwardsMappings.attributeMappings.get(attributeIdentifier);
wrapper.write(Type.STRING, oldKey != null ? oldKey : attributeIdentifier.replace("minecraft:", ""));
wrapper.passthrough(Type.DOUBLE);
int modifierSize = wrapper.passthrough(Type.VAR_INT);
for (int j = 0; j < modifierSize; j++) {
wrapper.passthrough(Type.UUID);
wrapper.passthrough(Type.DOUBLE);
wrapper.passthrough(Type.BYTE);
}
}
});
}
});
}
@Override
@ -69,10 +97,14 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
});
mapEntity(Entity1_16Types.EntityType.HOGLIN, Entity1_16Types.EntityType.COW).jsonName("Hoglin");
mapEntity(Entity1_16Types.EntityType.ZOGLIN, Entity1_16Types.EntityType.COW).jsonName("Zoglin");
mapEntity(Entity1_16Types.EntityType.PIGLIN, Entity1_16Types.EntityType.ZOMBIFIED_PIGLIN).jsonName("Piglin");
mapEntity(Entity1_16Types.EntityType.STRIDER, Entity1_16Types.EntityType.MAGMA_CUBE)
.spawnMetadata(storage -> storage.add(new Metadata(15, MetaType1_14.VarInt, 3))).jsonName("Strider");
registerMetaHandler().filter(Entity1_16Types.EntityType.ZOGLIN, 16).removed();
registerMetaHandler().filter(Entity1_16Types.EntityType.HOGLIN, 15).removed();
registerMetaHandler().filter(Entity1_16Types.EntityType.PIGLIN, 16).removed(); // charging crossbow
registerMetaHandler().filter(Entity1_16Types.EntityType.PIGLIN, 17).removed();
@ -98,13 +130,13 @@ public class EntityPackets1_16 extends EntityRewriter<Protocol1_15_2To1_16> {
@Override
protected int getOldEntityId(int newId) {
if (newId == Entity1_16Types.EntityType.HOGLIN.getId()) {
if (newId == Entity1_16Types.EntityType.HOGLIN.getId() || newId == Entity1_16Types.EntityType.ZOGLIN.getId()) {
return Entity1_15Types.EntityType.COW.getId();
} else if (newId == Entity1_16Types.EntityType.PIGLIN.getId()) {
return Entity1_15Types.EntityType.ZOMBIE_PIGMAN.getId();
} else if (newId == Entity1_16Types.EntityType.STRIDER.getId()) {
return Entity1_15Types.EntityType.MAGMA_CUBE.getId();
}
return newId;
return Protocol1_15_2To1_16.getNewEntityId(newId);
}
}

View File

@ -5520,6 +5520,10 @@
"id": "minecraft:zombie_pigman_spawn_egg",
"name": "1.16 Hoglin Spawn Egg"
},
"minecraft:zoglin_spawn_egg": {
"id": "minecraft:zombie_pigman_spawn_egg",
"name": "1.16 Zoglin Spawn Egg"
},
"minecraft:piglin_spawn_egg": {
"id": "minecraft:zombie_pigman_spawn_egg",
"name": "1.16 Piglin Spawn Egg"
@ -5735,6 +5739,13 @@
"entity.hoglin.hurt": "entity.ravager.hurt",
"entity.hoglin.retreat": "entity.ravager.hurt",
"entity.hoglin.step": "entity.ravager.step",
"entity.zoglin.ambient": "entity.ravager.ambient",
"entity.zoglin.angry": "entity.zombie_pigman.angry",
"entity.zoglin.attack": "entity.ravager.attack",
"entity.zoglin.death": "entity.ravager.death",
"entity.zoglin.hurt": "entity.ravager.hurt",
"entity.zoglin.retreat": "entity.ravager.hurt",
"entity.zoglin.step": "entity.ravager.step",
"entity.zombified_piglin.ambient": "entity.zombie_pigman.ambient",
"entity.zombified_piglin.angry": "entity.zombie_pigman.angry",
"entity.zombified_piglin.death": "entity.zombie_pigman.death",
@ -5782,6 +5793,7 @@
"entity.strider.hurt": "entity.drowned.hurt",
"entity.strider.step": "entity.drowned.step",
"entity.strider.step_lava": "entity.drowned.step",
"entity.strider.eat": "entity.horse.eat"
"entity.strider.eat": "entity.horse.eat",
"entity.hoglin.converted_to_zombified": "entity.husk.converted_to_zombie"
}
}

View File

@ -1,8 +1,14 @@
{
"1.16": {
"selectWorld.locked": "Locked by another running instance of Minecraft",
"selectWorld.access_failure": "Failed to access level",
"selectWorld.delete_failure": "Failed to delete level",
"block.minecraft.nether_gold_ore": "Nether Gold Ore",
"block.minecraft.soul_fire_torch": "Soul Fire Torch",
"block.minecraft.soul_fire_wall_torch": "Soul Fire Wall Torch",
"block.minecraft.respawn_anchor": "Respawn Anchor",
"block.minecraft.spawn.not_valid": "You have no home bed or respawn anchor, or it was obstructed",
"block.minecraft.set_spawn": "Respawn point set",
"block.minecraft.warped_wart_block": "Warped Wart Block",
"block.minecraft.warped_stem": "Warped Stem",
"block.minecraft.stripped_warped_stem": "Stripped Warped Stem",
@ -21,11 +27,12 @@
"block.minecraft.nether_sprouts": "Nether Sprouts",
"block.minecraft.shroomlight": "Shroomlight",
"block.minecraft.weeping_vines": "Weeping Vines",
"block.minecraft.weeping_vines_plant": "Weeping Vines",
"block.minecraft.weeping_vines_plant": "Weeping Vines Plant",
"block.minecraft.twisting_vines": "Twisting Vines",
"block.minecraft.twisting_vines_plant": "Twisting Vines",
"block.minecraft.twisting_vines_plant": "Twisting Vines Plant",
"block.minecraft.soul_soil": "Soul Soil",
"block.minecraft.basalt": "Basalt",
"block.minecraft.polished_basalt": "Polished Basalt",
"block.minecraft.warped_planks": "Warped Planks",
"block.minecraft.warped_slab": "Warped Slab",
"block.minecraft.warped_pressure_plate": "Warped Pressure Plate",
@ -55,12 +62,16 @@
"block.minecraft.potted_warped_roots": "Potted Warped Roots",
"block.minecraft.target": "Target",
"block.minecraft.soul_fire_lantern": "Soul Fire Lantern",
"block.minecraft.lodestone": "Lodestone",
"block.minecraft.netherite_block": "Block of Netherite",
"block.minecraft.ancient_debris": "Ancient Debris",
"block.minecraft.crying_obsidian": "Crying Obsidian",
"item.minecraft.hoglin_spawn_egg": "Hoglin Spawn Egg",
"item.minecraft.piglin_spawn_egg": "Piglin Spawn Egg",
"item.minecraft.strider_spawn_egg": "Strider Spawn Egg",
"item.minecraft.zoglin_spawn_egg": "Zoglin Spawn Egg",
"item.minecraft.zombified_piglin_spawn_egg": "Zombified Piglin Spawn Egg",
"item.minecraft.lodestone_compass": "Lodestone Compass",
"item.minecraft.netherite_scrap": "Netherite Scrap",
"item.minecraft.netherite_ingot": "Netherite Ingot",
"item.minecraft.netherite_helmet": "Netherite Helmet",
@ -72,43 +83,123 @@
"item.minecraft.netherite_hoe": "Netherite Hoe",
"item.minecraft.netherite_shovel": "Netherite Shovel",
"item.minecraft.netherite_sword": "Netherite Sword",
"item.minecraft.warped_fungus_on_a_stick": "Warped Fungus on a Stick",
"container.upgrade": "Upgrade",
"jigsaw_block.pool": "Target pool:",
"jigsaw_block.name": "Name:",
"jigsaw_block.target": "Target name:",
"jigsaw_block.joint_label": "Joint type:",
"jigsaw_block.joint.rollable": "Rollable",
"jigsaw_block.joint.aligned": "Aligned",
"entity.minecraft.hoglin": "Hoglin",
"entity.minecraft.piglin": "Piglin",
"entity.minecraft.strider": "Strider",
"entity.minecraft.zoglin": "Zoglin",
"entity.minecraft.zombified_piglin": "Zombified Piglin",
"death.fell.accident.weeping_vines": "%1$s fell off some weeping vines",
"death.fell.accident.twisting_vines": "%1$s fell off some twisting vines",
"death.fell.accident.scaffolding": "%1$s fell off a scaffolding",
"death.fell.accident.other_climbable": "%1$s fell while climbing",
"death.attack.magic.player": "%1$s was killed by magic whilst trying to escape %2$s",
"death.attack.badRespawnPoint.message": "%1$s was killed by %2$s",
"death.attack.badRespawnPoint.link": "Intentional Game Design",
"enchantment.minecraft.soul_speed": "Soul Speed",
"stat.minecraft.target_hit": "Targets Hit",
"stat.minecraft.interact_with_smithing_table": "Interactions with Smithing Table",
"attribute.name.horse.jump_strength": "Horse Jump Strength",
"attribute.name.zombie.spawn_reinforcements": "Zombie Reinforcements",
"attribute.name.generic.max_health": "Max Health",
"attribute.name.generic.follow_range": "Mob Follow Range",
"attribute.name.generic.knockback_resistance": "Knockback Resistance",
"attribute.name.generic.movement_speed": "Speed",
"attribute.name.generic.flying_speed": "Flying Speed",
"attribute.name.generic.attack_damage": "Attack Damage",
"attribute.name.generic.attack_knockback": "Attack Knockback",
"attribute.name.generic.attack_speed": "Attack Speed",
"attribute.name.generic.armor_toughness": "Armor Toughness",
"subtitles.block.beacon.activate": "Beacon activates",
"subtitles.block.beacon.ambient": "Beacon hums",
"subtitles.block.beacon.deactivate": "Beacon deactivates",
"subtitles.block.beacon.power_select": "Beacon power selected",
"subtitles.block.composter.empty": "Composter emptied",
"subtitles.block.composter.fill": "Composter filled",
"subtitles.block.composter.ready": "Composter composts",
"subtitles.block.conduit.activate": "Conduit activates",
"subtitles.block.conduit.ambient": "Conduit pulses",
"subtitles.block.conduit.attack.target": "Conduit attacks",
"subtitles.block.conduit.deactivate": "Conduit deactivates",
"subtitles.block.enchantment_table.use": "Enchanting table used",
"subtitles.block.end_portal.spawn": "End Portal opens!",
"subtitles.block.end_portal_frame.fill": "Eye of Ender attaches",
"subtitles.block.pumpkin.carve": "Shears carve",
"subtitles.block.respawn_anchor.ambient": "Portal whooshes",
"subtitles.block.respawn_anchor.charge": "Respawn anchor is charged",
"subtitles.block.respawn_anchor.deplete": "Respawn anchor depletes",
"subtitles.block.respawn_anchor.set_spawn": "Respawn anchor sets spawn",
"subtitles.block.smithing_table.use": "Smithing Table used",
"subtitles.entity.boat.paddle_land": "Rowing",
"subtitles.entity.boat.paddle_water": "Rowing",
"subtitles.entity.cat.beg_for_food": "Cat begs",
"subtitles.entity.cat.eat": "Cat eats",
"subtitles.entity.cat.hiss": "Cat hisses",
"subtitles.entity.drowned.ambient_water": "Drowned gurgles",
"subtitles.entity.ender_eye.death": "Eye of Ender falls",
"subtitles.entity.fishing_bobber.retrieve": "Bobber retrieved",
"subtitles.entity.hoglin.ambient": "Hoglin growls",
"subtitles.entity.hoglin.angry": "Hoglin growls angrily",
"subtitles.entity.hoglin.attack": "Hoglin attacks",
"subtitles.entity.hoglin.converted_to_zombified": "Hoglin converts to Zoglin",
"subtitles.entity.hoglin.death": "Hoglin dies",
"subtitles.entity.hoglin.hurt": "Hoglin hurts",
"subtitles.entity.hoglin.retreat": "Hoglin retreats",
"subtitles.entity.hoglin.step": "Hoglin steps",
"subtitles.entity.horse.land": "Horse lands",
"subtitles.entity.parrot.fly": "Parrot flutters",
"subtitles.entity.piglin.admiring_item": "Piglin admires item",
"subtitles.entity.piglin.ambient": "Piglin snorts",
"subtitles.entity.piglin.angry": "Piglin snorts angrily",
"subtitles.entity.piglin.celebrate": "Piglin celebrates",
"subtitles.entity.piglin.converted_to_zombified": "Piglin converts to Zombified Piglin",
"subtitles.entity.piglin.death": "Piglin dies",
"subtitles.entity.piglin.jealous": "Piglin snorts enviously",
"subtitles.entity.piglin.hurt": "Piglin hurts",
"subtitles.entity.piglin.jealous": "Piglin snorts enviously",
"subtitles.entity.piglin.retreat": "Piglin retreats",
"subtitles.entity.piglin.step": "Piglin steps",
"subtitles.entity.piglin.converted_to_zombified": "Piglin converts to Zombified Piglin",
"subtitles.entity.player.attack.crit": "Critical attack",
"subtitles.entity.player.attack.knockback": "Knockback attack",
"subtitles.entity.player.attack.strong": "Strong attack",
"subtitles.entity.player.attack.sweep": "Sweeping attack",
"subtitles.entity.player.attack.weak": "Weak attack",
"subtitles.entity.player.hurt_drown": "Player drowning",
"subtitles.entity.player.hurt_on_fire": "Player burns",
"subtitles.entity.strider.death": "Strider dies",
"subtitles.entity.strider.eat": "Strider eats",
"subtitles.entity.strider.happy": "Strider warbles",
"subtitles.entity.strider.hurt": "Strider hurts",
"subtitles.entity.strider.idle": "Strider chirps",
"subtitles.entity.strider.retreat": "Strider retreats",
"subtitles.entity.tropical_fish.death": "Tropical Fish dies",
"subtitles.entity.tropical_fish.flop": "Tropical Fish flops",
"subtitles.entity.tropical_fish.hurt": "Tropical Fish hurts",
"subtitles.entity.wandering_trader.disappeared": "Wandering Trader disappears",
"subtitles.entity.wandering_trader.drink_milk": "Wandering Trader drinks milk",
"subtitles.entity.wandering_trader.drink_potion": "Wandering Trader drinks potion",
"subtitles.entity.wandering_trader.reappeared": "Wandering Trader appears",
"subtitles.entity.zoglin.ambient": "Zoglin growls",
"subtitles.entity.zoglin.angry": "Zoglin growls angrily",
"subtitles.entity.zoglin.attack": "Zoglin attacks",
"subtitles.entity.zoglin.death": "Zoglin dies",
"subtitles.entity.zoglin.hurt": "Zoglin hurts",
"subtitles.entity.zoglin.step": "Zoglin steps",
"subtitles.entity.zombie.destroy_egg": "Turtle Egg stomped",
"subtitles.entity.zombified_piglin.ambient": "Zombified Piglin grunts",
"subtitles.entity.zombified_piglin.angry": "Zombified Piglin angers",
"subtitles.entity.zombified_piglin.death": "Zombified Piglin dies",
"subtitles.entity.zombified_piglin.hurt": "Zombified Piglin hurts",
"subtitles.item.armor.equip_netherite": "Netherite armor clanks",
"subtitles.item.bottle.empty": "Bottle empties",
"subtitles.item.bucket.fill_fish": "Fish captured",
"subtitles.item.lodestone_compass.lock": "Lodestone Compass locks onto Lodestone",
"subtitles.particle.soul_escape": "Soul escapes",
"advancements.adventure.bullseye.title": "Bullseye",
"advancements.adventure.bullseye.description": "Hit the bullseye of a Target block with an arrow",