mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-25 11:35:18 +01:00
commit
238c0e8d40
@ -2,7 +2,6 @@ sudo: false
|
||||
|
||||
language: java
|
||||
jdk:
|
||||
- oraclejdk8
|
||||
- openjdk11
|
||||
|
||||
cache:
|
||||
|
@ -1,4 +1,4 @@
|
||||
# ViaVersion 2.1.1 - Spigot, Sponge, BungeeCord, Velocity
|
||||
# ViaVersion 2.1.3 - Spigot, Sponge, BungeeCord, Velocity
|
||||
[![Build Status](https://travis-ci.com/ViaVersion/ViaVersion.svg?branch=master)](https://travis-ci.com/ViaVersion/ViaVersion)
|
||||
[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4-19w35a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4-19w35a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -7,6 +7,7 @@ import net.md_5.bungee.api.event.PlayerDisconnectEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.ViaAPI;
|
||||
import us.myles.ViaVersion.api.command.ViaCommandSender;
|
||||
@ -35,6 +36,17 @@ public class BungeePlugin extends Plugin implements ViaPlatform, Listener {
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
try {
|
||||
ProtocolConstants.class.getField("MINECRAFT_1_14_4");
|
||||
} catch (NoSuchFieldException e) {
|
||||
getLogger().warning(" / \\");
|
||||
getLogger().warning(" / \\");
|
||||
getLogger().warning(" / | \\");
|
||||
getLogger().warning(" / | \\ BUNGEECORD IS OUTDATED");
|
||||
getLogger().warning(" / \\ VIAVERSION MAY NOT WORK AS INTENDED");
|
||||
getLogger().warning(" / o \\");
|
||||
getLogger().warning("/_____________\\");
|
||||
}
|
||||
api = new BungeeViaAPI();
|
||||
config = new BungeeViaConfig(getDataFolder());
|
||||
commandHandler = new BungeeCommandHandler();
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4-19w35a</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
@ -0,0 +1,248 @@
|
||||
package us.myles.ViaVersion.api.entities;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Entity1_15Types {
|
||||
public static EntityType getTypeFromId(int typeID) {
|
||||
Optional<EntityType> type = EntityType.findById(typeID);
|
||||
|
||||
if (!type.isPresent()) {
|
||||
Via.getPlatform().getLogger().severe("Could not find type id " + typeID);
|
||||
return EntityType.ENTITY; // Fall back to the basic ENTITY
|
||||
}
|
||||
|
||||
return type.get();
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum EntityType {
|
||||
ENTITY(-1),
|
||||
|
||||
AREA_EFFECT_CLOUD(0, ENTITY),
|
||||
ENDER_CRYSTAL(18, ENTITY),
|
||||
EVOCATION_FANGS(22, ENTITY),
|
||||
XP_ORB(24, ENTITY),
|
||||
EYE_OF_ENDER_SIGNAL(25, ENTITY),
|
||||
FALLING_BLOCK(26, ENTITY),
|
||||
FIREWORKS_ROCKET(27, ENTITY),
|
||||
ITEM(35, ENTITY),
|
||||
LLAMA_SPIT(40, ENTITY),
|
||||
TNT(59, ENTITY),
|
||||
SHULKER_BULLET(64, ENTITY),
|
||||
FISHING_BOBBER(111, ENTITY),
|
||||
|
||||
LIVINGENTITY(-1, ENTITY),
|
||||
ARMOR_STAND(1, LIVINGENTITY),
|
||||
PLAYER(110, LIVINGENTITY),
|
||||
|
||||
ABSTRACT_INSENTIENT(-1, LIVINGENTITY),
|
||||
ENDER_DRAGON(19, ABSTRACT_INSENTIENT),
|
||||
|
||||
BEE(4, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_CREATURE(-1, ABSTRACT_INSENTIENT),
|
||||
|
||||
ABSTRACT_AGEABLE(-1, ABSTRACT_CREATURE),
|
||||
VILLAGER(85, ABSTRACT_AGEABLE),
|
||||
WANDERING_TRADER(89, ABSTRACT_AGEABLE),
|
||||
|
||||
// Animals
|
||||
ABSTRACT_ANIMAL(-1, ABSTRACT_AGEABLE),
|
||||
DOLPHIN(14, ABSTRACT_INSENTIENT),
|
||||
CHICKEN(9, ABSTRACT_ANIMAL),
|
||||
COW(11, ABSTRACT_ANIMAL),
|
||||
MOOSHROOM(50, COW),
|
||||
PANDA(53, ABSTRACT_INSENTIENT),
|
||||
PIG(55, ABSTRACT_ANIMAL),
|
||||
POLAR_BEAR(58, ABSTRACT_ANIMAL),
|
||||
RABBIT(60, ABSTRACT_ANIMAL),
|
||||
SHEEP(62, ABSTRACT_ANIMAL),
|
||||
TURTLE(78, ABSTRACT_ANIMAL),
|
||||
FOX(28, ABSTRACT_ANIMAL),
|
||||
|
||||
ABSTRACT_TAMEABLE_ANIMAL(-1, ABSTRACT_ANIMAL),
|
||||
CAT(7, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
OCELOT(51, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
WOLF(94, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
|
||||
ABSTRACT_PARROT(-1, ABSTRACT_TAMEABLE_ANIMAL),
|
||||
PARROT(54, ABSTRACT_PARROT),
|
||||
|
||||
// Horses
|
||||
ABSTRACT_HORSE(-1, ABSTRACT_ANIMAL),
|
||||
CHESTED_HORSE(-1, ABSTRACT_HORSE),
|
||||
DONKEY(13, CHESTED_HORSE),
|
||||
MULE(49, CHESTED_HORSE),
|
||||
LLAMA(39, CHESTED_HORSE),
|
||||
TRADER_LLAMA(76, CHESTED_HORSE),
|
||||
HORSE(32, ABSTRACT_HORSE),
|
||||
SKELETON_HORSE(67, ABSTRACT_HORSE),
|
||||
ZOMBIE_HORSE(96, ABSTRACT_HORSE),
|
||||
|
||||
// Golem
|
||||
ABSTRACT_GOLEM(-1, ABSTRACT_CREATURE),
|
||||
SNOWMAN(70, ABSTRACT_GOLEM),
|
||||
VILLAGER_GOLEM(86, ABSTRACT_GOLEM),
|
||||
SHULKER(63, ABSTRACT_GOLEM),
|
||||
|
||||
// Fish
|
||||
ABSTRACT_FISHES(-1, ABSTRACT_CREATURE),
|
||||
COD(10, ABSTRACT_FISHES),
|
||||
PUFFER_FISH(56, ABSTRACT_FISHES),
|
||||
SALMON_MOB(61, ABSTRACT_FISHES),
|
||||
TROPICAL_FISH(77, ABSTRACT_FISHES),
|
||||
|
||||
// Monsters
|
||||
ABSTRACT_MONSTER(-1, ABSTRACT_CREATURE),
|
||||
BLAZE(4, ABSTRACT_MONSTER),
|
||||
CREEPER(12, ABSTRACT_MONSTER),
|
||||
ENDERMITE(21, ABSTRACT_MONSTER),
|
||||
ENDERMAN(20, ABSTRACT_MONSTER),
|
||||
GIANT(30, ABSTRACT_MONSTER),
|
||||
SILVERFISH(65, ABSTRACT_MONSTER),
|
||||
VEX(84, ABSTRACT_MONSTER),
|
||||
WITCH(90, ABSTRACT_MONSTER),
|
||||
WITHER(91, ABSTRACT_MONSTER),
|
||||
RAVAGER(99, ABSTRACT_MONSTER),
|
||||
|
||||
// Illagers
|
||||
ABSTRACT_ILLAGER_BASE(-1, ABSTRACT_MONSTER),
|
||||
ABSTRACT_EVO_ILLU_ILLAGER(-1, ABSTRACT_ILLAGER_BASE),
|
||||
EVOCATION_ILLAGER(23, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
ILLUSION_ILLAGER(34, ABSTRACT_EVO_ILLU_ILLAGER),
|
||||
VINDICATION_ILLAGER(87, ABSTRACT_ILLAGER_BASE),
|
||||
PILLAGER(88, ABSTRACT_ILLAGER_BASE),
|
||||
|
||||
// Skeletons
|
||||
ABSTRACT_SKELETON(-1, ABSTRACT_MONSTER),
|
||||
SKELETON(66, ABSTRACT_SKELETON),
|
||||
STRAY(75, ABSTRACT_SKELETON),
|
||||
WITHER_SKELETON(92, ABSTRACT_SKELETON),
|
||||
|
||||
// Guardians
|
||||
GUARDIAN(31, ABSTRACT_MONSTER),
|
||||
ELDER_GUARDIAN(17, GUARDIAN),
|
||||
|
||||
// Spiders
|
||||
SPIDER(73, ABSTRACT_MONSTER),
|
||||
CAVE_SPIDER(8, SPIDER),
|
||||
|
||||
// Zombies
|
||||
ZOMBIE(95, ABSTRACT_MONSTER),
|
||||
DROWNED(16, ZOMBIE),
|
||||
HUSK(33, ZOMBIE),
|
||||
ZOMBIE_PIGMAN(57, ZOMBIE),
|
||||
ZOMBIE_VILLAGER(97, ZOMBIE),
|
||||
|
||||
// Flying entities
|
||||
ABSTRACT_FLYING(-1, ABSTRACT_INSENTIENT),
|
||||
GHAST(29, ABSTRACT_FLYING),
|
||||
PHANTOM(98, ABSTRACT_FLYING),
|
||||
|
||||
ABSTRACT_AMBIENT(-1, ABSTRACT_INSENTIENT),
|
||||
BAT(3, ABSTRACT_AMBIENT),
|
||||
|
||||
ABSTRACT_WATERMOB(-1, ABSTRACT_INSENTIENT),
|
||||
SQUID(74, ABSTRACT_WATERMOB),
|
||||
|
||||
// Slimes
|
||||
SLIME(68, ABSTRACT_INSENTIENT),
|
||||
MAGMA_CUBE(41, SLIME),
|
||||
|
||||
// Hangable objects
|
||||
ABSTRACT_HANGING(-1, ENTITY),
|
||||
LEASH_KNOT(38, ABSTRACT_HANGING),
|
||||
ITEM_FRAME(36, ABSTRACT_HANGING),
|
||||
PAINTING(52, ABSTRACT_HANGING),
|
||||
|
||||
ABSTRACT_LIGHTNING(-1, ENTITY),
|
||||
LIGHTNING_BOLT(100, ABSTRACT_LIGHTNING),
|
||||
|
||||
// Arrows
|
||||
ABSTRACT_ARROW(-1, ENTITY),
|
||||
ARROW(2, ABSTRACT_ARROW),
|
||||
SPECTRAL_ARROW(72, ABSTRACT_ARROW),
|
||||
TRIDENT(83, ABSTRACT_ARROW),
|
||||
|
||||
// Fireballs
|
||||
ABSTRACT_FIREBALL(-1, ENTITY),
|
||||
DRAGON_FIREBALL(15, ABSTRACT_FIREBALL),
|
||||
FIREBALL(37, ABSTRACT_FIREBALL),
|
||||
SMALL_FIREBALL(69, ABSTRACT_FIREBALL),
|
||||
WITHER_SKULL(93, ABSTRACT_FIREBALL),
|
||||
|
||||
// Projectiles
|
||||
PROJECTILE_ABSTRACT(-1, ENTITY),
|
||||
SNOWBALL(71, PROJECTILE_ABSTRACT),
|
||||
ENDER_PEARL(80, PROJECTILE_ABSTRACT),
|
||||
EGG(79, PROJECTILE_ABSTRACT),
|
||||
POTION(82, PROJECTILE_ABSTRACT),
|
||||
XP_BOTTLE(81, PROJECTILE_ABSTRACT),
|
||||
|
||||
// Vehicles
|
||||
MINECART_ABSTRACT(-1, ENTITY),
|
||||
CHESTED_MINECART_ABSTRACT(-1, MINECART_ABSTRACT),
|
||||
CHEST_MINECART(43, CHESTED_MINECART_ABSTRACT),
|
||||
HOPPER_MINECART(46, CHESTED_MINECART_ABSTRACT),
|
||||
MINECART(42, MINECART_ABSTRACT),
|
||||
FURNACE_MINECART(45, MINECART_ABSTRACT),
|
||||
COMMANDBLOCK_MINECART(44, MINECART_ABSTRACT),
|
||||
TNT_MINECART(48, MINECART_ABSTRACT),
|
||||
SPAWNER_MINECART(47, MINECART_ABSTRACT),
|
||||
BOAT(6, ENTITY);
|
||||
|
||||
private static final Map<Integer, EntityType> TYPES = new HashMap<>();
|
||||
|
||||
private final int id;
|
||||
private final EntityType parent;
|
||||
|
||||
EntityType(int id) {
|
||||
this.id = id;
|
||||
this.parent = null;
|
||||
}
|
||||
|
||||
static {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
TYPES.put(type.id, type);
|
||||
}
|
||||
}
|
||||
|
||||
public static Optional<EntityType> findById(int id) {
|
||||
if (id == -1)
|
||||
return Optional.absent();
|
||||
return Optional.fromNullable(TYPES.get(id));
|
||||
}
|
||||
|
||||
public boolean is(EntityType... types) {
|
||||
for (EntityType type : types)
|
||||
if (is(type))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean is(EntityType type) {
|
||||
return this == type;
|
||||
}
|
||||
|
||||
public boolean isOrHasParent(EntityType type) {
|
||||
EntityType parent = this;
|
||||
|
||||
do {
|
||||
if (parent == type)
|
||||
return true;
|
||||
|
||||
parent = parent.getParent();
|
||||
} while (parent != null);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ import us.myles.ViaVersion.protocols.protocol1_14_2to1_14_1.Protocol1_14_2To1_14
|
||||
import us.myles.ViaVersion.protocols.protocol1_14_3to1_14_2.Protocol1_14_3To1_14_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14_4to1_14_3.Protocol1_14_4To1_14_3;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1To1_9;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.Protocol1_9_3To1_9_1_2;
|
||||
@ -70,6 +71,8 @@ public class ProtocolRegistry {
|
||||
registerProtocol(new Protocol1_14_2To1_14_1(), Collections.singletonList(ProtocolVersion.v1_14_2.getId()), ProtocolVersion.v1_14_1.getId());
|
||||
registerProtocol(new Protocol1_14_3To1_14_2(), Collections.singletonList(ProtocolVersion.v1_14_3.getId()), ProtocolVersion.v1_14_2.getId());
|
||||
registerProtocol(new Protocol1_14_4To1_14_3(), Collections.singletonList(ProtocolVersion.v1_14_4.getId()), ProtocolVersion.v1_14_3.getId());
|
||||
|
||||
registerProtocol(new Protocol1_15To1_14_4(), Collections.singletonList(ProtocolVersion.v1_15.getId()), ProtocolVersion.v1_14_4.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,6 +40,7 @@ public class ProtocolVersion {
|
||||
public static final ProtocolVersion v1_14_2;
|
||||
public static final ProtocolVersion v1_14_3;
|
||||
public static final ProtocolVersion v1_14_4;
|
||||
public static final ProtocolVersion v1_15;
|
||||
public static final ProtocolVersion unknown;
|
||||
|
||||
private final int id;
|
||||
@ -76,6 +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(unknown = new ProtocolVersion(-1, "UNKNOWN"));
|
||||
}
|
||||
|
||||
|
@ -27,6 +27,7 @@ import us.myles.ViaVersion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class InventoryPackets {
|
||||
private static String NBT_TAG_NAME;
|
||||
@ -404,13 +405,13 @@ public class InventoryPackets {
|
||||
if (numberConverted != null) {
|
||||
oldId = numberConverted;
|
||||
}
|
||||
String[] newValues = BlockIdData.blockIdMapping.get(oldId);
|
||||
String[] newValues = BlockIdData.blockIdMapping.get(oldId.toLowerCase(Locale.ROOT));
|
||||
if (newValues != null) {
|
||||
for (String newValue : newValues) {
|
||||
newCanPlaceOn.add(new StringTag("", newValue));
|
||||
}
|
||||
} else {
|
||||
newCanPlaceOn.add(new StringTag("", oldId));
|
||||
newCanPlaceOn.add(new StringTag("", oldId.toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
tag.put(newCanPlaceOn);
|
||||
@ -426,13 +427,13 @@ public class InventoryPackets {
|
||||
if (numberConverted != null) {
|
||||
oldId = numberConverted;
|
||||
}
|
||||
String[] newValues = BlockIdData.blockIdMapping.get(oldId);
|
||||
String[] newValues = BlockIdData.blockIdMapping.get(oldId.toLowerCase(Locale.ROOT));
|
||||
if (newValues != null) {
|
||||
for (String newValue : newValues) {
|
||||
newCanDestroy.add(new StringTag("", newValue));
|
||||
}
|
||||
} else {
|
||||
newCanDestroy.add(new StringTag("", oldId));
|
||||
newCanDestroy.add(new StringTag("", oldId.toLowerCase(Locale.ROOT)));
|
||||
}
|
||||
}
|
||||
tag.put(newCanDestroy);
|
||||
|
@ -37,7 +37,6 @@ public class Protocol1_14To1_13_2 extends Protocol {
|
||||
registerOutgoing(State.PLAY, 0x1B, 0x1A);
|
||||
registerOutgoing(State.PLAY, 0x1C, 0x1B);
|
||||
registerOutgoing(State.PLAY, 0x1D, 0x54);
|
||||
registerOutgoing(State.PLAY, 0x1E, 0x1C);
|
||||
registerOutgoing(State.PLAY, 0x1F, 0x1D);
|
||||
registerOutgoing(State.PLAY, 0x20, 0x1E);
|
||||
registerOutgoing(State.PLAY, 0x21, 0x20);
|
||||
|
@ -73,7 +73,7 @@ public class MappingData {
|
||||
}
|
||||
}
|
||||
|
||||
private static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||
public static void mapIdentifiers(Map<Integer, Integer> output, JsonObject oldIdentifiers, JsonObject newIdentifiers) {
|
||||
for (Map.Entry<String, JsonElement> entry : oldIdentifiers.entrySet()) {
|
||||
Map.Entry<String, JsonElement> value = findValue(newIdentifiers, entry.getValue().getAsString());
|
||||
if (value == null) {
|
||||
@ -137,10 +137,10 @@ public class MappingData {
|
||||
int getNewSound(int old);
|
||||
}
|
||||
|
||||
private static class SoundMappingShortArray implements SoundMappings {
|
||||
public static class SoundMappingShortArray implements SoundMappings {
|
||||
private short[] oldToNew;
|
||||
|
||||
private SoundMappingShortArray(JsonArray mapping1_13_2, JsonArray mapping1_14) {
|
||||
public SoundMappingShortArray(JsonArray mapping1_13_2, JsonArray mapping1_14) {
|
||||
oldToNew = new short[mapping1_13_2.size()];
|
||||
Arrays.fill(oldToNew, (short) -1);
|
||||
mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14);
|
||||
@ -156,10 +156,10 @@ public class MappingData {
|
||||
int getNewBlock(int old);
|
||||
}
|
||||
|
||||
private static class BlockMappingsShortArray implements BlockMappings {
|
||||
public static class BlockMappingsShortArray implements BlockMappings {
|
||||
private short[] oldToNew;
|
||||
|
||||
private BlockMappingsShortArray(JsonObject mapping1_13_2, JsonObject mapping1_14) {
|
||||
public BlockMappingsShortArray(JsonObject mapping1_13_2, JsonObject mapping1_14) {
|
||||
oldToNew = new short[mapping1_13_2.entrySet().size()];
|
||||
Arrays.fill(oldToNew, (short) -1);
|
||||
mapIdentifiers(oldToNew, mapping1_13_2, mapping1_14);
|
||||
|
@ -26,7 +26,6 @@ import java.util.UUID;
|
||||
public class EntityPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
|
||||
// Spawn entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
|
@ -22,11 +22,18 @@ import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.storage.EntityTracker;
|
||||
import us.myles.ViaVersion.protocols.protocol1_14to1_13_2.types.Chunk1_14Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class WorldPackets {
|
||||
private static final int AIR = MappingData.blockStateMappings.getNewBlock(0);
|
||||
private static final int VOID_AIR = MappingData.blockStateMappings.getNewBlock(8591);
|
||||
private static final int CAVE_AIR = MappingData.blockStateMappings.getNewBlock(8592);
|
||||
public static final int SERVERSIDE_VIEW_DISTANCE = 64;
|
||||
private static final byte[] FULL_LIGHT = new byte[2048];
|
||||
|
||||
static {
|
||||
Arrays.fill(FULL_LIGHT, (byte) 0xff);
|
||||
}
|
||||
|
||||
public static void register(final Protocol protocol) {
|
||||
|
||||
@ -116,6 +123,30 @@ public class WorldPackets {
|
||||
}
|
||||
});
|
||||
|
||||
// Explosion
|
||||
protocol.registerOutgoing(State.PLAY, 0x1E, 0x1C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.FLOAT); // X
|
||||
map(Type.FLOAT); // Y
|
||||
map(Type.FLOAT); // Z
|
||||
map(Type.FLOAT); // Radius
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
float coord = wrapper.get(Type.FLOAT, i);
|
||||
|
||||
if (coord < 0f) {
|
||||
coord = (int) coord;
|
||||
wrapper.set(Type.FLOAT, i, coord);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Chunk
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x21, new PacketRemapper() {
|
||||
@Override
|
||||
@ -172,24 +203,39 @@ public class WorldPackets {
|
||||
PacketWrapper lightPacket = wrapper.create(0x24);
|
||||
lightPacket.write(Type.VAR_INT, chunk.getX());
|
||||
lightPacket.write(Type.VAR_INT, chunk.getZ());
|
||||
int skyLightMask = 0;
|
||||
|
||||
int skyLightMask = chunk.isGroundUp() ? 0x3ffff : 0; // all 18 bits set if ground up
|
||||
int blockLightMask = 0;
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection sec = chunk.getSections()[i];
|
||||
if (sec == null) continue;
|
||||
if (sec.hasSkyLight()) {
|
||||
if (!chunk.isGroundUp() && sec.hasSkyLight()) {
|
||||
skyLightMask |= (1 << (i + 1));
|
||||
}
|
||||
blockLightMask |= (1 << (i + 1));
|
||||
}
|
||||
|
||||
lightPacket.write(Type.VAR_INT, skyLightMask);
|
||||
lightPacket.write(Type.VAR_INT, blockLightMask);
|
||||
lightPacket.write(Type.VAR_INT, 0); // empty sky light mask
|
||||
lightPacket.write(Type.VAR_INT, 0); // empty block light mask
|
||||
|
||||
// not sending skylight/setting empty skylight causes client lag due to some weird calculations
|
||||
// only do this on the initial chunk send (not when chunk.isGroundUp() is false)
|
||||
if (chunk.isGroundUp())
|
||||
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(FULL_LIGHT).toArray(new Byte[0])); // chunk below 0
|
||||
for (ChunkSection section : chunk.getSections()) {
|
||||
if (section == null || !section.hasSkyLight()) continue;
|
||||
if (section == null || !section.hasSkyLight()) {
|
||||
if (chunk.isGroundUp()) {
|
||||
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(FULL_LIGHT).toArray(new Byte[0]));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(section.getSkyLight()).toArray(new Byte[0]));
|
||||
}
|
||||
if (chunk.isGroundUp())
|
||||
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(FULL_LIGHT).toArray(new Byte[0])); // chunk above 255
|
||||
|
||||
for (ChunkSection section : chunk.getSections()) {
|
||||
if (section == null) continue;
|
||||
lightPacket.write(Type.BYTE_ARRAY, Bytes.asList(section.getBlockLight()).toArray(new Byte[0]));
|
||||
|
@ -0,0 +1,41 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4;
|
||||
|
||||
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.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_14;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets.InventoryPackets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MetadataRewriter {
|
||||
|
||||
public static void handleMetadata(int entityId, Entity1_15Types.EntityType type, List<Metadata> metadatas, UserConnection connection) {
|
||||
for (Metadata metadata : new ArrayList<>(metadatas)) {
|
||||
try {
|
||||
if (metadata.getMetaType() == MetaType1_14.Slot) {
|
||||
InventoryPackets.toClient((Item) metadata.getValue());
|
||||
}
|
||||
|
||||
if (type == null) continue;
|
||||
|
||||
// Metadata 12 added to abstract_living
|
||||
if (metadata.getId() > 11 && type.isOrHasParent(Entity1_15Types.EntityType.LIVINGENTITY)) {
|
||||
metadata.setId(metadata.getId() + 1); //TODO is it 11 or 12? what is it for?
|
||||
}
|
||||
|
||||
//TODO new boolean with id 17 for enderman?
|
||||
} catch (Exception e) {
|
||||
metadatas.remove(metadata);
|
||||
if (!Via.getConfig().isSuppressMetadataErrors() || Via.getManager().isDebug()) {
|
||||
Via.getPlatform().getLogger().warning("An error occurred with entity metadata handler");
|
||||
Via.getPlatform().getLogger().warning("Metadata: " + metadata);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,271 @@
|
||||
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;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
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.WorldPackets;
|
||||
import us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage.EntityTracker;
|
||||
|
||||
public class Protocol1_15To1_14_4 extends Protocol {
|
||||
|
||||
@Override
|
||||
protected void registerPackets() {
|
||||
MappingData.init();
|
||||
EntityPackets.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
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Sound Id
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(Type.VAR_INT, 0, MappingData.soundMappings.getNewSound(wrapper.get(Type.VAR_INT, 0)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Sound Effect
|
||||
registerOutgoing(State.PLAY, 0x51, 0x52, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // Sound Id
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(Type.VAR_INT, 0, MappingData.soundMappings.getNewSound(wrapper.get(Type.VAR_INT, 0)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Edit Book
|
||||
registerIncoming(State.PLAY, 0x0C, 0x0D, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
InventoryPackets.toServer(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Advancements
|
||||
registerOutgoing(State.PLAY, 0x57, 0x58, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.passthrough(Type.BOOLEAN); // Reset/clear
|
||||
int size = wrapper.passthrough(Type.VAR_INT); // Mapping size
|
||||
|
||||
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.STRING); // Title
|
||||
wrapper.passthrough(Type.STRING); // Description
|
||||
InventoryPackets.toClient(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
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Tags
|
||||
registerOutgoing(State.PLAY, 0x5B, 0x5C, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
//TODO do the new (flower) tags have to be sent?
|
||||
int blockTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < blockTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Integer[] blockIds = wrapper.passthrough(Type.VAR_INT_ARRAY);
|
||||
for (int j = 0; j < blockIds.length; j++) {
|
||||
blockIds[j] = getNewBlockId(blockIds[j]);
|
||||
}
|
||||
}
|
||||
|
||||
int itemTagsSize = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < itemTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Integer[] itemIds = wrapper.passthrough(Type.VAR_INT_ARRAY);
|
||||
for (int j = 0; j < itemIds.length; j++) {
|
||||
itemIds[j] = InventoryPackets.getNewItemId(itemIds[j]);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
int entityTagsSize = wrapper.passthrough(Type.VAR_INT); // entity tags
|
||||
for (int i = 0; i < entityTagsSize; i++) {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Integer[] entitIds = wrapper.passthrough(Type.VAR_INT_ARRAY);
|
||||
for (int j = 0; j < entitIds.length; j++) {
|
||||
entitIds[j] = EntityPackets.getNewEntityId(entitIds[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
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);
|
||||
registerOutgoing(State.PLAY, 0x13, 0x14);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x15, 0x16);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x17, 0x18);
|
||||
registerOutgoing(State.PLAY, 0x18, 0x19);
|
||||
registerOutgoing(State.PLAY, 0x19, 0x1A);
|
||||
registerOutgoing(State.PLAY, 0x1A, 0x1B);
|
||||
registerOutgoing(State.PLAY, 0x1B, 0x1C);
|
||||
registerOutgoing(State.PLAY, 0x1C, 0x1D);
|
||||
registerOutgoing(State.PLAY, 0x1D, 0x1E);
|
||||
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);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x26, 0x27);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x28, 0x29);
|
||||
registerOutgoing(State.PLAY, 0x29, 0x2A);
|
||||
registerOutgoing(State.PLAY, 0x2A, 0x2B);
|
||||
registerOutgoing(State.PLAY, 0x2B, 0x2C);
|
||||
registerOutgoing(State.PLAY, 0x2C, 0x2D);
|
||||
registerOutgoing(State.PLAY, 0x2D, 0x2E);
|
||||
registerOutgoing(State.PLAY, 0x2E, 0x2F);
|
||||
registerOutgoing(State.PLAY, 0x2F, 0x30);
|
||||
registerOutgoing(State.PLAY, 0x30, 0x31);
|
||||
registerOutgoing(State.PLAY, 0x31, 0x32);
|
||||
registerOutgoing(State.PLAY, 0x32, 0x33);
|
||||
registerOutgoing(State.PLAY, 0x33, 0x34);
|
||||
registerOutgoing(State.PLAY, 0x34, 0x35);
|
||||
registerOutgoing(State.PLAY, 0x35, 0x36);
|
||||
registerOutgoing(State.PLAY, 0x36, 0x37);
|
||||
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);
|
||||
registerOutgoing(State.PLAY, 0x3E, 0x3F);
|
||||
registerOutgoing(State.PLAY, 0x3F, 0x40);
|
||||
registerOutgoing(State.PLAY, 0x40, 0x41);
|
||||
registerOutgoing(State.PLAY, 0x41, 0x42);
|
||||
registerOutgoing(State.PLAY, 0x42, 0x43);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x44, 0x45);
|
||||
registerOutgoing(State.PLAY, 0x45, 0x46);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x47, 0x48);
|
||||
registerOutgoing(State.PLAY, 0x48, 0x49);
|
||||
registerOutgoing(State.PLAY, 0x49, 0x4A);
|
||||
registerOutgoing(State.PLAY, 0x4A, 0x4B);
|
||||
registerOutgoing(State.PLAY, 0x4B, 0x4C);
|
||||
registerOutgoing(State.PLAY, 0x4C, 0x4D);
|
||||
registerOutgoing(State.PLAY, 0x4D, 0x4E);
|
||||
registerOutgoing(State.PLAY, 0x4E, 0x4F);
|
||||
registerOutgoing(State.PLAY, 0x4F, 0x50);
|
||||
|
||||
|
||||
registerOutgoing(State.PLAY, 0x52, 0x53);
|
||||
registerOutgoing(State.PLAY, 0x53, 0x54);
|
||||
registerOutgoing(State.PLAY, 0x54, 0x55);
|
||||
registerOutgoing(State.PLAY, 0x55, 0x56);
|
||||
registerOutgoing(State.PLAY, 0x56, 0x57);
|
||||
|
||||
registerOutgoing(State.PLAY, 0x58, 0x59);
|
||||
registerOutgoing(State.PLAY, 0x59, 0x5A);
|
||||
|
||||
|
||||
registerOutgoing(State.PLAY, 0x5C, 0x08);
|
||||
}
|
||||
|
||||
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);
|
||||
return 0;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(UserConnection userConnection) {
|
||||
userConnection.put(new EntityTracker(userConnection));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.data;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.google.gson.JsonObject;
|
||||
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.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 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...");
|
||||
us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.mapIdentifiers(oldToNewItems, mapping1_14.getAsJsonObject("items"), mapping1_15.getAsJsonObject("items"));
|
||||
Via.getPlatform().getLogger().info("Loading 1.14 -> 1.15 sound mapping...");
|
||||
soundMappings = new us.myles.ViaVersion.protocols.protocol1_14to1_13_2.data.MappingData.SoundMappingShortArray(mapping1_14.getAsJsonArray("sounds"), mapping1_15.getAsJsonArray("sounds"));
|
||||
}
|
||||
}
|
@ -0,0 +1,116 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
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.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.storage.EntityTracker;
|
||||
|
||||
public class EntityPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
// Spawn entity
|
||||
protocol.registerOutgoing(State.PLAY, 0x00, 0x00, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
// 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 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());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Spawn mob packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x03, 0x03, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.UUID);
|
||||
|
||||
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.passthrough(Type.DOUBLE);
|
||||
wrapper.passthrough(Type.DOUBLE);
|
||||
wrapper.passthrough(Type.DOUBLE);
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
wrapper.passthrough(Type.SHORT);
|
||||
wrapper.passthrough(Type.SHORT);
|
||||
wrapper.passthrough(Type.SHORT);
|
||||
wrapper.read(Types1_14.METADATA_LIST); // removed - probably sent in an update packet?
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn player packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x05, 0x05, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.UUID);
|
||||
|
||||
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.passthrough(Type.DOUBLE);
|
||||
wrapper.passthrough(Type.DOUBLE);
|
||||
wrapper.passthrough(Type.DOUBLE);
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
wrapper.passthrough(Type.BYTE);
|
||||
wrapper.read(Types1_14.METADATA); // removed - probably sent in an update packet?
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Metadata packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x43, 0x44, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Types1_14.METADATA_LIST); // 1 - Metadata list
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int entityId = wrapper.get(Type.VAR_INT, 0);
|
||||
Optional<Entity1_15Types.EntityType> type = wrapper.user().get(EntityTracker.class).get(entityId);
|
||||
MetadataRewriter.handleMetadata(entityId, type.orNull(), wrapper.get(Types1_14.METADATA_LIST, 0), wrapper.user());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static int getNewEntityId(int oldId) {
|
||||
return oldId >= 4 ? oldId + 1 : oldId; // 4 = bee
|
||||
}
|
||||
}
|
@ -0,0 +1,233 @@
|
||||
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.minecraft.item.Item;
|
||||
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_15to1_14_4.data.MappingData;
|
||||
|
||||
public class InventoryPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
// Window items packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x14, 0x15, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.FLAT_VAR_INT_ITEM_ARRAY); // 1 - Window Values
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
Item[] stacks = wrapper.get(Type.FLAT_VAR_INT_ITEM_ARRAY, 0);
|
||||
for (Item stack : stacks) toClient(stack);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Trade list packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x27, 0x28, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
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);
|
||||
toClient(input);
|
||||
|
||||
Item output = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(output);
|
||||
|
||||
if (wrapper.passthrough(Type.BOOLEAN)) { // Has second item
|
||||
// Second Item
|
||||
Item second = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM);
|
||||
toClient(second);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
wrapper.passthrough(Type.INT); // Maximum number of trade uses
|
||||
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.INT);
|
||||
wrapper.passthrough(Type.FLOAT);
|
||||
}
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.BOOLEAN);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Set slot packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x16, 0x17, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM); // 2 - Slot Value
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Entity Equipment Packet
|
||||
protocol.registerOutgoing(State.PLAY, 0x46, 0x47, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.VAR_INT); // 1 - Slot ID
|
||||
map(Type.FLAT_VAR_INT_ITEM); // 2 - Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
toClient(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Declare Recipes
|
||||
protocol.registerOutgoing(State.PLAY, 0x5A, 0x5B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int size = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int i = 0; i < size; i++) {
|
||||
String type = wrapper.passthrough(Type.STRING).replace("minecraft:", "");
|
||||
String id = wrapper.passthrough(Type.STRING);
|
||||
|
||||
switch (type) {
|
||||
case "crafting_shapeless": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT);
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
}
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
|
||||
break;
|
||||
}
|
||||
case "crafting_shaped": {
|
||||
int ingredientsNo = wrapper.passthrough(Type.VAR_INT) * wrapper.passthrough(Type.VAR_INT);
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
for (int j = 0; j < ingredientsNo; j++) {
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
}
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM)); // Result
|
||||
|
||||
break;
|
||||
}
|
||||
case "blasting":
|
||||
case "smoking":
|
||||
case "campfire_cooking":
|
||||
case "smelting": {
|
||||
wrapper.passthrough(Type.STRING); // Group
|
||||
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
wrapper.passthrough(Type.FLOAT); // EXP
|
||||
|
||||
wrapper.passthrough(Type.VAR_INT); // Cooking time
|
||||
|
||||
break;
|
||||
}
|
||||
case "stonecutting": {
|
||||
wrapper.passthrough(Type.STRING);
|
||||
Item[] items = wrapper.passthrough(Type.FLAT_VAR_INT_ITEM_ARRAY_VAR_INT); // Ingredients
|
||||
for (Item item : items) toClient(item);
|
||||
toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Click window packet
|
||||
protocol.registerIncoming(State.PLAY, 0x09, 0x09, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
map(Type.SHORT); // 1 - Slot
|
||||
map(Type.BYTE); // 2 - Button
|
||||
map(Type.SHORT); // 3 - Action number
|
||||
map(Type.VAR_INT); // 4 - Mode
|
||||
map(Type.FLAT_VAR_INT_ITEM); // 5 - Clicked Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Creative Inventory Action
|
||||
protocol.registerIncoming(State.PLAY, 0x26, 0x26, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.SHORT); // 0 - Slot
|
||||
map(Type.FLAT_VAR_INT_ITEM); // 1 - Clicked Item
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
toServer(wrapper.get(Type.FLAT_VAR_INT_ITEM, 0));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void toClient(Item item) {
|
||||
if (item == null) return;
|
||||
item.setIdentifier(getNewItemId(item.getIdentifier()));
|
||||
}
|
||||
|
||||
public static void toServer(Item item) {
|
||||
if (item == null) return;
|
||||
item.setIdentifier(getOldItemId(item.getIdentifier()));
|
||||
}
|
||||
|
||||
public static int getNewItemId(int id) {
|
||||
Integer newId = MappingData.oldToNewItems.get(id);
|
||||
if (newId == null) {
|
||||
Via.getPlatform().getLogger().warning("Missing 1.15 item for 1.14 item " + id);
|
||||
return 1;
|
||||
}
|
||||
return newId;
|
||||
}
|
||||
|
||||
public static int getOldItemId(int id) {
|
||||
Integer oldId = MappingData.oldToNewItems.inverse().get(id);
|
||||
return oldId != null ? oldId : 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.packets;
|
||||
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
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_15to1_14_4.Protocol1_15To1_14_4;
|
||||
|
||||
public class WorldPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
// Block Action
|
||||
protocol.registerOutgoing(State.PLAY, 0x0A, 0x0B, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14); // Location
|
||||
map(Type.UNSIGNED_BYTE); // Action id
|
||||
map(Type.UNSIGNED_BYTE); // Action param
|
||||
map(Type.VAR_INT); // Block id - /!\ NOT BLOCK STATE
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.set(Type.VAR_INT, 0, Protocol1_15To1_14_4.getNewBlockId(wrapper.get(Type.VAR_INT, 0)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Effect
|
||||
protocol.registerOutgoing(State.PLAY, 0x22, 0x23, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // Effect Id
|
||||
map(Type.POSITION1_14); // Location
|
||||
map(Type.INT); // Data
|
||||
handler(new PacketHandler() {
|
||||
@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);
|
||||
wrapper.set(Type.INT, 1, InventoryPackets.getNewItemId(data));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Spawn Particle
|
||||
protocol.registerOutgoing(State.PLAY, 0x23, 0x24, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.INT); // 0 - Particle ID
|
||||
map(Type.BOOLEAN); // 1 - Long Distance
|
||||
map(Type.FLOAT); // 2 - X
|
||||
map(Type.FLOAT); // 3 - Y
|
||||
map(Type.FLOAT); // 4 - Z
|
||||
map(Type.FLOAT); // 5 - Offset X
|
||||
map(Type.FLOAT); // 6 - Offset Y
|
||||
map(Type.FLOAT); // 7 - Offset Z
|
||||
map(Type.FLOAT); // 8 - Particle Data
|
||||
map(Type.INT); // 9 - Particle Count
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int id = wrapper.get(Type.INT, 0);
|
||||
if (id == 27) {
|
||||
InventoryPackets.toClient(wrapper.passthrough(Type.FLAT_VAR_INT_ITEM));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package us.myles.ViaVersion.protocols.protocol1_15to1_14_4.storage;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import us.myles.ViaVersion.api.data.ExternalJoinGameListener;
|
||||
import us.myles.ViaVersion.api.data.StoredObject;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.entities.Entity1_15Types;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class EntityTracker extends StoredObject implements ExternalJoinGameListener {
|
||||
private final Map<Integer, Entity1_15Types.EntityType> clientEntityTypes = new ConcurrentHashMap<>();
|
||||
|
||||
public EntityTracker(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void removeEntity(int entityId) {
|
||||
clientEntityTypes.remove(entityId);
|
||||
}
|
||||
|
||||
public void addEntity(int entityId, Entity1_15Types.EntityType type) {
|
||||
clientEntityTypes.put(entityId, type);
|
||||
}
|
||||
|
||||
public boolean has(int entityId) {
|
||||
return clientEntityTypes.containsKey(entityId);
|
||||
}
|
||||
|
||||
public Optional<Entity1_15Types.EntityType> get(int id) {
|
||||
return Optional.fromNullable(clientEntityTypes.get(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExternalJoinGame(int playerEntityId) {
|
||||
clientEntityTypes.put(playerEntityId, Entity1_15Types.EntityType.PLAYER);
|
||||
}
|
||||
}
|
2375
common/src/main/resources/assets/viaversion/data/mapping-1.15.json
Normal file
2375
common/src/main/resources/assets/viaversion/data/mapping-1.15.json
Normal file
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.3</version>
|
||||
<version>2.1.4-19w35a</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.3</version>
|
||||
<version>2.1.4-19w35a</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>viaversion-parent</name>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4-19w35a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4-19w35a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4-19w35a</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user