This commit is contained in:
KennyTV 2020-07-01 17:22:41 +02:00
parent bb583065f3
commit f3c30130d2
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
12 changed files with 478 additions and 19 deletions

View File

@ -10,7 +10,6 @@ public abstract class BackwardsProtocol<C1 extends ClientboundPacketType, C2 ext
extends Protocol<C1, C2, S1, S2> {
protected BackwardsProtocol() {
super();
}
protected BackwardsProtocol(boolean hasMappingDataToLoad) {

View File

@ -31,6 +31,7 @@ import nl.matsv.viabackwards.protocol.protocol1_15_1to1_15_2.Protocol1_15_1To1_1
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.Protocol1_15_2To1_16;
import nl.matsv.viabackwards.protocol.protocol1_15to1_15_1.Protocol1_15To1_15_1;
import nl.matsv.viabackwards.protocol.protocol1_16to1_16_1.Protocol1_16To1_16_1;
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.protocol.ProtocolVersion;
@ -88,6 +89,7 @@ public interface ViaBackwardsPlatform {
registerProtocol(new Protocol1_15_2To1_16(), ProtocolVersion.v1_15_2, ProtocolVersion.v1_16);
registerProtocol(new Protocol1_16To1_16_1(), ProtocolVersion.v1_16, ProtocolVersion.v1_16_1);
registerProtocol(new Protocol1_16_1To1_16_2(), ProtocolVersion.v1_16_1, ProtocolVersion.v1_16_2);
}
/**

View File

@ -5,8 +5,4 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
public class Protocol1_14_1To1_14_2 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
public Protocol1_14_1To1_14_2() {
super(ClientboundPackets1_14.class, ClientboundPackets1_14.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
}
}

View File

@ -1,13 +1,8 @@
package nl.matsv.viabackwards.protocol.protocol1_15_1to1_15_2;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
public class Protocol1_15_1To1_15_2 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
public Protocol1_15_1To1_15_2() {
super(ClientboundPackets1_15.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
}
}

View File

@ -1,13 +1,8 @@
package nl.matsv.viabackwards.protocol.protocol1_15to1_15_1;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
public class Protocol1_15To1_15_1 extends BackwardsProtocol<ClientboundPackets1_15, ClientboundPackets1_15, ServerboundPackets1_14, ServerboundPackets1_14> {
public Protocol1_15To1_15_1() {
super(ClientboundPackets1_15.class, ClientboundPackets1_15.class, ServerboundPackets1_14.class, ServerboundPackets1_14.class);
}
}

View File

@ -0,0 +1,170 @@
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data.BackwardsMappings;
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.BlockItemPackets1_16_2;
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets.EntityPackets1_16_2;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketHandler;
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.protocols.protocol1_16_2to1_16_1.Protocol1_16_2To1_16_1;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ServerboundPackets1_16_2;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class Protocol1_16_1To1_16_2 extends BackwardsProtocol<ClientboundPackets1_16, ClientboundPackets1_16, ServerboundPackets1_16_2, ServerboundPackets1_16> {
private BlockItemPackets1_16_2 blockItemPackets;
private TranslatableRewriter translatableRewriter;
public Protocol1_16_1To1_16_2() {
super(ClientboundPackets1_16.class, ClientboundPackets1_16.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16.class);
}
@Override
protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_16_2To1_16_1.class, BackwardsMappings::init);
translatableRewriter = new TranslatableRewriter(this);
translatableRewriter.registerBossBar(ClientboundPackets1_16.BOSSBAR);
translatableRewriter.registerCombatEvent(ClientboundPackets1_16.COMBAT_EVENT);
translatableRewriter.registerDisconnect(ClientboundPackets1_16.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_16.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_16.TITLE);
translatableRewriter.registerChatMessage(ClientboundPackets1_16.CHAT_MESSAGE);
translatableRewriter.registerOpenWindow(ClientboundPackets1_16.OPEN_WINDOW);
translatableRewriter.registerPing();
(blockItemPackets = new BlockItemPackets1_16_2(this, translatableRewriter)).register();
EntityPackets1_16_2 entityPackets = new EntityPackets1_16_2(this);
entityPackets.register();
SoundRewriter soundRewriter = new SoundRewriter(this,
id -> BackwardsMappings.soundMappings.getNewId(id), stringId -> BackwardsMappings.soundMappings.getNewId(stringId));
soundRewriter.registerSound(ClientboundPackets1_16.SOUND);
soundRewriter.registerSound(ClientboundPackets1_16.ENTITY_SOUND);
soundRewriter.registerNamedSound(ClientboundPackets1_16.NAMED_SOUND);
soundRewriter.registerStopSound(ClientboundPackets1_16.STOP_SOUND);
registerOutgoing(ClientboundPackets1_16.ADVANCEMENTS, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
int size = wrapper.passthrough(Type.VAR_INT);
for (int i = 0; i < size; i++) {
wrapper.passthrough(Type.STRING); // Identifier
// Parent
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING);
}
// Display data
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT); // Title
wrapper.passthrough(Type.COMPONENT); // Description
blockItemPackets.handleItemToClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Icon
wrapper.passthrough(Type.VAR_INT); // Frame type
int flags = wrapper.passthrough(Type.INT); // Flags
if ((flags & 1) != 0) {
wrapper.passthrough(Type.STRING); // Background texture
}
wrapper.passthrough(Type.FLOAT); // X
wrapper.passthrough(Type.FLOAT); // Y
}
wrapper.passthrough(Type.STRING_ARRAY); // Criteria
int arrayLength = wrapper.passthrough(Type.VAR_INT);
for (int array = 0; array < arrayLength; array++) {
wrapper.passthrough(Type.STRING_ARRAY); // String array
}
}
});
}
});
// Recipe book data has been split into 2 separate packets
registerIncoming(ServerboundPackets1_16.RECIPE_BOOK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int type = wrapper.read(Type.VAR_INT);
if (type == 0) {
// Shown, change to its own packet
wrapper.passthrough(Type.STRING); // Recipe
wrapper.setId(ServerboundPackets1_16_2.SEEN_RECIPE.ordinal());
} else {
wrapper.cancel();
// Settings
for (int i = 0; i < 3; i++) {
sendSeenRecipePacket(i, wrapper);
}
}
}
private void sendSeenRecipePacket(int recipeType, PacketWrapper wrapper) throws Exception {
boolean open = wrapper.read(Type.BOOLEAN);
boolean filter = wrapper.read(Type.BOOLEAN);
PacketWrapper newPacket = wrapper.create(ServerboundPackets1_16_2.RECIPE_BOOK_DATA.ordinal());
newPacket.write(Type.VAR_INT, recipeType);
newPacket.write(Type.BOOLEAN, open);
newPacket.write(Type.BOOLEAN, filter);
newPacket.sendToServer(Protocol1_16_1To1_16_2.class);
}
});
}
});
new TagRewriter(this, id -> BackwardsMappings.blockMappings.getNewId(id), id ->
MappingData.oldToNewItems.inverse().get(id), entityPackets::getOldEntityId).register(ClientboundPackets1_16.TAGS);
}
public static int getNewBlockStateId(int id) {
int newId = BackwardsMappings.blockStateMappings.getNewId(id);
if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 blockstate id for 1.16.2 block " + id);
return 0;
}
return newId;
}
public static int getNewBlockId(int id) {
int newId = BackwardsMappings.blockMappings.getNewId(id);
if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 block id for 1.16.2 block " + id);
return id;
}
return newId;
}
@Override
public void init(UserConnection user) {
if (!user.has(ClientWorld.class)) {
user.put(new ClientWorld(user));
}
if (!user.has(EntityTracker.class)) {
user.put(new EntityTracker(user));
}
user.get(EntityTracker.class).initProtocol(this);
}
public BlockItemPackets1_16_2 getBlockItemPackets() {
return blockItemPackets;
}
public TranslatableRewriter getTranslatableRewriter() {
return translatableRewriter;
}
}

View File

@ -0,0 +1,29 @@
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.data.VBItemMappings;
import nl.matsv.viabackwards.api.data.VBMappingDataLoader;
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.libs.gson.JsonObject;
public class BackwardsMappings {
public static Mappings blockStateMappings;
public static Mappings blockMappings;
public static VBSoundMappings soundMappings;
public static VBItemMappings itemMappings;
public static void init() {
ViaBackwards.getPlatform().getLogger().info("Loading 1.16.2 -> 1.16.1 mappings...");
JsonObject mapping1_16 = MappingDataLoader.getMappingsCache().get("mapping-1.16.json");
JsonObject mapping1_16_2 = MappingDataLoader.getMappingsCache().get("mapping-1.16.2.json");
JsonObject mapping1_16to1_16_2 = VBMappingDataLoader.loadFromDataDir("mapping-1.16to1.16.2.json");
blockStateMappings = new VBMappings(mapping1_16_2.getAsJsonObject("blockstates"), mapping1_16.getAsJsonObject("blockstates"), mapping1_16to1_16_2.getAsJsonObject("blockstates"));
blockMappings = new VBMappings(mapping1_16_2.getAsJsonObject("blocks"), mapping1_16.getAsJsonObject("blocks"), mapping1_16to1_16_2.getAsJsonObject("blocks"), false);
itemMappings = new VBItemMappings(mapping1_16_2.getAsJsonObject("items"), mapping1_16.getAsJsonObject("items"), mapping1_16to1_16_2.getAsJsonObject("items"));
soundMappings = new VBSoundMappings(mapping1_16_2.getAsJsonArray("sounds"), mapping1_16.getAsJsonArray("sounds"), mapping1_16to1_16_2.getAsJsonObject("sounds"));
}
}

View File

@ -0,0 +1,151 @@
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets;
import nl.matsv.viabackwards.ViaBackwards;
import nl.matsv.viabackwards.api.rewriters.EnchantmentRewriter;
import nl.matsv.viabackwards.api.rewriters.TranslatableRewriter;
import nl.matsv.viabackwards.protocol.protocol1_15_2to1_16.data.RecipeRewriter1_16;
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.data.BackwardsMappings;
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.BlockRewriter;
import us.myles.ViaVersion.api.rewriters.ItemRewriter;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.data.MappingData;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.types.Chunk1_16Type;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
public class BlockItemPackets1_16_2 extends nl.matsv.viabackwards.api.rewriters.ItemRewriter<Protocol1_16_1To1_16_2> {
private EnchantmentRewriter enchantmentRewriter;
public BlockItemPackets1_16_2(Protocol1_16_1To1_16_2 protocol, TranslatableRewriter translatableRewriter) {
super(protocol, translatableRewriter,
BlockItemPackets1_16_2::getOldItemId, BlockItemPackets1_16_2::getNewItemId, id -> BackwardsMappings.itemMappings.getMappedItem(id));
}
@Override
protected void registerPackets() {
ItemRewriter itemRewriter = new ItemRewriter(protocol, this::handleItemToClient, this::handleItemToServer);
BlockRewriter blockRewriter = new BlockRewriter(protocol, Type.POSITION1_14, Protocol1_16_1To1_16_2::getNewBlockStateId, Protocol1_16_1To1_16_2::getNewBlockId);
new RecipeRewriter1_16(this).register(ClientboundPackets1_16.DECLARE_RECIPES);
itemRewriter.registerSetCooldown(ClientboundPackets1_16.COOLDOWN, BlockItemPackets1_16_2::getOldItemId);
itemRewriter.registerWindowItems(ClientboundPackets1_16.WINDOW_ITEMS, Type.FLAT_VAR_INT_ITEM_ARRAY);
itemRewriter.registerSetSlot(ClientboundPackets1_16.SET_SLOT, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerEntityEquipmentArray(ClientboundPackets1_16.ENTITY_EQUIPMENT, Type.FLAT_VAR_INT_ITEM);
protocol.registerOutgoing(ClientboundPackets1_16.UNLOCK_RECIPES, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.BOOLEAN); // Open
wrapper.passthrough(Type.BOOLEAN); // Filter
wrapper.passthrough(Type.BOOLEAN); // Furnace Open
wrapper.passthrough(Type.BOOLEAN); // Filter furnace
// Blast furnace / smoker
wrapper.read(Type.BOOLEAN);
wrapper.read(Type.BOOLEAN);
wrapper.read(Type.BOOLEAN);
wrapper.read(Type.BOOLEAN);
});
}
});
protocol.registerOutgoing(ClientboundPackets1_16.TRADE_LIST, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
wrapper.passthrough(Type.VAR_INT);
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
for (int i = 0; i < size; i++) {
Item input = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
handleItemToClient(input);
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
handleItemToClient(output);
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
// Second Item
Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
handleItemToClient(second);
}
wrapper.passthrough(Type.BOOLEAN);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.INT);
wrapper.passthrough(Type.FLOAT);
wrapper.passthrough(Type.INT);
}
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.BOOLEAN);
});
}
});
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_16.ACKNOWLEDGE_PLAYER_DIGGING);
blockRewriter.registerBlockAction(ClientboundPackets1_16.BLOCK_ACTION);
blockRewriter.registerBlockChange(ClientboundPackets1_16.BLOCK_CHANGE);
blockRewriter.registerMultiBlockChange(ClientboundPackets1_16.MULTI_BLOCK_CHANGE);
protocol.registerOutgoing(ClientboundPackets1_16.CHUNK_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
Chunk chunk = wrapper.passthrough(new Chunk1_16Type(clientWorld));
for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection section = chunk.getSections()[i];
if (section == null) continue;
for (int j = 0; j < section.getPaletteSize(); j++) {
int old = section.getPaletteEntry(j);
section.setPaletteEntry(j, Protocol1_16_1To1_16_2.getNewBlockStateId(old));
}
}
});
}
});
blockRewriter.registerEffect(ClientboundPackets1_16.EFFECT, 1010, 2001, BlockItemPackets1_16_2::getOldItemId);
blockRewriter.registerSpawnParticle(ClientboundPackets1_16.SPAWN_PARTICLE, 3, 23, 34,
null, this::handleItemToClient, Type.FLAT_VAR_INT_ITEM, Type.DOUBLE);
itemRewriter.registerClickWindow(ServerboundPackets1_16.CLICK_WINDOW, Type.FLAT_VAR_INT_ITEM);
itemRewriter.registerCreativeInvAction(ServerboundPackets1_16.CREATIVE_INVENTORY_ACTION, Type.FLAT_VAR_INT_ITEM);
protocol.registerIncoming(ServerboundPackets1_16.EDIT_BOOK, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> handleItemToServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)));
}
});
}
public static int getNewItemId(int id) {
int newId = MappingData.oldToNewItems.get(id);
if (newId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16.2 item for 1.16 item " + id);
return 1;
}
return newId;
}
public static int getOldItemId(int id) {
int oldId = MappingData.oldToNewItems.inverse().get(id);
if (oldId == -1) {
ViaBackwards.getPlatform().getLogger().warning("Missing 1.16 item for 1.16.2 item " + id);
return 1;
}
return oldId;
}
}

View File

@ -0,0 +1,95 @@
package nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.packets;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
import us.myles.ViaVersion.api.entities.Entity1_16Types;
import us.myles.ViaVersion.api.entities.Entity1_16_2Types;
import us.myles.ViaVersion.api.entities.EntityType;
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.version.Types1_14;
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.viaversion.libs.gson.JsonElement;
public class EntityPackets1_16_2 extends EntityRewriter<Protocol1_16_1To1_16_2> {
public EntityPackets1_16_2(Protocol1_16_1To1_16_2 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
registerSpawnTrackerWithData(ClientboundPackets1_16.SPAWN_ENTITY, Entity1_16_2Types.EntityType.FALLING_BLOCK, Protocol1_16_1To1_16_2::getNewBlockStateId);
registerSpawnTracker(ClientboundPackets1_16.SPAWN_MOB);
registerExtraTracker(ClientboundPackets1_16.SPAWN_EXPERIENCE_ORB, Entity1_16_2Types.EntityType.EXPERIENCE_ORB);
registerExtraTracker(ClientboundPackets1_16.SPAWN_PAINTING, Entity1_16_2Types.EntityType.PAINTING);
registerExtraTracker(ClientboundPackets1_16.SPAWN_PLAYER, Entity1_16_2Types.EntityType.PLAYER);
registerEntityDestroy(ClientboundPackets1_16.DESTROY_ENTITIES);
registerMetadataRewriter(ClientboundPackets1_16.ENTITY_METADATA, Types1_14.METADATA_LIST);
protocol.registerOutgoing(ClientboundPackets1_16.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Entity ID
handler(wrapper -> {
boolean hardcore = wrapper.read(Type.BOOLEAN);
short gamemode = wrapper.read(Type.UNSIGNED_BYTE);
if (hardcore) {
gamemode |= 0x08;
}
wrapper.write(Type.UNSIGNED_BYTE, gamemode);
});
map(Type.BYTE); // Previous Gamemode
map(Type.STRING_ARRAY); // World List
map(Type.NBT); // Dimension Registry
map(Type.STRING); // Dimension Type
map(Type.STRING); // Dimension
map(Type.LONG); // Seed
handler(wrapper -> {
int maxPlayers = wrapper.read(Type.VAR_INT);
wrapper.write(Type.UNSIGNED_BYTE, (short) Math.max(maxPlayers, 255));
});
// ...
handler(wrapper -> {
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
String dimension = wrapper.get(Type.STRING, 0);
clientChunks.setEnvironment(dimension);
getEntityTracker(wrapper.user()).trackEntityType(wrapper.get(Type.INT, 0), Entity1_16_2Types.EntityType.PLAYER);
});
}
});
}
@Override
protected void registerRewrites() {
registerMetaHandler().handle(e -> {
Metadata meta = e.getData();
MetaType type = meta.getMetaType();
if (type == MetaType1_14.Slot) {
meta.setValue(protocol.getBlockItemPackets().handleItemToClient((Item) meta.getValue()));
} else if (type == MetaType1_14.BlockID) {
meta.setValue(Protocol1_16_1To1_16_2.getNewBlockStateId((int) meta.getValue()));
} else if (type == MetaType1_14.OptChat) {
JsonElement text = meta.getCastedValue();
if (text != null) {
protocol.getTranslatableRewriter().processText(text);
}
}
return meta;
});
mapTypes(Entity1_16_2Types.EntityType.values(), Entity1_16Types.EntityType.class);
mapEntity(Entity1_16_2Types.EntityType.PIGLIN_BRUTE, Entity1_16_2Types.EntityType.PIGLIN).jsonName("Piglin Brute");
}
@Override
protected EntityType getTypeFromId(int typeId) {
return Entity1_16Types.getTypeFromId(typeId);
}
}

View File

@ -5,8 +5,4 @@ import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ClientboundPackets1_16
import us.myles.ViaVersion.protocols.protocol1_16to1_15_2.ServerboundPackets1_16;
public class Protocol1_16To1_16_1 extends BackwardsProtocol<ClientboundPackets1_16, ClientboundPackets1_16, ServerboundPackets1_16, ServerboundPackets1_16> {
public Protocol1_16To1_16_1() {
super(ClientboundPackets1_16.class, ClientboundPackets1_16.class, ServerboundPackets1_16.class, ServerboundPackets1_16.class);
}
}

View File

@ -0,0 +1,19 @@
{
"blockstates": {
},
"items": {
"minecraft:piglin_brute_spawn_egg": {
"id": "minecraft:piglin_spawn_egg",
"name": "1.16.2 Piglin Brute Spawn Egg"
}
},
"sounds": {
"entity.parrot.imitate.piglin_brute" : "entity.parrot.imitate.piglin",
"entity.piglin_brute.ambient" : "entity.piglin.ambient",
"entity.piglin_brute.angry" : "entity.piglin.angry",
"entity.piglin_brute.death" : "entity.piglin.death",
"entity.piglin_brute.hurt" : "entity.piglin.hurt",
"entity.piglin_brute.step" : "entity.piglin.step",
"entity.piglin_brute.converted_to_zombified" : "entity.piglin.converted_to_zombified"
}
}

View File

@ -1,4 +1,16 @@
{
"1.16.2": {
"multiplayer.disconnect.missing_tags": "Incomplete set of tags received from server.\nPlease contact server operator.",
"item.minecraft.piglin_brute_spawn_egg": "Piglin Brute Spawn Egg",
"entity.minecraft.piglin_brute": "Piglin Brute",
"subtitles.entity.parrot.imitate.piglin_brute": "Parrot snorts mightily",
"subtitles.entity.piglin_brute.ambient": "Piglin Brute snorts",
"subtitles.entity.piglin_brute.angry": "Piglin Brute snorts angrily",
"subtitles.entity.piglin_brute.death": "Piglin Brute dies",
"subtitles.entity.piglin_brute.hurt": "Piglin Brute hurts",
"subtitles.entity.piglin_brute.step": "Piglin Brute steps",
"subtitles.entity.piglin_brute.converted_to_zombified": "Piglin Brute converts to Zombified Piglin"
},
"1.16": {
"gui.recipebook.search_hint": "Search...",
"selectWorld.edit.export_worldgen_settings": "Export World Generation Settings",