mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-22 10:05:12 +01:00
19w36a (#1435)
This commit is contained in:
parent
238c0e8d40
commit
23eadaeaee
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<version>2.1.4-19w36a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -269,4 +269,9 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean is1_14HitboxFix() {
|
||||
return getBoolean("change-1_14-hitbox", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_15InstantRespawn() {
|
||||
return getBoolean("use-1_15-instant-respawn", false);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<version>2.1.4-19w36a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -322,4 +322,9 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean is1_14HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_15InstantRespawn() {
|
||||
return getBoolean("use-1_15-instant-respawn", false);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<version>2.1.4-19w36a</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -337,4 +337,11 @@ public interface ViaVersionConfig {
|
||||
* @return True if enabled
|
||||
*/
|
||||
boolean is1_14HitboxFix();
|
||||
|
||||
/**
|
||||
* Should 1.15 clients respawn instantly / without showing the death screen
|
||||
*
|
||||
* @return True if enabled
|
||||
*/
|
||||
boolean is1_15InstantRespawn();
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class ProtocolVersion {
|
||||
register(v1_14_2 = new ProtocolVersion(485, "1.14.2"));
|
||||
register(v1_14_3 = new ProtocolVersion(490, "1.14.3"));
|
||||
register(v1_14_4 = new ProtocolVersion(498, "1.14.4"));
|
||||
register(v1_15 = new ProtocolVersion(551, "1.15"));
|
||||
register(v1_15 = new ProtocolVersion(552, "1.15"));
|
||||
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,10 @@ public class MetadataRewriter {
|
||||
try {
|
||||
if (metadata.getMetaType() == MetaType1_14.Slot) {
|
||||
InventoryPackets.toClient((Item) metadata.getValue());
|
||||
} else if (metadata.getMetaType() == MetaType1_14.BlockID) {
|
||||
// Convert to new block id
|
||||
int data = (int) metadata.getValue();
|
||||
metadata.setValue(Protocol1_15To1_14_4.getNewBlockStateId(data));
|
||||
}
|
||||
|
||||
if (type == null) continue;
|
||||
|
@ -3,7 +3,6 @@ package us.myles.ViaVersion.protocols.protocol1_15to1_14_4;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
@ -12,8 +11,10 @@ import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data.MappingData;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.EntityPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.PlayerPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.WorldPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class Protocol1_15To1_14_4 extends Protocol {
|
||||
|
||||
@ -21,25 +22,10 @@ public class Protocol1_15To1_14_4 extends Protocol {
|
||||
protected void registerPackets() {
|
||||
MappingData.init();
|
||||
EntityPackets.register(this);
|
||||
PlayerPackets.register(this);
|
||||
WorldPackets.register(this);
|
||||
InventoryPackets.register(this);
|
||||
|
||||
// Join Game
|
||||
registerOutgoing(State.PLAY, 0x25, 0x26, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Entity1_15Types.EntityType entType = Entity1_15Types.EntityType.PLAYER;
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.addEntity(wrapper.get(Type.INT, 0), entType);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Sound Effect (added somewhere in 1.14)
|
||||
registerOutgoing(State.PLAY, 0x50, 0x51, new PacketRemapper() {
|
||||
@Override
|
||||
@ -171,11 +157,9 @@ public class Protocol1_15To1_14_4 extends Protocol {
|
||||
|
||||
registerOutgoing(State.PLAY, 0x08, 0x09);
|
||||
registerOutgoing(State.PLAY, 0x09, 0x0A);
|
||||
registerOutgoing(State.PLAY, 0x0B, 0x0C);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x0D, 0x0E);
|
||||
registerOutgoing(State.PLAY, 0x0E, 0x0F);
|
||||
registerOutgoing(State.PLAY, 0x0F, 0x10);
|
||||
registerOutgoing(State.PLAY, 0x10, 0x11);
|
||||
registerOutgoing(State.PLAY, 0x11, 0x12);
|
||||
registerOutgoing(State.PLAY, 0x12, 0x13);
|
||||
@ -193,7 +177,6 @@ public class Protocol1_15To1_14_4 extends Protocol {
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x1F);
|
||||
registerOutgoing(State.PLAY, 0x1F, 0x20);
|
||||
registerOutgoing(State.PLAY, 0x20, 0x21);
|
||||
registerOutgoing(State.PLAY, 0x21, 0x22);
|
||||
|
||||
|
||||
registerOutgoing(State.PLAY, 0x24, 0x25);
|
||||
@ -218,7 +201,6 @@ public class Protocol1_15To1_14_4 extends Protocol {
|
||||
registerOutgoing(State.PLAY, 0x37, 0x38);
|
||||
registerOutgoing(State.PLAY, 0x38, 0x39);
|
||||
registerOutgoing(State.PLAY, 0x39, 0x3A);
|
||||
registerOutgoing(State.PLAY, 0x3A, 0x3B);
|
||||
registerOutgoing(State.PLAY, 0x3B, 0x3C);
|
||||
registerOutgoing(State.PLAY, 0x3C, 0x3D);
|
||||
registerOutgoing(State.PLAY, 0x3D, 0x3E);
|
||||
@ -255,10 +237,28 @@ public class Protocol1_15To1_14_4 extends Protocol {
|
||||
registerOutgoing(State.PLAY, 0x5C, 0x08);
|
||||
}
|
||||
|
||||
public static int getNewSoundId(int id) {
|
||||
int newId = MappingData.soundMappings.getNewSound(id);
|
||||
if (newId == -1) {
|
||||
Via.getPlatform().getLogger().warning("Missing 1.15 sound for 1.14.4 sound " + id);
|
||||
return 0;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
public static int getNewBlockStateId(int id) {
|
||||
int newId = MappingData.blockStateMappings.getNewBlock(id);
|
||||
if (newId == -1) {
|
||||
Via.getPlatform().getLogger().warning("Missing 1.15 blockstate for 1.14.4 blockstate " + id);
|
||||
return 0;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
public static int getNewBlockId(int id) {
|
||||
int newId = MappingData.blockMappings.getNewBlock(id);
|
||||
if (newId == -1) {
|
||||
Via.getPlatform().getLogger().warning("Missing 1.15 block for 1.14 block " + id);
|
||||
Via.getPlatform().getLogger().warning("Missing 1.15 block for 1.14.4 block " + id);
|
||||
return 0;
|
||||
}
|
||||
return newId;
|
||||
@ -267,5 +267,7 @@ public class Protocol1_15To1_14_4 extends Protocol {
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.put(new EntityTracker(userConnection));
|
||||
if (!userConnection.has(ClientWorld.class))
|
||||
userConnection.put(new ClientWorld(userConnection));
|
||||
}
|
||||
}
|
||||
|
@ -8,14 +8,15 @@ import us.myles.ViaVersion.api.Via;
|
||||
public class MappingData {
|
||||
public static BiMap<Integer, Integer> oldToNewItems = HashBiMap.create();
|
||||
public static us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.BlockMappings blockMappings;
|
||||
public static us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.BlockMappings blockStateMappings;
|
||||
public static us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.SoundMappings soundMappings;
|
||||
|
||||
public static void init() {
|
||||
JsonObject mapping1_14 = us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.loadData("mapping-1.14.json");
|
||||
JsonObject mapping1_15 = us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.loadData("mapping-1.15.json");
|
||||
|
||||
// New blockstates have just been appended to the old, so mappings are not (yet) necessary.
|
||||
|
||||
Via.getPlatform().getLogger().info("Loading 1.14 -> 1.15 blockstate mapping...");
|
||||
blockStateMappings = new us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.BlockMappingsShortArray(mapping1_14.getAsJsonObject("blockstates"), mapping1_15.getAsJsonObject("blockstates"));
|
||||
Via.getPlatform().getLogger().info("Loading 1.14 -> 1.15 block mapping...");
|
||||
blockMappings = new us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.BlockMappingsShortArray(mapping1_14.getAsJsonObject("blocks"), mapping1_15.getAsJsonObject("blocks"));
|
||||
Via.getPlatform().getLogger().info("Loading 1.14 -> 1.15 item mapping...");
|
||||
|
@ -10,8 +10,11 @@ import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_14;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.MetadataRewriter;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class EntityPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
@ -19,17 +22,34 @@ public class EntityPackets {
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity id
|
||||
map(Type.UUID); // 1 - UUID
|
||||
map(Type.VAR_INT); // 2 - Type
|
||||
map(Type.DOUBLE); // 3 - X
|
||||
map(Type.DOUBLE); // 4 - Y
|
||||
map(Type.DOUBLE); // 5 - Z
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
map(Type.INT); // 8 - Data
|
||||
map(Type.SHORT); // 9 - Velocity X
|
||||
map(Type.SHORT); // 10 - Velocity Y
|
||||
map(Type.SHORT); // 11 - Velocity Z
|
||||
|
||||
// Track Entity
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.UUID);
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
UUID uuid = wrapper.get(Type.UUID, 0);
|
||||
int typeId = wrapper.get(Type.VAR_INT, 1);
|
||||
|
||||
int typeId = wrapper.read(Type.VAR_INT);
|
||||
Entity1_15Types.EntityType entityType = Entity1_15Types.getTypeFromId(getNewEntityId(typeId));
|
||||
wrapper.user().get(EntityTracker.class).addEntity(entityId, entityType);
|
||||
wrapper.write(Type.VAR_INT, entityType.getId());
|
||||
wrapper.set(Type.VAR_INT, 1, entityType.getId());
|
||||
|
||||
if (entityType == Entity1_15Types.EntityType.FALLING_BLOCK) {
|
||||
wrapper.set(Type.INT, 0, Protocol1_15To1_14_4.getNewBlockStateId(wrapper.get(Type.INT, 0)));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -0,0 +1,91 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.remapper.ValueCreator;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class PlayerPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
// Respawn
|
||||
protocol.registerOutgoing(State.PLAY, 0x3A, 0x3B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 0);
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
}
|
||||
});
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.LONG, 0L); // Level Seed
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Join Game
|
||||
protocol.registerOutgoing(State.PLAY, 0x25, 0x26, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Entity ID
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Gamemode
|
||||
map(Type.INT); // 2 - Dimension
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Entity1_15Types.EntityType entType = Entity1_15Types.EntityType.PLAYER;
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.addEntity(wrapper.get(Type.INT, 0), entType);
|
||||
}
|
||||
});
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Store the player
|
||||
ClientWorld clientChunks = wrapper.user().get(ClientWorld.class);
|
||||
int dimensionId = wrapper.get(Type.INT, 1);
|
||||
clientChunks.setEnvironment(dimensionId);
|
||||
|
||||
// Register Type ID
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
int entityId = wrapper.get(Type.INT, 0);
|
||||
tracker.addEntity(entityId, Entity1_15Types.EntityType.PLAYER);
|
||||
}
|
||||
});
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.LONG, 0L); // Level Seed
|
||||
}
|
||||
});
|
||||
|
||||
map(Type.UNSIGNED_BYTE); // 3 - Max Players
|
||||
map(Type.STRING); // 4 - Level Type
|
||||
map(Type.VAR_INT); // 5 - View Distance
|
||||
map(Type.BOOLEAN); // 6 - Reduce Debug Info
|
||||
|
||||
create(new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.BOOLEAN, !Via.getConfig().is1_15InstantRespawn()); // Show Death Screen
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -1,13 +1,19 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.BlockChangeRecord;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.protocol.Protocol;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.packets.InventoryPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types.Chunk1_15Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
public class WorldPackets {
|
||||
|
||||
@ -29,6 +35,68 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Block Change
|
||||
protocol.registerOutgoing(State.PLAY, 0x0B, 0x0C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14);
|
||||
map(Type.VAR_INT);
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.VAR_INT, 0);
|
||||
|
||||
wrapper.set(Type.VAR_INT, 0, Protocol1_15To1_14_4.getNewBlockStateId(id));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Multi Block Change
|
||||
protocol.registerOutgoing(State.PLAY, 0x0F, 0x10, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Chunk X
|
||||
map(Type.INT); // 1 - Chunk Z
|
||||
map(Type.BLOCK_CHANGE_RECORD_ARRAY); // 2 - Records
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// Convert ids
|
||||
for (BlockChangeRecord record : wrapper.get(Type.BLOCK_CHANGE_RECORD_ARRAY, 0)) {
|
||||
int id = record.getBlockId();
|
||||
record.setBlockId(Protocol1_15To1_14_4.getNewBlockStateId(id));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Chunk Data
|
||||
protocol.registerOutgoing(State.PLAY, 0x21, 0x22, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld));
|
||||
wrapper.write(new Chunk1_15Type(clientWorld), chunk);
|
||||
|
||||
for (int s = 0; s < 16; s++) {
|
||||
ChunkSection section = chunk.getSections()[s];
|
||||
if (section == null) continue;
|
||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||
int old = section.getPaletteEntry(i);
|
||||
int newId = Protocol1_15To1_14_4.getNewBlockStateId(old);
|
||||
section.setPaletteEntry(i, newId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x23, new PacketRemapper() {
|
||||
@Override
|
||||
@ -40,9 +108,11 @@ public class WorldPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 1010) { // Play record
|
||||
int data = wrapper.get(Type.INT, 1);
|
||||
if (id == 1010) { // Play record
|
||||
wrapper.set(Type.INT, 1, InventoryPackets.getNewItemId(data));
|
||||
} else if (id == 2001) { // Block break + block break sound
|
||||
wrapper.set(Type.INT, 1, data = Protocol1_15To1_14_4.getNewBlockStateId(data));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -67,7 +137,10 @@ public class WorldPackets {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 27) {
|
||||
if (id == 3 || id == 23) {
|
||||
int data = wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.set(Type.VAR_INT, 0, Protocol1_15To1_14_4.getNewBlockStateId(data));
|
||||
} else if (id == 32) {
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,119 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.types;
|
||||
|
||||
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.BaseChunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_13;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
|
||||
public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
|
||||
|
||||
public Chunk1_15Type(ClientWorld param) {
|
||||
super(param, Chunk.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
||||
int chunkX = input.readInt();
|
||||
int chunkZ = input.readInt();
|
||||
|
||||
boolean groundUp = input.readBoolean();
|
||||
int primaryBitmask = Type.VAR_INT.read(input);
|
||||
CompoundTag heightMap = Type.NBT.read(input);
|
||||
Type.VAR_INT.read(input);
|
||||
|
||||
BitSet usedSections = new BitSet(16);
|
||||
ChunkSection[] sections = new ChunkSection[16];
|
||||
// Calculate section count from bitmask
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((primaryBitmask & (1 << i)) != 0) {
|
||||
usedSections.set(i);
|
||||
}
|
||||
}
|
||||
|
||||
int[] biomeData = groundUp ? new int[256] : null;
|
||||
if (groundUp) {
|
||||
//TODO Why 1024 ints?
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
//biomeData[i] = input.readInt();
|
||||
input.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
// Read sections
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (!usedSections.get(i)) continue; // Section not set
|
||||
short nonAirBlocksCount = input.readShort();
|
||||
ChunkSection section = Types1_13.CHUNK_SECTION.read(input);
|
||||
section.setNonAirBlocksCount(nonAirBlocksCount);
|
||||
sections[i] = section;
|
||||
}
|
||||
|
||||
List<CompoundTag> nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input)));
|
||||
|
||||
// Read all the remaining bytes (workaround for #681)
|
||||
if (input.readableBytes() > 0) {
|
||||
byte[] array = Type.REMAINING_BYTES.read(input);
|
||||
if (Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("Found " + array.length + " more bytes than expected while reading the chunk: " + chunkX + "/" + chunkZ);
|
||||
}
|
||||
}
|
||||
|
||||
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, heightMap, nbtData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception {
|
||||
output.writeInt(chunk.getX());
|
||||
output.writeInt(chunk.getZ());
|
||||
|
||||
output.writeBoolean(chunk.isGroundUp());
|
||||
Type.VAR_INT.write(output, chunk.getBitmask());
|
||||
Type.NBT.write(output, chunk.getHeightMap());
|
||||
|
||||
// Write biome data
|
||||
if (chunk.isBiomeData()) {
|
||||
//TODO Why 1024 ints?
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
output.writeInt(0);
|
||||
}
|
||||
/*for (int value : chunk.getBiomeData()) {
|
||||
output.writeInt(value & 0xFF); // This is a temporary workaround, we'll look into fixing this soon :)
|
||||
}*/
|
||||
}
|
||||
|
||||
ByteBuf buf = output.alloc().buffer();
|
||||
try {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
if (section == null) continue; // Section not set
|
||||
buf.writeShort(section.getNonAirBlocksCount());
|
||||
Types1_13.CHUNK_SECTION.write(buf, section);
|
||||
}
|
||||
buf.readerIndex(0);
|
||||
Type.VAR_INT.write(output, buf.readableBytes());
|
||||
output.writeBytes(buf);
|
||||
} finally {
|
||||
buf.release(); // release buffer
|
||||
}
|
||||
|
||||
// Write Block Entities
|
||||
Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Type> getBaseClass() {
|
||||
return BaseChunkType.class;
|
||||
}
|
||||
}
|
@ -126,6 +126,8 @@ change-1_9-hitbox: false
|
||||
# WARNING: This gives 1.14+ players the ability to sneak under blocks, that players under that version cannot (sneaking in places that are only 1.5 blocks high)!
|
||||
# Another thing to remember is that those players might be missed by projectiles and other hits directed at the very top of their head whilst sneaking.
|
||||
change-1_14-hitbox: false
|
||||
# Should 1.15+ clients respawn instantly / without showing a death screen?
|
||||
use-1_15-instant-respawn: false
|
||||
#
|
||||
# Enable serverside block-connections for 1.13+ clients
|
||||
serverside-blockconnections: false
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<version>2.1.4-19w36a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>viaversion-jar</name>
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<version>2.1.4-19w36a</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>viaversion-parent</name>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<version>2.1.4-19w36a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<version>2.1.4-19w36a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -275,4 +275,9 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean is1_14HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_15InstantRespawn() {
|
||||
return getBoolean("use-1_15-instant-respawn", false);
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<version>2.1.4-19w36a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -328,4 +328,9 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
|
||||
public boolean is1_14HitboxFix() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean is1_15InstantRespawn() {
|
||||
return getBoolean("use-1_15-instant-respawn", false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user