1.16 pre3

This commit is contained in:
KennyTV 2020-06-10 19:34:22 +02:00
parent 029f399a14
commit e1b2702231
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
5 changed files with 97 additions and 45 deletions

View File

@ -80,7 +80,7 @@ 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(722, "1.16"));
register(v1_16 = new ProtocolVersion(725, "1.16"));
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
}

View File

@ -10,7 +10,7 @@ import java.util.ArrayList;
import java.util.List;
public class TagRewriter {
public static final int[] EMPTY_ARRAY = {};
private static final int[] EMPTY_ARRAY = {-1};
private final Protocol protocol;
private final IdRewriteFunction blockRewriter;
private final IdRewriteFunction itemRewriter;
@ -26,6 +26,9 @@ public class TagRewriter {
this.entityRewriter = entityRewriter;
}
/**
* Adds an empty tag (since the client crashes if a checked tag is not registered.)
*/
public void addEmptyTag(TagType tagType, String id) {
getNewTags(tagType).add(new TagData(id, EMPTY_ARRAY));
}

View File

@ -104,6 +104,29 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
}
});
registerIncoming(ServerboundPackets1_16.INTERACT_ENTITY, new PacketRemapper() {
@Override
public void registerMap() {
handler(wrapper -> {
wrapper.passthrough(Type.VAR_INT); // Entity Id
int action = wrapper.passthrough(Type.VAR_INT);
if (action == 0 || action == 2) {
if (action == 2) {
// Location
wrapper.passthrough(Type.FLOAT);
wrapper.passthrough(Type.FLOAT);
wrapper.passthrough(Type.FLOAT);
}
wrapper.passthrough(Type.VAR_INT); // Hand
// New boolean: Whether the client is sneaking/pressing shift
wrapper.read(Type.BOOLEAN);
}
});
}
});
cancelIncoming(ServerboundPackets1_16.GENERATE_JIGSAW);
cancelIncoming(ServerboundPackets1_16.UPDATE_JIGSAW_BLOCK);
}
@ -164,7 +187,8 @@ public class Protocol1_16To1_15_2 extends Protocol<ClientboundPackets1_15, Clien
@Override
public void init(UserConnection userConnection) {
userConnection.put(new EntityTracker1_16(userConnection));
if (!userConnection.has(ClientWorld.class))
if (!userConnection.has(ClientWorld.class)) {
userConnection.put(new ClientWorld(userConnection));
}
}
}

View File

@ -3,15 +3,14 @@ package us.myles.ViaVersion.protocols.protocol1_16to1_15_2.packets;
import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.FloatTag;
import com.github.steveice10.opennbt.tag.builtin.IntTag;
import com.github.steveice10.opennbt.tag.builtin.ListTag;
import com.github.steveice10.opennbt.tag.builtin.LongTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.entities.Entity1_16Types;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.remapper.ValueTransformer;
import us.myles.ViaVersion.api.type.Type;
import us.myles.ViaVersion.api.type.types.version.Types1_14;
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
@ -53,6 +52,7 @@ public class EntityPackets {
static {
ListTag list = new ListTag("dimension", CompoundTag.class);
list.add(createOverworldEntry());
list.add(createOverworldCavesEntry());
list.add(createNetherEntry());
list.add(createEndEntry());
DIMENSIONS_TAG.put(list);
@ -60,45 +60,69 @@ public class EntityPackets {
private static CompoundTag createOverworldEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("key", "minecraft:overworld"));
CompoundTag elementTag = new CompoundTag("element");
elementTag.put(new ByteTag("natural", (byte) 1));
elementTag.put(new FloatTag("ambient_light", 0));
elementTag.put(new ByteTag("shrunk", (byte) 0));
elementTag.put(new ByteTag("ultrawarm", (byte) 0));
elementTag.put(new ByteTag("has_ceiling", (byte) 0));
elementTag.put(new ByteTag("has_skylight", (byte) 1));
tag.put(elementTag);
tag.put(new StringTag("name", "minecraft:overworld"));
tag.put(new ByteTag("has_ceiling", (byte) 0));
addSharedOverwaldEntries(tag);
return tag;
}
private static CompoundTag createOverworldCavesEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("name", "minecraft:overworld_caves"));
tag.put(new ByteTag("has_ceiling", (byte) 1));
addSharedOverwaldEntries(tag);
return tag;
}
private static void addSharedOverwaldEntries(CompoundTag tag) {
tag.put(new ByteTag("piglin_safe", (byte) 0));
tag.put(new ByteTag("natural", (byte) 1));
tag.put(new FloatTag("ambient_light", 0));
tag.put(new StringTag("infiniburn", "minecraft:infiniburn_overworld"));
tag.put(new ByteTag("respawn_anchor_works", (byte) 0));
tag.put(new ByteTag("has_skylight", (byte) 1));
tag.put(new ByteTag("bed_works", (byte) 1));
tag.put(new ByteTag("has_raids", (byte) 1));
tag.put(new IntTag("logical_height", 256));
tag.put(new ByteTag("shrunk", (byte) 0));
tag.put(new ByteTag("ultrawarm", (byte) 0));
}
private static CompoundTag createNetherEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("key", "minecraft:the_nether"));
CompoundTag elementTag = new CompoundTag("element");
elementTag.put(new ByteTag("natural", (byte) 0));
elementTag.put(new LongTag("fixed_time", 18000));
elementTag.put(new FloatTag("ambient_light", 0.1F));
elementTag.put(new ByteTag("shrunk", (byte) 1));
elementTag.put(new ByteTag("ultrawarm", (byte) 1));
elementTag.put(new ByteTag("has_ceiling", (byte) 1));
elementTag.put(new ByteTag("has_skylight", (byte) 0));
tag.put(elementTag);
tag.put(new ByteTag("piglin_safe", (byte) 1));
tag.put(new ByteTag("natural", (byte) 0));
tag.put(new FloatTag("ambient_light", 0.1F));
tag.put(new StringTag("infiniburn", "minecraft:infiniburn_nether"));
tag.put(new ByteTag("respawn_anchor_works", (byte) 1));
tag.put(new ByteTag("has_skylight", (byte) 0));
tag.put(new ByteTag("bed_works", (byte) 0));
tag.put(new LongTag("fixed_time", 18000));
tag.put(new ByteTag("has_raids", (byte) 0));
tag.put(new StringTag("name", "minecraft:the_nether"));
tag.put(new IntTag("logical_height", 128));
tag.put(new ByteTag("shrunk", (byte) 1));
tag.put(new ByteTag("ultrawarm", (byte) 1));
tag.put(new ByteTag("has_ceiling", (byte) 1));
return tag;
}
private static CompoundTag createEndEntry() {
CompoundTag tag = new CompoundTag("");
tag.put(new StringTag("key", "minecraft:the_end"));
CompoundTag elementTag = new CompoundTag("element");
elementTag.put(new ByteTag("natural", (byte) 0));
elementTag.put(new LongTag("fixed_time", 6000));
elementTag.put(new FloatTag("ambient_light", 0));
elementTag.put(new ByteTag("shrunk", (byte) 0));
elementTag.put(new ByteTag("ultrawarm", (byte) 0));
elementTag.put(new ByteTag("has_ceiling", (byte) 0));
elementTag.put(new ByteTag("has_skylight", (byte) 0));
tag.put(elementTag);
tag.put(new ByteTag("piglin_safe", (byte) 0));
tag.put(new ByteTag("natural", (byte) 0));
tag.put(new FloatTag("ambient_light", 0));
tag.put(new StringTag("infiniburn", "minecraft:infiniburn_end"));
tag.put(new ByteTag("respawn_anchor_works", (byte) 0));
tag.put(new ByteTag("has_skylight", (byte) 0));
tag.put(new ByteTag("bed_works", (byte) 0));
tag.put(new LongTag("fixed_time", 6000));
tag.put(new ByteTag("has_raids", (byte) 1));
tag.put(new StringTag("name", "minecraft:the_end"));
tag.put(new IntTag("logical_height", 256));
tag.put(new ByteTag("shrunk", (byte) 0));
tag.put(new ByteTag("ultrawarm", (byte) 0));
tag.put(new ByteTag("has_ceiling", (byte) 0));
return tag;
}
@ -161,17 +185,9 @@ public class EntityPackets {
public void registerMap() {
map(Type.INT); // Entity ID
map(Type.UNSIGNED_BYTE); // Gamemode
map(Type.NOTHING, new ValueTransformer<Void, String[]>(Type.STRING_ARRAY) { // World list - only used for command completion
@Override
public String[] transform(PacketWrapper wrapper, Void input) throws Exception {
return WORLD_NAMES;
}
});
map(Type.NOTHING, new ValueTransformer<Void, CompoundTag>(Type.NBT) { // whatever this is
@Override
public CompoundTag transform(PacketWrapper wrapper, Void input) throws Exception {
return DIMENSIONS_TAG;
}
handler(wrapper -> {
wrapper.write(Type.STRING_ARRAY, WORLD_NAMES); // World list - only used for command completion
wrapper.write(Type.NBT, DIMENSIONS_TAG); // Dimension registry
});
handler(DIMENSION_HANDLER); // Dimension
map(Type.LONG); // Seed

View File

@ -31,6 +31,15 @@ public class WorldPackets {
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
blockRewriter.registerAcknowledgePlayerDigging(ClientboundPackets1_15.ACKNOWLEDGE_PLAYER_DIGGING);
protocol.registerOutgoing(ClientboundPackets1_15.UPDATE_LIGHT, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.VAR_INT); // x
map(Type.VAR_INT); // y
handler(wrapper -> wrapper.write(Type.BOOLEAN, true)); // Take neighbour's light into account as well
}
});
protocol.registerOutgoing(ClientboundPackets1_15.CHUNK_DATA, new PacketRemapper() {
@Override
public void registerMap() {