This commit is contained in:
KennyTV 2020-11-12 21:47:46 +01:00
parent 6e011f9297
commit 56c80fb5c3
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
12 changed files with 139 additions and 12 deletions

View File

@ -16,7 +16,7 @@
<parent>
<artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId>
<version>3.3.0-20w45a</version>
<version>3.3.0-20w46a</version>
</parent>
<artifactId>viabackwards-all</artifactId>

View File

@ -16,7 +16,7 @@
<parent>
<artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId>
<version>3.3.0-20w45a</version>
<version>3.3.0-20w46a</version>
</parent>
<artifactId>viabackwards-bukkit</artifactId>

View File

@ -16,7 +16,7 @@
<parent>
<artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId>
<version>3.3.0-20w45a</version>
<version>3.3.0-20w46a</version>
</parent>
<artifactId>viabackwards-bungee</artifactId>

View File

@ -16,7 +16,7 @@
<parent>
<artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId>
<version>3.3.0-20w45a</version>
<version>3.3.0-20w46a</version>
</parent>
<artifactId>viabackwards-core</artifactId>

View File

@ -35,7 +35,7 @@ public class BackwardsMappings extends MappingData {
if (diffMappings != null) {
JsonObject diffItems = diffMappings.getAsJsonObject("items");
if (diffItems != null) {
backwardsItemMappings = VBMappingDataLoader.loadItemMappings(oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"), diffItems);
backwardsItemMappings = VBMappingDataLoader.loadItemMappings(oldMappings.getAsJsonObject("items"), newMappings.getAsJsonObject("items"), diffItems, true);
}
JsonObject diffSounds = diffMappings.getAsJsonObject("sounds");

View File

@ -2,8 +2,11 @@ package nl.matsv.viabackwards.protocol.protocol1_16_4to1_17;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.data.BackwardsMappings;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.rewriters.SoundRewriter;
import nl.matsv.viabackwards.protocol.protocol1_16_4to1_17.packets.BlockItemPackets1_17;
import nl.matsv.viabackwards.protocol.protocol1_16_4to1_17.packets.EntityPackets1_17;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.rewriters.StatisticsRewriter;
import us.myles.ViaVersion.api.rewriters.TagRewriter;
@ -15,6 +18,7 @@ import us.myles.ViaVersion.protocols.protocol1_17to1_16_4.Protocol1_17To1_16_4;
public class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPackets1_16_2, ClientboundPackets1_16_2, ServerboundPackets1_16_2, ServerboundPackets1_16_2> {
public static final BackwardsMappings MAPPINGS = new BackwardsMappings("1.17", "1.16.2", Protocol1_17To1_16_4.class, true);
private BlockItemPackets1_17 blockItemPackets;
public Protocol1_16_4To1_17() {
super(ClientboundPackets1_16_2.class, ClientboundPackets1_16_2.class, ServerboundPackets1_16_2.class, ServerboundPackets1_16_2.class);
@ -24,7 +28,10 @@ public class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPackets1_
protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_17To1_16_4.class, MAPPINGS::load);
new BlockItemPackets1_17(this, null).register();
blockItemPackets = new BlockItemPackets1_17(this, null);
blockItemPackets.register();
new EntityPackets1_17(this).register();
SoundRewriter soundRewriter = new SoundRewriter(this);
soundRewriter.registerSound(ClientboundPackets1_16_2.SOUND);
@ -45,6 +52,35 @@ public class Protocol1_16_4To1_17 extends BackwardsProtocol<ClientboundPackets1_
});
}
});
registerOutgoing(ClientboundPackets1_16_2.MAP_DATA, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
wrapper.passthrough(Type.VAR_INT);
wrapper.passthrough(Type.BYTE);
wrapper.write(Type.BOOLEAN, true); // Tracking position
wrapper.passthrough(Type.BOOLEAN);
boolean hasMarkers = wrapper.read(Type.BOOLEAN);
if (!hasMarkers) {
wrapper.write(Type.VAR_INT, 0); // Array size
}
});
}
});
}
@Override
public void init(UserConnection user) {
if (!user.has(EntityTracker.class)) {
user.put(new EntityTracker(user));
}
user.get(EntityTracker.class).initProtocol(this);
}
public BlockItemPackets1_17 getBlockItemPackets() {
return blockItemPackets;
}
@Override

View File

@ -0,0 +1,75 @@
package nl.matsv.viabackwards.protocol.protocol1_16_4to1_17.packets;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_16_4to1_17.Protocol1_16_4To1_17;
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.Particle;
import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.protocols.protocol1_16_2to1_16_1.ClientboundPackets1_16_2;
import us.myles.viaversion.libs.gson.JsonElement;
public class EntityPackets1_17 extends EntityRewriter<Protocol1_16_4To1_17> {
public EntityPackets1_17(Protocol1_16_4To1_17 protocol) {
super(protocol);
}
@Override
protected void registerPackets() {
registerSpawnTrackerWithData(ClientboundPackets1_16_2.SPAWN_ENTITY, Entity1_16_2Types.EntityType.FALLING_BLOCK);
registerSpawnTracker(ClientboundPackets1_16_2.SPAWN_MOB);
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_EXPERIENCE_ORB, Entity1_16_2Types.EntityType.EXPERIENCE_ORB);
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_PAINTING, Entity1_16_2Types.EntityType.PAINTING);
registerExtraTracker(ClientboundPackets1_16_2.SPAWN_PLAYER, Entity1_16_2Types.EntityType.PLAYER);
registerEntityDestroy(ClientboundPackets1_16_2.DESTROY_ENTITIES);
registerMetadataRewriter(ClientboundPackets1_16_2.ENTITY_METADATA, Types1_14.METADATA_LIST);
protocol.registerOutgoing(ClientboundPackets1_16_2.JOIN_GAME, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.INT); // Entity ID
handler(getTrackerHandler(Entity1_16_2Types.EntityType.PLAYER, Type.INT));
}
});
}
@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(protocol.getMappingData().getNewBlockStateId((int) meta.getValue()));
} else if (type == MetaType1_14.OptChat) {
JsonElement text = meta.getCastedValue();
if (text != null) {
//protocol.getTranslatableRewriter().processText(text); //TODO
}
} else if (type == MetaType1_14.PARTICLE) {
rewriteParticle((Particle) meta.getValue());
}
return meta;
});
registerMetaHandler().filter(7).removed(); // Ticks frozen
registerMetaHandler().handle(meta -> {
if (meta.getIndex() > 7) {
meta.getData().setId(meta.getIndex() - 1);
}
return meta.getData();
});
}
@Override
protected EntityType getTypeFromId(int typeId) {
return Entity1_16_2Types.getTypeFromId(typeId);
}
}

View File

@ -2,6 +2,10 @@
"blockstates": {
"minecraft:dirt_path": "minecraft:grass_path",
"minecraft:cauldron": "minecraft:cauldron[level=0]",
"minecraft:powder_snow_cauldron[level=1]": "minecraft:cauldron[level=1]",
"minecraft:powder_snow_cauldron[level=2]": "minecraft:cauldron[level=2]",
"minecraft:powder_snow_cauldron[level=3]": "minecraft:cauldron[level=3]",
"minecraft:powder_snow": "minecraft:snow_block",
"minecraft:water_cauldron[level=1]": "minecraft:cauldron[level=1]",
"minecraft:water_cauldron[level=2]": "minecraft:cauldron[level=2]",
"minecraft:water_cauldron[level=3]": "minecraft:cauldron[level=3]",
@ -791,6 +795,10 @@
"minecraft:lightning_rod": {
"id": "minecraft:end_rod",
"name": "1.17 Lightning Rod"
},
"minecraft:powder_snow_bucket": {
"id": "minecraft:milk_bucket",
"name": "1.17 Powder Snow Bucket"
}
},
"sounds": {
@ -837,9 +845,17 @@
"block.tuff.place": "",
"block.tuff.hit": "",
"block.tuff.fall": "",
"small_flame": ""
"item.bucket.empty_powder_snow": "",
"item.bucket.fill_powder_snow": "",
"entity.player.hurt_freeze": "",
"block.powder_snow.break": "",
"block.powder_snow.fall": "",
"block.powder_snow.hit": "",
"block.powder_snow.place": "",
"block.powder_snow.step": ""
},
"particles": {
"small_flame": "flame"
"small_flame": "flame",
"snowflake": "cloud"
}
}

View File

@ -16,7 +16,7 @@
<parent>
<artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId>
<version>3.3.0-20w45a</version>
<version>3.3.0-20w46a</version>
</parent>
<artifactId>viabackwards-fabric</artifactId>

View File

@ -16,7 +16,7 @@
<groupId>nl.matsv</groupId>
<artifactId>viabackwards-parent</artifactId>
<version>3.3.0-20w45a</version>
<version>3.3.0-20w46a</version>
<packaging>pom</packaging>
<description>Allow older clients to join newer server versions.</description>

View File

@ -16,7 +16,7 @@
<parent>
<artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId>
<version>3.3.0-20w45a</version>
<version>3.3.0-20w46a</version>
</parent>
<artifactId>viabackwards-sponge</artifactId>

View File

@ -16,7 +16,7 @@
<parent>
<artifactId>viabackwards-parent</artifactId>
<groupId>nl.matsv</groupId>
<version>3.3.0-20w45a</version>
<version>3.3.0-20w46a</version>
</parent>
<artifactId>viabackwards-velocity</artifactId>